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.
This commit is contained in:
Sergey Sharybin 2014-10-06 12:31:31 +02:00
parent 233de800e2
commit 939fa6759c
Notes: blender-bot 2024-03-22 15:57:27 +01:00
Referenced by issue #42130, Cycles - volume emission doesn't show up with transparent background enabled
1 changed files with 2 additions and 9 deletions

View File

@ -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