concinnity_render/uniforms/geometry.rs
1//! The passes that draw their own geometry into the main target: projected
2//! decals, world-space lines, and the GPU particle system.
3
4/// Per-frame view inputs to the projected-decal pass. Matches `DecalView` in
5/// `shaders/decal.slang`. 144 bytes.
6#[derive(Copy, Clone, bytemuck::NoUninit)]
7#[repr(C)]
8pub struct DecalView {
9 /// View-projection matrix used by the main pass (jittered when TAA is on).
10 pub vp: [[f32; 4]; 4],
11 /// Inverse of `vp`. The fragment shader uses it to reconstruct world space
12 /// from the depth attachment at each pixel.
13 pub inv_vp: [[f32; 4]; 4],
14 /// HDR target dimensions in pixels: drives the screen->NDC conversion.
15 pub viewport: [f32; 2],
16 /// Padding so the field layout matches the shader-side struct.
17 pub _pad: [f32; 2],
18}
19
20/// Per-decal uniforms uploaded before each draw. Matches `DecalParams` in
21/// `shaders/decal.slang`. 160 bytes (two float4x4s, a float4 tint, four scalars).
22#[derive(Copy, Clone, bytemuck::NoUninit)]
23#[repr(C)]
24pub struct DecalParams {
25 /// Model matrix, column-major.
26 pub model: [[f32; 4]; 4],
27 /// Inverse model matrix, column-major.
28 pub inv_model: [[f32; 4]; 4],
29 /// Linear RGBA tint multiplied into the sampled image.
30 pub tint: [f32; 4],
31 /// Exponent of the edge fade curve.
32 pub fade_pow: f32,
33 /// Padding so the field layout matches the shader-side struct.
34 pub _pad0: f32,
35 /// Padding so the field layout matches the shader-side struct.
36 pub _pad1: f32,
37 /// Padding so the field layout matches the shader-side struct.
38 pub _pad2: f32,
39}
40
41/// Per-frame view inputs to the line pass. Matches `LineView` in
42/// `shaders/line.slang`. 80 bytes.
43#[derive(Copy, Clone, bytemuck::NoUninit)]
44#[repr(C)]
45pub struct LineView {
46 /// View-projection matrix used by the main pass (jittered when TAA is on),
47 /// so a line lands on the same pixel the geometry it sits on did.
48 pub vp: [[f32; 4]; 4],
49 /// Alpha multiplier applied where a line falls behind scene geometry.
50 pub occluded_alpha: f32,
51 /// Padding so the field layout matches the shader-side struct.
52 pub _pad: [f32; 3],
53}
54
55/// Per-frame view inputs to the particle render pass. Matches `ParticleView` in
56/// `shaders/particle.slang`. 96 bytes.
57#[derive(Copy, Clone, bytemuck::NoUninit)]
58#[repr(C)]
59pub struct ParticleView {
60 /// View-projection matrix used by the main pass.
61 pub vp: [[f32; 4]; 4],
62 /// World-space camera right vector: drives the first billboard axis. The
63 /// shader reads a float4 whose trailing component is unused padding.
64 pub cam_right: [f32; 3],
65 /// Padding so the field layout matches the shader-side struct.
66 pub _pad0: f32,
67 /// World-space camera up vector: drives the second billboard axis.
68 pub cam_up: [f32; 3],
69 /// Padding so the field layout matches the shader-side struct.
70 pub _pad1: f32,
71}
72
73/// One particle slot in the pool the simulation kernel writes and the render
74/// pair reads. Matches `Particle` in `shaders/particle_types.slang`, which
75/// spells the same 32 bytes as two float4 lanes.
76#[derive(Copy, Clone, Default)]
77#[repr(C)]
78pub struct GpuParticle {
79 /// World-space position.
80 pub position: [f32; 3],
81 /// Seconds since the particle spawned.
82 pub age: f32,
83 /// World-space velocity in units per second.
84 pub velocity: [f32; 3],
85 /// Total lifetime in seconds.
86 pub lifetime: f32,
87}
88
89/// Per-dispatch parameters for the `rt_skin` compute kernel, which deforms one
90/// skinned object's bind-pose vertices into the shared deformed buffer the RT
91/// acceleration structure traces. Matches `SkinParams` in `rt_skin.slang`.
92///
93/// Metal writes it to buffer(3), Vulkan pushes it, DirectX takes it as root
94/// constants at b0.
95#[repr(C)]
96#[derive(Clone, Copy, bytemuck::NoUninit)]
97pub struct SkinParams {
98 /// First vertex of this object's region in the shared vertex buffer.
99 pub vertex_base: u32,
100 /// Vertices this dispatch deforms.
101 pub vertex_count: u32,
102 /// Palette size; joint indices are clamped below it.
103 pub joint_count: u32,
104 /// Morph targets in the delta buffer; zero when the object has none.
105 pub target_count: u32,
106}