Expand description
GPU.10 — KV6 sprite as a DDA-marchable voxel model.
Unlike the GPU.9 splatter (one thread per voxel, screen-space squares, overdraw + atomic contention), a sprite model is a small voxel volume the precise ray-DDA marches one ray per pixel — crisp, correct occlusion, no overdraw. This is the GPU.10.0 single sprite; instancing + tiling + LOD come in later sub-substages.
The volume reuses the chunk occupancy/colour scheme but sized to
the KV6 bbox: per-column occupancy bitmask (occ_words_per_col
u32s, CHUNK_Z-style 32-bits-per-word), a flat colour array in
ascending-z order per column, and a color_offsets prefix table.
The shader finds a voxel’s colour by offset[col] + popcount(bits below z), so colours MUST be ascending-z (we sort per column).
Structs§
- Sprite
Instance - One sprite instance: a model reference + world pose.
- Sprite
Instance Transform - Per-instance transform consumed by the model-DDA shader: the
inverse model→world rotation (so a world ray can be brought into
model-local space) plus the instance’s world position. Stored as
three padded columns for std140/std430 (
mat3x316-byte columns). - Sprite
Model - CPU-built voxel volume for one KV6 model.
- Sprite
Model Registry - A registry of sprite models. Instances reference a model by
model_id, which is a LOD chain id: each chain holds one or more concrete mip levels (finest first; GPU.10.4), and the renderer picks the level per instance by distance. Identical KV6s are added once and shared by many instances. Copy-on-modify:Self::forkdeep-copies a chain so edits to the fork leave the parent (and its instances) intact. - Sprite
Registry Resident - GPU-resident registry + instances: every model’s occupancy / colours / offsets concatenated into shared storage buffers, a per-model metadata table, and a capacity-sized instance buffer rewritten each frame with the frustum-visible subset (GPU.10.2). One bind group serves all models (same approach as the multi-grid scene).
- View
Frustum - View frustum for CPU instance culling, in world space. Built each
frame from the world camera.
half_w/half_hare the tangents of the half-FOV (so the side planes are|x| <= half_w * zetc. in camera space).
Functions§
- build_
sprite_ model - Build the DDA volume from a KV6. Columns are packed in
x + y*mxorder; each column’s voxels are sorted ascending by z so the shader’s popcount-rank colour lookup is correct.