Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
FFP / VertexShader Water Code #27395
05/15/04 07:36
05/15/04 07:36
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
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:
 ////////////////////////////////////////////////////////
// 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);
}


}



Re: FFP / VertexShader Water Code [Re: Steempipe] #27396
05/15/04 07:38
05/15/04 07:38
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
And here is the Water_Test_5 that may work on some of the geforce cards:

Read the fine print!!!

Code:
 ////////////////////////////////////////////////////////
// Environment Mapping Bump Mapping Water
//
// This is the code that may have worked on some geforce cards
//
////////////////////////////////////////////////////////

/*
Test 1,2,3,& 4 evidentally showed as black on geforce.

Note: for the troubleshooter's among us: How I got to test 5 was this way:
I took my waterbump.bmp and used ATI's "DUDVMapGenerator" and "NormalMapGenerator".
spit out each version of the waterbump map.
=========================================
Test #1:
=========================================
bmap waterbump = <waterbumpDOT3.tga>; //<<<<< note the texture formats
bmap baseskin = <water1.bmp>;

function mtl_ffpwater_init()
{

//bmap_to_normals(mtl.skin1,1);//0.2
//bmap_to_uv(mtl.Skin1);
mtl.enable_view = on;

}
=========================================
Test #2:
=========================================
bmap waterbump = <waterbumpDUDV.tga>;
bmap baseskin = <water1.bmp>;

function mtl_ffpwater_init()
{

//bmap_to_normals(mtl.skin1,1);//0.2
//bmap_to_uv(mtl.Skin1);
mtl.enable_view = on;

}

=========================================
Test #3:
=========================================
bmap waterbump = <waterbumpDUDV.tga>;
bmap baseskin = <water1.bmp>;

function mtl_ffpwater_init()
{

bmap_to_normals(mtl.skin1,1);//0.2
//bmap_to_uv(mtl.Skin1);
mtl.enable_view = on;

}


=========================================
Test #4:
=========================================
bmap waterbump = <waterbumpDOT3.tga>;
bmap baseskin = <water1.bmp>;

function mtl_ffpwater_init()
{

bmap_to_normals(mtl.skin1,1);//0.2
//bmap_to_uv(mtl.Skin1);
mtl.enable_view = on;

}



=========================================
Test #5:
=========================================

*/

bmap waterbump = <waterbumpDOT3.tga>;
bmap baseskin = <water1.bmp>;

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 vecDiffuse;
vector vecSkill41;
vector vecSunDir;
vector vecLight;
vector vecSpecular;

texture mtlSkin1;
texture mtlSkin2;

technique makewater
{

pass p0
{
zwriteenable=true;
zenable=true;
zfunc=less;
zbias=0.0;

ditherenable=false;
specularenable=true;
lighting=false;
specularmaterialsource=color2;
diffusematerialsource=Color1;
NormalizeNormals=false;
LocalViewer=True;

alphafunc=less;
AlphaBlendEnable = false;
alphatestenable=false;
alpharef=0x0;

SrcBlend = one;
DestBlend = zero;
blendop=add;

fillmode=solid;

fogenable=false;

cullmode=ccw;
clipping=true;

/////////////////////////////////////////
// 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] = BUMPENVMAPLUMINANCE;
//colorop[0]=bumpenvmap;
ColorArg2[0] = current;
BUMPENVLSCALE[0]=0.8;
BUMPENVLOFFSET[0]=0.0;
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};
vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[17]=<vecDiffuse>;
vertexShaderConstant[19]=<vecLight>;
vertexShaderConstant[18]=<vecSpecular>;
// Diffuse



// 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

dp3 r0,r0,-c16 // normal.light -> lighting constant
mul r0.xyz,r0,c17 // modulate against material diffuse color
add oD0.xyz,r0,c19 // Spit out Diffuse color register

mov oD1, c18 // Spit out Specular Color Register

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

return;
}




Re: FFP / VertexShader Water Code [Re: Steempipe] #27397
05/15/04 07:49
05/15/04 07:49
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
And if you recall..... this was the FFP only version that worked on I think all the ATI Radeons(?)

Code:
 ////////////////////////////////////////////////////////
// FFP Environment Mapping Bump Mapping Water
//
// Version 2
//
// Eric Hendrickson-Lambert (Steempipe)
//
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
// Since at this time I cannot get a cubic Env Map
// to work. I have taken out most references to it
// and used a basic sky texture because it needs
// the cloud noise for the specular
///////////////////////////////////////////////////////

bmap waterbump2 = <waterbump.bmp>;
bmap envspec2 = <sky.tga>; // <skycube+6.tga>;
bmap base2 = <gradient.bmp>;

function mtl_ffpwater2_1()
{

///////////////////////////////////////////////
// Lets make it scroll in some direction
//

mtl.skill1 += time;
mtl.matrix41 = floatd(mtl.skill1,4000);


}

function mtl_ffpwater2_init()
{

mtl.matrix11 = float(1.6);
mtl.matrix22 = float(0.8);

bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);

bmap_to_normals(mtl.skin1,0.5);

//bmap_to_cubemap(mtl.Skin2);

mtl.event = mtl_ffpwater2_1;

mtl.enable_view = on;

}


material mtl_ffpwater2
{
skin1=waterbump2;
skin2=envspec2;
skin3=base2;

event = mtl_ffpwater2_init;

effect = "

matrix matMtl;

texture mtlSkin1;
texture mtlSkin2;
texture mtlSkin3;

technique makewater2
{

pass p0
{

Texture[0] = <mtlSkin3>;

magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

AddressU[0]=Clamp;
AddressV[0]=Clamp;

ColorArg1[0] = Texture;
ColorOp[0] = modulate;
ColorArg2[0] = diffuse;

alphaop[0]=selectarg1;
alphaarg1[0]=texture;

texcoordindex[0]=1;


Texture[1] = <mtlSkin1>;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;

ColorArg1[1] = Texture;
ColorOp[1] = bumpenvmap;
ColorArg2[1] = current;

TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
Texcoordindex[1]=1;


Texture[2] = <mtlSkin2>;

magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;

AddressU[2]=Clamp;
AddressV[2]=Clamp;

ColorArg1[2] = Texture;
ColorOp[2] = Add;
ColorArg2[2] = Current;


TextureTransformFlags[2] =count3 | projected;

texcoordindex[2]= cameraspaceposition | 1; // For cubemap use: cameraspacereflectionvector

}

}

technique fallback { pass p0 { } }

";
}



action ffp_water2 {

my.material = mtl_ffpwater2;

}




Re: FFP / VertexShader Water Code [Re: Steempipe] #27398
05/15/04 07:59
05/15/04 07:59
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
And last of all... there is the TexBemL shader version that worked on ATI's only, I believe.

Code:
// *************************************************
// * TexBeml Water
// *************************************************

bmap basemap = <water1.bmp>;
bmap bumpmap = <waterbump1.bmp>;


MATERIAL mat_texbeml_water
{
Flags = tangent;

Skin1 = basemap;
Skin2 = bumpmap;


effect=
"

texture mtlSkin1;
texture mtlSkin2;



matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;

vector vecSunDir;
vector vecDiffuse;
vector vecAmbient;

vector vecFog;
vector vecSkill41;
vector vecLight;
vector vecViewPos;

Technique bump_spec
{


Pass p0
{

alphablendenable=true;
srcblend=one;
destblend=zero;

texture[0]=<mtlSkin2>;
texture[1]=<mtlSkin1>;


MagFilter[1]=Linear;
MinFilter[1]=Linear;
MipFilter[1]=Linear;
texcoordindex[1]=1;
texturetransformflags[1]=count2;
//BumpEnvMat00[1] = 0.5f;
//BumpEnvMat01[1] = 0.0f;
//BumpEnvMat10[1] = 0.0f;
//BumpEnvMat11[1] = 0.5f;



MagFilter[0]=linear;
MinFilter[0]=linear;
MipFilter[0]=linear;

BUMPENVLSCALE[1]=1.8;
BUMPENVLOFFSET[1]=2.8;

texcoordindex[0]=0;
texturetransformflags[0]=count2;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[8]=<matWorldView>;

VertexShaderConstant[41]=<vecSkill41>;

VertexShaderConstant[11]={0.0f, 0.6f, 0.0f, 0.0f};//0.2
VertexShaderConstant[12]={0.0f, -0.8f, 0.0f, 0.0f};


// scale - change according to model scaleing
VertexShaderConstant[14]={0.8f, 1.5f, 0.0f, 0.0f};//1.5 and 1.2
VertexShaderConstant[15]={1.0f, 1.0f, 0.0f, 0.0f};

vertexShaderConstant[17]=<vecSunDir>;
vertexShaderConstant[18]=<vecDiffuse>;
vertexShaderConstant[19]=<vecAmbient>;
//vertexShaderConstant[20]=<vecLight>;
vertexShaderConstant[21]=<vecFog>;
vertexShaderConstant[95]=(0.0f,0.0f,0.0f,0.0f);

vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //Tex
float v8[3]; //uv
}



asm
{

vs.1.1


// Transform position
m4x4 oPos, v0, c0

m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w

//dp3 r0,r0,-c17 // normal.light -> lighting constant
//mul r0.xyz,r0,c18 // modulate against material diffuse color
//add oD0.xyz,r0,c19 // add environment light

// Time
mov r0, c41.x


// Compute texture coordinates for 1st noise texture
mul r1, r0, c11
frc r1.xy, r1
mad oT0, v7, c14.xyxy, r1.xyxy



// Compute texture coordinates for 2nd noise texture
mul r1, r0, c12
frc r1.xy, r1
mad oT1, v7, c15.xyxy, r1.xyxy


mov r1.w,c21.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position
add r0,r0,-c21.x // distance-fog_start
mad r0.x,-r0.x,c21.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog.x,r0.x,c95.w // clamp with custom max value


};



pixelShader=
asm
{


ps.1.1

tex t0

texbeml t1, t0
mov r0, t1


}; //end of PS

} //end of pass

} //end of technique

"; //end of effect

} //end of material


starter mat_terrain_multitexture_init

{
//bmap_to_uv(mat_texbeml_water.Skin2);
bmap_to_normals(mat_texbeml_water.Skin2,2);//0.2
bmap_to_mipmap(mat_texbeml_water.skin1);
bmap_to_mipmap(mat_texbeml_water.skin2);

}




var ShaderCount;

ACTION texbeml_water
{
my.material = mat_texbeml_water;

my.transparent=off;



while(1)
{


my.skill41=float(ShaderCount);
my.skill42=float(0);
my.skill43=float(0);
my.skill44=float(0);

ShaderCount += 0.0015;
wait(1);}

}



Re: FFP / VertexShader Water Code [Re: Steempipe] #27399
05/15/04 08:22
05/15/04 08:22
Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
Drew Offline
Serious User
Drew  Offline
Serious User

Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
too cool. THANK YOU!!

Re: FFP / VertexShader Water Code [Re: Drew] #27400
05/15/04 09:12
05/15/04 09:12
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
If only I could rate you 100 stars. Hopefully, you have the Geforce problem figured out(wish I had a Geforce card to help you test).


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: FFP / VertexShader Water Code [Re: William] #27401
05/17/04 04:37
05/17/04 04:37
Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
Drew Offline
Serious User
Drew  Offline
Serious User

Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
loving these shaders...
How would I add transparancy effects to test #5?
Either a full 50% transparancy or even better throgh alpha channel on 32 bit textures? would love to be able to see through the water! thanks

Re: FFP / VertexShader Water Code [Re: Drew] #27402
05/17/04 08:55
05/17/04 08:55
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
That's a good question. Sounds like attempting to figure that out would be a nice project for this week!

Re: FFP / VertexShader Water Code [Re: Steempipe] #27403
05/18/04 00:35
05/18/04 00:35
Joined: Aug 2003
Posts: 52
Netherlands
VoodooFactory Offline
Junior Member
VoodooFactory  Offline
Junior Member

Joined: Aug 2003
Posts: 52
Netherlands
Probably a dumb question, but which shaders work with the commercial version. I don't believe the the camera_vectorspace thing works with commercial.

Re: FFP / VertexShader Water Code [Re: VoodooFactory] #27404
05/18/04 03:13
05/18/04 03:13
Joined: Mar 2002
Posts: 575
Saxony, Germany
Guido_Richter Offline
Developer
Guido_Richter  Offline
Developer

Joined: Mar 2002
Posts: 575
Saxony, Germany
Thats exactly what I also wanted to ask.
Would be really cool to have transparency.
I also have a new idea, just let my think of it and maybe you will see the result in the future.


Guido Richter Foppsoft Developments Wetterpool.de (German weather site) [work:] { not using 3DGS anymore }
Page 1 of 3 1 2 3

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1