Code:
bmap bmp_envcube = <blood_gsmall+6.tga>;
// generate a matrix that transforms camera space back to world space
function mtl_env_view()
{
mat_set(mtl.matrix,matViewInv);
// reset the translation part of the matrix
mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
}
function mtl_env_init()
{
bmap_to_cubemap(mtl.skin4);
// bmap_to_uv(bmap_for_entity(my,2));
mtl.event = mtl_env_view;
mtl.enable_view = on;
}
material mtl_envcube // environment cube
{
skin4 = bmp_envcube;
event = mtl_env_init;
effect = "
texture mtlSkin4;
// texture entSkin2;
matrix matMtl;
technique envcube
{
pass p0
{
/* BumpEnvMat00[0] = 0.5f;
BumpEnvMat01[0] = 0.0f;
BumpEnvMat10[0] = 0.0f;
BumpEnvMat11[0] = 0.5f;
Texture[0] = <entSkin2>;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
ColorOp[0] = BumpEnvMap;
*/
TextureFactor = 0xFFFF0000;
ColorArg1[0] = Tfactor;
ColorOp[0] = SelectArg1;
AddressU[1] = Clamp; // don't wrap around edges
AddressV[1] = Clamp;
TexCoordIndex[1] = CameraSpaceReflectionVector;
TextureTransformFlags[1] = Count3;
TextureTransform[1] = <matMtl>; // transform camera space back to world space
Texture[1] = <mtlSkin4>;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
ColorOp[1] = Add;
}
}
technique fallback { pass p0 { } } // empty fallback causes normal rendering without effect
";
}
action envcube {
my.material = mtl_envcube;
//while(1) { my.pan += time; wait(1); }
}