celestialsim/chunk_nodes/surface_custom.rs
1//! `celestial/chunk-surface-custom` — fill the per-slot surface buffers from a
2//! user's runtime-compiled GLSL (`crate::custom_surface`).
3//!
4//! Runs between upload and realize: one thread per tile texel of each realized
5//! chunk writes `surface_color/height/normal`, which realize (displacement) and
6//! bake (albedo/normal) then read via the existing `surface_enabled` path. A
7//! no-op unless a custom GPU surface is installed AND its shader compiled — the
8//! params transfer happens in the upload node (`upload_custom_params`), so this
9//! node only records the dispatch inside the compute list.
10
11use crate::chunk_nodes::ChunkNode;
12use crate::chunk_pipeline::ChunkCtx;
13
14pub struct ChunkSurfaceCustom;
15
16impl ChunkNode for ChunkSurfaceCustom {
17 fn name(&self) -> &'static str {
18 "celestial/chunk-surface-custom"
19 }
20
21 fn record(&mut self, ctx: &mut ChunkCtx<'_>) {
22 let count = ctx.realize_count;
23 if count == 0 || !ctx.gpu.custom_ready() {
24 return;
25 }
26 let list = ctx.list();
27 let mut rd = ctx.rd.clone();
28 ctx.gpu.record_custom_surface(&mut rd, list, count);
29 }
30}