Game Development Reference
In-Depth Information
Accessing shader properties in Cg/HLSL
A shader can be declared in its properties in a Properties block. If you want to access
some of those properties in Cg/HLSL shader programming, you need to declare a Cg/
HLSL variable with the same name and a matching type.
Consider the following example:
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
……
CGPROGRAM
sampler2D _MainTex;
The properties that map to the Cg/HLSL variables are as follows:
• Color and vector properties map to float4 variables.
• Range and float properties map to float variables.
• Texture properties map to sampler2D variables for regular (2D) textures. The
CUBE and RECT textures map to samplerCUBE and samplerRECT variables,
respectively.
Search WWH ::




Custom Search