Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,501 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 6 1 2 3 4 5 6
Re: Real DX9 Reflection [Re: MMike] #37722
12/15/04 07:21
12/15/04 07:21
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
OKay now im done with the size problem.. the script does a 128 cubemap ( its enough for now) and it work 100%

Now. I would like to take a screenshot 4 seconds in 4 seconds... and that overwrite them ..instead of saving as shot1, shot2, shot3 and so..

Anyone??

Last edited by Unknot; 12/15/04 07:43.
Re: Real DX9 Reflection [Re: MMike] #37723
12/15/04 08:18
12/15/04 08:18
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline
Senior Developer
Josh_Arldt  Offline
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
Use what Pappenheimer suggested.
This saves the bitmaps as a cubemap instead of shot1, shot2 ect...

savedir="output";
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_c=capture_cubemap;

Re: Real DX9 Reflection [Re: Josh_Arldt] #37724
12/15/04 08:29
12/15/04 08:29
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
the problem with this whole technique is that it is going to be extremely slow.. to do this properly you'd have to use render to texture.. instead of taking screenshots

Re: Real DX9 Reflection [Re: Matt_Aufderheide] #37725
12/15/04 08:36
12/15/04 08:36
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline
Senior Developer
Josh_Arldt  Offline
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
Not all of us have the render to texture feature.

Re: Real DX9 Reflection [Re: Josh_Arldt] #37726
12/15/04 09:12
12/15/04 09:12
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
thats why im taking this way..

Re: Real DX9 Reflection [Re: MMike] #37727
12/15/04 10:21
12/15/04 10:21
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
Okay i can do the screenshot overwrite...

Now my only problem is refresh The Bmap picture in the shader material.. what im not getting to work..

Re: Real DX9 Reflection [Re: MMike] #37728
12/15/04 13:06
12/15/04 13:06
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
Okay its done..
NOw it updates the environment cube, and it fake a real mirror..


Re: Real DX9 Reflection [Re: MMike] #37729
12/15/04 14:19
12/15/04 14:19
Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
Drew Offline
Serious User
Drew  Offline
Serious User

Joined: Jan 2002
Posts: 1,276
trapped in a paper bag
can you please share? very cool...

Re: Real DX9 Reflection [Re: key_46] #37730
12/15/04 22:19
12/15/04 22:19
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i wrote a plugin that writes to a image handle from wdl... kinda fast (however depends on the size).
do you write the image data into a tga file on hd, or in memory? if you want, i can share my c++ code to improve your feature...

Re: Real DX9 Reflection [Re: Joey] #37731
12/16/04 00:18
12/16/04 00:18
Joined: May 2002
Posts: 2,541
Berlin
EX Citer Offline
Expert
EX Citer  Offline
Expert

Joined: May 2002
Posts: 2,541
Berlin
I am using as a sky cube a 64x64per square or something (very small), and itīs looking good even if it is scaled very large. So the mirror map wouldnīt have to be big ether. maybe 32x32 per square would be enough.

EX Citer


:L
Page 2 of 6 1 2 3 4 5 6

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