Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CDeferredRP Class Reference

This object class will perform draw commands using "Deferred rendering". More...

#include <RenderPipeline/CDeferredRP.h>

Inheritance diagram for Skylicht::CDeferredRP:
Skylicht::CBaseRP irr::IEventReceiver Skylicht::IRenderPipeline

Public Member Functions

virtual bool OnEvent (const SEvent &event)
 Called if an event happened.
virtual bool canRenderMaterial (CMaterial *material)
virtual bool canRenderShader (CShader *shader)
virtual void initRender (int w, int h)
virtual void resize (int w, int h)
virtual void render (ITexture *target, CCamera *camera, CEntityManager *entityManager, const core::recti &viewport, int cubeFaceId=-1, IRenderPipeline *lastRP=NULL)
virtual void drawMeshBuffer (CMesh *mesh, int bufferID, CEntityManager *entity, int entityID, bool skinnedMesh)
virtual void drawInstancingMeshBuffer (CMesh *mesh, int bufferID, CShader *instancingShader, CEntityManager *entityMgr, int entityID, bool skinnedMesh)
void getRenderLightRect (CCamera *camera, const core::aabbox3df &box, float &x, float &y, float &w, float &h, float maxW, float maxH)
void setPostProcessor (IPostProcessor *pp)
void setIndirectMultipler (float f)
void setDirectMultipler (float f)
void setLightMultipler (float f)
Public Member Functions inherited from Skylicht::CBaseRP
virtual void setCamera (CCamera *camera)
virtual void setNextPipeLine (IRenderPipeline *next)
virtual void onNext (ITexture *target, CCamera *camera, CEntityManager *entity, const core::recti &vp, int cubeFaceId)
virtual void updateTextureResource (CMesh *mesh, int bufferID, CEntityManager *entity, int entityID, bool skinnedMesh)
virtual void updateShaderResource (CShader *shader, CEntityManager *entity, int entityID, video::SMaterial &irrMaterial)
void beginRender2D (float w, float h)
void renderBufferToTarget (float sx, float sy, float sw, float sh, SMaterial &material, bool flipY=true, bool flipX=false)
void renderBufferToTarget (float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh, SMaterial &material, bool flipY=true, bool flipX=false)
void renderEnvironment (CCamera *camera, CEntityManager *entityMgr, const core::vector3df &position, ITexture *texture[], int *face, int numFace, bool allPipeline)
void renderCubeEnvironment (CCamera *camera, CEntityManager *entityMgr, const core::vector3df &position, ITexture *texture, int *face, int numFace, bool allPipeline)
void unbindRTT ()
Public Member Functions inherited from Skylicht::IRenderPipeline
virtual ERenderPipelineType getType ()
virtual void render (ITexture *target, CCamera *camera, CEntityManager *entity, const core::recti &viewport, int cubeFaceId=-1, IRenderPipeline *lastRP=NULL)=0
virtual void onNext (ITexture *target, CCamera *camera, CEntityManager *entity, const core::recti &viewport, int cubeFaceId)=0
Public Member Functions inherited from irr::IEventReceiver
virtual ~IEventReceiver ()
 Destructor.

Static Public Member Functions

static void enableRenderIndirect (bool b)
static bool isEnableRenderIndirect ()
static void enableTestIndirect (bool b)
static void enableTestBuffer (int bufferId)
Static Public Member Functions inherited from Skylicht::CBaseRP
static void saveFBOToFile (ITexture *texture, const char *output)
static void setBakeMode (bool b)
static void setBakeLightmapMode (bool b)
static void setBakeLightingMapBounce (u32 i)
static void setClearColor (const SColor &c)
static void setMaxLight (u32 maxLights)

Protected Member Functions

void initDefferredMaterial ()
void initLightMaterial ()
void initRTT (int w, int h)
void releaseRTT ()
Protected Member Functions inherited from Skylicht::CBaseRP
void disableTextureBilinear (SMaterial &m, int slot)
void enableTextureBilinear (SMaterial &m, int slot)
void setTarget (ITexture *target, int faceId)
void drawSceneToTexture (ITexture *target, CCamera *camera, CEntityManager *entityMgr, bool allPipeline)
void drawSceneToCubeTexture (ITexture *target, CCamera *camera, video::E_CUBEMAP_FACE faceID, CEntityManager *entityMgr, bool allPipeline)

Protected Attributes

ITexturem_target
ITexturem_albedo
ITexturem_position
ITexturem_normal
ITexturem_data
ITexturem_indirect
ITexturem_lightBuffer
core::dimension2du m_size
core::array< irr::video::IRenderTargetm_multiRenderTarget
core::matrix4 m_viewMatrix
core::matrix4 m_projectionMatrix
bool m_isIndirectPass
int m_vertexColorShader
int m_textureColorShader
int m_textureLinearRGBShader
int m_lightmapArrayShader
int m_lightmapVertexShader
int m_lightmapSHShader
int m_lightmapSkinSHShader
int m_lightmapColorShader
int m_lightmapIndirectTestShader
int m_colorInstancing
int m_lmInstancingStandardSG
int m_lmInstancingTangentSG
int m_lightDirection
int m_lightDirectionSSR
int m_lightDirectionBake
SMaterial m_lightPass
SMaterial m_directionalLightPass
SMaterial m_finalPass
int m_pointLightShader
int m_pointLightShadowShader
int m_spotLightShader
int m_spotLightShadowShader
int m_areaLightShader
int m_areaLightShadowShader
float m_indirectMultipler
float m_directMultipler
float m_lightMultipler
IPostProcessorm_postProcessor
Protected Attributes inherited from Skylicht::CBaseRP
IRenderPipeline * m_next
CMeshBuffer< video::S3DVertex2TCoords > * m_drawBuffer
IVertexBufferm_verticesImage
IIndexBufferm_indicesImage
float m_viewport2DW
float m_viewport2DH
SMaterial m_unbindMaterial
int m_textureColorShaderID
Protected Attributes inherited from Skylicht::IRenderPipeline
ERenderPipelineType m_type

Additional Inherited Members

Public Types inherited from Skylicht::IRenderPipeline
enum  ERenderPipelineType { Forwarder , Deferred , ShadowMap , Mix }
Public Attributes inherited from Skylicht::IRenderPipeline
std::function< void(IRenderPipeline *)> OnFinish
Static Protected Attributes inherited from Skylicht::CBaseRP
static bool s_bakeMode
static bool s_bakeLMMode
static u32 s_bakeBounce
static u32 s_maxLight
static SColor s_clearColor

Detailed Description

This object class will perform draw commands using "Deferred rendering".

You can find more references here: https://learnopengl.com/Advanced-Lighting/Deferred-Shading

Only materials with the deferred=true property will be drawn in this method.

<shaderConfig name="Color" baseShader="SOLID" deferred="true">

So, the render pipeline only draws shaders located in the "Assets/BuiltIn/Shader/SpecularGlossiness/Deferred" folder. You can still combine drawing by first using Deferred rendering, and then drawing materials with Forward shaders afterward.

The advantage of this method is its support for real-time lights (CPointLight, CSpotLight, CDirectionalLight) and lighting. However, on smartphone devices like iOS and Android, it causes rapid overheating. Therefore, Deferred Rendering should only be used on PC.

Note that you need to set up an additional Shadow pass before Deferred Rendering.

CScene* scene = new CScene();
CZone* zone = scene->createZone();
...
// load or setup a scene
...
...
// camera
CGameObject* camObj = zone->createEmptyObject();
CCamera* camera = camObj->addComponent<CCamera>();
camera->setPosition(core::vector3df(0.0f, 1.5f, 4.0f));
camera->lookAt(
core::vector3df(0.0f, 0.0f, 0.0f), // look at target position
core::vector3df(0.0f, 1.0f, 0.0f) // head up vector
);
// init render pipeline
CBaseApp* app = getApplication();
u32 w = app->getWidth();
u32 h = app->getHeight();
CShadowMapRP* shadowRP = new CShadowMapRP();
shadowRP->initRender(w, h);
CDeferredRP* deferredRP = new CDeferredRP();
deferredRP->initRender(w, h);
shadowRP->setNextPipeLine(deferredRP);
// render function
shadowRP->render(
NULL, // render target is screen
camera, // the camera
scene->getEntityManager(), // all entities in scene
core::recti() // the viewport is fullscreen
);
Base class for managing the application lifecycle, rendering, and event system in Skylicht Engine.
Definition CBaseApp.h:57
int getHeight()
Get the screen height.
int getWidth()
Get the screen width.
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
void lookAt(const core::vector3df &position, const core::vector3df &target, const core::vector3df &up)
Configures the camera to look at a target from a specific position.
void setPosition(const core::vector3df &position)
Sets the world position of the camera.
This object class manages all other objects, it represents the data of a scene.
Definition CScene.h:103
Shadow mapping pipeline for generating depth maps.
Definition CShadowMapRP.h:59
It's the primary container object for the CScene; all CGameObject have a CZone as their root parent.
Definition CZone.h:37
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
rect< s32 > recti
Rectangle with int values.
Definition rect.h:273
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
See also
CShadowMapRP, CForwardRP

Member Function Documentation

◆ canRenderMaterial()

virtual bool Skylicht::CDeferredRP::canRenderMaterial ( CMaterial * material)
virtual

Reimplemented from Skylicht::CBaseRP.

◆ canRenderShader()

virtual bool Skylicht::CDeferredRP::canRenderShader ( CShader * shader)
virtual

Reimplemented from Skylicht::CBaseRP.

◆ drawInstancingMeshBuffer()

virtual void Skylicht::CDeferredRP::drawInstancingMeshBuffer ( CMesh * mesh,
int bufferID,
CShader * instancingShader,
CEntityManager * entityMgr,
int entityID,
bool skinnedMesh )
virtual

Reimplemented from Skylicht::CBaseRP.

◆ drawMeshBuffer()

virtual void Skylicht::CDeferredRP::drawMeshBuffer ( CMesh * mesh,
int bufferID,
CEntityManager * entity,
int entityID,
bool skinnedMesh )
virtual

Reimplemented from Skylicht::CBaseRP.

◆ initRender()

virtual void Skylicht::CDeferredRP::initRender ( int w,
int h )
virtual

◆ OnEvent()

virtual bool Skylicht::CDeferredRP::OnEvent ( const SEvent & event)
virtual

Called if an event happened.

Please take care that you should only return 'true' when you want to prevent Irrlicht from processing the event any further. So 'true' does mean that an event is completely done. Therefore your return value for all unprocessed events should be 'false'.

Returns
True if the event was processed.

Implements irr::IEventReceiver.

◆ render()

virtual void Skylicht::CDeferredRP::render ( ITexture * target,
CCamera * camera,
CEntityManager * entityManager,
const core::recti & viewport,
int cubeFaceId = -1,
IRenderPipeline * lastRP = NULL )
virtual

Implements Skylicht::CBaseRP.

◆ resize()

virtual void Skylicht::CDeferredRP::resize ( int w,
int h )
virtual

The documentation for this class was generated from the following file: