GLSL equivalents of C/C++ math functions

I was wondering what are the equivalents of the following C/C++ funtions in GLSL?

  • [li] log - Note that the this is the natural logarithm which means e = 2.71828… and not 2 like in the log2() I know in GLSL.[] log10 [] exp

Thanks in advance.

Note that the this is the natural logarithm which means e = 2.71828… and not 2 like in the log2() I know in GLSL.
No log base is better than any other. With just one log function, you can compute the log at any base.

Observe:

logbase e = logbase 2/logbase 2.

Yeah, I wasn’t saying that one was better than the other or anything, I’m just saying that they are not the same so maybe there was a function in GLSL that would be the exact same equivalent of the C/C++ functions. Anyway that’s what I’m looking for, if there are functions in GLSL that would do the same as the functions in the list, if not I would like to know if someone has the code to implement that the fastest way as possible since I’m pretty new to GLSL (as I’m still waiting for my copy of the orangebook to arrive, it will take about 25 days before it arrives).

You can download the spec from http://www.opengl.org/documentation/oglsl.html while you are waiting. Section 8.2 describes the exponential functions.

You have log, exp, log2, exp2, but not log10. log10 you’ll have to do as posted above.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.