..._var
..._flt
If the name of a floating point shader variable, array, or vector name ends with the character sequence "_var" or "_flt", it is automatically pre-set from a corresponding global variable, array, or struct defined in lite-C with the name preceding the "_var" resp. "_flt" character sequence. This way, a shader can use any global variable from the script. A7.75 LC
Type:
var or float (lite-C)
float, floatn, floatnxn (shader code)
Remarks:
- The variable is updated once per frame from the script to the shader. It is not updated in render events, which leads to wrong results when the variable is changed at render time. Use material skills, a material matrix,
or the mat_effect pointers
for variables or matrices that change at render time.
- A _var shader variable is automatically converted from var to float when updating from the script, thus it needs not be set up with floatv(). A _flt shader variable is not converted. For global VECTOR structs the y and z components are automatically swapped for conversion to float3 DirectX coordinates. For global COLOR structs the red and blue components are automatically swapped for conversion from BGR to float3 RGB colors.
- The size of the shader variable must match the size of the variable, array, or struct in the script.
- A shader can not write variables back to the script. The only way to evaluate results from a shader is
calling bmap_process and reading the content of the target bitmap.
Example (lite-C):
var PSSM_Splits[4];
float fMyMatrix[16] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
...
for (i=0; i<4; i++) {
PSSM_Splits[i] = (i+1)*split_distance;
...
MATERIAL* mtlPSSM =
{
effect = "
float4x4 fMyMatrix_flt; // access the global fMyMatrix array
float PSSM_Splits_var[4]; // access the global PSSM_Splits array
...
for (int i=0; i<4; i++) {
if (fDist < PSSM_Splits_var[i]) { ... //compare shadowmap depth
...
";
}
See also:
MATERIAL, shaders, shader parameters, ..._bmap
► latest version online