1 registered members (AndrewAMD),
1,310
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Fixed Function water?
[Re: ello]
#24675
03/29/04 22:15
03/29/04 22:15
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
OP
Expert
|
OP
Expert
Joined: Oct 2003
Posts: 4,131
|
ok ive gotten environmental bump mapping to work.. here is the code: Code:
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;
// mat_scale(mtl.matrix,0.5,0.5,0.5); }
function mtl_water_init { vec_set(mtl.emissive_blue,mat_model.emissive_blue); vec_set(mtl.ambient_blue,mat_model.ambient_blue); vec_set(mtl.diffuse_blue,mat_model.diffuse_blue); vec_set(mtl.specular_blue,mat_model.specular_blue); mtl.power=mat_model.power; mtl.albedo=mat_model.albedo; bmap_to_cubemap(mtl.skin3); mtl.enable_render=on; mtl.event=mtl_env_view; }
bmap water = <water_1.tga>; bmap caustic = <water_1_caustic.tga>; bmap enviromap = <envmap+6.tga>;
material mat_water { event=mtl_water_init; skin1=water; skin2=caustic; skin3=enviromap;
effect= " texture mtlSkin1; texture mtlSkin2; texture mtlSkin3; matrix matMtl; matrix matWorld;
technique envcube { pass p0 { Lighting = True; SpecularEnable = True;
ADDRESSU[0]=wrap; ADDRESSV[0]=wrap; ADDRESSU[1]=wrap; ADDRESSV[1]=wrap; ADDRESSU[2]=wrap; ADDRESSV[2]=wrap;
// Stage0 MinFilter[0] = Linear; MagFilter[0] = Linear; MipFilter[0] = Point;
Texture[0] = <mtlSkin1>; //TextureTransform[0] = <matWorld>; //TextureTransformFlags[0] = Count2; ColorOp[0] = SelectArg1; ColorArg1[0] = Texture; AlphaOp[0] = SelectArg2; AlphaArg2[0] = Current;
// Stage1 MinFilter[1] = Linear; MagFilter[1] = Linear; MipFilter[1] = Point; Texture[1] = <mtlSkin2>; // TextureTransform[1] = <matWorld>; // TextureTransformFlags[1] = Count2; ColorOp[1] = bumpenvmap; ColorArg1[1] = Texture; ColorArg2[1] = Current; AlphaOp[1] = SelectArg2; AlphaArg2[1] = Current;
// Stage2 MinFilter[2] = Linear; MagFilter[2] = Linear; MipFilter[2] = Point;
Texture[2] = <mtlSkin3>; TextureTransform[2] = <matMtl>; TextureTransformFlags[2] = Count3; TexCoordIndex[2] = cameraspacereflectionvector; ColorOp[2] = modulate; ColorArg1[2] = Texture; ColorArg2[2] = Current; AlphaOp[2] = SelectArg2; AlphaArg2[2] = Current;
} } "; }
|
|
|
Re: Fixed Function water?
[Re: Darkstorm]
#24677
03/29/04 23:45
03/29/04 23:45
|
Joined: Mar 2004
Posts: 102
Taros
Member
|
Member
Joined: Mar 2004
Posts: 102
|
If anyone think this will help them then here you go (it's a combination of dot3 bumpmapping and enviromental mapping:
Code:
bmap bumpmap = <waves.tga>; // add some bumpmap
bmap enviromentmap = <cubecloudy+6.tga>; // cubemap
material mat_bump
{
skin2 = bumpmap; // set the bumpmap
skin3 = enviromentmap;
scale1 = 0.2; // factor for the skin scale at stage 0
// define a material effect string
effect = "
// declare the used textures and variables
texture entSkin1; // the entity skin
texture mtlSkin2; // the bump map
texture mtlSkin3; // the enviroment map
dword mtlSkill1; // the light vector
// default technique
technique bump_dot3
{
pass P0
{
// set texture stage states
Texture[0] = <mtlSkin2>;
Texture[1] = <entSkin1>;
Texture[2] = <mtlSkin3>;
TextureFactor = <mtlSkill1>;
ColorArg1[0] = Texture; // stage 0 = bumpmap
ColorOp[0] = DotProduct3;
ColorArg2[0] = TFactor;
ColorArg1[1] = Texture; // stage 1 - skin texture
ColorOp[1] = AddSigned;
ColorArg2[1] = Current;
texCoordIndex[2]=cameraSpaceReflectionVector;
ColorOp[2] = AddSigned;
ColorArg1[2] = Texture;
ColorArg2[2] = Current;
ColorArg1[3] = Diffuse; // stage 2 - lighting
ColorOp[3] = Modulate2x;
ColorArg2[3] = Current;
}
}
// fallback technique for devices that do not support bumpmapping
technique fallback
{
pass P0
{
// set texture stage states
Texture[0] = <entSkin1>;
ColorArg1[0] = Texture; // stage 0 = skin texture
ColorOp[0] = Modulate2x;
ColorArg2[0] = Diffuse; // modulate by lighting
}
}
"; // end of the effect string
}
starter mat_bump_init {
// initialize the material properties
vec_set(mat_bump.ambient_blue,mat_model.ambient_blue);
vec_set(mat_bump.diffuse_blue,mat_model.diffuse_blue);
vec_set(mat_bump.specular_blue,mat_model.specular_blue);
mat_bump.power = mat_model.power;
// create the normals map for DOT3 bumpmapping
bmap_to_normals(mat_bump.skin2,2);
// set a lighting vector for DOT3 bumpmapping
mat_bump.skill1 = pixel_for_vec(vector(200,200,200),100,8888);
bmap_to_cubemap(mat_bump.skin3);
}
action envbump
{
my.material = mat_bump;
}
Also, if you want to have env. mapping in ps1.1 you can fake it using texbem or texbeml instructions. I almost got it to work (but it lacks color, for now )
|
|
|
|