Skip to main content

celestialsim/chunk_nodes/
bake.rs

1//! `celestial/chunk-bake` — Phase-4 compute dispatch that bakes per-chunk
2//! colour + normal detail tiles into the atlas textures. One thread per tile
3//! texel (`realize_count * tile_res²`). Runs after `chunk-realize`; reads the
4//! same uploaded descriptors and writes the colour/normal atlases the surface
5//! fragment shader samples.
6
7use crate::chunk_nodes::ChunkNode;
8use crate::chunk_pipeline::ChunkCtx;
9
10pub struct ChunkBake;
11
12impl ChunkNode for ChunkBake {
13    fn name(&self) -> &'static str {
14        "celestial/chunk-bake"
15    }
16
17    fn record(&mut self, ctx: &mut ChunkCtx<'_>) {
18        let count = ctx.realize_count;
19        if count == 0 {
20            return;
21        }
22        let tr = ctx.gpu.tile_res();
23        let texel_threads = count * tr * tr;
24        let list = ctx.list();
25        let mut rd = ctx.rd.clone();
26        ctx.gpu.record_bake(&mut rd, list, texel_threads);
27    }
28}