9 RaySelfPrimitives
self;
20struct ShadowPayload : RayPayload {
24 uint *r_num_recorded_hits;
30 RaySelfPrimitives
self;
35 LocalIntersection *local_isect;
38# define SET_HIPRT_RAY(RAY_RT, RAY) \
39 RAY_RT.direction = RAY->D; \
40 RAY_RT.origin = RAY->P; \
41 RAY_RT.maxT = RAY->tmax; \
42 RAY_RT.minT = RAY->tmin;
44# define GET_TRAVERSAL_STACK() \
45 Stack stack(kg->global_stack_buffer, kg->shared_stack); \
46 Instance_Stack instance_stack;
48# define GET_TRAVERSAL_ANY_HIT(FUNCTION_TABLE, RAY_TYPE, RAY_TIME) \
49 hiprtSceneTraversalAnyHitCustomStack<Stack, Instance_Stack> traversal( \
50 (hiprtScene)kernel_data.device_bvh, \
55 hiprtTraversalHintDefault, \
57 kernel_params.FUNCTION_TABLE, \
61# define GET_TRAVERSAL_CLOSEST_HIT(FUNCTION_TABLE, RAY_TYPE, RAY_TIME) \
62 hiprtSceneTraversalClosestCustomStack<Stack, Instance_Stack> traversal( \
63 (hiprtScene)kernel_data.device_bvh, \
68 hiprtTraversalHintDefault, \
70 kernel_params.FUNCTION_TABLE, \
84 isect->prim = hit.primID + prim_offset;
85 isect->object = object_id;
113 const int prim_offset = data_offset.
y;
116 const int curve_index = prim_info.
x;
117 const int key_value = prim_info.
y;
119# ifdef __SHADOW_LINKING__
129 const float ray_time = payload->ray_time;
134 if (ray_time < prims_time.x || ray_time > prims_time.
y) {
140 const bool b_hit = curve_intersect(kg,
147 curve_index + prim_offset,
154 hit.primID = isect.
prim;
155 payload->prim_type = isect.
type;
170 const int prim_id_local =
kernel_data_fetch(custom_prim_info, hit.primID + data_offset.
x).x;
171 const int prim_id_global = prim_id_local + prim_offset;
194 hit.primID = isect.
prim;
195 payload->prim_type = isect.
type;
201ccl_device_inline bool motion_triangle_custom_local_intersect(
const hiprtRay &ray,
202 LocalPayload *payload,
205# ifdef __OBJECT_MOTION__
208 const int object_id = payload->local_object;
212 const int prim_id_local =
kernel_data_fetch(custom_prim_info, hit.primID + data_offset.
x).x;
213 const int prim_id_global = prim_id_local + prim_offset;
219 return motion_triangle_intersect_local(kg,
220 payload->local_isect,
237ccl_device_inline bool motion_triangle_custom_volume_intersect(
const hiprtRay &ray,
241# ifdef __OBJECT_MOTION__
254 const int prim_id_local =
kernel_data_fetch(custom_prim_info, hit.primID + data_offset.
x).x;
255 const int prim_id_global = prim_id_local + prim_offset;
278 hit.primID = isect.
prim;
279 payload->prim_type = isect.
type;
292# if defined(__POINTCLOUD__)
300 const int prim_id_local = prim_info.
x;
301 const int prim_id_global = prim_id_local + prim_offset;
303 const int primitive_type = prim_info.
y;
305# ifdef __SHADOW_LINKING__
315 const float ray_time = payload->ray_time;
320 if (ray_time < prims_time.x || ray_time > prims_time.
y) {
326 const bool b_hit = point_intersect(kg,
341 hit.primID = isect.
prim;
342 payload->prim_type = isect.
type;
361 const int prim = hit.primID + prim_offset;
363# ifdef __SHADOW_LINKING__
377 ShadowPayload *payload,
383 const uint num_hits = payload->num_hits;
384 const uint max_hits = payload->max_hits;
385 const int state = payload->in_state;
390 const int prim = hit.primID + prim_offset;
392 const float ray_tmax = hit.t;
394# ifdef __SHADOW_LINKING__
400# ifdef __VISIBILITY_FLAG__
401 if ((
kernel_data_fetch(objects,
object).visibility & payload->visibility) == 0) {
414 const float u = hit.uv.x;
415 const float v = hit.uv.y;
418# ifndef __TRANSPARENT_SHADOWS__
421 if (num_hits >= max_hits ||
427 uint record_index = *payload->r_num_recorded_hits;
429 payload->num_hits = num_hits + 1;
430 *(payload->r_num_recorded_hits) += 1;
433 if (record_index >= max_record_hits) {
435 uint max_recorded_hit = 0;
437 for (
int i = 1;
i < max_record_hits;
i++) {
439 if (isect_t > max_recorded_t) {
440 max_recorded_t = isect_t;
441 max_recorded_hit =
i;
445 if (ray_tmax >= max_recorded_t) {
449 record_index = max_recorded_hit;
464 ShadowPayload *payload,
470 const uint num_hits = payload->num_hits;
471 const uint num_recorded_hits = *(payload->r_num_recorded_hits);
472 const uint max_hits = payload->max_hits;
476 const int prim = hit.primID;
478 const float ray_tmax = hit.t;
480# ifdef __SHADOW_LINKING__
487# ifdef __VISIBILITY_FLAG__
488 if ((
kernel_data_fetch(objects,
object).visibility & payload->visibility) == 0) {
501 const float u = hit.uv.x;
502 const float v = hit.uv.y;
504 if (u == 0.0f || u == 1.0f) {
508 const int primitive_type = payload->prim_type;
510# ifndef __TRANSPARENT_SHADOWS__
513 if (num_hits >= max_hits ||
519 float throughput = *payload->r_throughput;
521 *payload->r_throughput = throughput;
522 payload->num_hits += 1;
533 LocalPayload *payload,
539 const int object_id = payload->local_object;
540 const uint max_hits = payload->max_hits;
555 const int prim = hit.primID + prim_offset;
556# ifndef __RAY_OFFSET__
566 const int hit_index = local_intersect_get_record_index(
567 payload->local_isect, hit.t, payload->lcg_state, max_hits);
568 if (hit_index == -1) {
572 Intersection *isect = &payload->local_isect->hits[hit_index];
577 isect->
object = object_id;
578 isect->
type = primitive_type;
580 payload->local_isect->Ng[hit_index] = hit.normal;
594 const int prim = hit.primID + prim_offset;
606HIPRT_DEVICE
bool intersectFunc(
const uint geom_type,
608 const hiprtFuncTableHeader &tableHeader,
613 const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
617 return curve_custom_intersect(ray, (RayPayload *)payload, hit);
620 return motion_triangle_custom_intersect(ray, (RayPayload *)payload, hit);
622 return motion_triangle_custom_local_intersect(ray, (LocalPayload *)payload, hit);
624 return motion_triangle_custom_volume_intersect(ray, (RayPayload *)payload, hit);
627 return point_custom_intersect(ray, (RayPayload *)payload, hit);
634HIPRT_DEVICE
bool filterFunc(
const uint geom_type,
636 const hiprtFuncTableHeader &tableHeader,
641 const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
644 return closest_intersection_filter(ray, (RayPayload *)payload, hit);
646 return shadow_intersection_filter_curves(ray, (ShadowPayload *)payload, hit);
650 return shadow_intersection_filter(ray, (ShadowPayload *)payload, hit);
653 return local_intersection_filter(ray, (LocalPayload *)payload, hit);
656 return volume_intersection_filter(ray, (RayPayload *)payload, hit);
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_forceinline int intersection_get_shader_flags(KernelGlobals kg, const int prim, const int type)
ccl_device_inline bool intersection_skip_shadow_link(KernelGlobals kg, const ccl_ray_data RaySelfPrimitives &self, const int isect_object)
ccl_device_inline bool intersection_skip_self_shadow(const ccl_ray_data RaySelfPrimitives &self, const int object, const int prim)
ccl_device_inline bool intersection_skip_self(const ccl_ray_data RaySelfPrimitives &self, const int object, const int prim)
#define CURVE_SHADOW_TRANSPARENCY_CUTOFF
ccl_device_inline float intersection_curve_shadow_transparency(KernelGlobals kg, const int object, const int prim, const int type, const float u)
ccl_device_forceinline bool intersection_skip_shadow_already_recoded(KernelGlobals kg, IntegratorShadowState state, const int object, const int prim, const int num_hits)
ccl_device_inline bool intersection_skip_self_local(const ccl_ray_data RaySelfPrimitives &self, const int prim)
#define kernel_data_fetch(name, index)
#define INTEGRATOR_SHADOW_ISECT_SIZE
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
@ Motion_Triangle_Filter_Volume
@ Motion_Triangle_Filter_Local
@ Triangle_Filter_Closest
@ Motion_Triangle_Filter_Shadow
@ Motion_Triangle_Intersect_Shadow
@ Curve_Intersect_Function
@ Motion_Triangle_Intersect_Function
@ Point_Intersect_Function
@ Motion_Triangle_Intersect_Volume
@ Motion_Triangle_Intersect_Local
@ SD_HAS_TRANSPARENT_SHADOW
ccl_device_inline bool motion_triangle_intersect(KernelGlobals kg, ccl_private Intersection *isect, const float3 P, const float3 dir, const float tmin, const float tmax, const float time, const uint visibility, const int object, const int prim, const int prim_addr)
#define INTEGRATOR_STATE_ARRAY_WRITE(state, nested_struct, array_index, member)
#define INTEGRATOR_STATE_ARRAY(state, nested_struct, array_index, member)