Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, monarch), 1,432 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 7 of 9 1 2 3 4 5 6 7 8 9
Re: Realtime water reflections shader [Re: Nadester] #40498
02/11/05 09:46
02/11/05 09:46
Joined: Jul 2002
Posts: 2,813
U.S.
Nadester Offline

Expert
Nadester  Offline

Expert

Joined: Jul 2002
Posts: 2,813
U.S.
You can also code just the pixel shader in ASM, and code the rest in HLSL - and it will work fine.


--Eric
Re: Realtime water reflections shader [Re: oliver2s] #40499
02/11/05 10:28
02/11/05 10:28
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
There is still something strange with this shader and terrains.
Here you can see the effect working ok:

And if you walk just two steps back with the cam you can see the bad one:


Here without the transparency code:



Last edited by Sorcerer; 02/11/05 10:52.
Re: Realtime water reflections shader [Re: XNASorcerer] #40500
02/12/05 05:54
02/12/05 05:54
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Have you applied the "terrainobject" action to the terrain? All objects that are in water must have this action for clipping underwater in the mirror view.

[EDIT]: use this new action:
Code:
MATERIAL terrain_clipping //for clipping the terrain underwater in the mirror view

{
event = render_event();

flags = enable_view;

effect=
"

float4x4 matWorldViewProj: register(c0);

texture entSkin1;

vector vecSkill41;

float1 mtlSkill1;

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

VS_OUTPUT VS_p0(float4 Pos1: POSITION, float2 basemap: TEXCOORD0)
{
VS_OUTPUT Out;

Out.Pos = mul(Pos1, matWorldViewProj);

Out.texCoord = basemap;

Out.eyeLinear.x = Pos1.x;
Out.eyeLinear.y = Pos1.y;
Out.eyeLinear.z = Pos1.z;

return Out;
}

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

float4 PS_p0( float2 texCoord: TEXCOORD0,
float3 eyeLinear: TEXCOORD1) : COLOR
{
float4 base = tex2D(BaseMap, texCoord);

clip((eyeLinear.y-vecSkill41)*mtlSkill1);

// Output

return base * 1.2;
}
technique water
{
pass p1
{
VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();
}
}
";
}

ACTION terrainobject
{
var hoch1;
my.material = terrain_clipping;
my.nofog = on;
hoch1 = water_ent.z*0.049;
while(1)
{
my.skill41 = float(hoch1);
wait(1);
}
}



Last edited by oliver2s; 02/12/05 06:00.
Re: Realtime water reflections shader [Re: oliver2s] #40501
02/12/05 07:32
02/12/05 07:32
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Yes, I have. But the problem still persist. If you want, I could send this level for you to see it.

Last edited by Sorcerer; 02/12/05 07:33.
Re: Realtime water reflections shader [Re: XNASorcerer] #40502
02/12/05 08:24
02/12/05 08:24
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Sorry, but I haven't enough time at the moment to debug the level.

Re: Realtime water reflections shader [Re: oliver2s] #40503
02/12/05 13:19
02/12/05 13:19
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Maybe, I could send you a video.

Re: Realtime water reflections shader [Re: oliver2s] #40504
02/12/05 22:53
02/12/05 22:53
Joined: Nov 2003
Posts: 44
sriram Offline
Newbie
sriram  Offline
Newbie

Joined: Nov 2003
Posts: 44
Hey this code is awesome...but unfortunately,its not working on my level
I've created a new map with just your floor_mdl and a terrain object.I've assigned the 'ater' action to the floor and 'terrainobject' action to the terrain and also uncommented the pro code...but I'm getting these Compilation errors :

<mirror.nocull=on>
Error(0): parameter unknown mirror parameter

<loadfx();>
Error(29): keyword unknown loadfx

<d3d_shaderversion<2020>
Error(63): parameter unknown d3d_shaderversion

<my.material=terrain_clipping;>
Error(29): keyword unknown my.material

My modified Code is :
Code:
 
// shader_test.wdl

var video_mode = 7;
var video_depth = 32;
var d3d_mipmapping = 3;
var d3d_anisotropy = 16;
var clip_range = 200000;
var clip_factor = 1;
var clip_size = 0;
var clip_factor= 1;
var fps_max = 70;
var fps_min = 35;
var max_entities = 1000;
var d3d_transform = on;
var move_friction = 0;
var d3d_antialias = 6;
var logo = 0;
var video_screen = 1;

var bumpness = 100;
var speed = 1;

bmap slider_tga = "slider.tga";
bmap mauszeiger_bmp = "mauszeiger.bmp";
bmap slider_box_tga = "slider_box.tga";

PANEL pan_sliders
{
bmap = slider_box_tga;
hslider = 492, 4, 610, slider_tga, 0, 500, bumpness;
hslider = 492, 30, 610, slider_tga, 0, 10, speed;
}

FUNCTION loadfx();

function main
{
d3d_autotransparency = on;
level_load("water_shader.wmb");
}

SKY himmel1
{
type = <himmel3+6.tga>;
layer = 3;
flags = cube,visible;
z = 0;
}

VIEW mirror
{
layer = 10;
}

entity* water_ent;

function render_event();

MATERIAL waterfx
{
}

var hoch;
var hoch1 = 3.2;

ACTION water
{
var count;
var count1;
var a = 180;
var b;
water_ent = me;
my.nofog = on;
// my.invisible = on;
my.material = waterfx;
my.scale_x = 40;
my.scale_y = 40;
my.z += 20;
hoch = my.z;
while(1)
{
my.z = hoch;
my.skill41=float(count);
my.skill42=float(count1);
my.skill43=float(0);
my.skill44=float(0);
a += speed*time;
a %= 360;
b += speed*time;
b %= 360;
count = sin(a)+bumpness;
count1 = cos(b)+bumpness;
hoch1 = my.z*0.049;
wait(1);
}
}

STARTER init_water
{
wait(2);

camera.x = -1552;
camera.y = -935;
camera.z = 98;
camera.pan = 43;
camera.tilt = -4;

mirror.size_x = camera.size_x;
mirror.size_y = camera.size_y;

d3d_fogcolor1.red = 128;
d3d_fogcolor1.green = 128;
d3d_fogcolor1.blue = 150;

fog_color = 1;

camera.fog_start = 20;
camera.fog_end = 5000;
mirror.fog_start = 20;
mirror.fog_end = 5000;

camera.clip_near = 0;
mirror.clip_near = 0;
mirror.nocull = on;

/*If you have A6 Pro Version*/
mirror.bmap = bmap_for_entity(water_ent,1);
// refrview.bmap = bmap_for_entity(water_ent,2);
mirror.aspect = -1;
mirror.visible = on;
// refrview.visible = on;

/*If you have A6 Com Version

IF(d3d_shaderversion < 2020)
{
pan_sliders.visible = off;
while(1)
{
draw_text("You need a video card with Pixelshader 2.0",screen_size.x-520,screen_size.y-280,vector(0,0,0));
wait(1);
}
}

make_mirror();
mirror.aspect = -1;*/

mouse_map = mauszeiger_bmp;

proc_late();
while(1)
{
mirror.x = camera.x;
mirror.y = camera.y;
mirror.z = -camera.z+ (2*water_ent.z);
mirror.pan = camera.pan;
mirror.tilt = -camera.tilt;

mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;

pan_sliders.pos_x = (screen_size.x/2)-800;
pan_sliders.pos_y = screen_size.y-52;

wait(1);
}
}

/*FUNCTION make_mirror
{
mirror.visible = on;
pan_sliders.visible = off;
mouse_mode = 0;
mirror.size_x = camera.size_x;
mirror.size_y = camera.size_y;
water_ent.visible = off;
wait(1);
bmap_for_screen(bmap_for_entity(water_ent,1),1,0);
mirror.visible = off;
water_ent.visible = on;
pan_sliders.visible = on;
mouse_mode = 2;*/

loadfx();
}

MATERIAL terrain_clipping //for clipping the terrain underwater in the mirror view
{
event = render_event();

flags = enable_view;

effect=
"

float4x4 matWorldViewProj: register(c0);

texture entSkin1;

vector vecSkill41;

float1 mtlSkill1;

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

VS_OUTPUT VS_p0(float4 Pos1: POSITION, float2 basemap: TEXCOORD0)
{
VS_OUTPUT Out;

Out.Pos = mul(Pos1, matWorldViewProj);

Out.texCoord = basemap;

Out.eyeLinear.x = Pos1.x;
Out.eyeLinear.y = Pos1.y;
Out.eyeLinear.z = Pos1.z;

return Out;
}

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

float4 PS_p0( float2 texCoord: TEXCOORD0,
float3 eyeLinear: TEXCOORD1) : COLOR
{
float4 base = tex2D(BaseMap, texCoord);

clip((eyeLinear.y-vecSkill41)*mtlSkill1);

// Output

return base * 1.2;
}
technique water
{
pass p1
{
VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();
}
}
";
}

FUNCTION loadfx
{
effect_load(terrain_clipping,"clip.fx");
effect_load(waterfx,"water.fx");
}

ACTION terrainobject
{
IF(d3d_shaderversion < 2020) { return; }
my.material = terrain_clipping;
my.nofog = on;
while(1)
{
my.skill41 = float(hoch1);
wait(1);
}

}

function render_event()
{
if(render_view == camera)
{
mtl.skill1 = float(0);
}
if(render_view == mirror)
{
mtl.skill1 = float(1);
}
}



Any help is appericiated..BTW,I have A6 Pro..and I have a GeForceFX 5200,so the problem is with the code

Re: Realtime water reflections shader [Re: sriram] #40505
02/12/05 22:58
02/12/05 22:58
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
I have not tested it, but I think my the code is only working with A6.31

Re: Realtime water reflections shader [Re: oliver2s] #40506
02/13/05 01:18
02/13/05 01:18
Joined: Nov 2003
Posts: 44
sriram Offline
Newbie
sriram  Offline
Newbie

Joined: Nov 2003
Posts: 44
Thanks for replyig oliver...I'm using 3DGS A6 Pro v6.22.I reverted from 6.31 as I've started making a game in 6.22...so,could someone please post a code with the necessary changes so that it would work in 6.22 ?

Thanks

Re: Realtime water reflections shader [Re: sriram] #40507
02/13/05 01:42
02/13/05 01:42
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
because 6.22 is directx8 not 9 this shader will not work(because it's HLSL). A new shader would have to be written to use ps 1.1-1.4 in assembler. It probably wouldnt work though, as there is no clip function in the lower shader versions..you need to render the terrain manually in a dll with a clip plane.

Your best solution is to go to 6.31.. you won't regret it.

Page 7 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