Skip to main content

Module surface

Module surface 

Source
Expand description

Neutral CPU-baked surface type + the provider trait that supplies it.

The chunked planet bakes each chunk’s surface into three per-slot GPU buffers — colour (rgba8), height (f32, in the provider’s own vertical unit) and normal (rgba8-packed) — and the realize/bake shaders read them when the surface is enabled. TWO paths fill those buffers:

This module holds ONLY the neutral data type and the trait — no concrete surface source, no Godot rendering.

Structs§

ChunkSurface
A resampled per-chunk surface: color is tile_res·tile_res·4 RGBA8, height is tile_res·tile_res elevations (the provider’s vertical unit, scaled by CpuSurfaceProvider::height_scale on the GPU), and normal is tile_res·tile_res·4 rgba8-packed world normals — all row-major. The chunk’s real footprint is the lower-left triangle, but the WHOLE square holds valid data (texels past the diagonal replicate the nearest diagonal sample; see [crate::surface_tiles::build_patch]).

Traits§

CpuSurfaceProvider
A source of CPU-baked chunk surfaces (colour/height/normal). Implementors run on the bake worker pool (bake is called off the main thread, so it must be Send + Sync and use interior mutability for any shared state). The other hooks run on the main thread.