Vizard 8 » Command Index » Vizard objects » composer » <composer>.addGlobals
8.1

<composer>.addGlobals

Add global variables to the composer

<composer>.addGlobals(  
source  
)  
source
Source code or filename containing global variable definitions.

Remarks

This command will add global variables to the composer from the specified source. The variables in the source will override any existing variables with the same name.

A composer global variable is a collection of shader code that will automatically be inserted into the final shader if any effect code references the variable name.

Return Value

None

Example

composer = viz.addEffectComposer('composer.vizfx')

code = """
Global ColorIntensity {
    BEGIN FragmentHeader
    #define ColorIntensity(color) (dot(color,vec3(0.222,0.707,0.071)))
    END
}
"""
composer.addGlobals(code)

code = """
Effect "MyEffect" {

    Shader {
        BEGIN Material
        m.alpha += ColorIntensity(m.diffuse);
        END
    }
}
"""
effect = viz.addEffect(code)

model.apply(composer)
model.apply(effect)