Fix: Cycles mesh light ignores some valid samples in volume segment

Ref: #118534
turns out `in_volume_segment` does need to be checked. If the ray origin
lies on the wrong side of the mesh light, part of the ray could still be
lit by the other side, so the sample should not be considered invalid.

Pull Request: https://projects.blender.org/blender/blender/pulls/119529
This commit is contained in:
Weizhen Huang 2024-03-15 18:11:40 +01:00 committed by Weizhen Huang
parent 1111903416
commit 682f984dbe
1 changed files with 3 additions and 1 deletions

View File

@ -146,7 +146,9 @@ ccl_device_forceinline bool triangle_light_sample(KernelGlobals kg,
ls->shader = kernel_data_fetch(tri_shader, prim);
const float distance_to_plane = dot(N0, V[0] - P) / dot(N0, N0);
const int ls_shader_flag = kernel_data_fetch(shaders, ls->shader & SHADER_MASK).flags;
if (!(ls_shader_flag & (distance_to_plane > 0 ? SD_MIS_BACK : SD_MIS_FRONT))) {
if (!in_volume_segment &&
!(ls_shader_flag & (distance_to_plane > 0 ? SD_MIS_BACK : SD_MIS_FRONT)))
{
return false;
}