[Texture] Type, range and sampler


I would like some help to understand more correctly OpenGL and GLSL specifications about texture managment.

Focus is on 2D texture and basic/normal format (keep away compressed or other funny formats). So :

b Type[/b] : (Use to describe CPU data, right ?)
[ul]li[/li] [LIST][li]GL_FLOAT[/li] [li]GL_INT[/li] [li]GL_UNSIGNED_INT[/li] [/ul]li[/li] [ul][li]GL_HALF_FLOAT_ARB[/li] [li]GL_SHORT[/li] [li]GL_UNSIGNED_SHORT[/li] [/ul]li[/li] [ul][li]GL_BYTE[/li] [li]GL_UNSIGNED_BYTE[/li] [/ul][/LIST]

b Format[/b] : (Use to describe CPU data, right ?)
Internal format : (Use to describe GPU data, right?)
So possible direct (any conversion is done) internal formats are :

Rmq : NINT, NSHORT and NCHAR are actually stored as unsigned type on CPU side.


According to GLSL 1.4 specifications there are three sampler for basic 2D texture :
So compatible sampler/texture are :


Range of values at submitting time (CPU value)
[ul][li]FLOAT, HALF : [0,1][]INT, SHORT, CHAR : [-2^(N-1),2^(N-1)-1][]UINT, USHORT, UCHAR : [0,2^N-1][*]NINT, NSHORT, NCHAR : [0,2^N-1][/ul][/li]Right?

Range of values at sampling time (GPU value)
[ul][li]FLOAT, HALF : [0,1][]INT, SHORT, CHAR : [-2^31,2^31-1][]UINT, USHORT, UCHAR : [0,2^32-1][*]NINT, NSHORT, NCHAR : [0,1][/ul][/li]Right?

So how do you create a float texture with value above 1.0 ? Is it possible ?

Framebuffer : Render to texture
When you bind a float texture to a framebuffer (for instance a GL_R32F texture) and you write float value above 1.0, are they clamped ?

What is real differences between normal texture and depth texture? For instance is there a difference between a GL_R32F texture and a GL_DEPTH_COMPONENT32F texture?

Thank in advance.


Nice overview, i think you are correct about the ranges/formats for the most part except the float range:

Yes. All float values can be uploaded to a float texture. I use a texture to store 3D vertex positions in a current project, for example.

By default, output is not clamped for float buffers, see: http://www.opengl.org/registry/specs/ARB/color_buffer_float.txt

Hmm, i think you always need a depth texture for the shadow sampler for example. There might be more differences, maybe this helps:

Thanks you for all of your answers ! :slight_smile: