chrono::irrlicht::EffectHandler Class Reference

Description

Main effect handling class, use this to apply shadows and effects.

#include <ChIrrEffects.h>

Public Member Functions

 EffectHandler (irr::IrrlichtDevice *irrlichtDevice, const irr::core::dimension2du &screenRTTSize=irr::core::dimension2du(0, 0), const bool useVSMShadows=false, const bool useRoundSpotLights=false, const bool use32BitDepthBuffers=false)
 
 ~EffectHandler ()
 Destructor.
 
void addShadowLight (const SShadowLight &shadowLight)
 Adds a shadow light. Check out the shadow light constructor for more information.
 
SShadowLight & getShadowLight (irr::u32 index)
 Retrieves a reference to a shadow light. You may get the max amount from getShadowLightCount.
 
irr::u32 getShadowLightCount () const
 Retrieves the current number of shadow lights.
 
irr::video::ITexture * getShadowMapTexture (const irr::u32 resolution, const bool secondary=false)
 Retrieves the shadow map texture for the specified square shadow map resolution. More...
 
irr::video::ITexture * getDepthMapTexture ()
 Retrieves the screen depth map texture if the depth pass is enabled. More...
 
void addNodeToDepthPass (irr::scene::ISceneNode *node)
 This function is now unrelated to shadow mapping. More...
 
void removeNodeFromDepthPass (irr::scene::ISceneNode *node)
 This function is now unrelated to shadow mapping. More...
 
void enableDepthPass (bool enableDepthPass)
 Enables/disables an additional pass before applying post processing effects (If there are any) which records screen depth info to the depth buffer for use with post processing effects that require screen depth info, such as SSAO or DOF. More...
 
void removeShadowFromNode (irr::scene::ISceneNode *node)
 Removes shadows from a scene node.
 
void excludeNodeFromLightingCalculations (irr::scene::ISceneNode *node)
 
void update (irr::video::ITexture *outputTarget=0)
 Updates the effects handler. More...
 
void addShadowToNode (irr::scene::ISceneNode *node, E_FILTER_TYPE filterType=EFT_NONE, E_SHADOW_MODE shadowMode=ESM_BOTH)
 Adds a shadow to the scene node. More...
 
irr::f32 getTime ()
 Returns the device time divided by 100, for use with the shader callbacks.
 
void setClearColour (irr::video::SColor ClearCol)
 Sets the scene clear color, for when the scene is cleared before smgr->drawAll().
 
void addPostProcessingEffect (irr::s32 MaterialType, IPostProcessingRenderCallback *callback=0)
 A very easy to use post processing function. More...
 
void setPostProcessingRenderCallback (irr::s32 MaterialType, IPostProcessingRenderCallback *callback=0)
 Sets the IPostProcessingRenderCallback for the specified post processing effect. More...
 
void removePostProcessingEffect (irr::s32 MaterialType)
 Removes the first encountered post processing effect with the specified material type.
 
irr::s32 addPostProcessingEffectFromFile (const irr::core::stringc &filename, IPostProcessingRenderCallback *callback=0)
 Adds a post processing effect by reading a pixel shader from a file. More...
 
void setPostProcessingEffectConstant (const irr::s32 materialType, const irr::core::stringc &name, const irr::f32 *data, const irr::u32 count)
 Sets a shader parameter for a post-processing effect. More...
 
const CScreenQuadgetScreenQuad ()
 Returns the screen quad scene node. More...
 
void setActiveSceneManager (irr::scene::ISceneManager *smgrIn)
 Sets the active scene manager.
 
irr::scene::ISceneManager * getActiveSceneManager ()
 Gets the active scene manager.
 
void setPostProcessingUserTexture (irr::video::ITexture *userTexture)
 This allows the user to specify a custom, fourth texture to be used in the post-processing effects. More...
 
void setAmbientColor (irr::video::SColor ambientColour)
 Sets the global ambient color for shadowed scene nodes.
 
irr::video::SColor getAmbientColor () const
 Gets the global ambient color.
 
irr::video::ITexture * generateRandomVectorTexture (const irr::core::dimension2du &dimensions, const irr::core::stringc &name="randVec")
 Generates a randomized texture composed of uniformly distributed 3 dimensional vectors.
 
void setScreenRenderTargetResolution (const irr::core::dimension2du &resolution)
 Sets a new screen render target resolution.
 
irr::IrrlichtDevice * getIrrlichtDevice ()
 Returns the device that this EffectHandler was initialized with.
 

Member Function Documentation

◆ addNodeToDepthPass()

void chrono::irrlicht::EffectHandler::addNodeToDepthPass ( irr::scene::ISceneNode *  node)
inline

This function is now unrelated to shadow mapping.

It simply adds a node to the screen space depth map render, for use with post processing effects that require screen depth info. If you want the functionality of the old method (A node that only casts but does not receive shadows, use addShadowToNode with the ESM_CAST shadow mode.

◆ addPostProcessingEffect()

void chrono::irrlicht::EffectHandler::addPostProcessingEffect ( irr::s32  MaterialType,
IPostProcessingRenderCallback *  callback = 0 
)
inline

A very easy to use post processing function.

Simply add a material type to apply to the screen as a post processing effect and it will be applied. You can add as many material types as you desire, and they will be double buffered and executed in sequence.

For the material types, I recommend using "ScreenQuadCB" as the callback and referring to the texture names that are passed (When using OpenGL, in DirectX uniforms are not required to bind textures). Please note that this will only work in OpenGL on vanilla Irrlicht, DX requires the large RTT patch to be able to create sufficiently sized render targets for post processing. (Or you can just remove the engine check for Pow2).

The structure of the textures is as follows:

Texture1 - "ColorMapSampler" This is passed on from the previous post processing effect as they are executed in sequence. For example, if you do a horizontal blur on the first post processing material, then a vertical blur in the second material, you will use this sampler to access the post processed data of the horizontal blur when it is time to do the vertical blur. If accessed from the first post processing material, it will just contain the untainted screen map data.

Texture2 - "ScreenMapSampler" The second texture will always contain the untainted screen map data, from when the scene is first rendered. It will remain unchanged no matter how many post processing materials are applied. This kind of data is necessary, for example in bloom or DOF, you would require a copy of the blurred scene data and a copy of the normal untainted, unblurred screen data, and mix between them based on certain factors such as depth or luminance.

Texture3 - "DepthMapSampler" If a depth pass has been enabled using enableDepthPass, then this sampler will contain the screen space depth information. For better quality this is encoded to 16bits, and can be decoded like so: Texture.red + (Texture.green / 256.0f); That is by adding the red channel to the green channel which is first divided by 256. The data can still be used without decoding, in 8 bit precision, by just accessing the red component of the texture. Though this is not recommended as 8 bit precision is usually not sufficient for modern post processing effects.

Texture4 - "UserMapSampler" A custom texture that can be set by the user using setPostProcessingUserTexture(irr::video::ITexture* userTexture).

The last parameter is the render callback, you may pass 0 if you do not need one. Please see IPostProcessingRenderCallback for more info about this callback.

◆ addPostProcessingEffectFromFile()

irr::s32 chrono::irrlicht::EffectHandler::addPostProcessingEffectFromFile ( const irr::core::stringc &  filename,
IPostProcessingRenderCallback *  callback = 0 
)
inline

Adds a post processing effect by reading a pixel shader from a file.

The vertex shader is taken care of. The vertex shader will pass the correct screen quad texture coordinates via the TEXCOORD0 semantic in Direct3D or the gl_TexCoord[0] varying in OpenGL. See addPostProcessingEffect for more info. Returns the Irrlicht material type of the post processing effect.

◆ addShadowToNode()

void chrono::irrlicht::EffectHandler::addShadowToNode ( irr::scene::ISceneNode *  node,
E_FILTER_TYPE  filterType = EFT_NONE,
E_SHADOW_MODE  shadowMode = ESM_BOTH 
)
inline

Adds a shadow to the scene node.

The filter type specifies how many shadow map samples to take, a higher value can produce a smoother or softer result. The shadow mode can be either ESM_BOTH, ESM_CAST, or ESM_RECEIVE. ESM_BOTH casts and receives shadows, ESM_CAST only casts shadows, and is unaffected by shadows or lighting, and ESM_RECEIVE only receives but does not cast shadows.

◆ enableDepthPass()

void chrono::irrlicht::EffectHandler::enableDepthPass ( bool  enableDepthPass)
inline

Enables/disables an additional pass before applying post processing effects (If there are any) which records screen depth info to the depth buffer for use with post processing effects that require screen depth info, such as SSAO or DOF.

For nodes to be rendered in this pass, they must first be added using addNodeToDepthPass(SceneNode).

◆ getDepthMapTexture()

irr::video::ITexture* chrono::irrlicht::EffectHandler::getDepthMapTexture ( )
inline

Retrieves the screen depth map texture if the depth pass is enabled.

This is unrelated to the shadow map, and is meant to be used for post processing effects that require screen depth info, eg. DOF or SSAO.

◆ getScreenQuad()

const CScreenQuad& chrono::irrlicht::EffectHandler::getScreenQuad ( )
inline

Returns the screen quad scene node.

This is not required in any way, but some advanced users may want to adjust its material settings accordingly.

◆ getShadowMapTexture()

irr::video::ITexture * chrono::irrlicht::EffectHandler::getShadowMapTexture ( const irr::u32  resolution,
const bool  secondary = false 
)
inline

Retrieves the shadow map texture for the specified square shadow map resolution.

Only one shadow map is kept for each resolution, so if multiple lights are using the same resolution, you will only see the last light drawn's output. The secondary param specifies whether to retrieve the secondary shadow map used in blurring.

◆ removeNodeFromDepthPass()

void chrono::irrlicht::EffectHandler::removeNodeFromDepthPass ( irr::scene::ISceneNode *  node)
inline

This function is now unrelated to shadow mapping.

It simply removes a node to the screen space depth map render, for use with post processing effects that require screen depth info.

◆ setPostProcessingEffectConstant()

void chrono::irrlicht::EffectHandler::setPostProcessingEffectConstant ( const irr::s32  materialType,
const irr::core::stringc &  name,
const irr::f32 *  data,
const irr::u32  count 
)
inline

Sets a shader parameter for a post-processing effect.

The first parameter is the material type, the second is the uniform paratmeter name, the third is a float pointer that points to the data and the last is the component count of the data. Please note that the float pointer must remain valid during render time. To disable the setting of a parameter you may simply pass a null float pointer.

◆ setPostProcessingRenderCallback()

void chrono::irrlicht::EffectHandler::setPostProcessingRenderCallback ( irr::s32  MaterialType,
IPostProcessingRenderCallback *  callback = 0 
)
inline

Sets the IPostProcessingRenderCallback for the specified post processing effect.

The old callback if previously set will be automatically deleted.

◆ setPostProcessingUserTexture()

void chrono::irrlicht::EffectHandler::setPostProcessingUserTexture ( irr::video::ITexture *  userTexture)
inline

This allows the user to specify a custom, fourth texture to be used in the post-processing effects.

See addPostProcessingEffect for more info.

◆ update()

void chrono::irrlicht::EffectHandler::update ( irr::video::ITexture *  outputTarget = 0)
inline

Updates the effects handler.

This must be done between IVideoDriver::beginScene and IVideoDriver::endScene. This function now replaces smgr->drawAll(). So place it where smgr->drawAll() would normally go. Please note that the clear color from IVideoDriver::beginScene is not preserved, so you must instead specify the clear color using EffectHandler::setClearColour(Color). A render target may be passed as the output target, else rendering will commence on the backbuffer.


The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono_irrlicht/ChIrrEffects.h