Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GL_RG_INTEGER

47 views
Skip to first unread message

Nicolas Bonneel

unread,
Oct 22, 2009, 1:12:57 PM10/22/09
to
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/

Nicolas Bonneel

unread,
Oct 22, 2009, 1:52:31 PM10/22/09
to
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

unread,
Oct 22, 2009, 8:54:15 PM10/22/09
to
I also add that glGetError() after that returns 0 (so, there is no error)

fungus

unread,
Oct 23, 2009, 4:52:27 AM10/23/09
to
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

--
<\___/>
/ O O \
\_____/ FTB.

Nicolas Bonneel

unread,
Oct 23, 2009, 6:39:36 AM10/23/09
to
fungus a �crit :

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).

Timo Kunze

unread,
Oct 23, 2009, 1:43:58 PM10/23/09
to
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."

Nicolas Bonneel

unread,
Oct 24, 2009, 7:05:50 AM10/24/09
to
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

fungus

unread,
Oct 24, 2009, 7:30:40 AM10/24/09
to
On Oct 23, 7:43 pm, 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.

Timo Kunze

unread,
Oct 24, 2009, 5:15:26 PM10/24/09
to
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.

Nicolas Bonneel

unread,
Oct 24, 2009, 9:23:02 PM10/24/09
to
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!

Nicolas Bonneel

unread,
Oct 27, 2009, 7:49:12 AM10/27/09
to
Nicolas Bonneel a écrit :

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).

0 new messages