matrix

matrix11 .. matrix44

matMtl

A user-writable 4x4 floating point matrix that is available for shaders or material effects through the matMtl effect variable. The matrix parameter can be used for matrix operations, and the elements of the matrix are separately accessible through the matrix11..matrix44 float variables.

Type:

float (lite-C), float4x4 (shader)

Remarks:

In C-Script the matrix elements can be set to floating point values through the floatv() function. In lite-C they can be set directly.

Examples:

// use a matrix for cubic environment mapping
function mtl_env_init()
{
  bmap_to_cubemap(mtl.skin1);
  // generate a user matrix that transforms camera space back to world space
  while(1)
  {
    mat_set(mtl.matrix,mat_viewinv);
    // reset the translation part of the matrix
    mtl.matrix41 = 0; // 0 is the same as floatv(0)
    mtl.matrix42 = 0;
    mtl.matrix43 = 0;
    wait(1);
  }
}

MATERIAL* mtl_envcube // environment cube
{
  skin1 = bmp_envcube;
  event = mtl_env_init;
  effect = 
  "
  texture mtlSkin1;
  matrix matMtl;
  technique envcube
  {
    pass p0
    {
       Texture[0]=<mtlSkin1>;
       AddressU[0] = Clamp; // don't wrap around edges
       AddressV[0] = Clamp;
       TexCoordIndex[0] = CameraSpaceReflectionVector;
       TextureTransformFlags[0] = Count3;
       TextureTransform[0] = <matMtl>; // transform camera space back to world space
       ColorOp[0] = SelectArg1; // ignore the ambient light
       ColorArg1[0] = Texture;
    }
  }
  ";
}

See also:

MATERIAL, shader, shader variables, floatv, floatd, floatr

 

► latest version online