Expand description
Custom GPU surface layers: splice a user’s terrain GLSL into the library template and drive the per-slot surface buffers on the render device.
This is the code-authored terrain extension point for consumers who want
procedural terrain that runs entirely on the GPU (no CPU bake pool). The user
writes a small .glsl file defining terrain_height / terrain_color (and
optionally terrain_normal); assemble_source wraps it in
TEMPLATE — which owns the per-texel gnomonic direction mapping, the
finite-difference auto-normal, and the writes into the same
surface_color/height/normal buffers the built-in realize/bake shaders read
when surface_enabled == 1. Godot’s RenderingDevice compiles the assembled
GLSL at runtime, so no slangc and nothing new ships — it reuses Godot’s
own shader compiler. The compiled pipeline runs as the
celestial/chunk-surface-custom node (crate::chunk_nodes::surface_custom),
between upload and realize.
Contrast with crate::surface::CpuSurfaceProvider, which bakes the same
buffers on CPU worker threads (for data-driven / streaming terrain).
Enums§
- Assemble
Error - Errors assembling a custom-surface shader from user GLSL.
Constants§
- MAX_
USER_ PARAMS - Max generic user params (
@export var name: float) surfaced to a GPU builder’s.glsl. Matches thefloat cels_user[16]tail in the template’s binding-4Paramsblock and the pad inpack_params. - TEMPLATE
- The library GLSL template. The user’s source replaces the
// __CELS_USER_CODE__marker line.
Functions§
- assemble_
source - Splice
user_glslintoTEMPLATE, producing a complete compute shader. - assemble_
source_ with_ params - Like
assemble_source, but also splices a#defineblock — one line perparam_namesentry — at the defines marker so the user’s.glslcan reference each@export var name: floaton the builder as the UPPERCASENAME(backed byP.cels_user[<index>]). Names pastMAX_USER_PARAMSare ignored (they have no backing slot). - pack_
params - Pack the custom-surface params buffer (std430) read by the template’s
binding-4
Paramsblock: the four fixed fields{chunk_count, tile_res, water_height, height_scale}followed byMAX_USER_PARAMSuser floats (cels_user[16]). Extrauservalues are ignored; missing ones are zero-filled. Total =16 + 4*MAX_USER_PARAMSbytes.