Torque 3D - Script Manual: ShaderData Class Reference

TorqueScript

Main   Class List   Namespace List   Online

ShaderData Class Reference
[Shaders]

Special type of data block that stores information about a handwritten shader. More...

Inheritance diagram for ShaderData:

List of all members.

Public Member Functions

void reload ()
 Rebuilds all the vertex and pixel shader instances created from this ShaderData.

Public Attributes

string defines
 String of case-sensitive defines passed to the shader compiler.
filename DXPixelShaderFile
 Path to the DirectX pixel shader file to use for this ShaderData.
filename DXVertexShaderFile
 Path to the DirectX vertex shader file to use for this ShaderData.
filename OGLPixelShaderFile
 Path to an OpenGL pixel shader file to use for this ShaderData.
filename OGLVertexShaderFile
 Path to an OpenGL vertex shader file to use for this ShaderData.
float pixVersion
 Indicates target level the shader should be compiled.
bool useDevicePixVersion
 If true, the maximum pixel shader version offered by the graphics card will be used.

Detailed Description

Special type of data block that stores information about a handwritten shader.

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.

Example:
// Used for the procedural clould system
singleton ShaderData( CloudLayerShader )
{
   DXVertexShaderFile   = "shaders/common/cloudLayerV.hlsl";
   DXPixelShaderFile    = "shaders/common/cloudLayerP.hlsl";
   OGLVertexShaderFile = "shaders/common/gl/cloudLayerV.glsl";
   OGLPixelShaderFile = "shaders/common/gl/cloudLayerP.glsl";
   pixVersion = 2.0;
};

Member Function Documentation

void ShaderData::reload (  ) 

Rebuilds all the vertex and pixel shader instances created from this ShaderData.

Example:
// Rebuild the shader instances from ShaderData CloudLayerShader
CloudLayerShader.reload();

Member Data Documentation

String of case-sensitive defines passed to the shader compiler.

The string should be delimited by a semicolon, tab, or newline character.

Example:
singleton ShaderData( FlashShader )
{
DXVertexShaderFile   = "shaders/common/postFx/flashV.hlsl";
DXPixelShaderFile    = "shaders/common/postFx/flashP.hlsl";

 //Define setting the color of WHITE_COLOR.
defines = "WHITE_COLOR=float4(1.0,1.0,1.0,0.0)";

pixVersion = 2.0
}

Path to the DirectX pixel shader file to use for this ShaderData.

It must contain only one program and no vertex shader, just the pixel shader. It can be either an HLSL or assembly level shader. HLSL's must have a filename extension of .hlsl, otherwise its assumed to be an assembly file.

Path to the DirectX vertex shader file to use for this ShaderData.

It must contain only one program and no pixel shader, just the vertex shader.It can be either an HLSL or assembly level shader. HLSL's must have a filename extension of .hlsl, otherwise its assumed to be an assembly file.

Path to an OpenGL pixel shader file to use for this ShaderData.

It must contain only one program and no vertex shader, just the pixel shader.

Path to an OpenGL vertex shader file to use for this ShaderData.

It must contain only one program and no pixel shader, just the vertex shader.

Indicates target level the 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 the hardware does not support the level of shader compiled.

If true, the maximum pixel shader version offered by the graphics card will be used.

Otherwise, the script-defined pixel shader version will be used.



Copyright © GarageGames, LLC. All Rights Reserved.