From 5c34e34195e2ec46c4a4e17fd2ddea784f69d628 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 4 Nov 2021 18:23:45 +0100 Subject: Fix part of T91797: Cycles CPU and GPU render differences with camera inside volume --- intern/cycles/kernel/integrator/intersect_volume_stack.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/cycles/kernel/integrator/intersect_volume_stack.h b/intern/cycles/kernel/integrator/intersect_volume_stack.h index 1c91318ff9c..dd0587db9d8 100644 --- a/intern/cycles/kernel/integrator/intersect_volume_stack.h +++ b/intern/cycles/kernel/integrator/intersect_volume_stack.h @@ -83,6 +83,10 @@ ccl_device void integrator_intersect_volume_stack(KernelGlobals kg, IntegratorSt Ray volume_ray ccl_optional_struct_init; integrator_state_read_ray(kg, state, &volume_ray); + + /* Trace ray in random direction. Any direction works, Z up is a guess to get the + * fewest hits. */ + volume_ray.D = make_float3(0.0f, 0.0f, 1.0f); volume_ray.t = FLT_MAX; const uint visibility = (INTEGRATOR_STATE(state, path, flag) & PATH_RAY_ALL_VISIBILITY); @@ -147,7 +151,7 @@ ccl_device void integrator_intersect_volume_stack(KernelGlobals kg, IntegratorSt int enclosed_volumes[MAX_VOLUME_STACK_SIZE]; int step = 0; - while (stack_index < volume_stack_size - 1 && enclosed_index < volume_stack_size - 1 && + while (stack_index < volume_stack_size - 1 && enclosed_index < MAX_VOLUME_STACK_SIZE - 1 && step < 2 * volume_stack_size) { Intersection isect; if (!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) { -- cgit v1.2.3