Fix #30049: cycles noise texture producing nan values with some
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 17:32:01 +0000 (17:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 17:32:01 +0000 (17:32 +0000)
texture coordinates, due to int overflow.

Also minor tweak in shader code to avoid copying uninitialized
values, should have no effect though because they were not used.

intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/svm/svm_noise.h

index 7e0b0ff..46ef5d2 100644 (file)
@@ -368,12 +368,13 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
 #else
        label = svm_bsdf_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
 #endif
+       if(*pdf != 0.0f) {
+               bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass);
 
-       bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass);
-
-       if(sd->num_closure > 1 && *pdf != 0.0f) {
-               float sweight = sc->sample_weight;
-               _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
+               if(sd->num_closure > 1) {
+                       float sweight = sc->sample_weight;
+                       _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
+               }
        }
 
        return label;
index 28ad028..1d3ace0 100644 (file)
@@ -84,8 +84,9 @@ __device uint phash(int kx, int ky, int kz, int3 p)
 
 __device float floorfrac(float x, int* i)
 {
-    *i = quick_floor(x);
-    return x - *i;
+    float f = floorf(x);
+    *i = (int)f;
+    return x - f;
 }
 
 __device float fade(float t)