Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Werner <stewreo@gmail.com>2017-08-17 16:05:48 +0300
committerStefan Werner <stewreo@gmail.com>2017-08-17 16:07:59 +0300
commit7a4696197dbb088a94d82edd78304e8fc32bd6e7 (patch)
tree74873cae15f526c6c40080cc7f21802b80524876 /intern/cycles/kernel/kernel_light.h
parent743bacaa6f4e7dd4b621b8b908513ea6ce7b18e4 (diff)
Cycles: Fix for a division by zero that could happen with solid angle triangle light sampling
Diffstat (limited to 'intern/cycles/kernel/kernel_light.h')
-rw-r--r--intern/cycles/kernel/kernel_light.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index d747c452de2..cd05e29ca54 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -954,7 +954,11 @@ ccl_device_forceinline void triangle_light_sample(KernelGlobals *kg, int prim, i
const float3 U = safe_normalize(C - dot(C, A) * A);
- const float q = ((v * t - u * s) * cos_alpha - v) / ((v * s + u * t) * sin_alpha);
+ float q = 1.0f;
+ const float det = ((v * s + u * t) * sin_alpha);
+ if(det != 0.0f) {
+ q = ((v * t - u * s) * cos_alpha - v) / det;
+ }
const float temp = max(1.0f - q*q, 0.0f);
const float3 C_ = safe_normalize(q * A + sqrtf(temp) * U);