Skip to main content

proof_engine/svogi/
mod.rs

1// Sparse Voxel Octree Global Illumination (SVOGI)
2//
3// Clean-room implementation based on published SIGGRAPH papers:
4// - Crassin et al., "Interactive Indirect Illumination Using Voxel Cone Tracing" (2011)
5// - Kaplanyan & Dachsbacher, "Cascaded Light Propagation Volumes" (2010)
6// - Kaplanyan, "Light Propagation Volumes in CryEngine 3" (2009)
7
8pub mod octree;
9pub mod voxelize;
10pub mod atlas;
11pub mod inject;
12pub mod propagate;
13pub mod cone_trace;
14pub mod integration;
15pub mod sh;
16
17pub use octree::{SparseVoxelOctree, OctreeNode, VoxelData, VoxelGrid, Aabb};
18pub use voxelize::{VoxelizeConfig, Triangle, voxelize_triangles};
19pub use atlas::{BrickAtlas, Brick, BlockPacker};
20pub use inject::{LightSource, DirectionalLight, PointLight, SpotLight, ShadowMap};
21pub use propagate::{PropagationConfig, propagate_light};
22pub use cone_trace::{ConeTraceConfig, ConeTraceResult, trace_cone};
23pub use integration::{SvogiSystem, SvogiConfig};
24pub use sh::{SH2, SH3};
25
26pub use octree::morton_encode_3d;
27pub use octree::morton_decode_3d;
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32    use glam::Vec3;
33
34    #[test]
35    fn full_pipeline_smoke_test() {
36        let bounds = Aabb { min: Vec3::ZERO, max: Vec3::splat(8.0) };
37        let config = SvogiConfig {
38            resolution: 8,
39            max_depth: 3,
40            gi_intensity: 1.0,
41            ao_intensity: 1.0,
42            bounce_count: 2,
43            update_rate: integration::UpdateRate::EveryFrame,
44        };
45        let mut system = SvogiSystem::init(bounds, config);
46
47        let tri = Triangle {
48            v0: Vec3::new(1.0, 1.0, 1.0),
49            v1: Vec3::new(3.0, 1.0, 1.0),
50            v2: Vec3::new(2.0, 3.0, 1.0),
51            normal: Vec3::Z,
52            color: glam::Vec4::new(1.0, 0.0, 0.0, 1.0),
53            emission: glam::Vec4::ZERO,
54        };
55        system.voxelize_scene(&[tri]);
56        assert!(system.octree.node_count() > 0);
57    }
58}