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 lite-C scripts and DirectX functions in render events. They have the same name in shaders and in 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.

matProjInv

The inverse projection matrix. A8.24

matViewProj

The product of view transformation and projection matrix.

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, set up by the entity's uv parameters.

matMtl

A general purpose matrix set up from the material.matrix array (shaders only).

matEffect1..matEffect8

8 general purpose float4x4 matrices that can be set to any float[16] array through the mat_effect1..mat_effect8 pointers.

Remarks

Example:

float4x4 matWorldViewProj;
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_2_0 vs_flicker_red();

   }
}

See also:

Material, shaders, matrix, mat_identity, mat_scale, mat_set, mat_inverse, mat_transpose, mat_multiply

► latest version online