Fix T40561: cycles refraction node with sharp distribution gives black.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 11 Jun 2014 17:52:14 +0000 (19:52 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 11 Jun 2014 17:55:16 +0000 (19:55 +0200)
intern/cycles/kernel/svm/svm_closure.h

index 27c5a19a7a0769015b0f05f1ea3ff2e2310935be..a7982c64c49ab10714728aaa03d135a94dd2bf2d 100644 (file)
@@ -203,18 +203,26 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 
                        if(sc) {
                                sc->N = N;
-                               sc->data0 = param1;
 
                                float eta = fmaxf(param2, 1e-5f);
-                               sc->data1 = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
+                               eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
 
                                /* setup bsdf */
-                               if(type == CLOSURE_BSDF_REFRACTION_ID)
+                               if(type == CLOSURE_BSDF_REFRACTION_ID) {
+                                       sc->data0 = eta;
+                                       sc->data1 = 0.0f;
+
                                        sd->flag |= bsdf_refraction_setup(sc);
-                               else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID)
-                                       sd->flag |= bsdf_microfacet_beckmann_refraction_setup(sc);
-                               else
-                                       sd->flag |= bsdf_microfacet_ggx_refraction_setup(sc);
+                               }
+                               else {
+                                       sc->data0 = param1;
+                                       sc->data1 = eta;
+
+                                       if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID)
+                                               sd->flag |= bsdf_microfacet_beckmann_refraction_setup(sc);
+                                       else
+                                               sd->flag |= bsdf_microfacet_ggx_refraction_setup(sc);
+                               }
                        }
 
                        break;