From 9df0d209571c71a0077be7bd3103d6f00ae23965 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 20 Sep 2022 20:58:07 +0200 Subject: Cycles: don't allow negative BSDF weights This doesn't work with path guiding, and likely other features. --- intern/cycles/kernel/closure/alloc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'intern') 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 -- cgit v1.2.3