How to get the 'fast' exp2?

Hi there,
I recall from that there was a fast, approximate variant of the exp2 function only accurate for 12 bits or so, but very useful for all things fogging, where full precision exp would be overkill.

In HLSL, you could ‘hint’ the compiler to generate this instruction by using intrinsic exp2() function on half floats. Like this:

half result = exp2( (half) argument );

(… and check the compiler output that it indeed generates the exp2pp instruction)

Unless I’m reading the GLSL specs backwards, there doesn’t seem to exist either half precision floats nor approximate variants of the exp2/log2 functions, so how do I access this feature through GLSL?

You don’t.

Or you can try some NVidia specific features, if it fits your needs. NVidia provides the ‘half’ type, so maybe the half exp2 is the fast one.

http://www.opengl.org/wiki/GLSL_:_nVidia_specific_features