Render stages
Render stages define how given objects are rendered (usually with their associated effect/shader). They also let you control advanced properties such as sorting and filtering objects.
Opaque and ShadowCaster stages, or the Transparent stage.
Note
graphics compositor.
Effect slots
Effect slots determine which effect/shader a render stage uses. You choose the effect slot with EffectSlotName. If multiple render stages exclusively render different objects, the stages can share the same effect slot. For example, as the opaque stage only renders opaque objects and the transparent stage only renders transparent objects, both stages can use the main effect slot. If they render any of the same objects, they can’t share effect slots. This is why, for example, we typically render opaque meshes with the main effect slot, then render opaque meshes again with the shadow caster effect slot to create shadows. A typical setup of render stages:
Sort objects in a render stage
SortMode defines how Xenko sorts objects in that render stage. Xenko comes with several SortMode implementations, such as:
- FrontToBackSortMode, which renders objects from front to back with limited precision, and tries to avoid state changes in the same depth range of objects (useful for opaque objects and shadows)
- BackToFrontSortMode, which renders objects strictly from back to front (useful for transparent objects)
- StateChangeSortMode, which tries to reduce state changesOf course, you’re free to implement your own, too.
Filter objects in a render stage
RenderStageFilter.Render stage selectors
Render stage selectors define which objects in your scene are sent to which render stage, and choose which effect to use when rendering a given object. For example, this is the typical setup for meshes: - MeshTransparentRenderStageSelector chooses either the
MainorTransparentrender stage, depending on the material properties. The default effect isXenkoForwardShadingEffectdefined by Xenko (you can create your own if you want). - ShadowMapRenderStageSelector selects opaque meshes that cast shadows and adds them to the
ShadowMapCasterrender stage. The default effect isXenkoForwardShadingEffect.ShadowMapCaster, defined by Xenko.Either can filter by render group. You can customize everything, so you can add other predefined render stage selectors (eg to add UI to a later full-screen pass), or create your own selector specific to your game.See also
- Rendering pipeline
- Render features
- Effects and shaders
- Graphics compositor
