[Bf-blender-cvs] [144f41b] soc-2016-cycles_denoising: Cycles: Fix potential divide by zero in the area light sampling code

Lukas Stockner noreply at git.blender.org
Sat Aug 6 05:41:06 CEST 2016


Commit: 144f41ba4e7b548ae9e344ff4a02523b5dd47148
Author: Lukas Stockner
Date:   Thu Aug 4 17:56:17 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rB144f41ba4e7b548ae9e344ff4a02523b5dd47148

Cycles: Fix potential divide by zero in the area light sampling code

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

M	intern/cycles/kernel/kernel_light.h

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

diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 93c4bd3..bb6c44a 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -102,7 +102,7 @@ ccl_device float area_light_sample(float3 P,
 		float cu = 1.0f / sqrtf(fu * fu + b0sq) * (fu > 0.0f ? 1.0f : -1.0f);
 		cu = clamp(cu, -1.0f, 1.0f);
 		/* Compute xu. */
-		float xu = -(cu * z0) / sqrtf(1.0f - cu * cu);
+		float xu = -(cu * z0) / max(sqrtf(1.0f - cu * cu), 1e-7f);
 		xu = clamp(xu, x0, x1);
 		/* Compute yv. */
 		float z0sq = z0 * z0;




More information about the Bf-blender-cvs mailing list