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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, M_D), 1,217 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
cubemap/watershader for 6.4 coord problem #79599
06/26/06 16:58
06/26/06 16:58
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
hi all,
i recently updated form 6.3 to 6.4.
now, the cubemap shader isn't working any more as it should. somehow, it seems that the cube has been turned to the left, over one side, and is now lying on one side, at least that is it what my water reflections tell me. sceenie:



see, where the arrow is? that's the sun... look down on the surfac, there it is not. instead, the brown ground is visible.

code:

wdl
Code:

function mtl_water_init()
{

bmap_to_cubemap(bmap_to_mipmap(mtl.skin2));
bmap_to_mipmap(mtl.Skin1);

}


material water_fx {

skin1=water_bump;
skin2=water_cube;

flags=tangent;

event = mtl_water_init;

}

var ShaderCount;


Action WaterShader
{
my.material = water_fx;

my.transparent=on;
my.alpha=99;
my.nofog = off;


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

ShaderCount += 0.001;

wait(1);
}
}

function load_water_fx() {

if (d3d_shaderversion >= 1111)
{
effect_load(water_fx,"watershader.fx");
wait(5);
return;
}
else
{
wait(5);
exit;
}

}



fx-file

Code:

/******************************************************
Water Shader for 3DGameStudio

By: Eric Hendrickson-Lambert (Steempipe)

v11.08.04.1
******************************************************/

float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldView;

float3 vecViewPos;
float3 vecSkill41;
float4 vecFog;

float RippleScale = 0.3;

Texture mtlSkin1; // Normalmap
Texture mtlSkin2; // Cubemap


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

////////////////////////////////////////////////////////////////////////////////
// Ripple Test #1
//
//Out.Bump= (IN.Bump.xy * RippleScale) + (IN.Bump.xy += (vecSkill41.x * 0.02));
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Ripple Test #2
//
float SC1 = {0.3};
float SC2 = {0.3};
float cos_x = cos(RippleScale * vecSkill41.x *SC1);
float sin_y = sin(RippleScale * vecSkill41.x *SC1);
Out.Bump = float2(IN.Bump.x+cos_x, IN.Bump.y-sin_y);
////////////////////////////////////////////////////////////////////////////////


float3x3 ObjToTan;

ObjToTan[0] = RippleScale * IN.Tangent;
ObjToTan[1] = RippleScale * cross(IN.Tangent, IN.Normal);
ObjToTan[2] = 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 WaterBump
{

pass One
{
Sampler[0] = (s_Bump);
//Sampler[1] = (s_Cube);
//Sampler[2] = (s_Cube);
Sampler[3] = (s_Cube);

AlphaBlendEnable = true;
ZwriteEnable = true;
ZEnable = true;


// Main point is that pixelShaderConstant 'W' will control
// the alpha tranparency. The XYZ will adjust
// some coloring.

PixelShaderConstant[0] = {0.90,0.99,0.99,0.90}; // x, y, z, w

VertexShader = compile vs_1_1 WaterBump_VS();


PixelShader =
asm
{
ps.1.1

tex t0 // Normalmap


texm3x3pad t1, t0_bx2
texm3x3pad t2, t0_bx2
texm3x3vspec t3, t0_bx2

mul r0, t3, c0

};
}
}



thanks in advance.

Last edited by DaBro0zar; 06/26/06 18:14.
Re: cubemap/watershader for 6.4 coord problem [Re: broozar] #79600
06/28/06 07:49
06/28/06 07:49
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
for those who are interested: the problem didn't occur anymore after I re-saved the water surface hmp file the effect was applied to.
thx for all who had a look at this, nevertheless.

Re: cubemap/watershader for 6.4 coord problem [Re: broozar] #79601
06/30/06 11:46
06/30/06 11:46
Joined: Sep 2002
Posts: 758
Sunny Scotland
xoNoid Offline
Developer
xoNoid  Offline
Developer

Joined: Sep 2002
Posts: 758
Sunny Scotland
You would be my very friend if you could post a compiled example of the watershader as I've been trying to get it to work for a long while .

Re: cubemap/watershader for 6.4 coord problem [Re: xoNoid] #79602
07/02/06 09:15
07/02/06 09:15
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
what i posted abouv is all you need codewise. 2 bitmaps are needed as well, skin1(normalmap) and skin2(cubemap).

save what i posted under "fx file" as "watershader.fx" and put it in your main directory (nowhere else, it's required to put it there).

save what i put under "wdl" as "watershader.wdl", include it in your main script. define two bitmaps at the very beginning of your script,
bmap water_bump=<yourbumpmap.tga>;
bmap water_cube=<yourcubemap.tga>;

now add "load_water_fx()" in your main(). that's all.


a cubvemap would be too large to upload, get one maybe from earthcontrol.de (ello's site).
the bump map i use is this:

DL it, it's a *.png. you need to resave it as *.tga with alpha channlen, 32 bit uncompressed.

Re: cubemap/watershader for 6.4 coord problem [Re: broozar] #79603
07/05/06 18:45
07/05/06 18:45
Joined: Sep 2002
Posts: 758
Sunny Scotland
xoNoid Offline
Developer
xoNoid  Offline
Developer

Joined: Sep 2002
Posts: 758
Sunny Scotland
I've tried doing as specified but for some unknown reason it refuses to work correctly (I cannot even accurately describe the problem). I would be most greatful if you could put together a testlevel so that I'd have something to work with.

Re: cubemap/watershader for 6.4 coord problem [Re: xoNoid] #79604
07/05/06 19:01
07/05/06 19:01
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
hmm.. ok.. however, a short descr. of the error message and/or screen shots could have done it, too. but i am social today and here you are.

the artwork included (skybox, cubemap) is NOT for free and i will not tolerate anything that is done with it without my knowledge.

the codes are made by steempipe, so ask him if you can use it.

download here: steempipe's water shader example

Re: cubemap/watershader for 6.4 coord problem [Re: broozar] #79605
07/05/06 19:03
07/05/06 19:03
Joined: Sep 2002
Posts: 758
Sunny Scotland
xoNoid Offline
Developer
xoNoid  Offline
Developer

Joined: Sep 2002
Posts: 758
Sunny Scotland
thats mate (5 stars to you) . This has helped me alot.

Re: cubemap/watershader for 6.4 coord problem [Re: xoNoid] #79606
07/05/06 19:08
07/05/06 19:08
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
np. if you have minor questions, togh i am no shader guy, ask again. the fx file itself is quite well documented, however if you want to change alpha, speed, ripple scale, direction or anything else you will have to search there.


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