The vizfx framework simplifies the process of writing custom vertex and fragment shaders that you can combine with existing shaders. Vizard uses the OpenGL Shading Language (GLSL) for shaders, so some knowledge of GLSL is required to create custom effects. Don’t let this discourage you though. Vizard does much of the work so there is no need to re-implement the entire shader pipeline (vertex transformation, lighting, fog, etc.). Simply write a few lines of code and Vizard will combine it with existing effects to generate the full shader. These existing effects can be automatically generated through the OSG 3ds Max export workflow or others you’ve defined through code.

In this tech tip we’ll write a simple fragment shader that modifies the final color of a model to create a highlight effect. First we add the model that will later have the shader applied to it using the vizfx.addChild command:

import viz
import vizfx
import vizcam
viz.setMultiSample(4)
viz.go()
logo = vizfx.addChild(‘logo.osgb’)
cam = vizcam.PivotNavigate(distance=3.5)
cam.centerNode(logo)
env = viz.addEnvironmentMap(‘sky.jpg’)
sky = viz.addCustomNode(‘skydome.dlc’)
sky.texture(env)