Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,789 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: PS 1.1 water - Adjusting RGB during runtime [Re: ello] #53164
08/28/05 14:15
08/28/05 14:15
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline OP
Senior Developer
Thomas_Nitschke  Offline OP
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
Okay, everything working now.
Thanks!


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: PS 1.1 water - Adjusting RGB during runtime [Re: Thomas_Nitschke] #53165
08/28/05 19:19
08/28/05 19:19
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline
Expert
XNASorcerer  Offline
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Put the code here for other people to use and to learn.

Re: PS 1.1 water - Adjusting RGB during runtime [Re: XNASorcerer] #53166
08/29/05 12:29
08/29/05 12:29
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline OP
Senior Developer
Thomas_Nitschke  Offline OP
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
This is the code I already posted above, modified with what happens to work for me
Code:

material mat_water
{
power = 10;
ambient_red = 0;
ambient_green = 0;
ambient_blue = 0;
diffuse_red = 200;
diffuse_blue = 200;
diffuse_green = 200;
albedo = 50;
specular_red = 0;
specular_green = 0;
specular_blue = 0;
emissive_red = 0;
emissive_blue = 0;
emissive_green = 0;
skin1 = sfx_waterBump0;
skin2 = sfx_cubemap0;
flags = tangent;
event = eff_initWater;
}

function eff_initWater()
{
bmap_to_cubemap(mtl.skin2);
//bmap_to_mipmap(mtl.Skin1);
/* new: */ mtl.skill1 = float(waterColor_red);
/* new: */ mtl.skill2 = float(waterColor_green);
/* new: */ mtl.skill3 = float(waterColor_blue);
return(false);
}

water.fx:

float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldView;
float3 vecViewPos;
float3 vecSkill41;
float3 vecSkill1;
float4 vecFog;
Texture mtlSkin1;
Texture mtlSkin2;

sampler s_Bump = sampler_state
{
Texture = (mtlSkin1);
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
sampler s_Cube = sampler_state
{
Texture = (mtlSkin2);
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
struct VS_IN
{
float4 Pos: POSITION;
float3 Normal: NORMAL;
float2 Bump: TEXCOORD0;
float3 Tangent: TEXCOORD1;
};
struct VS_OUT
{
float4 Pos: POSITION;
float Fog: FOG;
float2 Bump: TEXCOORD0;
float4 TanToCube0: TEXCOORD1;
float4 TanToCube1: TEXCOORD2;
float4 TanToCube2: TEXCOORD3;
};
VS_OUT WaterBump_VS(VS_IN IN)
{
VS_OUT Out;
Out.Pos = mul(IN.Pos, matWorldViewProj);
float2 WaveDir;
WaveDir.x = 5*IN.Bump.x;
WaveDir.x += 0.01*vecSkill41.x;
WaveDir.y = 5*IN.Bump.y;
WaveDir.y += 0.01*vecSkill41.x;
Out.Bump = WaveDir.xy;
float3x3 ObjToTan;
ObjToTan[0] = IN.Tangent,
ObjToTan[1] = cross(IN.Normal, IN.Tangent);
ObjToTan[2] = 5*IN.Normal;
Out.TanToCube0.xyz = mul(ObjToTan, matWorld[0].xyz);
Out.TanToCube1.xyz = mul(ObjToTan, matWorld[1].xyz);
Out.TanToCube2.xyz = mul(ObjToTan, matWorld[2].xyz);
float3 PositionWorld = mul(IN.Pos, matWorld);
float3 ViewerDir = normalize(vecViewPos - PositionWorld);
Out.TanToCube0.w = ViewerDir.x;
Out.TanToCube1.w = ViewerDir.y;
Out.TanToCube2.w = ViewerDir.z;
float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * vecFog.z;
Out.Fog = ofog;
return Out;
}
technique drawWater
{
pass p0
{
AlphaBlendEnable = true;
ZwriteEnable = true;
ZEnable = true;
Sampler[0] = (s_Bump);
Sampler[3] = (s_Cube);
/* new */ PixelShaderConstant[0] = float4(vecSkill1.r,vecSkill1.g,vecSkill1.b,0.8); //last value = alpha
VertexShader = compile vs_1_1 WaterBump_VS();
PixelShader =
asm
{
ps.1.1
tex t0
texm3x3pad t1, t0_bx2
texm3x3pad t2, t0_bx2
texm3x3vspec t3, t0_bx2
mul r0, t3, c0
};
}
}
technique fallback
{
pass p0
{
Texture[0] = <mtlSkin1>;
}
}



Have fun with it, and thanks again @ello ^^


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Page 2 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | 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