View Full Version : How to get the 'fast' exp2?

Christian Schüler
09-23-2009, 10:07 AM
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?

Alfonse Reinheart
09-23-2009, 10:21 AM
You don't.

Nicolas Lelong
09-23-2009, 11:30 AM
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.