Skip to main content

Module decal

Module decal 

Source
Expand description

Backend-agnostic decal support. Owns the per-decal model / inverse-model matrix math the projected-decal pass needs at runtime, the DecalRecord the backends consume, and the DecalSet slot table they drive the pass from. Decals are stamped onto the scene depth buffer by drawing a unit-box volume per decal: the fragment shader reconstructs the world-space point of each rasterised pixel from depth and tests whether it lies inside the box.

Structs§

AtCapacity
Returned by DecalSet::insert when every slot up to the set’s capacity is live. The capacity is the backend’s own per-decal descriptor reservation, so the backend words the error.
DecalRecord
Per-decal data the renderer consumes each frame. Built once at GraphicsSystem init from the world’s Decal components.
DecalSet
The decals a backend’s projected-decal pass draws, addressed by the slot id DecalSet::insert returns. That id is stable until DecalSet::remove tombstones it, and indexes the backend’s parallel per-decal resources (an albedo descriptor, a uniform ring slot).
VisibleDecal
A decal that survived the frustum cull, with the per-decal inputs its draw needs.

Enums§

RemoveError
Why DecalSet::remove rejected an id.

Functions§

build_decal_records
Resolve a list of Decal components into DecalRecords the backend can consume. Skips decals whose texture reference is missing, invisible decals, and decals whose size is degenerate (any non-positive component).
decal_model_matrix
Build the world-space model matrix for a decal: T(position) * R_yxz * S(size). Column-major; the inner index is the row. Matches the rotation convention used by Prop::model_matrix.
invert_decal_model
Invert an affine TRS matrix of the form built by decal_model_matrix. The 3×3 linear part is R * diag(size); its inverse is diag(1/size) * R_transpose. The translation flips into the inverted frame: -inv_linear * translation.