Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
some problems with my watershader #145020
08/01/07 13:25
08/01/07 13:25
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hello
i am working on a watershader,but 1 stuck on some places...
-the first thing is: if i try to make waves, on the sides of the screen parts of the opposite screen part appears..i know why it is so but not how i can solve it

-the second thing is: i want to have reflection and refraction, but there must bean mistake in the part where i lerp both pictures, because there is _nearly_ only refraction visible.

here is a picture you can see what i mean:


and here is the fx file and the bit c-script i use:

Code:
float4x4 matWorld;
float4x4 matWorldViewProj;
float4x4 saturate_mat = { -0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0,-0.5, 0.0,
-0.5,-0.5,-0.5,-1.0};
float4 vecTime;
float4 vecViewDir;

texture entSkin1;
texture entSkin2;
texture mtlSkin1;

sampler2D reflectionMap = sampler_state
{
Texture=<entSkin1>;
};

sampler2D refractionMap = sampler_state
{
Texture=<entSkin2>;
};

sampler2D normalMap = sampler_state
{
Texture=<mtlSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};

void waterVS( in float2 tex :TEXCOORD0,
in float4 pos :POSITION,
in float3 tangent :TEXCOORD2,
in float3 N :NORMAL,
out float4 oPos :POSITION,
out float4 crdPos :TEXCOORD0,
out float2 oTex :TEXCOORD1,
out float3 tangentView :TEXCOORD2)
{
oPos=mul(pos,matWorldViewProj);
crdPos=oPos;
crdPos = mul(crdPos,saturate_mat);
oTex=tex;

float3x3 TBN;
TBN[0]=mul(tangent,matWorld);
TBN[1]=mul(cross(tangent,N),matWorld);
TBN[2]=mul(N,matWorld);

tangentView =normalize(mul(TBN,vecViewDir.xyz));
}

float4 waterPS( in float4 pos :TEXCOORD0,
in float2 texcrd :TEXCOORD1,
in float3 tangentView :TEXCOORD2):COLOR
{
float4 blue = {0.0,1.0,1.5,1.0};
texcrd.x += vecTime.w/1000;
pos += 5*tex2D(normalMap,texcrd);
float4 mix = saturate(dot(2*tex2D(normalMap,texcrd)-1,tangentView));
return lerp(blue*tex2Dproj(refractionMap,pos),tex2Dproj(reflectionMap,pos),mix);
}

technique water
{
pass p0
{
Vertexshader = compile vs_1_0 waterVS();
Pixelshader = compile ps_2_0 waterPS();
}
}



AND the c-script:

Code:
bmap water_bump = <water_bump.tga>;

material water_mtl
{
effect="water.fx";
skin1 = water_bump;
flags="tangent";
}

view refraction
{
flags=noflag1,visible;
}

view mirror
{
flags=visible;
aspect=-1;
}

action water
{
my.passable=on;
my.material=water_mtl;
refraction.bmap = bmap_for_entity(me,2);
mirror.bmap = bmap_for_entity(me,1);
while(1)
{
vec_set(mirror.x,vector(camera.x,camera.y,my.z-(camera.z-my.z)));
vec_Set(mirror.pan,vector(camera.pan,-camera.tilt,camera.roll));
wait(1);
}
}

[...]


vec_set(refraction.x,camera.x);
vec_set(refraction.pan,camera.pan);



Re: some problems with my watershader [Re: Scorpion] #145021
08/01/07 16:05
08/01/07 16:05
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Hey Scorpion! Long time, no see...

Make sure you clamp your refraction/reflection texture

AddressU = Clamp;
AddressV = Clamp;

This way if the read UV exceeds the size, it doesn't tile around to the other side.


xXxGuitar511
- Programmer
Re: some problems with my watershader [Re: xXxGuitar511] #145022
08/02/07 12:03
08/02/07 12:03
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
thank you for your help,
but how you can imagine, now there are just stripes on the sides :S

if i am right this effect was also by the sylex3 demo with the raindrops, so no way to hide that?

Last edited by Scorpion; 08/02/07 12:05.
Re: some problems with my watershader [Re: Scorpion] #145023
08/03/07 17:30
08/03/07 17:30
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
there is, you just have to scale the image to fit the screen (what I'm currently working on now with help from Julz)...


xXxGuitar511
- Programmer
Re: some problems with my watershader [Re: xXxGuitar511] #145024
08/03/07 17:41
08/03/07 17:41
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
that i don'T get...how to scale it here, because i have to change the position somehow :S

btw: are you able to let the template water-shader make sense? I don't know how they did it

Re: some problems with my watershader [Re: Scorpion] #145025
08/03/07 17:43
08/03/07 17:43
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
I'll take a look in a little bit. I've got some stuff to do first.

I've got alot on my mind, so I'm probably just not thinking straight...

Last edited by xXxGuitar511; 08/03/07 17:43.

xXxGuitar511
- Programmer

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