Shader Templates

All of the tree and grass shaders are generated from shader templates included in the SpeedTree Compiler application. These templates hold all of the code necessary for both complex and simple effects and everything in between. Each of the effects are controlled by compile- or run-time flags in the shader source. When a level of effects is chosen, the Compiler will #define a series of macros that describe which effects are employed. The source files are passed into the target platform's off-line compiler utility (e.g. fxc.exe for DirectX/360), ultimately generating short, concise, precisely-fitted shaders for use with the SDK.

Note: The SpeedTree collection of shader templates and associated utility files are designed to compile on all SpeedTree-supported platforms, including OpenGL/GLSL.

The Compiler will also generate custom vertex shader inputs and interpolants based on the active effects (info on adding user-defined interpolants).

The templates are located in the [SpeedTree_Apps_Location]/Bin/Exporters/ShaderTemplates folder where [SpeedTree_Apps_Location] is the SpeedTree Applications (e.g. Modeler or Compiler) installation location. There are four main templates used for a traditional forward-rendering pipeline (details for deferred rendering pipelines):

In addition to deferred versions of these templates, there are two other variations of these templates for 3D geometry: Template_3dGeometry_*_ShadowCast.fx and Template_3dGeometry_*_DepthPrepass.fx, and billboard geometry: Template_Billboard_*_ShadowCast.fx and Template_Billboard_*_DepthPrepass.fx.

There are also a series of common FX files shared by all of the shaders, including (not an exhaustive list):