Is there a way to calculate powers of doubles in GLSL?
The pow function gives me this error when trying to use doubles:
unable to find compatible overloaded function "pow(float64_t, float)"
According to this:
the extension is missing any goniometric,pow,exp,log
functions.
So you can not use 64bit pow nor encode it using log,exp approach. You still might be able to implement Power by squaring or your own log,exp functions for this. I think for that exact reason they added these:
genDType frexp(genDType x, out genIType exp);
genDType ldexp(genDType x, in genIType exp);
However I never used them I just found them while searching the doc for log/exp/pow
functions. Also implementing pow
in GLSL will be a hard work due to lack of breakpoints, stepping/tracing ... This might help a lot:
But still I suggest to implement this on CPU side first and once working then port to GLSL.
pow
requires both arguments to be the same. You can take a look at the documentation here. You could probably cast the variable before using pow
:
pow(float(your_variable), the_power);
or
pow(your_variable, float64_t(the_power));
As I have never worked with float64_t before, I am not sure this will work. I am pretty sure the first one will, though.