"Surface shaders" describe the appearance of surfaces and how they react to
the scene lights. If you have used WTStudio, you may know them as
Materials. If not, think of them as "super-textures" that let you define multiple
layers and effects such as shifters and reflection mapping.
Surface shaders are applied to models and actors just like bitmaps - use the
setSurfaceShader()
method. In fact, this method will override any previous setTexture()
calls.
The purpose of this lab is to let you play with a surface shader of
up to three layers. You can pick from a selection of models and spin them
around by dragging the mouse. Click on the thumbnails to select new bitmaps and use the
controls to play with different layer properties. The "Preset" buttons will give
you a good place to start.
Keep in mind that the first, second, and third layers are named layer 0, layer
1, and layer 2, respectively.
You can do a lot more stuff with surface shaders than this lab demonstrates: independent
scaling of U & V coordinates; independent control of offset in the U & V directions;
independent control of shifters in the U & V directions;
diffuse, emissive, and ambient color overrides; and control over mip-mapping levels.
Of course, all these values are "gettable" as well.
If you use a layer source of "diffuse," the texture map will be
ignored and the diffuse color of the geometry will be used instead.
These colors apply to any layer that uses a diffuse layer source.
If you use a layer type of "replace" for any layer, you will lose the geometry's
shading. "Multiply" is a good type to use for the first layer.
Surface shaders are an advanced rendering effect. DirectX 7 and higher drivers
should have no problem rendering complex shaders, unless the video card
is limited to single-texturing. DirectX 5 drivers will always limit you to
single-texturing. In software rendering mode, only the first layer of a surface shader
will be used.
Surface shader specular highlights can appear at the same time as highlights
set with the WTModel::setMaterial() method. We recommend you use only surface
shaders for specular highlights.
You can also set the frame buffer operation using surface shaders for
some nice-looking advanced effects
like lens flares.
Another advanced feature of surface shaders is the ability to toggle options
like buffer writing and depth testing.