Developer Documentation
ACG::SceneGraph::ACG::ShaderModifier Class Reference
Inheritance diagram for ACG::SceneGraph::ACG::ShaderModifier:
ACG::SceneGraph::ACG::IRenderer::DepthMapPass ACG::SceneGraph::ClippingNode::ClippingShaderModifier

Public Member Functions

virtual void modifyVertexIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the vertex shader. More...
 
virtual void modifyVertexBeginCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyVertexEndCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyGeometryIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the geometry shader. More...
 
virtual void modifyTessControlIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation control shader. More...
 
virtual void modifyTessEvalIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation evaluation shader. More...
 
virtual void modifyFragmentIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the fragment shader. More...
 
virtual void modifyFragmentBeginCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyFragmentEndCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyLightingCode (QStringList *_code, int _lightId, ShaderGenLightType _lightType)
 Modify the default lighting code of the shader generator. More...
 
virtual bool replaceDefaultLightingCode ()
 Specify whether this modifier replaces or extends the default lighting code. More...
 
unsigned int getID ()
 Returns the modifier ID. More...
 
 operator std::vector< unsigned int > () const
 
std::vector< unsigned int > operator| (const std::vector< unsigned int > &_v) const
 
virtual void modifyVertexIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the vertex shader. More...
 
virtual void modifyVertexBeginCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyVertexEndCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyGeometryIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the geometry shader. More...
 
virtual void modifyTessControlIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation control shader. More...
 
virtual void modifyTessEvalIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation evaluation shader. More...
 
virtual void modifyFragmentIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the fragment shader. More...
 
virtual void modifyFragmentBeginCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyFragmentEndCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyLightingCode (QStringList *_code, int _lightId, ShaderGenLightType _lightType)
 Modify the default lighting code of the shader generator. More...
 
virtual bool replaceDefaultLightingCode ()
 Specify whether this modifier replaces or extends the default lighting code. More...
 
unsigned int getID ()
 Returns the modifier ID. More...
 
 operator std::vector< unsigned int > () const
 
std::vector< unsigned int > operator| (const std::vector< unsigned int > &_v) const
 
virtual void modifyVertexIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the vertex shader. More...
 
virtual void modifyVertexBeginCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyVertexEndCode (QStringList *_code)
 Append code the the vertex shader. More...
 
virtual void modifyGeometryIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the geometry shader. More...
 
virtual void modifyTessControlIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation control shader. More...
 
virtual void modifyTessEvalIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the tessellation evaluation shader. More...
 
virtual void modifyFragmentIO (ShaderGenerator *_shader)
 Add your own inputs/outputs to the fragment shader. More...
 
virtual void modifyFragmentBeginCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyFragmentEndCode (QStringList *_code)
 Append code the the fragment shader. More...
 
virtual void modifyLightingCode (QStringList *_code, int _lightId, ShaderGenLightType _lightType)
 Modify the default lighting code of the shader generator. More...
 
virtual bool replaceDefaultLightingCode ()
 Specify whether this modifier replaces or extends the default lighting code. More...
 
unsigned int getID ()
 Returns the modifier ID. More...
 
 operator std::vector< unsigned int > () const
 
std::vector< unsigned int > operator| (const std::vector< unsigned int > &_v) const
 

Static Public Member Functions

static ShaderModifierloadFromFile (QString _filename)
 Load a modifier from file. More...
 
static ShaderModifierloadFromFile (QString _filename)
 Load a modifier from file. More...
 
static ShaderModifierloadFromFile (QString _filename)
 Load a modifier from file. More...
 

Private Attributes

unsigned int modifierID_
 

Friends

class ShaderProgGenerator
 

Detailed Description

A shader modifier can modify uniforms, in/outputs and glsl code of vertex and fragment shaders. This is useful for global effects like shadow mapping and depth peeling, where only little changes in code are necessary.

Usage:

  1. Derive a new subclass of ShaderModifier and implement necessary modify functions.
  2. Allocate a static instance of your modifier and register it to ShaderProgGenerator to get it's modifier-ID
  3. Create ShaderProgGenerator with a bitwise combination of modifier IDs to activate them.

Example:

// First modifier
class VertexShaderModifier1 : public ACG::ShaderModifier {
public:
void modifyVertexEndCode(QStringList* _code) {
_code->push_back("// Vertex End Code Modifier begin");
_code->push_back("< Some glsl code > ");
_code->push_back("// Vertex End Code Modifier end");
}
static VertexShaderModifier1 instance;
};
// Static instance required!
VertexShaderModifier YarnVertexShaderModifier::instance;
class VertexShaderModifier2 : public ACG::ShaderModifier {
public:
void modifyVertexEndCode(QStringList* _code) {
_code->push_back("// Vertex End Code Modifier 2 begin");
_code->push_back("< Some glsl code > ");
_code->push_back("// Vertex End Code Modifier 2 end");
}
static VertexShaderModifier2 instance;
};
VertexShaderModifier2 VertexShaderModifier2::instance;

To use the modifiers, you have to register them to the shader generator:

// Register the modifiers
ACG::ShaderProgGenerator::registerModifier(&VertexShaderModifier::instance);
ACG::ShaderProgGenerator::registerModifier(&VertexShaderModifier2::instance);
// Use them via the shader cache
GLSL::Program* prog = ACG::ShaderCache::getInstance()->getProgram(&shDesc,(VertexShaderModifier::instance.getID() | VertexShaderModifier2::instance.getID() ));

Definition at line 938 of file MeshNode2T.cc.

Member Function Documentation

unsigned int ACG::SceneGraph::ACG::ShaderModifier::getID ( )
inline

Returns the modifier ID.

Returns
Id of the modifier

Definition at line 1101 of file MeshNode2T.cc.

unsigned int ACG::SceneGraph::ACG::ShaderModifier::getID ( )
inline

Returns the modifier ID.

Returns
Id of the modifier

Definition at line 1101 of file MeshNode2T.cc.

unsigned int ACG::SceneGraph::ACG::ShaderModifier::getID ( )
inline

Returns the modifier ID.

Returns
Id of the modifier

Definition at line 1101 of file MeshNode2T.cc.

static ShaderModifier* ACG::SceneGraph::ACG::ShaderModifier::loadFromFile ( QString  _filename)
static

Load a modifier from file.

Shader Mod text file format:

The file can begin with a glsl version directive (optionally): #version glsl_version

The rest of the file contains glsl code blocks, which are separated by keywords. Each keyword must be at the beginning of a line. Furthermore they end on a colon ':'. The keyword defines the meaning of the following code block.

IO code blocks are specified by the keywords: VertexIO:, TessControlIO:, TessEvalIO:, GeometryIO: and FragmentIO:

example

VertexIO: in vec3 customInputName; out vec3 custumOutputName; uniform vec4 param0;

Shader code modifications are done via the keywords: VertexBeginCode:, VertexEndCode:, FragmentBeginCode: and FragmentEndCode:

The returned modifier should not be deleted manually.

Parameters
_filenameabsolute or relative (from shaderdir) file name
Returns
pointer to shader modifier, 0 if loading failed
static ShaderModifier* ACG::SceneGraph::ACG::ShaderModifier::loadFromFile ( QString  _filename)
static

Load a modifier from file.

Shader Mod text file format:

The file can begin with a glsl version directive (optionally): #version glsl_version

The rest of the file contains glsl code blocks, which are separated by keywords. Each keyword must be at the beginning of a line. Furthermore they end on a colon ':'. The keyword defines the meaning of the following code block.

IO code blocks are specified by the keywords: VertexIO:, TessControlIO:, TessEvalIO:, GeometryIO: and FragmentIO:

example

VertexIO: in vec3 customInputName; out vec3 custumOutputName; uniform vec4 param0;

Shader code modifications are done via the keywords: VertexBeginCode:, VertexEndCode:, FragmentBeginCode: and FragmentEndCode:

The returned modifier should not be deleted manually.

Parameters
_filenameabsolute or relative (from shaderdir) file name
Returns
pointer to shader modifier, 0 if loading failed
static ShaderModifier* ACG::SceneGraph::ACG::ShaderModifier::loadFromFile ( QString  _filename)
static

Load a modifier from file.

Shader Mod text file format:

The file can begin with a glsl version directive (optionally): #version glsl_version

The rest of the file contains glsl code blocks, which are separated by keywords. Each keyword must be at the beginning of a line. Furthermore they end on a colon ':'. The keyword defines the meaning of the following code block.

IO code blocks are specified by the keywords: VertexIO:, TessControlIO:, TessEvalIO:, GeometryIO: and FragmentIO:

example

VertexIO: in vec3 customInputName; out vec3 custumOutputName; uniform vec4 param0;

Shader code modifications are done via the keywords: VertexBeginCode:, VertexEndCode:, FragmentBeginCode: and FragmentEndCode:

The returned modifier should not be deleted manually.

Parameters
_filenameabsolute or relative (from shaderdir) file name
Returns
pointer to shader modifier, 0 if loading failed
virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 1054 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 1054 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 1054 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentEndCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ACG::IRenderer::DepthMapPass.

Definition at line 1070 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentEndCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ACG::IRenderer::DepthMapPass.

Definition at line 1070 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentEndCode ( QStringList *  _code)
inlinevirtual

Append code the the fragment shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ACG::IRenderer::DepthMapPass.

Definition at line 1070 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the fragment shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1038 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the fragment shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1038 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyFragmentIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the fragment shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1038 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyGeometryIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the geometry shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 999 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyGeometryIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the geometry shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 999 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyGeometryIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the geometry shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 999 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyLightingCode ( QStringList *  _code,
int  _lightId,
ShaderGenLightType  _lightType 
)
inlinevirtual

Modify the default lighting code of the shader generator.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify.

Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.
_lightIdlight index, use g_vLightDir__{_lightId}, etc. in shader code to use light parameters
_lightTypelight type: point, spot or directional light

Definition at line 1089 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyLightingCode ( QStringList *  _code,
int  _lightId,
ShaderGenLightType  _lightType 
)
inlinevirtual

Modify the default lighting code of the shader generator.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify.

Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.
_lightIdlight index, use g_vLightDir__{_lightId}, etc. in shader code to use light parameters
_lightTypelight type: point, spot or directional light

Definition at line 1089 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyLightingCode ( QStringList *  _code,
int  _lightId,
ShaderGenLightType  _lightType 
)
inlinevirtual

Modify the default lighting code of the shader generator.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify.

Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.
_lightIdlight index, use g_vLightDir__{_lightId}, etc. in shader code to use light parameters
_lightTypelight type: point, spot or directional light

Definition at line 1089 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessControlIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation control shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1012 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessControlIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation control shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1012 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessControlIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation control shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1012 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessEvalIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation evaluation shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1025 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessEvalIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation evaluation shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1025 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyTessEvalIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the tessellation evaluation shader.

your implementation may look like this:

_shader->addInput("sampler2D depthSampler");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 1025 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ClippingNode::ClippingShaderModifier.

Definition at line 971 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ClippingNode::ClippingShaderModifier.

Definition at line 971 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexBeginCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here.

Parameters
_codestring list of shader code.

Reimplemented in ACG::SceneGraph::ClippingNode::ClippingShaderModifier.

Definition at line 971 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexEndCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 986 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexEndCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 986 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexEndCode ( QStringList *  _code)
inlinevirtual

Append code the the vertex shader.

Refer to the generation structure (Shader Generator ) to see where your code is added and which variables you can modify. Use

_code->push_back("...");

to insert your code here

Parameters
_codestring list of shader code.

Definition at line 986 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the vertex shader.

Your implementation may look like this:

_shader->addInput("vec4 inTangent");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 957 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the vertex shader.

Your implementation may look like this:

_shader->addInput("vec4 inTangent");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 957 of file MeshNode2T.cc.

virtual void ACG::SceneGraph::ACG::ShaderModifier::modifyVertexIO ( ShaderGenerator _shader)
inlinevirtual

Add your own inputs/outputs to the vertex shader.

Your implementation may look like this:

_shader->addInput("vec4 inTangent");
_shader->addUniform("vec4 shaderParam");
Parameters
_shadershader interface

Definition at line 957 of file MeshNode2T.cc.

virtual bool ACG::SceneGraph::ACG::ShaderModifier::replaceDefaultLightingCode ( )
inlinevirtual

Specify whether this modifier replaces or extends the default lighting code.

Returns
return false if this modifier modifies an already computed lighting color, return true if this modifier replaces the default lighting color

Definition at line 1095 of file MeshNode2T.cc.

virtual bool ACG::SceneGraph::ACG::ShaderModifier::replaceDefaultLightingCode ( )
inlinevirtual

Specify whether this modifier replaces or extends the default lighting code.

Returns
return false if this modifier modifies an already computed lighting color, return true if this modifier replaces the default lighting color

Definition at line 1095 of file MeshNode2T.cc.

virtual bool ACG::SceneGraph::ACG::ShaderModifier::replaceDefaultLightingCode ( )
inlinevirtual

Specify whether this modifier replaces or extends the default lighting code.

Returns
return false if this modifier modifies an already computed lighting color, return true if this modifier replaces the default lighting color

Definition at line 1095 of file MeshNode2T.cc.


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