Ray tracing built-ins¶
Import: import system.gpu;
This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation. Shader-only declarations can be used only inside shader entry points and helpers reached from them; using them elsewhere is a compile error.
trace_ray¶
Traces ray against scene and waits for the hit or miss shader to fill in payload. Hits run the first hit group plus the instance's hit group offset; misses run the first miss shader. mask is compared with each instance's mask, so 255 sees everything.
public extern fun trace_ray<P>(
scene: GpuAccelerationStructure,
flags: GpuRayFlags,
mask: uint,
ray: GpuRay,
ref payload: P
): void
trace_ray_indexed¶
Like trace_ray, selecting hit groups as hit_group_offset + instance offset * hit_group_stride and the miss shader by miss_index, for several ray types in one pipeline.
public extern fun trace_ray_indexed<P>(
scene: GpuAccelerationStructure,
flags: GpuRayFlags,
mask: uint,
hit_group_offset: int,
hit_group_stride: int,
miss_index: int,
ray: GpuRay,
ref payload: P
): void
call_shader¶
Runs the pipeline's callable shader number index with data.
dispatch_ray_index¶
This thread's position in the ray tracing dispatch grid, for example its pixel.
dispatch_ray_dimensions¶
The size of the ray tracing dispatch grid.
world_ray_origin¶
The current ray's origin in world space.
world_ray_direction¶
The current ray's direction in world space.
object_ray_origin¶
The current ray's origin in the hit instance's object space.
object_ray_direction¶
The current ray's direction in the hit instance's object space.
ray_t_min¶
The current ray's t_min.
ray_t_current¶
The distance to the current hit, or the ray's t_max in miss shaders.
hit_instance_id¶
The GpuInstance.with_id value of the hit instance.
hit_primitive_index¶
The index of the hit triangle or box within its geometry.
hit_kind¶
The value the intersection shader passed to report_hit as kind, or 254 and 255 for front- and back-facing triangles.
ignore_hit¶
Rejects the current candidate hit; the ray continues as if it was not there.
accept_hit_and_end_search¶
Accepts the current candidate hit and stops searching; the closest-hit shader runs for it.
report_hit¶
Reports a hit on custom geometry at distance t with a kind from 0 to 127 and the attributes the hit shaders receive. Returns true when the hit was accepted.