9 RaySelfPrimitives
self;
20struct ShadowPayload : RayPayload {
22 uint max_transparent_hits;
23 uint num_transparent_hits;
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,
236ccl_device_inline bool motion_triangle_custom_volume_intersect(
const hiprtRay &ray,
240# ifdef __OBJECT_MOTION__
253 const int prim_id_local =
kernel_data_fetch(custom_prim_info, hit.primID + data_offset.
x).x;
254 const int prim_id_global = prim_id_local + prim_offset;
277 hit.primID = isect.
prim;
278 payload->prim_type = isect.
type;
291# if defined(__POINTCLOUD__)
299 const int prim_id_local = prim_info.
x;
300 const int prim_id_global = prim_id_local + prim_offset;
302 const int primitive_type = prim_info.
y;
304# ifdef __SHADOW_LINKING__
314 const float ray_time = payload->ray_time;
319 if (ray_time < prims_time.x || ray_time > prims_time.
y) {
325 const bool b_hit = point_intersect(kg,
340 hit.primID = isect.
prim;
341 payload->prim_type = isect.
type;
360 const int prim = hit.primID + prim_offset;
362# ifdef __SHADOW_LINKING__
376 ShadowPayload *payload,
382 uint num_transparent_hits = payload->num_transparent_hits;
383 const uint max_transparent_hits = payload->max_transparent_hits;
384 const int state = payload->in_state;
389 const int prim = hit.primID + prim_offset;
391 const float ray_tmax = hit.t;
393# ifdef __SHADOW_LINKING__
399# ifdef __VISIBILITY_FLAG__
400 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__
427 if (num_transparent_hits > max_transparent_hits) {
431 uint record_index = *payload->r_num_recorded_hits;
433 payload->num_transparent_hits = num_transparent_hits;
434 *(payload->r_num_recorded_hits) += 1;
437 if (record_index >= max_record_hits) {
439 uint max_recorded_hit = 0;
441 for (
int i = 1;
i < max_record_hits;
i++) {
443 if (isect_t > max_recorded_t) {
444 max_recorded_t = isect_t;
445 max_recorded_hit =
i;
449 if (ray_tmax >= max_recorded_t) {
453 record_index = max_recorded_hit;
468 ShadowPayload *payload,
474 uint num_transparent_hits = payload->num_transparent_hits;
475 const uint num_recorded_hits = *(payload->r_num_recorded_hits);
476 const uint max_transparent_hits = payload->max_transparent_hits;
480 const int prim = hit.primID;
482 const float ray_tmax = hit.t;
484# ifdef __SHADOW_LINKING__
491# ifdef __VISIBILITY_FLAG__
492 if ((
kernel_data_fetch(objects,
object).visibility & payload->visibility) == 0) {
507 const float u = hit.uv.x;
508 const float v = hit.uv.y;
510 if (u == 0.0f || u == 1.0f) {
514 const int primitive_type = payload->prim_type;
516# ifndef __TRANSPARENT_SHADOWS__
525 if (num_transparent_hits > max_transparent_hits) {
529 float throughput = *payload->r_throughput;
531 *payload->r_throughput = throughput;
532 payload->num_transparent_hits = num_transparent_hits;
543 LocalPayload *payload,
549 const int object_id = payload->local_object;
550 const uint max_hits = payload->max_hits;
565 const int prim = hit.primID + prim_offset;
566# ifndef __RAY_OFFSET__
576 const int hit_index = local_intersect_get_record_index(
577 payload->local_isect, hit.t, payload->lcg_state, max_hits);
578 if (hit_index == -1) {
582 Intersection *isect = &payload->local_isect->hits[hit_index];
587 isect->
object = object_id;
588 isect->
type = primitive_type;
590 payload->local_isect->Ng[hit_index] = hit.normal;
604 const int prim = hit.primID + prim_offset;
616HIPRT_DEVICE
bool intersectFunc(
const uint geom_type,
618 const hiprtFuncTableHeader &tableHeader,
623 const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
627 return curve_custom_intersect(ray, (RayPayload *)payload, hit);
630 return motion_triangle_custom_intersect(ray, (RayPayload *)payload, hit);
632 return motion_triangle_custom_local_intersect(ray, (LocalPayload *)payload, hit);
634 return motion_triangle_custom_volume_intersect(ray, (RayPayload *)payload, hit);
637 return point_custom_intersect(ray, (RayPayload *)payload, hit);
644HIPRT_DEVICE
bool filterFunc(
const uint geom_type,
646 const hiprtFuncTableHeader &tableHeader,
651 const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
654 return closest_intersection_filter(ray, (RayPayload *)payload, hit);
656 return shadow_intersection_filter_curves(ray, (ShadowPayload *)payload, hit);
660 return shadow_intersection_filter(ray, (ShadowPayload *)payload, hit);
663 return local_intersection_filter(ray, (LocalPayload *)payload, hit);
666 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_forceinline bool intersection_skip_shadow_already_recoded(IntegratorShadowState state, const int object, const int prim, const int num_hits)
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_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)