The default render strategy used within the component. More...
Public Member Functions | |
DefaultRenderStrategy () noexcept | |
virtual | ~DefaultRenderStrategy () |
const nkMemory::BufferCast< SlotEntry > & | getSlots () const |
float | getLodQualityFactor () const |
bool | getFrustumCull () const |
bool | getOrderQueue () const |
bool | getUseLodSystem () const |
void | setLodQualityFactor (float value) |
void | setFrustumCull (bool value) |
void | setOrderQueue (bool value) |
void | setUseLodSystem (bool value) |
virtual RenderCommandQueue | bakeRenderCommandQueue (Shader *shader, bool transparent) override |
virtual void | updateAddRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override |
virtual void | updateEraseRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override |
Public Member Functions inherited from nkGraphics::RenderStrategy | |
RenderStrategy () | |
virtual | ~RenderStrategy () |
The default render strategy used within the component.
The strategy offers, out of the box, a way to render passes with some optimizations.
It will by default frustum cull, reorder, and collapse commands in an attempt to limit their number, and reduce the amount of GPU calls.
It will also use the rendering information by selecting one LOD to render from each slots provided. The selection will happen based on its quality metric, which is expected to represent its relative height in the view frustum.
|
noexcept |
Default constructor.
|
virtual |
Destructor.
const nkMemory::BufferCast<SlotEntry>& nkGraphics::DefaultRenderStrategy::getSlots | ( | ) | const |
float nkGraphics::DefaultRenderStrategy::getLodQualityFactor | ( | ) | const |
bool nkGraphics::DefaultRenderStrategy::getFrustumCull | ( | ) | const |
bool nkGraphics::DefaultRenderStrategy::getOrderQueue | ( | ) | const |
bool nkGraphics::DefaultRenderStrategy::getUseLodSystem | ( | ) | const |
void nkGraphics::DefaultRenderStrategy::setLodQualityFactor | ( | float | value | ) |
Sets the quality factor used for LOD selection. This is a direct multiplier for an object's height ratio when comparing it against the view's height. As an example, if an object has a height accounting for 20% of the view and the quality factor is set to 2, then the retained ratio will be 40%. By default, this is set to 1.
value | The factor to use during LOD selection. |
void nkGraphics::DefaultRenderStrategy::setFrustumCull | ( | bool | value | ) |
Sets whether the strategy should frustum cull or not when generating the command queue. Frustum culling adds a check when baking the LODs to render, by checking their bounds against the active camera frustum. If they are not inside, implying they won't color any pixels, then the drawing command won't be issued in the first place. On by default, this can be turned off to reduce load on CPU if required.
value | Whether the culling should happen (true) or not (false). |
void nkGraphics::DefaultRenderStrategy::setOrderQueue | ( | bool | value | ) |
Sets whether the strategy should reorder its commands or not within the command queue. Reordering aims to reduce the number of potential state switching required by the renderer, and improve drawing speed / quality. It will :
- If transparent : - Reorder from back to front to properly handle alpha blending - If not transparent : - If MonoMaterialPass : - Order by Mesh ID first to reduce the number of vertex buffer changes - Order from front to back to try to limit overdraw - If RenderScenePass : - Order by Program ID to reduce the number of PSO switches - Order by Mesh ID to then reduce the number of vertex buffer changes - Order from front to back to try to limit overdraw
Enabling it also allows to further optimize the queue as it will improve the command collapsing results, as similar resources using commands they get packed together. On by default, this can be turned off to reduce load on CPU if required.
value | Whether the reordering should happen (true) or not (false). |
void nkGraphics::DefaultRenderStrategy::setUseLodSystem | ( | bool | value | ) |
Sets whether the strategy should run its LOD selection logic during rendering.
If enabled, LOD selection will happen based an object's height ratio, compared against the view's height at object's distance. The metric is then expected to be a float within [0, 1+]. For instance, if a LOD level is marked with 0.6 as a value, then this LOD level will be used with the item is taking up to 60% of the view.
On by default, this can be turned off to reduce load on CPU if required. The LOD at index 0 will then be selected.
value | Whether the LOD selection should happen (true) or not (false). |
|
overridevirtual |
Generates the final command queue that will be communicated to the active Renderer. This method is called whenever a RenderQueue is rendered, and should return the queue to be executed from it.
shader | A shader, provided by a MonoMaterialPass if it is the caller, nullptr otherwise. |
transparent | Whether the pass has been marked as transparent (true) or not (false). |
Implements nkGraphics::RenderStrategy.
|
overridevirtual |
Called whenever a parent RenderQueue's Entity gets a new slot added to it.
ent | The entity calling. |
slot | The slot newly created. |
Implements nkGraphics::RenderStrategy.
|
overridevirtual |
Called whenever a parent RenderQueue's Entity loses a slot.
ent | The entity calling. |
slot | The slot erased. |
Implements nkGraphics::RenderStrategy.