21 # ifdef __SPLIT_KERNEL__
25 shadow_blocked_volume_path_state(KernelGlobals *
kg,
31 # ifdef __SPLIT_KERNEL__
41 if (
dot(sd->Ng, ray->
D) < 0.0f) {
42 kernel_volume_stack_enter_exit(
kg, sd, ps->volume_stack);
63 if (volume_state->volume_stack[0].shader !=
SHADER_NONE) {
64 Ray segment_ray = *ray;
65 segment_ray.
t = isect->t;
66 kernel_volume_shadow(
kg, shadow_sd, volume_state, &segment_ray, throughput);
84 kernel_volume_stack_enter_exit(
kg, shadow_sd, volume_state->volume_stack);
93 const uint visibility,
102 kernel_volume_shadow(
kg, shadow_sd,
state, ray, shadow);
108 #ifdef __TRANSPARENT_SHADOWS__
109 # ifdef __SHADOW_RECORD_ALL__
135 # define SHADOW_STACK_MAX_HITS 64
142 ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *
kg,
146 const uint visibility,
156 const bool blocked = scene_intersect_shadow_all(
kg, ray, hits, visibility, max_hits, &num_hits);
158 # ifdef __KERNEL_OPTIX__
167 if (!blocked && num_hits > 0) {
171 int bounce =
state->transparent_bounce;
174 # ifdef __SPLIT_KERNEL__
177 PathState *ps = shadow_blocked_volume_path_state(
kg, &volume_state,
state, sd, ray);
179 sort_intersections(hits, num_hits);
180 for (
int hit = 0; hit < num_hits; hit++, isect++) {
182 float new_t = isect->
t;
187 if (last_t == new_t) {
204 ray->
P = shadow_sd->P;
205 if (ray->
t != FLT_MAX) {
213 kernel_volume_shadow(
kg, shadow_sd, ps, ray, &throughput);
216 *shadow = throughput;
222 # ifdef __SPLIT_KERNEL__
225 PathState *ps = shadow_blocked_volume_path_state(
kg, &volume_state,
state, sd, ray);
226 kernel_volume_shadow(
kg, shadow_sd, ps, ray, shadow);
235 ccl_device bool shadow_blocked_transparent_all(KernelGlobals *
kg,
239 const uint visibility,
244 # ifdef __SPLIT_KERNEL__
247 # elif defined(__KERNEL_CUDA__)
253 # ifndef __KERNEL_GPU__
261 if (max_hits + 1 > SHADOW_STACK_MAX_HITS) {
262 if (
kg->transparent_shadow_intersections ==
NULL) {
263 const int transparent_max_bounce =
kernel_data.integrator.transparent_max_bounce;
265 (transparent_max_bounce + 1));
267 hits =
kg->transparent_shadow_intersections;
271 return shadow_blocked_transparent_all_loop(
272 kg, sd, shadow_sd,
state, visibility, ray, hits, max_hits, shadow);
276 # if defined(__KERNEL_GPU__) || !defined(__SHADOW_RECORD_ALL__)
289 ccl_device bool shadow_blocked_transparent_stepped_loop(KernelGlobals *
kg,
293 const uint visibility,
297 const bool is_transparent_isect,
301 # ifdef __KERNEL_OPTIX__
307 if (blocked && is_transparent_isect) {
310 int bounce =
state->transparent_bounce;
312 # ifdef __SPLIT_KERNEL__
315 PathState *ps = shadow_blocked_volume_path_state(
kg, &volume_state,
state, sd, ray);
318 if (bounce >=
kernel_data.integrator.transparent_max_bounce) {
324 if (!shader_transparent_shadow(
kg, isect)) {
341 if (ray->
t != FLT_MAX) {
349 kernel_volume_shadow(
kg, shadow_sd, ps, ray, &throughput);
352 *shadow *= throughput;
358 # ifdef __SPLIT_KERNEL__
361 PathState *ps = shadow_blocked_volume_path_state(
kg, &volume_state,
state, sd, ray);
362 kernel_volume_shadow(
kg, shadow_sd, ps, ray, shadow);
368 ccl_device bool shadow_blocked_transparent_stepped(KernelGlobals *
kg,
372 const uint visibility,
378 bool is_transparent_isect = blocked ? shader_transparent_shadow(
kg, isect) : false;
379 return shadow_blocked_transparent_stepped_loop(
380 kg, sd, shadow_sd,
state, visibility, ray, isect, blocked, is_transparent_isect, shadow);
394 #if !defined(__KERNEL_OPTIX__)
398 if (ray->
t == 0.0f) {
402 #ifdef __SHADOW_TRICKS__
413 #if !defined(__KERNEL_OPTIX__) || !defined(__TRANSPARENT_SHADOWS__)
415 # ifdef __TRANSPARENT_SHADOWS__
422 #ifdef __TRANSPARENT_SHADOWS__
423 # ifdef __SHADOW_RECORD_ALL__
427 const int transparent_max_bounce =
kernel_data.integrator.transparent_max_bounce;
431 if (
state->transparent_bounce >= transparent_max_bounce) {
434 uint max_hits = transparent_max_bounce -
state->transparent_bounce - 1;
435 # if defined(__KERNEL_OPTIX__)
439 max_hits =
min(max_hits, SHADOW_STACK_MAX_HITS - 1);
440 # elif defined(__KERNEL_GPU__)
448 const bool is_transparent_isect = blocked ? shader_transparent_shadow(
kg, &isect) :
false;
449 if (!blocked || !is_transparent_isect || max_hits + 1 >= SHADOW_STACK_MAX_HITS) {
450 return shadow_blocked_transparent_stepped_loop(
451 kg, sd, shadow_sd,
state, visibility, ray, &isect, blocked, is_transparent_isect, shadow);
454 return shadow_blocked_transparent_all(
455 kg, sd, shadow_sd,
state, visibility, ray, max_hits, shadow);
458 return shadow_blocked_transparent_stepped(
459 kg, sd, shadow_sd,
state, visibility, ray, &isect, shadow);
464 #undef SHADOW_STACK_MAX_HITS
ccl_device_inline float3 ray_offset(float3 P, float3 Ng)
ccl_device_intersect bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect)
CCL_NAMESPACE_BEGIN ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, const ShaderData *sd)
#define ccl_global_size(d)
#define ccl_device_forceinline
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_inline void path_state_modify_bounce(ccl_addr_space PathState *state, bool increase)
CCL_NAMESPACE_BEGIN ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state, ccl_global float *buffer, int path_flag)
CCL_NAMESPACE_BEGIN ccl_device_forceinline bool shadow_handle_transparent_isect(KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, Intersection *isect, Ray *ray, float3 *throughput)
ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *sd, ShaderData *shadow_sd, ccl_addr_space PathState *state, Ray *ray, float3 *shadow)
ccl_device bool shadow_blocked_opaque(KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, const uint visibility, Ray *ray, Intersection *isect, float3 *shadow)
#define kernel_split_state
@ PATH_RAY_SHADOW_NON_CATCHER
@ PATH_RAY_SHADOW_CATCHER
@ PATH_RAY_SHADOW_TRANSPARENT
ccl_device_inline float dot(const float2 &a, const float2 &b)
ccl_device_inline float2 normalize_len(const float2 &a, float *t)
ccl_device_inline bool is_zero(const float2 &a)
ccl_device_inline float3 one_float3()