CgFX Shaders in Maya

A demonstration


Programmable shaders are one of the simplest and most entertaining ways to create rich visual effects on 3D geometry. Because they run directly on your graphics card, they are generally very fast and you can see the effects of your tweaks as you make them.

Here I present some simple visual effects using CgFX shaders in Maya. Because of their speed, these effects are often used in video games. The ability to display in the Maya viewport also makes them particularly useful to Maya artists.

You can download source files used in this demo here.


Parallax

This is a standard shader - one that you've likely seen variations of in most modern videogames. It is the classic phong shader with all of the simple techniques layered on top of it: texture maps to give it detailed color; normal maps so that light shining off its surface appears to follow the cracks and crevices of the surface; gloss maps so that shiny areas appear shiny and matte areas do not; and parallax maps.

Parallax maps are a way to do fake displacement mapping. In true displacement mapping, a heightmap is used to deform a flat surface until it follows the topography of the height map. In parallax mapping, the shape of the surface does not change, but the texture coordinates (uvs) are tweaked per pixel to give the appearance of displacement mapping. It's not perfect, but it's very fast and on nearly flat surfaces, the illusion can be convincing.

Code listing


SoftLight

This is a very simple, but visually very dramatic effect. Artists will often have situations where they want to display beams or cones of light - be it laser blasts from guns or a narrow shaft of sun poking into a dusty room. This shader will turn any mesh into a volume of light that will be composited to illuminate your scene rather than obscure it.

Code listing


Fur

As one of the more recent additions to the shader programming toolbox, geometry shaders allow you to go from manipulating the colors of pixels to modifying the geometry itself. By turning individual faces into clusters of lines, this simple fur shader can make any surface look fuzzy.

Code listing




Return to www.kitfox.com