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

Specifying Hand Written Shaders

To use hand written shaders, a ShaderData datablock must be used. This datablock refers only to the vertex and pixel shader filenames and a hardware target level. Shaders are API specific, so DirectX and OpenGL shaders must be explicitly identified. At the time of this writing, only Direct3D is implemented so only the following data is relevant:

DXVertexShaderFile

Indicates a filename that contains a DirectX vertex shader program. It must contain only one program and no pixel shader, just the vertex shader. It can be either an HLSL or assembly level shader. The former must have a filename extension of .hlsl, otherwise it assumes it is an assembly file.

DXPixelShaderFile

Indicates a filename that contains a DirectX pixel shader program. It must contain only one program and no vertex shader, just the pixel shader. It can be either an HLSL or assembly level shader. The former must have a filename extension of .hlsl, otherwise it assumes it is an assembly file.

pixVersion

This indicates what target level of shader should be compiled. Valid numbers at the time of this writing are 1.1, 1.4, 2.0, and 3.0. The shader will not run properly if your hardware does not support the level of shader you have compiled.

Sample ShaderData

Example 4.1. 

Here is a sample ShaderData datablock. This is used in conjuction with CustomMaterials. Multiple CustomMaterials can reference the same ShaderData structure. See shaders.cs for more examples.

datablock ShaderData( BumpCubemap )
{
   DXVertexShaderFile 	= "shaders/bumpCubeV.hlsl";
   DXPixelShaderFile 	= "shaders/bumpCubeP.hlsl";
   pixVersion = 1.1;
};