PDA

View Full Version : Specifications for float texture



Kiwaiii
11-04-2009, 04:11 AM
Hi !

I just have a question/remark on GLSL specifications about float texture and sampler. (Just consider the case of GL 3.x and GLSL 1.3 or higher).

In the GLSL specification :

"Texture data can be stored by the GL as floating point, unsigned normalized integer, unsigned integer or
signed integer data. This is determined by the type of the internal format of the texture. Texture lookups
on unsigned normalized integer and floating point data return floating point values in the range [0, 1]."

and

"If an integer sampler type is used, the result of a texture lookup is an ivec4. If an unsigned integer sampler
type is used, the result of a texture lookup is a uvec4. If a floating point sampler type is used, the result of
a texture lookup is a vec4, where each component is in the range [0, 1]."
GLSL 1.5 Specifications p.97

But I believed that GL and GLSL support natively float textures and thus float values in [-oo, +oo].

According to the GL's Wiki :
Are Values Clamped from 0.0 to 1.0 ?

No, you can use the full range supported. GL_RGBA32F_ARB, GL_RGB32F_ARB, GL_ALPHA32F_ARB, GL_INTENSITY32F_ARB, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB for 32 bit floats.
GL_RGBA16F_ARB, GL_RGB16F_ARB, GL_ALPHA16F_ARB, GL_INTENSITY16F_ARB, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB for 16 bit floats.
For GL 3.0, you can drop the _ARB postfix since float textures are a requirement.
OpenGL's Wiki (http://www.opengl.org/wiki/Floating_point_and_mipmapping_and_filtering)

Who is right ?

Thanks.

Brolingstanz
11-04-2009, 08:29 AM
FYI it's page 91.

Well, my read is that they're all correct: depth/stencil texture samplers (floating point or normalized integer) return components in the range [0..1]; whereas plain ole floating point and integer samplers should return unmodified values (otherwise they'd be of little use). Delving none too deeply it appears to be a question of semantics, though it should be clear enough from the context IMHO.

Alfonse Reinheart
11-04-2009, 10:45 AM
That is a very strange spec bug. It should read something like this:

"If a floating point sampler type is used, the result of a texture lookup is a vec4, where the range of each component depends on the format of the texture. Floating point textures can return any floating-poiint value, unsigned normalized integer textures return values in the range [0, 1], and signed normalized integer textures return values in the range [-1, 1]."

It's also odd how they completely missed signed-normalized formats (_SNORM).

Kiwaiii
11-04-2009, 10:57 PM
Thanks for your replies.