Posted By: Steempipe
FFP / VertexShader Water Code - 05/15/04 07:36
Hopefully someone can get this to work on all cards. And hopefully they will post it!
After getting the EMBM to appear on all cards the envirmonment map still needs to be projected like "CameraSpaceRelflexionVector". I think that the NVidia SDK/Effects browser has a vertexshader that is an implementation of "CameraSpaceRelflexionVector". Something to keep in mind. Also, ventilators vertexshader for mapping the thing to a plane may be of help.
There is also something that is not working right with the texcoord of "envmap"??
This is essentially the minimal code that runs on my ATI Radeon 9200
Code:
After getting the EMBM to appear on all cards the envirmonment map still needs to be projected like "CameraSpaceRelflexionVector". I think that the NVidia SDK/Effects browser has a vertexshader that is an implementation of "CameraSpaceRelflexionVector". Something to keep in mind. Also, ventilators vertexshader for mapping the thing to a plane may be of help.
There is also something that is not working right with the texcoord of "envmap"??
This is essentially the minimal code that runs on my ATI Radeon 9200
Code:
////////////////////////////////////////////////////////
// Environment Mapping Bump Mapping Water
//
// This is the bare minimum that runs on my ATI Radeon 9200
//
////////////////////////////////////////////////////////
bmap waterbump = <waterbump.bmp>; // Some B&W bumpmap texture 24bpp
bmap baseskin = <water1.bmp>; // Just a colormap
function mtl_ffpwater_init()
{
bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
bmap_to_normals(mtl.skin1,1);//0.2
//bmap_to_uv(mtl.Skin1);
mtl.enable_view = on;
}
material mtl_ffpwater
{
skin1=waterbump;
skin2=baseskin;
event = mtl_ffpwater_init;
effect = "
matrix matWorldViewProj;
matrix matViewInv;
vector vecSkill41;
texture mtlSkin1;
texture mtlSkin2;
technique makewater
{
pass p0
{
zwriteenable=true;
zenable=true;
AlphaBlendEnable = false;
/////////////////////////////////////////
// stage 0 /
/////////////////////////////////////////
Texture[0] = <mtlSkin1>;
magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
AddressU[0]=wrap;
AddressV[0]=wrap;
ColorArg1[0] = Texture;
ColorOp[0] = BUMPENVMAP;//LUMINANCE;
ColorArg2[0] = current;
BUMPENVLSCALE[0]=0.5;
BUMPENVLOFFSET[0]=0.5;
TextureTransformFlags[0]=count2;
TexCoordIndex[0]=0;
///////////////////////////////////////
// stage 1
///////////////////////////////////////
Texture[1] = <mtlSkin2>;
magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;
ColorArg1[1] = Texture;
ColorOp[1] =selectarg1;
TextureTransformFlags[1]=count2;
TexCoordIndex[1]=1;
colorop[2] = disable;
alphaop[2] = disable;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matViewInv>;
// scroll speed
VertexShaderConstant[11]={0.09f, 0.04f, 0.0f, 0.0f};
VertexShaderConstant[12]={-0.5f, 0.2f, 0.0f, 0.0f};
// scale
VertexShaderConstant[14]={0.4f, 0.6f, 0.0f, 0.0f};
VertexShaderConstant[15]={1.5f, 1f, 0.0f, 0.0f};
// time
VertexShaderConstant[41]=<vecSkill41>;
vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //uv
}
asm
{
vs.1.1
m4x4 oPos,v0,c0
//dp3 r0.x, v3, c4
//dp3 r0.y, v3, c5
//dp3 r0.z, v3, c6
//dp3 r0.w, r0, r0
//rsq r0.w, r0.w
//mul r0, r0, r0.w
mov r0, c41.x
mul r1, r0, c12
frc r1.xy, r1
mad oT1.xy, v7.xy, c15.xy, r1.xy
mul r1, r0, c11
frc r1.xy, r1
mad oT0.xy, v7.xy, c14.xy, r1.xy
};
}
}
technique fallback { pass p0 { } }
";
}
var count;
action ffp_water {
my.metal=on;
my.material = mtl_ffpwater;
while(1)
{
my.skill41=float(Count);
my.skill42=float(0);
my.skill43=float(0);
my.skill44=float(0);
Count += 0.0015;
wait(1);
}
}