////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include this script in your project. Make sure to use the same name for your sky cube bitmap and for the bmp_envcube
// definition from below. Place any model in your level and attach it the action named "cubic_map". That's all.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BMAP* bmp_envcube = "t_sunrise_sky+6.tga";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function mtl_envmirror_view()
{
mat_set(mtl.matrix, matViewInv);
mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
mat_scale(mtl.matrix, 1, -1, 1);
}
function mtl_envmirror_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event = mtl_envmirror_view;
/*mtl.flags=*/set(mtl,ENABLE_VIEW);
}
MATERIAL* mtl_envmirror = // environment cube
{
skin1 = bmp_envcube;
event = mtl_envmirror_init;
effect = "
texture mtlSkin1;
texture entSkin1;
matrix matMtl;
technique envcube
{
pass p0
{
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
Texture[0] = <mtlSkin1>;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
ColorOp[0] = Modulate2x;
Texture[1] = <entSkin1>;
TextureFactor = 0xC0FFFFFF;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
ColorOp[1] = BlendFactorAlpha; // blend by 75% (= oxC0)
}
}
//technique fallback { pass p0 { } } // empty fallback causes normal rendering without effect
";
}
action cubic_map()
{
my.material = mtl_envmirror;
}