#[repr(C)]pub struct GpuLight {
pub position: [f32; 3],
pub range: f32,
pub color: [f32; 3],
pub intensity: f32,
pub direction: [f32; 3],
pub kind: u32,
pub cos_inner: f32,
pub cos_outer: f32,
pub shadow_index: i32,
pub data_index: i32,
}Expand description
One local light in the per-scene storage buffer the forward pass iterates
(bound at Metal fragment buffer(8)). 64 bytes = four 16-byte lanes, so every
packed_float3 sits inside one lane with no GPU alignment promotion. Must match
the GpuLight struct in the single-source shaders.
Fields§
§position: [f32; 3]World-space position (point / spot).
range: f32Maximum reach in metres; attenuation reaches zero at this distance.
color: [f32; 3]Linear RGB light colour.
intensity: f32Radiance scale.
direction: [f32; 3]Unit vector the light points along (spot / area). Zero for a point light.
kind: u32LIGHT_KIND_* discriminant.
cos_inner: f32Spot cone: cosine of the inner (full-bright) and outer (cutoff) half-angles.
Both zero for a point light; the shader gates the cone term on kind.
cos_outer: f32Cosine of the spot cone’s outer (cutoff) half-angle.
shadow_index: i32Index into the spot shadow atlas, or -1 when the light casts no shadow.
data_index: i32Index into the AreaLightData table for an area light, or -1 for a point /
spot light. A rect needs two edge vectors that do not fit in the spare
fields here, so the extra data lives in a parallel table (the same shape
shadow_index uses for the spot shadow slices).