[ACCEPTED]-What exactly is a floating point texture?-textures

Accepted answer
Score: 19

Here is a read a little bit here about it.

Basically 29 floating point texture is a texture in which 28 data is of floating point type :) That is 27 it is not clamped. So if you have 3.14f 26 in your texture you will read the same value 25 in the shader.

You may create them with different 24 numbers of channels. Also you may crate 23 16 or 32 bit textures depending on the format. e.g.

// create 32bit 4 component texture, each component has type float    
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 16, 0, GL_RGBA, GL_FLOAT, data);

where 22 data could be like this:

float data[16][16];
for(int i=0;i<16*16;++i) data[i] = sin(i*M_PI/180.0f); // whatever

then in shader you 21 can get exactly same (if you use FLOAT32 20 texture) value.


uniform sampler2D myFloatTex;
float value = texture2D(myFloatTex, texcoord.xy);

If you were using 16bit 19 format, say GL_RGBA16F, then whenever you 18 read in shader you will have a convertion. So, to 17 avoid this you may use half4 type: half4 16 value = texture2D(my16BitTex, texcoord.xy);

So, basically, difference 15 between the normalized 8bit and floating 14 point texture is that in the first case 13 your values will be brought to [0..1] range 12 and clamped, whereas in latter you will 11 receive your values as is ( except for 16<->32 10 conversion, see my example above).

Not that 9 you'd probably want to use them with FBO 8 as a render target, in this case you need 7 to know that not all of the formats may 6 be attached as a render target. E.g. you 5 cannot attach Luminance and intensity formats.

Also 4 not all hardware supports filtering of floating 3 point textures, so you need to check it 2 first for your case if you need it.

Hope 1 this helps.

Score: 4

FP textures have a special designated range 11 of internal formats (RGBA_16F,RGBA_32F,etc). Regular 10 textures store fixed-point data, so reading 9 from them gives you [0,1] range values. Contrary, FP 8 textures give you [-inf,+inf] range as a 7 result (not necessarily with a higher precision).

In 6 many cases (like HDR rendering) you can 5 easily proceed without FP textures, just 4 by transforming the values to fit in [0,1] range. But 3 there are cases like deferred rendering 2 when you may want to store, for example, world-space 1 coordinate without caring about their range.

More Related questions