atan/atan2 functions in slshader

This commit is contained in:
Zeno Rogue 2019-10-21 22:43:19 +02:00
parent aff0f4a69e
commit bb7e96a3d0
1 changed files with 1 additions and 7 deletions

View File

@ -1328,18 +1328,12 @@ EX namespace slr {
}
EX string slshader =
"float atan2(float y, float x) {"
" if(x == 0.) return y > 0. ? PI/2. : -PI/2.;"
" if(x > 0.) return atan(y / x);"
" if(y >= 0.) return atan(y / x) + PI;"
" if(y < 0.) return atan(y / x) - PI;"
" }"
"uniform mediump float uIndexSL;"
"uniform mediump int uIterations;"
"vec4 inverse_exp(vec4 h) {"
"if(h[0]*h[0] + h[1] * h[1] < 1e-6) return vec4(0, 0, atan(h[2], h[3]) + uIndexSL, 1);"
"if(h[0]*h[0] + h[1] * h[1] < 1e-6) return vec4(0, 0, atan2(h[2], h[3]) + uIndexSL, 1);"
"float r = asinh(sqrt(h[0] * h[0] + h[1] * h[1]));"
"float phi = atan2(h[2], h[3]) + uIndexSL;"
"float theta = atan2(h[1], h[0]) + phi + uIndexSL;"