CrystalSpace

Public API Reference

CS::RenderManager::PostEffectManager Class Reference

Helper for post processing effects usage in render managers. More...

#include <csplugincommon/rendermanager/posteffects.h>

Inheritance diagram for CS::RenderManager::PostEffectManager:

List of all members.

Classes

class  Layer
 An effect layer. More...
struct  LayerInputMap
 Custom input mapping for a layer. More...
struct  LayerOptions
 Options for a postprocessing layer. More...

Public Member Functions

void ClearIntermediates ()
 Discard (and thus cause recreation of) all intermediate textures.
void ClearLayers ()
 Remove all layers.
void DrawPostEffects (RenderTreeBase &renderTree)
 Draw post processing effects after the scene was rendered to the handle returned by GetScreenTarget().
iTextureHandleGetEffectsOutputTarget () const
 Get the render target used to ultimatively render to.
const char * GetIntermediateTargetFormat ()
 Get the texture format for the intermediate textures used.
LayerGetLastLayer ()
 Get the layer that was added last.
iTextureHandleGetLayerOutput (const Layer *layer)
 Get the output texture of a layer.
void GetLayerRenderSVs (const Layer *layer, csShaderVariableStack &svStack) const
 Get SV context used for rendering.
LayerGetScreenLayer ()
 Get the layer representing the "screen" a scene is rendered to.
iTextureHandleGetScreenTarget ()
 Get the texture to render a scene to for post processing.
void Initialize (iObjectRegistry *objectReg)
 Initialize.
bool RemoveLayer (Layer *layer)
 Remove a layer.
bool ScreenSpaceYFlipped ()
 Returns whether the screen space is flipped in Y direction.
void SetEffectsOutputTarget (iTextureHandle *tex)
 Set the render target used to ultimatively render to.
void SetIntermediateTargetFormat (const char *textureFmt)
 Set the texture format for the intermediate textures used.



LayerAddLayer (iShader *shader, const LayerOptions &opt, size_t numMaps, const LayerInputMap *maps)
 Add an effect pass with custom input mappings.
LayerAddLayer (iShader *shader, size_t numMaps, const LayerInputMap *maps)
 Add an effect pass with custom input mappings.
LayerAddLayer (iShader *shader, const LayerOptions &opt)
 Add an effect pass with custom input mappings.
LayerAddLayer (iShader *shader)
 Add an effect pass. Uses last added layer as the input.
void SetChainedOutput (PostEffectManager &nextEffects)
 Add an effect pass with custom input mappings.
void SetChainedOutput (PostEffectManager *nextEffects)
 Chain another post effects manager to the this one.
bool SetupView (uint width, uint height, CS::Math::Matrix4 &perspectiveFixup)
 Add an effect pass with custom input mappings.
bool SetupView (iView *view, CS::Math::Matrix4 &perspectiveFixup)
 Set up post processing manager for a view.

Detailed Description

Helper for post processing effects usage in render managers.

Provides a simple way to render the screen to a texture and then use a number of full screen passes with settable shader to get the desired effect.

To use post processing effects, rendering of the main context has to be redirected to a target managed by the post processing manager. After drawing the scene another call applies the effects. Example:

 // Set up post processing manager for the given view
 postEffects.SetupView (renderView);

 // Set up start context,
 RenderTreeType::ContextNode* startContext = renderTree.CreateContext (renderView);
 // render to a target for later postprocessing
 startContext->renderTargets[rtaColor0].texHandle = postEffects.GetScreenTarget ();

 // ... draw stuff ...

 // Apply post processing effects
 postEffects.DrawPostEffects ();

Post processing setups are a graph of effects (with nodes called "layers" for historic reasons). Each node has one output and multiple inputs. Inputs can be the output of another node or the render of the current scene.

Post processing setups are usually read from an external source by using PostEffectLayersParser. Example:

 const char* effectsFile = cfg->GetStr ("MyRenderManager.Effects", 0);
 if (effectsFile)
 {
   PostEffectLayersParser postEffectsParser (objectReg);
   postEffectsParser.AddLayersFromFile (effectsFile, postEffects);
 }

A setup is not required to use a post processing manager. If no setup is provided the scene will just be drawn to the screen.

Post processing managers can be "chained" which means the output of a manager serves as the input of the following, "chained" post processing manager instead of the normal rendered scene. Notably, using HDR exposure effects involved chaining an post processing manager for HDR to a another post processing manager. Example:

 hdr.Setup (...);
 // Chain HDR post processing effects to normal effects
 postEffects.SetChainedOutput (hdr.GetHDRPostEffects());
 // Just use postEffects as usual, chained effects are applied transparently

Definition at line 104 of file posteffects.h.


Member Function Documentation

Layer* CS::RenderManager::PostEffectManager::AddLayer ( iShader shader,
const LayerOptions opt,
size_t  numMaps,
const LayerInputMap maps 
)

Add an effect pass with custom input mappings.

Layer* CS::RenderManager::PostEffectManager::AddLayer ( iShader shader,
size_t  numMaps,
const LayerInputMap maps 
)

Add an effect pass with custom input mappings.

Layer* CS::RenderManager::PostEffectManager::AddLayer ( iShader shader,
const LayerOptions opt 
)

Add an effect pass with custom input mappings.

Layer* CS::RenderManager::PostEffectManager::AddLayer ( iShader shader  ) 

Add an effect pass. Uses last added layer as the input.

void CS::RenderManager::PostEffectManager::ClearIntermediates (  ) 

Discard (and thus cause recreation of) all intermediate textures.

void CS::RenderManager::PostEffectManager::ClearLayers (  ) 

Remove all layers.

void CS::RenderManager::PostEffectManager::DrawPostEffects ( RenderTreeBase renderTree  ) 

Draw post processing effects after the scene was rendered to the handle returned by GetScreenTarget().

iTextureHandle* CS::RenderManager::PostEffectManager::GetEffectsOutputTarget (  )  const [inline]

Get the render target used to ultimatively render to.

Definition at line 312 of file posteffects.h.

const char* CS::RenderManager::PostEffectManager::GetIntermediateTargetFormat (  ) 

Get the texture format for the intermediate textures used.

Layer* CS::RenderManager::PostEffectManager::GetLastLayer (  )  [inline]

Get the layer that was added last.

Definition at line 289 of file posteffects.h.

iTextureHandle* CS::RenderManager::PostEffectManager::GetLayerOutput ( const Layer layer  ) 

Get the output texture of a layer.

void CS::RenderManager::PostEffectManager::GetLayerRenderSVs ( const Layer layer,
csShaderVariableStack svStack 
) const

Get SV context used for rendering.

Layer* CS::RenderManager::PostEffectManager::GetScreenLayer (  )  [inline]

Get the layer representing the "screen" a scene is rendered to.

Definition at line 286 of file posteffects.h.

iTextureHandle* CS::RenderManager::PostEffectManager::GetScreenTarget (  ) 

Get the texture to render a scene to for post processing.

void CS::RenderManager::PostEffectManager::Initialize ( iObjectRegistry objectReg  ) 

Initialize.

bool CS::RenderManager::PostEffectManager::RemoveLayer ( Layer layer  ) 

Remove a layer.

bool CS::RenderManager::PostEffectManager::ScreenSpaceYFlipped (  ) 

Returns whether the screen space is flipped in Y direction.

This usually happens when rendering to a texture due post effects.

void CS::RenderManager::PostEffectManager::SetChainedOutput ( PostEffectManager nextEffects  )  [inline]

Add an effect pass with custom input mappings.

Definition at line 324 of file posteffects.h.

void CS::RenderManager::PostEffectManager::SetChainedOutput ( PostEffectManager nextEffects  ) 

Chain another post effects manager to the this one.

The output of this manager is automatically used as input to the next.

void CS::RenderManager::PostEffectManager::SetEffectsOutputTarget ( iTextureHandle tex  )  [inline]

Set the render target used to ultimatively render to.

Setting this on a post effects manager in a chain effectively sets the output target of the last chain member.

Definition at line 304 of file posteffects.h.

void CS::RenderManager::PostEffectManager::SetIntermediateTargetFormat ( const char *  textureFmt  ) 

Set the texture format for the intermediate textures used.

bool CS::RenderManager::PostEffectManager::SetupView ( uint  width,
uint  height,
CS::Math::Matrix4 perspectiveFixup 
)

Add an effect pass with custom input mappings.

bool CS::RenderManager::PostEffectManager::SetupView ( iView view,
CS::Math::Matrix4 perspectiveFixup 
)

Set up post processing manager for a view.

Returns:
Whether the manager has changed. If true some values, such as the screen texture, must be reobtained from the manager. perspectiveFixup returns a matrix that should be applied after the normal perspective matrix (this is needed as the screen texture may be larger than the desired viewport and thus the projection must be corrected for that).

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

Generated for Crystal Space 2.0 by doxygen 1.6.1