Torque Shader EngineTorque Shader Engine Documentation
CVS Revision Label 0.1.x

Chapter 4. Shaders

Table of Contents

Procedural Shader Generation
Specifying Hand Written Shaders

Shader support is handled two different ways in the TSE. The first way is fort the engine itself to procedurally generate shaders from base Material properties. The second way is for programmers to specify their own shaders by using CustomMaterials and ShaderData structures.

Procedural Shader Generation

Procedural shaders are output into human readable HLSL form in the example/shaders directory. The vertex and pixel shaders have the respective shaderVxxx.hlsl and shaderPxxx.hlsl filenames where xxx is an incremental number. Each number is the same for matching vertex and pixel shaders, so shaderV010.hlsl and shaderP010.hlsl are the complete shader pair.

The procedurally generated shaders are created and compiled at run time every time the engine starts. This will likely change in the future such that they are cached. The shaders are generated specifically for whatever hardware they are running on. As a result, the number and length of the shader files will vary depending on the video card being used.

The engine can be set so new shaders are not generated. This is useful for debugging and modifying procedural shaders. See Tips and Tricks for more info.