diff options
author | Sebastian Herholz <sherholz> | 2022-04-28 19:03:24 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-04-28 19:14:06 +0300 |
commit | fbc884d2a82951c3a8c0f92993de3a0eb9907d86 (patch) | |
tree | 0404bd829d753f28226b4ba103575431b938c3ec /intern/cycles/kernel/closure/bsdf_principled_sheen.h | |
parent | bd327e3bf3e0768aa2768949304571e0eb73ab80 (diff) |
Ensure BSDF evals and pdfs are zero on invalid samples
Currently, the `eval` and `pdf` are not explicitly set to zero when a BSDF sample is invalid (e.g., below the upper hemisphere), when calling
`bsdf_sample` or `bsdf_eval`. It is assumed that `eval` and `pdf` are set to zero before these functions are called, which can cause problems if not.
This patch fixes this potential problem by explicitly setting `eval` and `pdf` to zero when the sampled direction is invalid.
I also added a sanity check if `eval` and `pdf` are valid (i.e., >= 0.f).
The check is activated when build in debug mode and with the `WITH_CYCLES_DEBUG` set to `ON`.
Reviewed By: brecht, sergey
Differential Revision: https://developer.blender.org/D14776
Diffstat (limited to 'intern/cycles/kernel/closure/bsdf_principled_sheen.h')
-rw-r--r-- | intern/cycles/kernel/closure/bsdf_principled_sheen.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_principled_sheen.h b/intern/cycles/kernel/closure/bsdf_principled_sheen.h index ea2ea03adb9..3a96a93db73 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_sheen.h +++ b/intern/cycles/kernel/closure/bsdf_principled_sheen.h @@ -86,6 +86,7 @@ ccl_device float3 bsdf_principled_sheen_eval_transmit(ccl_private const ShaderCl const float3 omega_in, ccl_private float *pdf) { + *pdf = 0.0f; return make_float3(0.0f, 0.0f, 0.0f); } @@ -120,6 +121,7 @@ ccl_device int bsdf_principled_sheen_sample(ccl_private const ShaderClosure *sc, #endif } else { + *eval = make_float3(0.0f, 0.0f, 0.0f); *pdf = 0.0f; } return LABEL_REFLECT | LABEL_DIFFUSE; |