[Bf-blender-cvs] [939fa67] master: Cycles: Fix for camera-in-volume detection

Sergey Sharybin noreply at git.blender.org
Mon Oct 6 12:39:26 CEST 2014


Commit: 939fa6759c5d6e72fa4ef8c9d10075488f4d7666
Author: Sergey Sharybin
Date:   Mon Oct 6 12:31:31 2014 +0200
Branches: master
https://developer.blender.org/rB939fa6759c5d6e72fa4ef8c9d10075488f4d7666

Cycles: Fix for camera-in-volume detection

Ray actually should have infinite length, so we can detect camera in a volume
which is bigger that the far clipping of the camera.

This might also give some speedup (wouldn't expect much tho) because we don't
need to re-calculate ray direction and length after every bounce now.

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

M	intern/cycles/kernel/kernel_volume.h

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

diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index dd947a5..0100a5b 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -978,6 +978,8 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
 	const float3 Pend = ray->P + ray->D*ray->t;
 	Ray volume_ray = *ray;
+	volume_ray.t = FLT_MAX;
+
 	int stack_index = 0, enclosed_index = 0;
 	int enclosed_volumes[VOLUME_STACK_SIZE];
 
@@ -1019,15 +1021,6 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
 		/* Move ray forward. */
 		volume_ray.P = ray_offset(sd.P, -sd.Ng);
-		if(volume_ray.t != FLT_MAX) {
-			volume_ray.D = normalize_len(Pend - volume_ray.P, &volume_ray.t);
-			/* TODO(sergey): Find a faster way detecting that ray_offset moved
-			 * us pass through the end point.
-			 */
-			if(dot(ray->D, volume_ray.D) < 0.0f) {
-				break;
-			}
-		}
 	}
 	/* 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