#[repr(C)]pub struct FogParams {Show 17 fields
pub inv_vp: [[f32; 4]; 4],
pub color: [f32; 4],
pub cam_pos: [f32; 3],
pub _pad0: f32,
pub sun_dir: [f32; 3],
pub _pad1: f32,
pub sun_color: [f32; 3],
pub _pad2: f32,
pub density: f32,
pub height_falloff: f32,
pub height_reference: f32,
pub max_distance: f32,
pub phase_g: f32,
pub ambient: f32,
pub viewport: [f32; 2],
pub inv_max_distance: f32,
pub _pad3: [f32; 3],
}Expand description
Per-frame uniform consumed by the volumetric-fog ray-march. Carries the
clamped authored tunables plus the view inputs the shader needs to
reconstruct world positions from depth and integrate sun-aligned
scattering. Pushed verbatim to the fog fragment shader, so the layout must
stay in sync with FogParams in metal/shaders/fog.metal. 176 bytes.
Fields§
§inv_vp: [[f32; 4]; 4]Inverse view-projection: reconstructs world position from depth.
color: [f32; 4]Linear-space fog tint (RGB); alpha unused.
cam_pos: [f32; 3]World-space camera position. The marcher starts here and walks the
view ray to the scene point. _pad keeps cam_pos 16-byte aligned
inside MSL.
_pad0: f32Padding so the field layout matches the shader-side struct.
sun_dir: [f32; 3]First directional light’s world-space direction (toward the light), used for the Henyey-Greenstein phase and the per-step sun radiance.
_pad1: f32Padding so the field layout matches the shader-side struct.
sun_color: [f32; 3]First directional light’s colour pre-multiplied with its intensity. Drives the per-step sun in-scatter alongside the phase function.
_pad2: f32Padding so the field layout matches the shader-side struct.
density: f32Base density at height_reference (per world unit).
height_falloff: f32Exponential height-falloff rate; 0 = homogeneous medium.
height_reference: f32World-space Y at which density equals density.
max_distance: f32Ray-march cap in world units.
phase_g: f32Henyey-Greenstein anisotropy in (-0.95, 0.95).
ambient: f32Ambient (sky-side) scattering term added each step.
viewport: [f32; 2]Width / height of the HDR resolve target in pixels: drives the screen→NDC conversion in the fragment shader.
inv_max_distance: f32Pre-computed reciprocal of max_distance; the shader uses it to skip
a per-step 1 / max_distance divide.
_pad3: [f32; 3]Padding so the field layout matches the shader-side struct.