Fix T54105: random walk SSS missing in branched indirect paths.
[blender-staging.git] / intern / cycles / kernel / split / kernel_subsurface_scatter.h
index e50d63ea3bc6d5900463ebc8cd502b5f3e94d804..af0303d860890d71557cfb95b5fba5c075f8a726 100644 (file)
@@ -228,7 +228,9 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
                if(sd->flag & SD_BSSRDF) {
 
 #ifdef __BRANCHED_PATH__
-                       if(!kernel_data.integrator.branched) {
+                       if(!kernel_data.integrator.branched ||
+                          IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT))
+                       {
 #endif
                                if(kernel_path_subsurface_scatter(kg,
                                                                  sd,
@@ -243,27 +245,6 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg)
                                }
 #ifdef __BRANCHED_PATH__
                        }
-                       else if(IS_FLAG(ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
-                               float bssrdf_u, bssrdf_v;
-                               path_state_rng_2D(kg,
-                                                 state,
-                                                 PRNG_BSDF_U,
-                                                 &bssrdf_u, &bssrdf_v);
-
-                               const ShaderClosure *sc = shader_bssrdf_pick(sd, throughput, &bssrdf_u);
-
-                               /* do bssrdf scatter step if we picked a bssrdf closure */
-                               if(sc) {
-                                       uint lcg_state = lcg_state_init_addrspace(state, 0x68bc21eb);
-                                       subsurface_scatter_step(kg,
-                                                               sd,
-                                                               state,
-                                                               sc,
-                                                               &lcg_state,
-                                                               bssrdf_u, bssrdf_v,
-                                                               false);
-                               }
-                       }
                        else {
                                kernel_split_branched_path_subsurface_indirect_light_init(kg, ray_index);