#[repr(C)]pub struct RtGeomEntry {
pub index_offset: u32,
pub base_vertex: u32,
pub albedo_index: u32,
pub normal_index: u32,
pub tint: [f32; 3],
pub roughness: f32,
pub metallic: f32,
pub emissive: [f32; 3],
pub model: [[f32; 4]; 4],
pub emissive_map_index: u32,
pub _pad: [u32; 3],
}Expand description
One entry of the ray-tracing geometry table, indexed by the intersector’s
instance_id (the instance’s position in the TLAS instance buffer, one
entry per instance, in instance order). Lets the RT kernel find the hit
triangle’s indices in the shared index buffer, transform its local-space
vertices into world space for the geometric normal, and pick a base albedo to
shade the hit with. #[repr(C)], 128 bytes: the layout must stay in sync
with the RtGeomEntry struct in the shared RT records (rt_types.slang), where
tint and emissive are packed_float3 so the field offsets match; a plain
float3 there would stride the buffer differently and fault the trace. The
_pad tail rounds the struct to 128 bytes so its array stride is a multiple
of the 16-byte GPU alignment of the float4x4 model (MSL/HLSL/GLSL round a
matrix-bearing struct up to a 16-byte multiple, so a 116-byte Rust struct
would stride 116 while the shader strides 128 and faults the trace). The
size_eq / offsets unit tests below lock the Rust side. The model matrix is
stored here (rather than read from the intersector’s instance transform) so
the kernel’s normal math is self-contained.
Fields§
§index_offset: u32Element offset of this object’s first index in the shared index buffer
(DrawObject::index_offset).
base_vertex: u32Value added to each fetched index before the vertex lookup
(DrawObject::base_vertex).
albedo_index: u32Index into the bindless albedo texture pool (DrawObject::texture_slot,
clamped to the albedo count). The textured RT-hit shader samples
tex_pool[albedo_index] at the hit UV; the flat fallback ignores it.
normal_index: u32Index into the bindless texture pool for this object’s normal map
(albedo_count + normal_map_slot). The textured RT-hit shader samples
tex_pool[normal_index] to perturb the hit normal via the interpolated
tangent frame; objects with no normal map resolve to the 1x1 flat-normal
fallback at normal slot 0, so the sample is always safe (no perturbation).
tint: [f32; 3]Base albedo for hit shading (the material tint), [r, g, b]. The
textured shader multiplies the sampled albedo by this; the flat fallback
uses it directly.
roughness: f32Surface roughness, used to pick the IBL prefilter mip at the hit.
metallic: f32Metallic factor [0, 1] for the hit PBR response: metals drop the diffuse term and tint the reflected environment specular by their albedo.
emissive: [f32; 3]Self-emission added to the hit colour, so glowing surfaces light up in
reflections regardless of incident lighting. Fills the three words that
pad metallic out to a 16-byte boundary (the MSL side reads it as a
packed_float3 at the same offset; the layout test pins the exact size).
model: [[f32; 4]; 4]Column-major object-to-world transform (DrawObject::model), used to
lift the hit triangle’s local-space vertices into world space.
emissive_map_index: u32Bindless albedo-pool index for the emissive map (0 = none). The textured
RT-hit shader multiplies the self-emission by this map sample, so glowing
textured surfaces (e.g. the bistro string lights) reflect in colour rather
than the scalar emissive; the flat fallback ignores it. Mirrors
MaterialUniforms::emissive_map_index / GpuObjectData::emissive_map_index.
_pad: [u32; 3]Pads the struct to 128 bytes (a multiple of the 16-byte GPU alignment of
the float4x4 model) so the Rust array stride matches the shader stride.
Trait Implementations§
Source§impl Clone for RtGeomEntry
impl Clone for RtGeomEntry
Source§fn clone(&self) -> RtGeomEntry
fn clone(&self) -> RtGeomEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more