Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 748 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 9 of 11 1 2 7 8 9 10 11
Re: Released! - HLSL Water Code [Re: Steempipe] #35893
01/24/05 19:39
01/24/05 19:39
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline
Expert
XNASorcerer  Offline
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Steempipe, how can I make the shader to showa terrain also, like you did in your demo?

Re: Water Shader: Exchange the cube_map [Re: XNASorcerer] #35894
01/25/05 02:14
01/25/05 02:14
Joined: Mar 2002
Posts: 7,726
old_bill Offline
Senior Expert
old_bill  Offline
Senior Expert

Joined: Mar 2002
Posts: 7,726
Quote:

Quote:

Yes, now the code from ventilator works.
I used it to create a CubeMap from the position of my water (inside a room) and replaced the
sky cube map with the one from the script, and now i have a "real" environment reflection!





old_bill,

Can you should me how to do that? Thanks




Yes, its quiet simple:

Copy this script into your wdl file:

Code:
 var_nsave fh;
bmap* canvas;
bmap* b_render1;
bmap* b_render2;
bmap* b_render3;
bmap* b_render4;
bmap* b_render5;
bmap* b_render6;
var cubenumber = 0;
var directions[18] = 180, 0, 0, 90, 0, 0, 0, 0, 0, -90, 0, 0, 90, -90, 0, 90, 90, 0;
string tempstring1;
string tempstring2;
string _ts_;

//----------------------------------------------------------------------------- write_cubemap
function write8(byte) // write char
{
file_asc_write(fh, byte);
}

function write16(short) // write unsigned short
{
file_asc_write(fh, short&255);
file_asc_write(fh, (short>>8)&255);
}

function str_padding(str, number, padding)
{
str_for_num(_ts_, number);
var i = 0;
i = padding - str_len(_ts_);
while(i > 0)
{
str_cat(str, "0");
i-=1;
}
str_cat(str, _ts_);
}

function write_cubemap()
{
var i;
var xx;
var yy;
var format;
var pixel;
var pixelalpha;
var canvas_size[2];

canvas_size.x = bmap_width(b_render1);
canvas_size.y = bmap_height(b_render1);
format = bmap_lock(b_render1, 0);
bmap_lock(b_render2, 0);
bmap_lock(b_render3, 0);
bmap_lock(b_render4, 0);
bmap_lock(b_render5, 0);
bmap_lock(b_render6, 0);

str_cpy(tempstring1, "cubemap");
str_padding(tempstring1, cubenumber, 4);
str_cat(tempstring1, "+6.tga");
fh = file_open_write(tempstring1);
cubenumber+=1;
//--------------------------------------------------------write header
write8(0);
write8(0);
write8(2); // image type
write16(0);
write16(0);
write8(0);
write16(0);
write16(0);
write16(canvas_size.x * 6); // width
write16(canvas_size.y); // height
write8(24); // color depth
write8(0);
//--------------------------------------------------------write image data
yy = canvas_size.y - 1;
while(yy >= 0)
{
i = 0;
while(i < 6)
{
if(i==0){canvas=b_render1;}
if(i==1){canvas=b_render2;}
if(i==2){canvas=b_render3;}
if(i==3){canvas=b_render4;}
if(i==4){canvas=b_render5;}
if(i==5){canvas=b_render6;}
xx = 0;
while(xx < canvas_size.x)
{
pixel = pixel_for_bmap(canvas, xx, yy);
pixel_to_vec(temp, pixelalpha, format, pixel);
write8(temp.x); // b
write8(temp.y); // g
write8(temp.z); // r
xx+=1;
}
i+=1;
}
yy-=1;
}
file_close(fh);
bmap_unlock(b_render1);
bmap_unlock(b_render2);
bmap_unlock(b_render3);
bmap_unlock(b_render4);
bmap_unlock(b_render5);
bmap_unlock(b_render6);
}

//----------------------------------------------------------------------------- capture_cubemap
function capture_cubemap
{
var old_arc;
var old_x;
var old_y;
var old_screen;

b_render1 = bmap_create("render.tga"); // use a 256x256 tga for example -> determines cube map size
b_render2 = bmap_create("render.tga");
b_render3 = bmap_create("render.tga");
b_render4 = bmap_create("render.tga");
b_render5 = bmap_create("render.tga");
b_render6 = bmap_create("render.tga");

old_arc = camera.arc;
old_x = screen_size.x;
old_y = screen_size.y;
old_screen = video_screen;

camera.arc = 90;
video_set(256, 256, 32, 2); // should be same resolution as render.tga

freeze_mode = on;
vec_set(camera.pan, directions[0]); wait(1); bmap_for_screen(b_render1,1,0);
vec_set(camera.pan, directions[3]); wait(1); bmap_for_screen(b_render2,1,0);
vec_set(camera.pan, directions[6]); wait(1); bmap_for_screen(b_render3,1,0);
vec_set(camera.pan, directions[9]); wait(1); bmap_for_screen(b_render4,1,0);
vec_set(camera.pan, directions[12]); wait(1); bmap_for_screen(b_render5,1,0);
vec_set(camera.pan, directions[15]); wait(1); bmap_for_screen(b_render6,1,0);
freeze_mode = off;

wait(1);
write_cubemap();

wait(1);
camera.arc = old_arc;
video_set(old_x, old_y, 32, old_screen);
}

on_h=capture_cubemap;


Make sure that an empty tga file named "render" is in your save folder.

Then go to the position where the water is and move with the cam to the ground and look to the sky (tilt 90°).
Press h and the screen will become black for some seconds.
Close the engine and search for "cubemap0000+6.tga" in your save folder.

Assign this file to the water shader as "water_cube".
It looks nice, but remember it will not display the player and it only works for small planes.
Realtime reflection would require the pro edition.

But try it!

old_bill


Success is walking from failure to failure with no loss of enthusiasm.
Re: Water Shader: Exchange the cube_map [Re: old_bill] #35895
01/25/05 05:48
01/25/05 05:48
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline
Expert
XNASorcerer  Offline
Expert

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

Realtime reflection would require the pro edition




Thank you for answering so fast.
I have the Pro version. How can I do that with the shader?

Re: Water Shader: Exchange the cube_map [Re: XNASorcerer] #35896
01/25/05 06:16
01/25/05 06:16
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
To do real reflections with a shader and render targets, i dont recommend using cubic environment mapping. You are better off rendering the scene to a texture with a user clipping plane at the water surface. Then map this texture projectively on to the water, and you should have real reflections.. this method works better because you only need one render-to-texture, not 6.

Re: Water Shader: Exchange the cube_map [Re: Matt_Aufderheide] #35897
01/25/05 06:35
01/25/05 06:35
Joined: Oct 2000
Posts: 1,543
Germany
A
Alexander Esslinger Offline
Senior Developer
Alexander Esslinger  Offline
Senior Developer
A

Joined: Oct 2000
Posts: 1,543
Germany
...though there are no user-defined clipping planes in GameStudio

Well, we have the mirrows, but they clip levelgeometry only, which prevents entitys to walk in the water...

Re: Water Shader: Exchange the cube_map [Re: Matt_Aufderheide] #35898
01/25/05 06:51
01/25/05 06:51
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline
Expert
XNASorcerer  Offline
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Thanks, but I don't make any idea of how to use render-to-texture. Can you haelp me with that?

Re: Water Shader: Exchange the cube_map [Re: XNASorcerer] #35899
01/26/05 05:18
01/26/05 05:18
Joined: Aug 2002
Posts: 791
NRW, Deutschland
inFusion Offline
User
inFusion  Offline
User

Joined: Aug 2002
Posts: 791
NRW, Deutschland
Please don't overgo my question:
Can I somehow tile the normal-map to make the waves much smaller to use this code for a huge ocean?


"Wer nicht mit der Zeit geht, muss mit der Zeit gehen" - Bernd Stromberg
----
www.kihaki.de/reincarnation
Re: Water Shader: Exchange the cube_map [Re: inFusion] #35900
01/26/05 05:29
01/26/05 05:29
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Maybe you can monkey with code like this for scaling the texture. Browse way back in this thread and there may be some more info.

Code:

//////////////////////////////////////////////
float2 WaveDir;
float SpeedComp = {0.02}; // Adjust depending on the
// RippleScale setting

WaveDir.x = IN.Bump.x * RippleScale;
WaveDir.x -= (vecSkill41.x * SpeedComp); // Direction of U (either + or -)

WaveDir.y = IN.Bump.y * RippleScale;
//WaveDir.y += (vecSkill41.x * SpeedComp); // Direction of V (either + or -)

Out.Bump = WaveDir.xy;
////////////////////////////////////////////



Re: Water Shader: Exchange the cube_map [Re: Alexander Esslinger] #35901
01/26/05 11:26
01/26/05 11:26
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Quote:

...though there are no user-defined clipping planes in GameStudio

Well, we have the mirrows, but they clip levelgeometry only, which prevents entitys to walk in the water...




Yes but couldnt it somehow be done in the vetex shader? I believe i've seen such code before..There is a brute force way to do it in any case, just use two different terrains, one with the top half of the map, one with the parts under water, then when you render the reflection view make the water and the lower terain invisible.

The best thing of course would be to have a user clip plane implemented by JCL..

Re: Water Shader: Exchange the cube_map [Re: Matt_Aufderheide] #35902
01/27/05 10:39
01/27/05 10:39
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Quote:

Hey... Steempipe did you ever convert the pixel shader to HLSL? i have tried but i dont really get the theory here.. I know you have to use a higher PS version, at probably 1.4 or 2.0 becuase 1.1 doesnt support dependent reads..




It's pretty close...... However, I'm Side-tracked into terrain FX.

Page 9 of 11 1 2 7 8 9 10 11

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