Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 2 of 2 1 2
Re: Man.... water is good to drink, but hard to make. [Re: Steempipe] #23499
03/22/04 06:25
03/22/04 06:25
Joined: Mar 2004
Posts: 102
T
Taros Offline
Member
Taros  Offline
Member
T

Joined: Mar 2004
Posts: 102
Hey that shader is cool Keep up the good work.

I kinda modified your shader but i couldn't test it. I just added the ventilator's enviromental mapping shader as another pass, but i can't guarantee it'll work cause i'm a newbie to shader programing.

-------------------------------------------------------------------------------
bmap water = <water.tga>;
bmap waternoise = <waternoise.bmp>;
bmap enviroment = <mornsky+6.tga>; // Enviromental cube map

MATERIAL mat_riverwater
{

Skin1 = water;
Skin2 = waternoise;
Skin3 = enviroment;

effect=
"
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;

vector vecSunDir;
vector vecDiffuse;
vector vecAmbient;
vector vecLight;
vector vecFog;
vector vecSkill41;

texture mtlSkin1; //Water
texture mtlSkin2; //Noise
texture mtlSkin3; //Enviromental map

technique riverwater
{
pass p0
{

Texture[0]=<mtlSkin1>; // Texture
Texture[1]=<mtlSkin2>; // Noise Texture
Texture[2]=<mtlSkin2>; // Noise Texture
Texture[3]=<mtlSkin2>; // Noise Texture


ALPHATESTENABLE= true;
ALPHAFUNC=NOTEQUAL;
ALPHAREF= 0x00;
ALPHABLENDENABLE= true;
SRCBLEND=SRCALPHA;
DESTBLEND= INVSRCALPHA;
Cullmode=1;
zWriteEnable=true;


magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
//ADDRESSU[0]=wrap;
//ADDRESSV[0]=wrap;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;
//ADDRESSU[1]=wrap;
//ADDRESSV[1]=wrap;

magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;
//ADDRESSU[2]=wrap;
//ADDRESSV[2]=wrap;

magFilter[3]=linear;
minFilter[3]=linear;
mipFilter[3]=linear;
//ADDRESSU[3]=wrap;
//ADDRESSV[3]=wrap;

//////////////////////////////////////////////////////
// Vertex Shader Constants

// c0..c3 - MVP

// c11.xy - scroll speed 1
// c12.xy - scroll speed 2
// c13.xy - scroll speed 3
// c14.xy - scale 1
// c15.xy - scale 2
// c16.xy - scale 3
// c41.x - time


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


// scroll speed - change as needed with model scaling
VertexShaderConstant[11]={0.0f, 1.0f, 0.0f, 0.0f};
VertexShaderConstant[12]={0.0f, -1.2f, 0.0f, 0.0f};
VertexShaderConstant[13]={1.0f, 1.5f, 0.0f, 0.0f};

// scale - change according to model scaleing
VertexShaderConstant[14]={2.0f, 2.0f, 0.0f, 0.0f};
VertexShaderConstant[15]={3.0f, 3.0f, 0.0f, 0.0f};
VertexShaderConstant[16]={4.0f, 4.0f, 0.0f, 0.0f};


vertexShaderConstant[17]=<vecSunDir>;
vertexShaderConstant[18]=<vecDiffuse>;
vertexShaderConstant[19]=<vecAmbient>;
vertexShaderConstant[20]=<vecLight>;
vertexShaderConstant[21]=<vecFog>;


// time
VertexShaderConstant[41]=<vecSkill41>;

vertexShaderConstant[95]=(0.0f,0.0f,0.0f,0.0f);
///////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////
// Pixel Shader Constants

// distortion (pertrubation factors)
PixelShaderConstant[1]={0.3f, 0.2f, 0.0f, 0.0f};
PixelShaderConstant[2]={0.1f, 0.3f, 0.0f, 0.0f};
PixelShaderConstant[3]={0.1f, 0.1f, 0.0f, 0.0f};

// hight-based bias and scale
PixelShaderConstant[4]={0.5f, 0.1f, 0.0f, 0.0f};

///////////////////////////////////////////////////////////




vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //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

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


// Pass base texture coordinates
mov oT0, v7

// Time
mov r0, c41.x


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


// Time
mov r0, c41.y

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

// Time
mov r0, -c41.x


// Compute texture coordinates for 3rd noise texture
mul r1, r0, c13
frc r1.xy, r1
mad oT3, v7, c16.xyxy, r1.xyxy



};



pixelShader=
asm
{
ps.1.4


// Pass base texture coordinates
texcrd r0.rgb, t0

// Fetch noise
texld r1, t1
texld r2, t2
texld r3, t3

// noise0 * disamount0
mul r1.rgb, c1, r1_bx2

// noise1 * disamount1 + noise0 * disamount0
mad r1.rgb, c2, r2_bx2, r1

// noise2 * disamount2 + noise1 * disamount1 + noise0 * disamount0
mad r1.rgb, c3, r3_bx2, r1

// Scale and bias y coord of base map based on height
+mad r0.a, 1-r0.g, c4.x, c4.y

// Multiply distortion by scaled biased y coord
mad r1.rgb, r1, r0.a, r0

phase

// Perturb
texld r0, r1


};
{
pass p1
{
texture[0]=<mtlSkin1>;
texture[1]=<mtlSkin3>;

zWriteEnable=true;
alphaBlendEnable=false;

colorArg1[0]=Texture;
colorOp[0]=Modulate2x;
colorArg2[0]=Diffuse;

colorArg1[1]=Texture;
colorOp[1]=AddSigned; //blendCurrentAlpha if this doesn't work
addressU[1]=Clamp;
addressV[1]=Clamp;
texCoordIndex[1]=cameraSpaceReflectionVector;
// textureTransformFlags[1]=Count3;
// textureTransform[1]=<matMtl>; // transform camera space back to world space
}

} // end of pass
} // end of technique
";// end of effect
} // end of material





starter mat_riverwater_init

{
// Need to create MipMaps for the mtlSkins
bmap_to_mipmap(mat_riverwater.skin1);
bmap_to_mipmap(mat_riverwater.skin2);
// Create the CubeMap for the shader
bmap_to_cubemap(mat_riverwater.skin3);
}
-------------------------------------------------------------------------------

Hope it works. Now i must learn physics, i have a test tommorow . Good night

Re: Man.... water is good to drink, but hard to make. [Re: Taros] #23500
03/23/04 00:10
03/23/04 00:10
Joined: Oct 2003
Posts: 23
Shurik Offline
Newbie
Shurik  Offline
Newbie

Joined: Oct 2003
Posts: 23
mat_riverwater syntax error


Re: Man.... water is good to drink, but hard to make. [Re: Shurik] #23501
03/23/04 05:47
03/23/04 05:47
Joined: Mar 2004
Posts: 102
T
Taros Offline
Member
Taros  Offline
Member
T

Joined: Mar 2004
Posts: 102
Yep, tried it. Doesn't work. I also tried to use some other methods, but nothing. Guess i'm too much of a noob (for now ). I'll keep trying, no sense in giving up.

But i must say, this water looks really really good even without env. mapping.

Re: Man.... water is good to drink, but hard to make. [Re: Taros] #23502
03/23/04 06:11
03/23/04 06:11
Joined: Aug 2003
Posts: 375
USA
BlueFireV2 Offline
Senior Member
BlueFireV2  Offline
Senior Member

Joined: Aug 2003
Posts: 375
USA
Yeah, you did a great job with the water,but might want to not have waves, seems to slow down the game for me.

Re: Man.... water is good to drink, but hard to make. [Re: BlueFireV2] #23503
03/23/04 11:50
03/23/04 11:50
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
I have uploaded (2) different files. The effect is quite different than the first riverwater demo at the beginning of this thread.

It is still necessary to have pixelshader 1.4 and vertexshader 1.1.

Each file is about 2.8MB and as follows:
riverwater without waves
riverwater with waves

@Taros: Yah... I tried, fiddled with different things and could not get the envmap thing to work right. I am with you and am not going to give up. It's frustrating at times, but this is how we learn. Thanks for the contrib and the words.

@Num1BushFan: I have not gotten anything optimized yet. I hope to get some things figured out and optimized as such as I learn more. In case it helps for performance on someones machine, a version without mesh deforming is avail.

Later,
Eric




Re: Man.... water is good to drink, but hard to make. [Re: Steempipe] #23504
03/23/04 12:21
03/23/04 12:21
Joined: Aug 2003
Posts: 375
USA
BlueFireV2 Offline
Senior Member
BlueFireV2  Offline
Senior Member

Joined: Aug 2003
Posts: 375
USA
I just tried the one without waves, it's pretty nice, it's a little faster but about the same as the other one. I dunno, I have a Geforce FX 128mb something or another and it's just a weird card...could just be my PC too.

Re: Man.... water is good to drink, but hard to make. [Re: BlueFireV2] #23505
03/24/04 01:40
03/24/04 01:40
Joined: Aug 2003
Posts: 52
Netherlands
VoodooFactory Offline
Junior Member
VoodooFactory  Offline
Junior Member

Joined: Aug 2003
Posts: 52
Netherlands
Well, it's improved over the first one, but I think that it would look better if you made the water shapes(kinda hard to explain, the reflections?) a lot bigger. The water looks very realistic if you look at it when you're right above it, but further away, it looks crap.

Re: Man.... water is good to drink, but hard to make. [Re: VoodooFactory] #23506
03/24/04 09:01
03/24/04 09:01
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
I know what you mean by your explanation. It is important that you and others notice and mention these things. Sometimes in the scope of frustration and such it may go unnoticed to me. This helps keep things in focus for me.

I have fiddled with different textures, texture stage changes, and am trying to digesting as much info about shaders as I can to learn what instructions I should be using and how to make them work. I was hoping that there would be some additional changes and/or versions from other users as well.

I have tried to use VEC_DIST operations based on the player-to-the-object distance to pass info to the vertex shader. For example, when near to the water the textures are scaled smaller. When the player is far away, then the textures are scaled larger. This has it's own problems of being quite noticable when the change takes place.

As a basic example, the action modified to this:
///////////////////////////////////////////
if (vec_dist(my.x, player.x) < 100)
{
my.skill43=float(5); //z
my.skill44=float(3); //w
}
if (vec_dist(my.x, player.x) > 101)
{
my.skill43=float(1); //z
my.skill44=float(1); //w
}
////////////////////////////////////////

Then the vertex shader was changed to this:
////////////////////////////////////////
// Compute texture coordinates for 1st noise texture
mul r1, r0, c11
frc r1.xy, r1
mad oT1, v7, c14.zzzz, r1.xyxy


// Time
mov r0, c41.x

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

// Time
mov r0, c41.x


// Compute texture coordinates for 3rd noise texture
mul r1, r0, c13
frc r1.xy, r1
mad oT3, v7, c14.zzzz, r1.xyxy


Good luck and thanks for any input that you have to give.

Eric


Re: Man.... water is good to drink, but hard to make. [Re: Steempipe] #23507
03/24/04 16:23
03/24/04 16:23
Joined: Aug 2003
Posts: 52
Netherlands
VoodooFactory Offline
Junior Member
VoodooFactory  Offline
Junior Member

Joined: Aug 2003
Posts: 52
Netherlands
Can't seem to get it working, but I don't know much about programming. Perhaps you could also try to have an environment shader when you're further away, that would fade to this shader when you're closer to it...

Also, it's really noticable that one of texturemap stays in one place all the time.

Re: Man.... water is good to drink, but hard to make. [Re: VoodooFactory] #23508
03/25/04 09:59
03/25/04 09:59
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Just a heads up to any of you guys who want to make a quick buck. I need various water shaders that are ps1.1 compatible.

thread link

Thanks.

Page 2 of 2 1 2

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