diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-10 02:06:03 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-10 02:06:03 +0400 |
commit | 8cf374d4012e193a50a58f1e2abcdae306ae33cd (patch) | |
tree | f808c24cb69591385f1a07eaebd82df9ffa0bb14 /intern/cycles/kernel/shaders/node_texture.h | |
parent | ad10cbf04aed17c69ccd4e15921669d18ed987e1 (diff) |
Cycles: different fix for perlin noise generating nan values, now check for
the result to be finite afterwards which is a bit faster and works for OSL
too without needing to slow down OSL itself.
Diffstat (limited to 'intern/cycles/kernel/shaders/node_texture.h')
-rw-r--r-- | intern/cycles/kernel/shaders/node_texture.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/intern/cycles/kernel/shaders/node_texture.h b/intern/cycles/kernel/shaders/node_texture.h index 1b3ba8207ab..2de0fc0ea57 100644 --- a/intern/cycles/kernel/shaders/node_texture.h +++ b/intern/cycles/kernel/shaders/node_texture.h @@ -151,12 +151,23 @@ float voronoi_CrS(point p) { return 2.0 * voronoi_Cr(p) - 1.0; } /* Noise Bases */ +float safe_noise(point p) +{ + float f = noise(p); + + /* can happen for big coordinates, things even out to 0.5 then anyway */ + if(!isfinite(f)) + return 0.5; + + return f; +} + float noise_basis(point p, string basis) { float result = 0.0; if (basis == "Perlin") - result = noise(p); /* returns perlin noise in range 0..1 */ + result = safe_noise(p); /* returns perlin noise in range 0..1 */ if (basis == "Voronoi F1") result = voronoi_F1S(p); if (basis == "Voronoi F2") |