Predefined matrices
Additionally to the user-defined matrices and material matrices, there
are
several predefined 4x4 floating point matrices that can be accessed
by shaders as well as by the script in render events.
They have the same name for shaders and for scripts.
matView
The view transformation matrix, determined by the view position
and angles.
matViewInv
The inverse view transformation matrix.
matProj
The view projection matrix, determined by the view aspect, arc,
and clip_near / clip_far range.
matViewProj
The product of view transformation and projection matrix A7.07 LC .
matWorld
The world transformation matrix, determined by the entities'
position, scale, and angles.
matWorldInv
The inverse world transformation matrix (shaders only).
matWorldView
The product of world and view matrix (shaders only).
matWorldViewProj
The product of world, view, and projection matrix (shaders only).
matTexture
The texture
transformation matrix, determined by the entities' uv values.
LC
A7.07
matMtl
A general purpose matrix set up from the material.matrix array (shaders only).
matEffect
A general purpose matrix that can be set to any var[16] array
with the mat_effect function (shaders
only).
matEffect1..matEffect8
8 general purpose matrices that can be set to any float[16] array through the matEffect1..matEffect8 pointers. LC A7.08
Remarks
- All matrices contain float values, rather than var. For preventing the conversion of float to var when assigning a float value to a var array element under lite-C,
use the floatv function or
cast the value to a pointer, as in var my_float = (void*)(float)1.0;.
- All matrices are compatible to the DirectX D3DMATRIX format
and can be manipulated with DirectX functions.
Example:
float4x4 matWorldViewProj : WORLDVIEWPROJ;
float4 vecTime;
void vs_flicker_red(
in float4 iPos : POSITION,
in float2 iTex0 : TEXCOORD0,
in float2 iTex1 : TEXCOORD1,
out float4 oPos : POSITION,
out float4 oDiffuse: COLOR0,
out float2 oTex0 : TEXCOORD0,
out float2 oTex1 : TEXCOORD1)
{
oPos = mul(iPos,matWorldViewProj);
oTex0 = iTex0;
oTex1 = iTex1;
oDiffuse.r = fmod(vecTime.w * 0.1,1.0);
oDiffuse.g = 0.0;
oDiffuse.b = 0.0;
oDiffuse.a = 1.0;
}
technique flicker
{
pass p0
{
VertexShader = compile vs_1_1 vs_flicker_red();
}
}
See also:
Material, shaders, matrix, mat_identity, mat_scale, mat_set, mat_inverse, mat_transpose, mat_multiply
► latest
version online