Skip to main content

cvkg_render_gpu/passes/
gi.rs

1//! Global Illumination (GI) and Baked Lightmaps / Irradiance Volumes pass structures.
2//! Provides precomputed indirect diffuse and specular lighting inputs to PBR shaders.
3
4use crate::kvasir::nodes::PassId;
5use crate::kvasir::{ExecutionContext, KvasirNode, ResourceId};
6
7/// Irradiance Volume configuration representing a grid of light probes.
8#[derive(Debug, Clone)]
9pub struct IrradianceVolume {
10    /// Dimension bounds (min corner in world space).
11    pub origin: glam::Vec3,
12    /// Probe step distance/spacing.
13    pub spacing: glam::Vec3,
14    /// Probe count in x, y, and z.
15    pub dimensions: [u32; 3],
16}
17
18/// Environment probe for local specular reflections.
19#[derive(Debug, Clone)]
20pub struct EnvironmentProbe {
21    /// Center of the probe capture region.
22    pub center: glam::Vec3,
23    /// Influence bounds for box/sphere projection.
24    pub bounds_half_size: glam::Vec3,
25}
26
27/// GI contribution pass node.
28pub struct GlobalIlluminationNode {
29    /// Irradiance Volume configuration parameters.
30    pub volume: IrradianceVolume,
31    /// Local specular environment probes active in the scene.
32    pub environment_probes: Vec<EnvironmentProbe>,
33    /// Global baked lightmap texture (if present).
34    pub lightmap: Option<ResourceId>,
35}
36
37impl KvasirNode for GlobalIlluminationNode {
38    fn label(&self) -> &'static str {
39        "GlobalIlluminationPass"
40    }
41
42    fn inputs(&self) -> &[ResourceId] {
43        &[]
44    }
45
46    fn outputs(&self) -> &[ResourceId] {
47        &[]
48    }
49
50    fn pass_id(&self) -> PassId {
51        PassId::Opaque3d
52    }
53
54    fn execute(&self, _ctx: &mut ExecutionContext) {
55        tracing::debug!(
56            "GlobalIlluminationNode::execute - Sampling baked GI inputs: grid dimensions: {:?}, active probes: {}",
57            self.volume.dimensions,
58            self.environment_probes.len()
59        );
60        // Prepares light volume uniforms or samples precomputed GI.
61    }
62}