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