diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index bb50ccc9581..ecb2f84b0f9 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -280,6 +280,16 @@ ccl_device kernel_assert(ls.pdf != 0.0f); + const bool is_transmission = dot(ls.D, sd->N) < 0.0f; + + if (ls.prim != PRIM_NONE && ls.prim == sd->prim && ls.object == sd->object) { + /* Skip self intersection if light direction lies in the same hemisphere as the geometric + * normal. */ + if (dot(ls.D, is_transmission ? -sd->Ng : sd->Ng) > 0.0f) { + return; + } + } + /* Evaluate light shader. * * TODO: can we reuse sd memory? In theory we can move this after @@ -292,8 +302,6 @@ ccl_device Ray ray ccl_optional_struct_init; BsdfEval bsdf_eval ccl_optional_struct_init; - const bool is_transmission = dot(ls.D, sd->N) < 0.0f; - int mnee_vertex_count = 0; #ifdef __MNEE__ IF_KERNEL_FEATURE(MNEE)