Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 06/30/24 02:01
Lapsa's very own thread
by Lapsa. 06/26/24 12:45
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 938 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 5 of 9 1 2 3 4 5 6 7 8 9
Re: Realtime water reflections shader [Re: Matt_Aufderheide] #40478
02/07/05 06:33
02/07/05 06:33
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Quote:

... put this in the pixel shader input
float4 fresnel:COLOR0 ...




I have no pixel shader input.
Also matWorld and vecViewPos are not declared.

Here is the code:
Code:
 
float4x4 matWorldViewProj: register(c0);

texture entSkin1;
texture entSkin2;
texture entSkin3;

vector vecSkill41;

float1 mtlSkill1;

struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 eyeLinear: TEXCOORD1;
};

VS_OUTPUT VS_p0(float4 Pos: POSITION)
{
VS_OUTPUT Out;

float4 pos = float4(1 * Pos.x, 1 * Pos.y - 1, 1 * Pos.z, 1);
float4 pPos = mul(float4(pos.xyz,1), matWorldViewProj);

Out.Pos = pPos;

Out.texCoord.x = Pos.x * 0.5;
Out.texCoord.y = Pos.z * 0.5;

Out.eyeLinear.x = 0.5 * (pPos.z + pPos.x);
Out.eyeLinear.y = 0.5 * (pPos.z - pPos.y);
Out.eyeLinear.z = pPos.z * 1;

return Out;
}

sampler BumpMap = sampler_state
{
texture=(entSkin3);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

sampler RefractionMap = sampler_state
{
texture=(entSkin2);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

sampler ReflectionMap = sampler_state
{
texture=(entSkin1);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

float4 PS_p0( float2 texCoord: TEXCOORD0,float3 eyeLinear: TEXCOORD1) : COLOR
{

// addiere die Geschindigkeit von vecSkill41 hinzu für Wellenbewegung
float2 waterCoord = texCoord.xy * 0.001 * vecSkill41;

// die Bumpmap mit der waterCoord Koordinaten
float4 bump = tex2D(BumpMap, waterCoord) * 2 - 1;
bump = normalize(bump);

float2 mid = eyeLinear.xy / eyeLinear.z + bump.xy * 0.1f ;

// Reflektierte Wasseroberfläche
float4 reflection = tex2D(ReflectionMap, mid);

float4 final=reflection;


// Output
return reflection;
}
technique water
{
pass p1
{

VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();

}
}



Re: Realtime water reflections shader [Re: XNASorcerer] #40479
02/07/05 08:10
02/07/05 08:10
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
well simply declare the vectors at the beginning
and the pixel shader input goes in this line:
PS_p0( float2 texCoord: TEXCOORD0,float3 eyeLinear: TEXCOORD1, float4 fresnel:COLOR0)

Re: Realtime water reflections shader [Re: Matt_Aufderheide] #40480
02/07/05 08:44
02/07/05 08:44
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Matt_Aufderheide,

I must be making something wrong, because it doesn't work. Will it be that you can help me and to alter the code?
Thanks.

Re: Realtime water reflections shader [Re: XNASorcerer] #40481
02/07/05 09:35
02/07/05 09:35
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
what errors do you get?

Re: Realtime water reflections shader [Re: Matt_Aufderheide] #40482
02/07/05 11:21
02/07/05 11:21
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Nothing is happenig!
Please change the code for me.

Re: Realtime water reflections shader [Re: XNASorcerer] #40483
02/08/05 06:05
02/08/05 06:05
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Any would be apreciated.

Re: Realtime water reflections shader [Re: XNASorcerer] #40484
02/08/05 17:50
02/08/05 17:50
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
post the code you made with my chnages so i can see what is wrong

Re: Realtime water reflections shader [Re: Matt_Aufderheide] #40485
02/09/05 02:39
02/09/05 02:39
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Ok. Here it is:
Code:
  
float4x4 matWorldViewProj: register(c0);
///////////////////////////////////////////////////
float4 matWorld;
float4 vecViewPos;
///////////////////////////////////////////////////

texture entSkin1;
texture entSkin2;
texture entSkin3;

vector vecSkill41;

float1 mtlSkill1;

struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 eyeLinear: TEXCOORD1;
//////////////////////////////////////////////////////////
float4 fresnel: COLOR0;
//////////////////////////////////////////////////////////
};

VS_OUTPUT VS_p0(float4 Pos: POSITION)
{
VS_OUTPUT Out;

float4 pos = float4(1 * Pos.x, 1 * Pos.y - 1, 1 * Pos.z, 1);
float4 pPos = mul(float4(pos.xyz,1), matWorldViewProj);

Out.Pos = pPos;

Out.texCoord.x = Pos.x * 0.5;
Out.texCoord.y = Pos.z * 0.5;

Out.eyeLinear.x = 0.5 * (pPos.z + pPos.x);
Out.eyeLinear.y = 0.5 * (pPos.z - pPos.y);
Out.eyeLinear.z = pPos.z * 1;
///////////////////////////////////////////////////////
float3 PositionWorld = mul(Pos, matWorld);
float dist=distance(PositionWorld, vecViewPos);

if (dist<=300)
{
Out.fresnel.xyzw=dist*0.005;
}

if (dist>300)
{
Out.fresnel.xyzw=1.0;
}
/////////////////////////////////////////////////////////

return Out;
}

sampler BumpMap = sampler_state
{
texture=(entSkin3);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

sampler RefractionMap = sampler_state
{
texture=(entSkin2);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

sampler ReflectionMap = sampler_state
{
texture=(entSkin1);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

float4 PS_p0( float2 texCoord: TEXCOORD0,float3 eyeLinear: TEXCOORD1, float4 fresnel: COLOR0) : COLOR //////////////
{

// addiere die Geschindigkeit von vecSkill41 hinzu für Wellenbewegung
float2 waterCoord = texCoord.xy * 0.001 * vecSkill41;

// die Bumpmap mit der waterCoord Koordinaten
float4 bump = tex2D(BumpMap, waterCoord) * 2 - 1;
bump = normalize(bump);

float2 mid = eyeLinear.xy / eyeLinear.z + bump.xy * 0.1f ;

// Reflektierte Wasseroberfläche
float4 reflection = tex2D(ReflectionMap, mid);

float4 final=reflection;

///////////////////////////////////////////////////////
float3 watercolor=(0.58,0.65,0.63); //adjust this change water coloring

final.rgb*=watercolor;

final.w=(1*fresnel)*0.8;
////////////////////////////////////////////////////////


// Output
return reflection;
}
technique water
{
pass p1
{
/////////////////////////////////////////////////////////
zwriteenable=false;
zenable=true;
alphablendenable=true;
/////////////////////////////////////////////////////////
VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();

}
}



Re: Realtime water reflections shader [Re: XNASorcerer] #40486
02/09/05 03:47
02/09/05 03:47
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
change this line:
// Output return reflection

to:
return final;

Re: Realtime water reflections shader [Re: Matt_Aufderheide] #40487
02/09/05 06:58
02/09/05 06:58
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Thank you Matt_Aufderheide. The transparency is working now.

But now, I found a bug. The objective of the transparency is to show a little of what is underneath of the water. Therefore I put a block underneath of the water, because before I didn't have anything there. Only that now it appears another reflection layer above the water.

In this pic, you can see the bug layer. It only appears in areas that have something under.


Here I am under that layer.


And here, I am above that layer.


Last edited by Sorcerer; 02/09/05 07:08.
Page 5 of 9 1 2 3 4 5 6 7 8 9

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