Fix 34831: SSS issue with non-progressive render, due to error in closure merging...
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 2 Apr 2013 15:53:24 +0000 (15:53 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 2 Apr 2013 15:53:24 +0000 (15:53 +0000)
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/svm/svm_closure.h

index 572255f938d6c09f028e4f8e0af77e54795155bf..b5acf4824e327d7688dcab574e72017571ef2365 100644 (file)
@@ -906,7 +906,7 @@ __device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
                        ShaderClosure *scj = &sd->closure[j];
 
 #ifdef __OSL__
-                       if(!sci->prim && sci->type == scj->type && sci->data0 == scj->data0 && sci->data1 == scj->data1) {
+                       if(!sci->prim && !scj->prim && sci->type == scj->type && sci->data0 == scj->data0 && sci->data1 == scj->data1) {
 #else
                        if(sci->type == scj->type && sci->data0 == scj->data0 && sci->data1 == scj->data1) {
 #endif
@@ -918,6 +918,7 @@ __device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
                                        memmove(scj, scj+1, size*sizeof(ShaderClosure));
 
                                sd->num_closure--;
+                               j--;
                        }
                }
        }
index a37646beb2e8d7bad8f4308dd00e5016e4f6fc55..72e6a0471586103fe58f5a83f0cbe0c238f9a68a 100644 (file)
@@ -25,6 +25,7 @@ __device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type,
        if(type == CLOSURE_BSDF_SHARP_GLASS_ID) {
                if(refract) {
                        sc->data0 = eta;
+                       sc->data1 = 0.0f;
                        sd->flag |= bsdf_refraction_setup(sc);
                }
                else
@@ -58,6 +59,9 @@ __device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, Clo
        if(sd->num_closure < MAX_CLOSURE) {
                sc->weight *= mix_weight;
                sc->type = type;
+#ifdef __OSL__
+               sc->prim = NULL;
+#endif
                sd->num_closure++;
                return sc;
        }
@@ -79,6 +83,9 @@ __device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float m
                sc->weight = weight;
                sc->sample_weight = sample_weight;
                sd->num_closure++;
+#ifdef __OSL__
+               sc->prim = NULL;
+#endif
                return sc;
        }
 
@@ -125,10 +132,13 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                                float roughness = param1;
 
                                if(roughness == 0.0f) {
+                                       sc->data0 = 0.0f;
+                                       sc->data1 = 0.0f;
                                        sd->flag |= bsdf_diffuse_setup(sc);
                                }
                                else {
                                        sc->data0 = roughness;
+                                       sc->data1 = 0.0f;
                                        sd->flag |= bsdf_oren_nayar_setup(sc);
                                }
                        }
@@ -138,6 +148,8 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                        ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight);
 
                        if(sc) {
+                               sc->data0 = 0.0f;
+                               sc->data1 = 0.0f;
                                sc->N = N;
                                sd->flag |= bsdf_translucent_setup(sc);
                        }
@@ -147,6 +159,8 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                        ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight);
 
                        if(sc) {
+                               sc->data0 = 0.0f;
+                               sc->data1 = 0.0f;
                                sc->N = N;
                                sd->flag |= bsdf_transparent_setup(sc);
                        }
@@ -164,6 +178,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                        if(sc) {
                                sc->N = N;
                                sc->data0 = param1;
+                               sc->data1 = 0.0f;
 
                                /* setup bsdf */
                                if(type == CLOSURE_BSDF_REFLECTION_ID)
@@ -302,6 +317,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
 
                                /* sigma */
                                sc->data0 = clamp(param1, 0.0f, 1.0f);
+                               sc->data1 = 0.0f;
                                sd->flag |= bsdf_ashikhmin_velvet_setup(sc);
                        }
                        break;
@@ -324,6 +340,9 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                                        sc->sample_weight = sample_weight;
                                        sc->data0 = radius.x;
                                        sc->data1 = eta;
+#ifdef __OSL__
+                                       sc->prim = NULL;
+#endif
                                        sc->N = N;
                                        sd->flag |= bssrdf_setup(sc);
 
@@ -336,6 +355,9 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                                        sc->sample_weight = sample_weight;
                                        sc->data0 = radius.y;
                                        sc->data1 = eta;
+#ifdef __OSL__
+                                       sc->prim = NULL;
+#endif
                                        sc->N = N;
                                        sd->flag |= bssrdf_setup(sc);
 
@@ -348,6 +370,9 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
                                        sc->sample_weight = sample_weight;
                                        sc->data0 = radius.z;
                                        sc->data1 = eta;
+#ifdef __OSL__
+                                       sc->prim = NULL;
+#endif
                                        sc->N = N;
                                        sd->flag |= bssrdf_setup(sc);