Fix shadow linking for Cycles Metal RT

The shadow intersection kernels needs to perform extra checks
to see whether object is really considered a blocker.

Pull Request: https://projects.blender.org/blender/blender/pulls/112012
This commit is contained in:
Sergey Sharybin 2023-09-06 15:25:30 +02:00 committed by Sergey Sharybin
parent b51a2dde3f
commit 7e4a51329b
2 changed files with 18 additions and 3 deletions

@ -255,8 +255,8 @@ ccl_device_inline bool intersection_skip_self_local(ccl_ray_data const RaySelfPr
}
#ifdef __SHADOW_LINKING__
ccl_device_inline uint64_t ray_get_shadow_set_membership(KernelGlobals kg,
ccl_private const RaySelfPrimitives &self)
ccl_device_inline uint64_t
ray_get_shadow_set_membership(KernelGlobals kg, ccl_ray_data const RaySelfPrimitives &self)
{
if (self.light != LAMP_NONE) {
return kernel_data_fetch(lights, self.light).shadow_set_membership;
@ -271,7 +271,7 @@ ccl_device_inline uint64_t ray_get_shadow_set_membership(KernelGlobals kg,
#endif
ccl_device_inline bool intersection_skip_shadow_link(KernelGlobals kg,
ccl_private const RaySelfPrimitives &self,
ccl_ray_data const RaySelfPrimitives &self,
const int isect_object)
{
#ifdef __SHADOW_LINKING__

@ -218,6 +218,13 @@ bool metalrt_shadow_all_hit(constant KernelParamsMetal &launch_params_metal,
return true;
}
# ifdef __SHADOW_LINKING__
if (context.intersection_skip_shadow_link(nullptr, payload.self, object)) {
/* continue search */
return true;
}
# endif
# ifndef __TRANSPARENT_SHADOWS__
/* No transparent shadows support compiled in, make opaque. */
payload.result = true;
@ -372,6 +379,14 @@ inline TReturnType metalrt_visibility_test(
/* Shadow ray early termination. */
if (visibility & PATH_RAY_SHADOW_OPAQUE) {
# ifdef __SHADOW_LINKING__
if (context.intersection_skip_shadow_link(nullptr, payload.self, object)) {
result.accept = false;
result.continue_search = true;
return result;
}
# endif
if (context.intersection_skip_self_shadow(payload.self, object, prim)) {
result.accept = false;
result.continue_search = true;