[Texture] Type, range and sampler

Hi!

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 ?)
[ul][li]GL_RED[]GL_RG[]GL_RGB[]GL_RGBA[]GL_DEPTH_COMPONENT[/ul][/li]
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.

Right?

Sampler
According to GLSL 1.4 specifications there are three sampler for basic 2D texture :
[ul][li]GL_SAMPLER_2D[]GL_INT_SAMPLER_2D_EXT[]GL_UNSIGNED_INT_SAMPLER_2D_EXT[/ul][/li]
So compatible sampler/texture are :

Right?

Range
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 ?

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

Kiwi.

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:
http://www.opengl.org/registry/specs/ARB/depth_buffer_float.txt

Thanks you for all of your answers ! :slight_smile: