Open topic with navigation
Vizard's effect framework provides a simple yet powerful interface for creating complex shader effects. Multiple effects can be combined together, making it easy to maintain and reuse shader code. The vizfx library also includes many common effects, including:
Material effects (bump, specular, parallax, reflection, ...)
Custom lighting models (blinn, phong, half-lambert, ...)
The effect framework introduces two new Vizard objects: effects and composers. Effects are used to define small units of shader code and any associated properties (floats, colors, textures, ...). Composers are used to define how the effects are combined to generate the final shader code.
The vizfx.addChild or vizfx.addAvatar commands can be used to load a model and automatically apply shader effects. For example:
In most cases, this is all that is needed to use the effect framework. However, effects and composers can also be manually created using the viz.addEffect and viz.addEffectComposer commands. Effects and composers must be applied to a node in order for it to render the effect. The <node3d>.apply command is used to apply effects and composers to a node. Multiple effects can be applied to a node, however only one composer can be applied.
Note: When enabling effects on an object, many built-in texture related commands will not work properly since they rely on fixed-function rendering.
The vizfx.addChild and vizfx.addAvatar commands in the example above automatically generate effects for the model from the following sources:
Models created by the OpenSceneGraph 3ds Max exporter
Avatars created by the Cal3d 3ds Max exporter
The current fixed function texture/color state of any model
Effects can also be generated manually by using the <node3d>.generateEffects command.
As mentioned in the introduction, composer objects are necessary for combining and rendering effects on an object. The vizfx library automatically creates a default global composer and applies it to a node when using the vizfx.addChild or vizfx.addAvatar commands.
The default composer can be accessed using the vizfx.getComposer() command. For example, if you want to apply a global texture projector effect, you can add it to the default composer:
The default vizfx composer also applies an ambient light effect. The ambient light color can be accessed using the vizfx.setAmbientColor and vizfx.getAmbientColor commands. The following example changes the ambient color to a light blue:
Or you can turn off the ambient light by changing the color to black: