-
-
Notifications
You must be signed in to change notification settings - Fork 53
How It Works
BACK > Home
This page explains how the functionality behind kDecals works.
Data diagram for kDecals.
Decals are created either manually in the Editor or at runtime via the DecalSystem
API. All enabled decals are tracked by the DecalSystem
.
Each decal generates a projection matrix and set of clip planes. These are cached and only updated when the decal's DecalData or Transform are altered.
The DecalRenderereature
creates an instance of a DecalRenderPass
to use for decal rendering. A single pass is used, looping over all decals.
The first part of rendering is sorting. All active decals on the DecalSystem
are sorted by their Sorting Order. Decals with the same sorting order are drawn in an undefined order.
Next culling is calculated per decal. Culling happens in three stages. First the decal is culled if it is behind the camera. Next it is culled if it is outside the active Camera frustum. Finally, object culling results are calculated using the decal's clip planes. These are used later for drawing.
Next, per-decal shader uniforms are set. These include the decal's projection matrix, direction and DecalData properties.
Finally, the decal is drawn. Sorting, drawing and filtering settings are created from the DecalData and DrawRenderers
is called. Objects projected on by the same decal are batched, regardless of their own batching properties.