code for envmapping?

Posted By: Buluen

code for envmapping? - 09/03/04 11:59

anyone got a working code of enviroment mapping? if so can you post it plz
Posted By: Stefan

Re: code for envmapping? - 09/03/04 19:40

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); }
}



Posted By: MMike

Re: code for envmapping? - 09/03/04 21:01

What kind of envmap??
For surfaces or models??
And you want Faked Env Cube map (for shperes and curved surfaces)
Or flat Mirror cube???
© 2024 lite-C Forums