Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/shadow_catcher.h
| Show All 10 Lines | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #include "kernel/film/write_passes.h" | |||||
| #include "kernel/integrator/path_state.h" | #include "kernel/integrator/path_state.h" | ||||
| #include "kernel/integrator/state_util.h" | #include "kernel/integrator/state_util.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Check whether current surface bounce is where path is to be split for the shadow catcher. */ | /* Check whether current surface bounce is where path is to be split for the shadow catcher. */ | ||||
| ccl_device_inline bool kernel_shadow_catcher_is_path_split_bounce(KernelGlobals kg, | ccl_device_inline bool kernel_shadow_catcher_is_path_split_bounce(KernelGlobals kg, | ||||
| IntegratorState state, | IntegratorState state, | ||||
| Show All 15 Lines | #ifdef __SHADOW_CATCHER__ | ||||
| const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag); | const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag); | ||||
| if ((path_flag & PATH_RAY_TRANSPARENT_BACKGROUND) == 0) { | if ((path_flag & PATH_RAY_TRANSPARENT_BACKGROUND) == 0) { | ||||
| /* Split only on primary rays, secondary bounces are to treat shadow catcher as a regular | /* Split only on primary rays, secondary bounces are to treat shadow catcher as a regular | ||||
| * object. */ | * object. */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (path_flag & PATH_RAY_SHADOW_CATCHER_PASS) { | if (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| #else | #else | ||||
| (void)object_flag; | (void)object_flag; | ||||
| return false; | return false; | ||||
| #endif | #endif | ||||
| Show All 24 Lines | ccl_device_forceinline bool kernel_shadow_catcher_is_matte_path(const uint32_t path_flag) | ||||
| return (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) == 0; | return (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) == 0; | ||||
| } | } | ||||
| ccl_device_forceinline bool kernel_shadow_catcher_is_object_pass(const uint32_t path_flag) | ccl_device_forceinline bool kernel_shadow_catcher_is_object_pass(const uint32_t path_flag) | ||||
| { | { | ||||
| return path_flag & PATH_RAY_SHADOW_CATCHER_PASS; | return path_flag & PATH_RAY_SHADOW_CATCHER_PASS; | ||||
| } | } | ||||
| /* Write shadow catcher passes on a bounce from the shadow catcher object. */ | |||||
| ccl_device_forceinline void kernel_write_shadow_catcher_bounce_data( | |||||
| KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer) | |||||
| { | |||||
| kernel_assert(kernel_data.film.pass_shadow_catcher_sample_count != PASS_UNUSED); | |||||
| kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED); | |||||
| const uint32_t render_pixel_index = INTEGRATOR_STATE(state, path, render_pixel_index); | |||||
| const uint64_t render_buffer_offset = (uint64_t)render_pixel_index * | |||||
| kernel_data.film.pass_stride; | |||||
| ccl_global float *buffer = render_buffer + render_buffer_offset; | |||||
| /* Count sample for the shadow catcher object. */ | |||||
| kernel_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_sample_count, 1.0f); | |||||
| /* Since the split is done, the sample does not contribute to the matte, so accumulate it as | |||||
| * transparency to the matte. */ | |||||
| const float3 throughput = INTEGRATOR_STATE(state, path, throughput); | |||||
| kernel_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_matte + 3, | |||||
| average(throughput)); | |||||
| } | |||||
| #endif /* __SHADOW_CATCHER__ */ | #endif /* __SHADOW_CATCHER__ */ | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||