GL_RG_INTEGER

  • Follow


Hi,
I tried using 32 bits integer RG textures and use them in a shader, but 
I don't get meaningful values in my shader (if I just replace GL_RG32I 
by GL_RG32F, GL_RG_INTEGER by GL_RG, GL_INT by GL_FLOAT, and my int* by 
a float* it works properly without any other changes neither in the code 
nor in the shader).

to load the texture, I do :

int* pixs = ...;
glTexImage2D(GL_TEXTURE_2D,0,GL_RG32I,w,h,0,GL_RG_INTEGER,GL_INT,pixs );

The values in "pixs" are integers beetween 0 and 1024 (or between 0.f 
and 1024.f when I use a float*).

I have a GTX280 and OpenGL 3.1.

Any idea ?

Thanks!

-- 
Nicolas Bonneel
http://www-sop.inria.fr/reves/Nicolas.Bonneel/
0
Reply Nicolas 10/22/2009 5:12:57 PM

Nicolas Bonneel a �crit :
> I have a GTX280 and OpenGL 3.1.

I just tried updating my driver (now with OpenGL 3.2), using 
UNSIGNED_INT instead and SHORT also, but they all fail.


-- 
Nicolas Bonneel
http://www-sop.inria.fr/reves/Nicolas.Bonneel/
0
Reply Nicolas 10/22/2009 5:52:31 PM


I also add that glGetError() after that returns 0 (so, there is no error)
0
Reply Nicolas 10/23/2009 12:54:15 AM

On Oct 22, 7:12=A0pm, Nicolas Bonneel <Nicolas.Bonn...@sophia.inria.fr>
wrote:
> Hi,
> I tried using 32 bits integer RG textures and use them in a shader, but
> I don't get meaningful values in my shader (if I just replace GL_RG32I
> by GL_RG32F, GL_RG_INTEGER by GL_RG, GL_INT by GL_FLOAT, and my int* by
> a float* it works properly without any other changes neither in the code
> nor in the shader).
>
> to load the texture, I do :
>
> int* pixs =3D ...;
> glTexImage2D(GL_TEXTURE_2D,0,GL_RG32I,w,h,0,GL_RG_INTEGER,GL_INT,pixs );
>
> The values in "pixs" are integers beetween 0 and 1024 (or between 0.f
> and 1024.f when I use a float*).
>
> I have a GTX280 and OpenGL 3.1.
>
> Any idea ?
>

I think integer values are divided by 2^32 so they
always represent a number between 0 and 1.

eg. integer 1024 becomes 0.000000238418



--
<\___/>
/ O O \
\_____/  FTB.
0
Reply fungus 10/23/2009 8:52:27 AM

fungus a �crit :
> On Oct 22, 7:12 pm, Nicolas Bonneel <Nicolas.Bonn...@sophia.inria.fr>
> wrote:
>> Hi,
>> I tried using 32 bits integer RG textures and use them in a shader, but
>> I don't get meaningful values in my shader (if I just replace GL_RG32I
>> by GL_RG32F, GL_RG_INTEGER by GL_RG, GL_INT by GL_FLOAT, and my int* by
>> a float* it works properly without any other changes neither in the code
>> nor in the shader).
>>
>> to load the texture, I do :
>>
>> int* pixs = ...;
>> glTexImage2D(GL_TEXTURE_2D,0,GL_RG32I,w,h,0,GL_RG_INTEGER,GL_INT,pixs );
>>
>> The values in "pixs" are integers beetween 0 and 1024 (or between 0.f
>> and 1024.f when I use a float*).
>>
>> I have a GTX280 and OpenGL 3.1.
>>
>> Any idea ?
>>
> 
> I think integer values are divided by 2^32 so they
> always represent a number between 0 and 1.
> 
> eg. integer 1024 becomes 0.000000238418

mmm, even multiplying with 2^32 in the shader still gives 0. (and even 
2^64.. just in case.. which shows that I get strictly 0 in my shader).

-- 
Nicolas Bonneel
http://www-sop.inria.fr/reves/Nicolas.Bonneel/
0
Reply Nicolas 10/23/2009 10:39:36 AM

IIRC, you can't access integer textures with float texture coordinates.
If you want to use integer textures, you also have to use integer
texture coordinates (and the appropriate texture access functions).

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Reply Timo 10/23/2009 5:43:58 PM

Timo Kunze a écrit :
> IIRC, you can't access integer textures with float texture coordinates.
> If you want to use integer textures, you also have to use integer
> texture coordinates (and the appropriate texture access functions).
> 
> Timo

I don't see anything else than texture2D, texture2DLod and texture2DProj 
to access my textures in the shader... Is there another one specific for 
integer textures ?
Why should the textures coordinates be integers ? This means that I 
cannot interpolate/filter my texture and I should only use a GL_NEAREST 
filtering ?

Thanks
0
Reply Nicolas 10/24/2009 11:05:50 AM

On Oct 23, 7:43=A0pm, Timo Kunze <TKunze71...@gmx.de> wrote:
> IIRC, you can't access integer textures with float texture coordinates.
> If you want to use integer textures, you also have to use integer
> texture coordinates (and the appropriate texture access functions).
>

I haven't tried it but I don't believe this - makes
no sense.


--
<\___/>
/ O O \
\_____/  FTB.
0
Reply fungus 10/24/2009 11:30:40 AM

Have a look at specifications of EXT_gpu_shader4. On page 26, there's a
table which combinations are supported. You cannot access integer
textures with a float sampler - at least not with EXT_gpu_shader4.

I tried something similar some months ago: Access a foat rg texture with
integer coordinates. I failed for the same reason.

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Reply Timo 10/24/2009 9:15:26 PM

Timo Kunze a écrit :
> Have a look at specifications of EXT_gpu_shader4. On page 26, there's a
> table which combinations are supported. You cannot access integer
> textures with a float sampler - at least not with EXT_gpu_shader4.
> 
> I tried something similar some months ago: Access a foat rg texture with
> integer coordinates. I failed for the same reason.
> 
> Timo

isampler2D! :)
thanks! I'll try that!
I hope it's not slower than floating points textures since I wanted to 
use that to speedup my code (send my int* directly to the card instead 
of converting them to float* before).

thanks!
0
Reply Nicolas 10/25/2009 1:23:02 AM

Nicolas Bonneel a écrit :
> Timo Kunze a écrit :
>> Have a look at specifications of EXT_gpu_shader4. On page 26, there's a
>> table which combinations are supported. You cannot access integer
>> textures with a float sampler - at least not with EXT_gpu_shader4.
>>
>> I tried something similar some months ago: Access a foat rg texture with
>> integer coordinates. I failed for the same reason.
>>
>> Timo
> 
> isampler2D! :)
> thanks! I'll try that!
> I hope it's not slower than floating points textures since I wanted to 
> use that to speedup my code (send my int* directly to the card instead 
> of converting them to float* before).

I just had time to try it today. I confirm that it works and it odesn't 
seem to have lost performance...
I just had to replace my sampler2D by an isampler2D. The texture 
coordinates remains floats (between 0 and 1 inside the texture).

-- 
Nicolas Bonneel
http://www-sop.inria.fr/reves/Nicolas.Bonneel/
0
Reply Nicolas 10/27/2009 11:49:12 AM

10 Replies
178 Views

(page loaded in 3.979 seconds)

Similiar Articles:









7/20/2012 9:14:17 AM


Reply: