Game Development Reference
In-Depth Information
Finally, we associate a shader with a particular pass, as follows:
// Define Main:
OUTPUT Main(INPUT input){...}
// Compile Main:
vertexshader vs = compile vs_2_0 Main();
pass P0
{
// Set 'vs' as the vertex shader for this pass.
vertexshader = (vs);
...
}
Or more compactly as:
pass P0
{
// Set the vertex shader whose entry point is “Main()” as the
// vertex shader for this pass.
vertexShader = compile vs_2_0 Main();
...
}
Note: It is worth mentioning, so that you are at least aware of it,
that you can initialize a vertexshader and pixelshader type using
this syntax:
vertexshader vs = asm { /*assembly instructions go here */ };
pixelshader ps = asm { /*assembly instructions go here */ };
This syntax is used if you are writing your shaders in the assembly
language.
19.2.4 Strings
Finally, there is a string object that can be used as shown here:
string filename = "texName.bmp";
Although string types are not used by any functions in HLSL, they
can be read by the application. This way, we can further encapsulate
references to data files that an effect uses, such as texture filenames
and XFile names.
19.2.5 Annotations
In addition to the semantic syntax we have already discussed, an anno-
tation may be attached to variables. Annotations are not used by HLSL,
but they can be accessed by the application through the effects frame-
work. They merely serve to attach a “note” to a variable that the
application might want associated with that variable. Annotations are
Search WWH ::




Custom Search