diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-09-20 21:58:07 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-09-20 22:07:29 +0300 |
commit | 9df0d209571c71a0077be7bd3103d6f00ae23965 (patch) | |
tree | e68bd74cf0b1f36cbaa78be53401c39200ba7c97 /intern/cycles | |
parent | ed6c8d82b804c8c197a5ebeed5cf17a586320d95 (diff) |
Cycles: don't allow negative BSDF weights
This doesn't work with path guiding, and likely other features.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/closure/alloc.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/intern/cycles/kernel/closure/alloc.h b/intern/cycles/kernel/closure/alloc.h index 1cf06614f3b..f1af3b12269 100644 --- a/intern/cycles/kernel/closure/alloc.h +++ b/intern/cycles/kernel/closure/alloc.h @@ -53,6 +53,9 @@ ccl_device_inline ccl_private ShaderClosure *bsdf_alloc(ccl_private ShaderData * { kernel_assert(isfinite_safe(weight)); + /* No negative weights allowed. */ + weight = max(weight, zero_float3()); + const float sample_weight = fabsf(average(weight)); /* Use comparison this way to help dealing with non-finite weight: if the average is not finite |