[Bf-blender-cvs] [25f33e0] master: Fix T43562: Cycles gets stuck with camera in volume in certain setup

Sergey Sharybin noreply at git.blender.org
Thu Feb 5 12:18:58 CET 2015


Commit: 25f33e058a7b57d4f5964609b29b3f0834b3e6b6
Author: Sergey Sharybin
Date:   Thu Feb 5 16:06:22 2015 +0500
Branches: master
https://developer.blender.org/rB25f33e058a7b57d4f5964609b29b3f0834b3e6b6

Fix T43562: Cycles gets stuck with camera in volume in certain setup

The issue was caused by the way how we shoot the ray to see which rays we're
inside which might start bouncing back-n-forth between two close to parallel
intersecting faces.

Real solution would be to record all the intersections when shooting the ray,
but it's kinda tricky on GPU because of needed sorting and uncertainty of
how huge intersection array should be.

For now we'll just limit number of steps in the check so in worst case we'll
have some samples not being correct which will be compensated with further
sampling. Shouldn't be an issue since probability of such a lock is quite
small actually.

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

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

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

diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 8eb6866..a1012cf 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -373,8 +373,9 @@ ccl_device void kernel_path_subsurface_update_volume_stack(KernelGlobals *kg,
 
 	Ray volume_ray = *ray;
 	Intersection isect;
-
-	while(scene_intersect_volume(kg, &volume_ray, &isect))
+	int step = 0;
+	while(step < VOLUME_STACK_SIZE &&
+	      scene_intersect_volume(kg, &volume_ray, &isect))
 	{
 		ShaderData sd;
 		shader_setup_from_ray(kg, &sd, &isect, &volume_ray, 0, 0);
@@ -383,6 +384,7 @@ ccl_device void kernel_path_subsurface_update_volume_stack(KernelGlobals *kg,
 		/* Move ray forward. */
 		volume_ray.P = ray_offset(sd.P, -sd.Ng);
 		volume_ray.t -= sd.ray_length;
+		++step;
 	}
 }
 #endif
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index b218195..9d6c233 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -980,9 +980,11 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
 	int stack_index = 0, enclosed_index = 0;
 	int enclosed_volumes[VOLUME_STACK_SIZE];
+	int step = 0;
 
 	while(stack_index < VOLUME_STACK_SIZE - 1 &&
-	      enclosed_index < VOLUME_STACK_SIZE - 1)
+	      enclosed_index < VOLUME_STACK_SIZE - 1 &&
+	      step < 2 * VOLUME_STACK_SIZE)
 	{
 		Intersection isect;
 		if(!scene_intersect_volume(kg, &volume_ray, &isect)) {
@@ -1017,6 +1019,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
 		/* Move ray forward. */
 		volume_ray.P = ray_offset(sd.P, -sd.Ng);
+		++step;
 	}
 	/* stack_index of 0 means quick checks outside of the kernel gave false
 	 * positive, nothing to worry about, just we've wasted quite a few of




More information about the Bf-blender-cvs mailing list