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

This is the object class that performs the draw call onto a texture. It's used in cases where you need to display planar reflections. More...

#include <RenderPipeline/CRenderToTextureRP.h>

Inheritance diagram for Skylicht::CRenderToTextureRP:
Skylicht::CBaseRP Skylicht::IRenderPipeline

Public Member Functions

 CRenderToTextureRP (u32 id, video::ECOLOR_FORMAT format, const core::dimension2du &customSize=core::dimension2du(), float scale=1.0f)
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)
void setCustomCamera (CCamera *camera)
CCameragetCustomCamera ()
int getId ()
bool isEnable ()
void setEnable (bool b)
ITexturegetTarget ()
void setCustomPipleline (IRenderPipeline *pipeline)
void enableAutoGenerateMipmap (bool b)
bool isAutoGenerateMipmap ()
Public Member Functions inherited from Skylicht::CBaseRP
virtual bool canRenderMaterial (CMaterial *m)
virtual bool canRenderShader (CShader *s)
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 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)
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

Static Public Member Functions

static const float * getMatrix (int id)
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 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

int m_id
bool m_enable
core::matrix4 m_bias
float m_scale
core::dimension2du m_size
core::dimension2du m_customSize
CCameram_customCamera
ITexturem_renderTarget
IRenderPipelinem_customPipleline
video::ECOLOR_FORMAT m_format
bool m_autoGenerateMipmap
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 is the object class that performs the draw call onto a texture. It's used in cases where you need to display planar reflections.

The setCustomCamera method is used to set up the camera for rendering, for example, a reflection camera with a viewing direction symmetrical to the current rendering camera.

Here's an example of a shader that needs to get parameters from RenderToTexture.

<shaderConfig name="WaterPlanarReflection" baseShader="SOLID">
<uniforms>
<vs>
...
<uniform name="uRTTMatrix" type="RENDER_TEXTURE_MATRIX" valueIndex="0" value="0" float="16" matrix = "true"/>
</vs>
<fs>
...
<uniform name="uTexReflect" type="DEFAULT_VALUE" value="3" float="1" directX="false"/>
</fs>
</uniforms>
<resources>
<resource name="uTexReflect" type="RTT0"/>
...
</resources>
<customUI>
...
</customUI>
...
</shaderConfig>
  • In which the RENDER_TEXTURE_MATRIX uniform type will return the matrix that transforms 3D world into 2D coordinates already projected onto the texture.
  • And resource type RTT0 will help the engine find the source texture that has been Rendered To Texture.

You can view the shader details in the file BuiltIn\Shader\PBR\Forward\PBRLightmapPlanarReflection.xml.

When you initialize a CRenderToTextureRP with id=1, the resource type will be RTT1, and RENDER_TEXTURE_MATRIX valueIndex=1.

You can attach it to the main render pipeline and setEnable it whenever you need to use RTT.

// 1st
m_shadowMapRendering = new CShadowMapRP();
m_shadowMapRendering->initRender(w, h);
m_rttRP = new CRenderToTextureRP(0, video::ECF_A8R8G8B8, core::dimension2du(1024, 1024));
m_rttRP->initRender(w, h);
m_rttRP->setEnable(false);
// 2rd
m_forwardRP = new CForwardRP(!postEffect);
m_forwardRP->enableUpdateEntity(false);
// link rp
m_shadowMapRendering->setNextPipeLine(m_rttRP);
m_rttRP->setNextPipeLine(m_forwardRP);
This object class will perform draw commands using "Forwarder rendering".
Definition CForwardRP.h:41
Shadow mapping pipeline for generating depth maps.
Definition CShadowMapRP.h:59
dimension2d< u32 > dimension2du
Typedef for an unsigned integer dimension.
Definition dimension2d.h:212
@ ECF_A8R8G8B8
Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha.
Definition SColor.h:32
See also
CShaderRTT

Member Function Documentation

◆ initRender()

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

◆ render()

virtual void Skylicht::CRenderToTextureRP::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::CRenderToTextureRP::resize ( int w,
int h )
virtual

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