[Bf-blender-cvs] [29c733e] master: Fix T49078: Cycles tries to render volume from another render layer when camera is in volume

Sergey Sharybin noreply at git.blender.org
Thu Aug 25 10:56:03 CEST 2016


Commit: 29c733e6f2dd779153fe49d94b0f3de41c58b030
Author: Sergey Sharybin
Date:   Thu Aug 25 10:55:16 2016 +0200
Branches: master
https://developer.blender.org/rB29c733e6f2dd779153fe49d94b0f3de41c58b030

Fix T49078: Cycles tries to render volume from another render layer when camera is in volume

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

M	intern/cycles/kernel/kernel_path_state.h
M	intern/cycles/kernel/kernel_volume.h

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

diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index e0e35d7..661dc52 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -45,9 +45,9 @@ ccl_device_inline void path_state_init(KernelGlobals *kg,
 	state->volume_bounce = 0;
 
 	if(kernel_data.integrator.use_volumes) {
-		/* initialize volume stack with volume we are inside of */
-		kernel_volume_stack_init(kg, stack_sd, ray, state->volume_stack);
-		/* seed RNG for cases where we can't use stratified samples */
+		/* Initialize volume stack with volume we are inside of. */
+		kernel_volume_stack_init(kg, stack_sd, state, ray, state->volume_stack);
+		/* Seed RNG for cases where we can't use stratified samples .*/
 		state->rng_congruential = lcg_init(*rng + sample*0x51633e2d);
 	}
 	else {
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 9dafed9..4ab51b8 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -1010,7 +1010,8 @@ ccl_device bool kernel_volume_use_decoupled(KernelGlobals *kg, bool heterogeneou
 
 ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
                                          ShaderData *stack_sd,
-                                         Ray *ray,
+                                         const PathState *state,
+                                         const Ray *ray,
                                          VolumeStack *stack)
 {
 	/* NULL ray happens in the baker, does it need proper initialization of
@@ -1031,9 +1032,12 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 		return;
 	}
 
+	kernel_assert(state->flag & PATH_RAY_CAMERA);
+
 	Ray volume_ray = *ray;
 	volume_ray.t = FLT_MAX;
 
+	const uint visibility = (state->flag & PATH_RAY_ALL_VISIBILITY);
 	int stack_index = 0, enclosed_index = 0;
 
 #ifdef __VOLUME_RECORD_ALL__
@@ -1042,7 +1046,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 	                                           &volume_ray,
 	                                           hits,
 	                                           2*VOLUME_STACK_SIZE,
-	                                           PATH_RAY_ALL_VISIBILITY);
+	                                           visibility);
 	if(num_hits > 0) {
 		int enclosed_volumes[VOLUME_STACK_SIZE];
 		Intersection *isect = hits;
@@ -1091,7 +1095,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 	      step < 2 * VOLUME_STACK_SIZE)
 	{
 		Intersection isect;
-		if(!scene_intersect_volume(kg, &volume_ray, &isect, PATH_RAY_ALL_VISIBILITY)) {
+		if(!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) {
 			break;
 		}




More information about the Bf-blender-cvs mailing list