From 70424195a8a68f5d08f91b5947008825af7b4ee8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 23 Nov 2021 15:11:00 +0100 Subject: Cycles: Fix possible access to non-initialized light sample in volume Happened in barbershop file where number of bounces to the light was reached. Differential Revision: https://developer.blender.org/D13336 --- intern/cycles/kernel/light/light.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'intern/cycles/kernel/light') diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index 2e7f862a715..97dca936552 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -73,7 +73,7 @@ ccl_device_inline bool light_sample(KernelGlobals kg, ls->P = zero_float3(); ls->Ng = zero_float3(); ls->D = zero_float3(); - ls->pdf = true; + ls->pdf = 1.0f; ls->t = FLT_MAX; return true; } @@ -131,7 +131,7 @@ ccl_device_inline bool light_sample(KernelGlobals kg, float3 dir = make_float3(klight->spot.dir[0], klight->spot.dir[1], klight->spot.dir[2]); ls->eval_fac *= spot_light_attenuation( dir, klight->spot.spot_angle, klight->spot.spot_smooth, ls->Ng); - if (ls->eval_fac == 0.0f) { + if (!in_volume_segment && ls->eval_fac == 0.0f) { return false; } } @@ -170,7 +170,7 @@ ccl_device_inline bool light_sample(KernelGlobals kg, float3 sample_axisu = axisu; float3 sample_axisv = axisv; - if (klight->area.tan_spread > 0.0f) { + if (!in_volume_segment && klight->area.tan_spread > 0.0f) { if (!light_spread_clamp_area_light( P, Ng, &ls->P, &sample_axisu, &sample_axisv, klight->area.tan_spread)) { return false; @@ -203,7 +203,7 @@ ccl_device_inline bool light_sample(KernelGlobals kg, ls->pdf *= kernel_data.integrator.pdf_lights; - return (ls->pdf > 0.0f); + return in_volume_segment || (ls->pdf > 0.0f); } ccl_device bool lights_intersect(KernelGlobals kg, -- cgit v1.2.3