PostEffect

consoledoc.h

A fullscreen shader effect.

More...

Callbacks

void

Called when this object is first created and registered.

void

Called when an effect is processed but before textures are bound. This allows the user to change texture related paramaters or macros at runtime.

void

Called immediate before processing this effect. This is the user's chance to set the value of shader uniforms (constants).

bool

Called when this effect becomes enabled. If the user returns false from this callback the effect will not be enabled.

void

Called when this effect becomes disabled.

Public Attributes

bool

Is this effect processed during reflection render passes.

bool

Is the effect on.

bool

Allows you to turn on a PostEffect for only a single frame.

bool

Allows you to turn on a PostEffect for only a single frame.

string

Name of a renderBin, used if renderTime is PFXBeforeBin or PFXAfterBin.

float

PostEffects are processed in DESCENDING order of renderPriority if more than one has the same renderBin/Time.

When to process this effect during the frame.

string

Name of a GFXShaderData for this effect.

bool

Skip processing of this PostEffect and its children even if its parent is enabled. Parent and sibling PostEffects in the chain are still processed.

string

String identifier of this effect's target texture.

Describes when the target texture should be cleared.

LinearColorF

Color to which the target texture is cleared before rendering.

string

Optional string identifier for this effect's target depth/stencil texture.

Format of the target texture, not applicable if writing to the backbuffer.

Point2F

If targetSize is zero this is used to set a relative size from the current target.

Point2I

If non-zero this is used as the absolute target size.

Specifies how the viewport should be set up for a target texture.

filename
texture [8]

Input textures to this effect ( samplers ).

bool

Set input texture to be sRGB.

Public Functions

void

Remove all shader macros.

void

Disables the effect.

String

Dumps this PostEffect shader's disassembly to a temporary text file.

void

Enables the effect.

bool
void

Reloads the effect shader and textures.

void
removeShaderMacro(string key)

Remove a shader macro. This will usually be called within the preProcess callback.

void
setShaderConst(string name, string value)

Sets the value of a uniform defined in the shader. This will usually be called within the setShaderConsts callback. Array type constants are not supported.

void
setShaderMacro(string key, string value)

Adds a macro to the effect's shader or sets an existing one's value. This will usually be called within the onAdd or preProcess callback.

void
setTexture(int index, string filePath)

This is used to set the texture file and load the texture on a running effect. If the texture file is not different from the current file nothing is changed. If the texture cannot be found a null texture is assigned.

bool

Toggles the effect between enabled / disabled.

Detailed Description

A fullscreen shader effect.

PFXTextureIdentifiers

Callbacks

onAdd()

Called when this object is first created and registered.

preProcess()

Called when an effect is processed but before textures are bound. This allows the user to change texture related paramaters or macros at runtime.

function SSAOPostFx::preProcess( %this )
{
   if ( $SSAOPostFx::quality !$= %this.quality )
   {
      %this.quality = mClamp( mRound( $SSAOPostFx::quality ), 0, 2 );
      
      %this.setShaderMacro( "QUALITY", %this.quality );
   }
   %this.targetScale = $SSAOPostFx::targetScale;
}

setShaderConsts()

Called immediate before processing this effect. This is the user's chance to set the value of shader uniforms (constants).

onEnabled()

Called when this effect becomes enabled. If the user returns false from this callback the effect will not be enabled.

return:

True to allow this effect to be enabled.

onDisabled()

Called when this effect becomes disabled.

Public Attributes

bool allowReflectPass 

Is this effect processed during reflection render passes.

bool Enabled 

Is the effect on.

bool oneFrameOnly 

Allows you to turn on a PostEffect for only a single frame.

bool onThisFrame 

Allows you to turn on a PostEffect for only a single frame.

string renderBin 

Name of a renderBin, used if renderTime is PFXBeforeBin or PFXAfterBin.

float renderPriority 

PostEffects are processed in DESCENDING order of renderPriority if more than one has the same renderBin/Time.

PFXRenderTime renderTime 

When to process this effect during the frame.

string shader 

Name of a GFXShaderData for this effect.

bool skip 

Skip processing of this PostEffect and its children even if its parent is enabled. Parent and sibling PostEffects in the chain are still processed.

GFXStateBlockData stateBlock 

Name of a GFXStateBlockData for this effect.

string Target 

String identifier of this effect's target texture.

see:

PFXTextureIdentifiers

PFXTargetClear targetClear 

Describes when the target texture should be cleared.

LinearColorF targetClearColor 

Color to which the target texture is cleared before rendering.

string targetDepthStencil 

Optional string identifier for this effect's target depth/stencil texture.

see:

PFXTextureIdentifiers

GFXFormat targetFormat 

Format of the target texture, not applicable if writing to the backbuffer.

Point2F targetScale 

If targetSize is zero this is used to set a relative size from the current target.

Point2I targetSize 

If non-zero this is used as the absolute target size.

PFXTargetViewport targetViewport 

Specifies how the viewport should be set up for a target texture.

filename texture [8]

Input textures to this effect ( samplers ).

see:

PFXTextureIdentifiers

bool textureSRGB [8]

Set input texture to be sRGB.

Public Functions

clearShaderMacros()

Remove all shader macros.

disable()

Disables the effect.

dumpShaderDisassembly()

Dumps this PostEffect shader's disassembly to a temporary text file.

return:

Full path to the dumped file or an empty string if failed.

enable()

Enables the effect.

getAspectRatio()

return:

Width over height of the backbuffer.

isEnabled()

return:

True if the effect is enabled.

reload()

Reloads the effect shader and textures.

removeShaderMacro(string key)

Remove a shader macro. This will usually be called within the preProcess callback.

Parameters:

key

Macro to remove.

setShaderConst(string name, string value)

Sets the value of a uniform defined in the shader. This will usually be called within the setShaderConsts callback. Array type constants are not supported.

Parameters:

name

Name of the constanst, prefixed with '$'.

value

Value to set, space seperate values with more than one element.

function MyPfx::setShaderConsts( %this )
{
   // example float4 uniform
   %this.setShaderConst( "$colorMod", "1.0 0.9 1.0 1.0" );
   // example float1 uniform
   %this.setShaderConst( "$strength", "3.0" );
   // example integer uniform
   %this.setShaderConst( "$loops", "5" );}

setShaderMacro(string key, string value)

Adds a macro to the effect's shader or sets an existing one's value. This will usually be called within the onAdd or preProcess callback.

Parameters:

key

lval of the macro.

value

rval of the macro, or may be empty.

function MyPfx::onAdd( %this )
{
   %this.setShaderMacro( "NUM_SAMPLES", "10" );
   %this.setShaderMacro( "HIGH_QUALITY_MODE" );
   
   // In the shader looks like... 
   // #define NUM_SAMPLES 10
   // #define HIGH_QUALITY_MODE
}

setTexture(int index, string filePath)

This is used to set the texture file and load the texture on a running effect. If the texture file is not different from the current file nothing is changed. If the texture cannot be found a null texture is assigned.

Parameters:

index

The texture stage index.

filePath

The file name of the texture to set.

toggle()

Toggles the effect between enabled / disabled.

return:

True if effect is enabled.