[Bf-blender-cvs] [6147c40] master: Cycles: Fix wrong volume stack after SSS bounce

Sergey Sharybin noreply at git.blender.org
Sat Nov 28 16:13:18 CET 2015


Commit: 6147c4037d288c7032c8dd63d6c448a9cebcc117
Author: Sergey Sharybin
Date:   Sat Nov 28 20:06:44 2015 +0500
Branches: master
https://developer.blender.org/rB6147c4037d288c7032c8dd63d6c448a9cebcc117

Cycles: Fix wrong volume stack after SSS bounce

Was introduced by a recent fixes, now it should be all correct and additionally
it solves the TODO mentioned in the code.

===================================================================

M	intern/cycles/kernel/kernel_bake.h
M	intern/cycles/kernel/kernel_path.h

===================================================================

diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index c2845db..715c11c 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -65,7 +65,6 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
 		if((is_combined || is_sss_sample) && (sd->flag & SD_BSSRDF)) {
 			/* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
 			SubsurfaceIndirectRays ss_indirect;
-			Ray orig_ray = ray;
 			kernel_path_subsurface_init_indirect(&ss_indirect);
 			if(kernel_path_subsurface_scatter(kg,
 			                                  sd,
@@ -79,7 +78,6 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
 				while(ss_indirect.num_rays) {
 					kernel_path_subsurface_setup_indirect(kg,
 					                                      &ss_indirect,
-					                                      &orig_ray,
 					                                      &state,
 					                                      &ray,
 					                                      &L_sample,
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index baffdb5..72c0f7a 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -511,6 +511,20 @@ ccl_device bool kernel_path_subsurface_scatter(
 				hit_state->ray_t = 0.0f;
 #endif
 
+#ifdef __VOLUME__
+				if(ss_indirect->need_update_volume_stack) {
+					Ray volume_ray = *ray;
+					/* Setup ray from previous surface point to the new one. */
+					volume_ray.D = normalize_len(hit_ray->P - volume_ray.P,
+					                             &volume_ray.t);
+
+					kernel_volume_stack_update_for_subsurface(
+					    kg,
+					    &volume_ray,
+					    hit_state->volume_stack);
+				}
+#endif
+
 				ss_indirect->num_rays++;
 			}
 			else {
@@ -545,7 +559,6 @@ ccl_device void kernel_path_subsurface_accum_indirect(
 ccl_device void kernel_path_subsurface_setup_indirect(
         KernelGlobals *kg,
         SubsurfaceIndirectRays *ss_indirect,
-        const Ray *orig_ray,
         PathState *state,
         Ray *ray,
         PathRadiance *L,
@@ -562,20 +575,6 @@ ccl_device void kernel_path_subsurface_setup_indirect(
 	Ray *indirect_ray = &ss_indirect->rays[ss_indirect->num_rays];
 	PathRadiance *indirect_L = &ss_indirect->L[ss_indirect->num_rays];
 
-#ifdef __VOLUME__
-	if(ss_indirect->need_update_volume_stack) {
-		Ray volume_ray = *orig_ray;
-
-		/* Setup ray from previous surface point to the new one. */
-		volume_ray.D = normalize_len(indirect_ray->P - volume_ray.P,
-		                             &volume_ray.t);
-
-		kernel_volume_stack_update_for_subsurface(kg,
-		                                          &volume_ray,
-		                                          state->volume_stack);
-	}
-#endif  /* __VOLUME__ */
-
 	*state = ss_indirect->state[ss_indirect->num_rays];
 	*ray = *indirect_ray;
 	*L = *indirect_L;
@@ -607,12 +606,6 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
 	SubsurfaceIndirectRays ss_indirect;
 	kernel_path_subsurface_init_indirect(&ss_indirect);
 
-	/* TODO(sergey): Avoid having explicit copy of the pre-subsurface scatter
-	 * ray by storing an updated version of state in the ss_indirect which will
-	 * be updated to the new volume stack.
-	 */
-	Ray ss_orig_ray;
-
 	for(;;) {
 #endif
 
@@ -862,7 +855,6 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
 			                                  &throughput,
 			                                  &ss_indirect))
 			{
-				ss_orig_ray = ray;
 				break;
 			}
 		}
@@ -885,7 +877,6 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
 		if(ss_indirect.num_rays) {
 			kernel_path_subsurface_setup_indirect(kg,
 			                                      &ss_indirect,
-			                                      &ss_orig_ray,
 			                                      &state,
 			                                      &ray,
 			                                      &L,




More information about the Bf-blender-cvs mailing list