fixed numerical artifacts in Nil

This commit is contained in:
Zeno Rogue 2019-08-08 00:09:06 +02:00
parent 6ab7535088
commit 5a3a408831
1 changed files with 2 additions and 1 deletions

View File

@ -408,7 +408,8 @@ namespace nilv {
"for(int it=0; it<50; it++) {"
"float w = (wmin + wmax) / 2.;"
"float z = b * b * (s + (sin(w) - w)/(cos(w) - 1.)) + w;"
// the formula after ':' produces visible numerical artifacts for w~0
"float z = b * b * (s + (abs(w) < .1 ? w/3. + w*w*w/90. + w*w*w*w*w/2520.: (sin(w) - w)/(cos(w) - 1.))) + w;"
"if(h[2] > z) wmin = w;"
"else wmax = w;"
"}"