Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Performance problems with rain effect #403215
06/16/12 17:04
06/16/12 17:04
Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
G
gameplan Offline OP
Member
gameplan  Offline OP
Member
G

Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
Hi,

I am trying to realize a rain effect. First I tried to accieve this with particle effects. See here: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=402970&page=2

But the particels stay allways in direction of the cameraview. That isnt very realistic. So I trying to get a better raineffect with entityraindrops, so no particles.

The problem with my code is, that the fps is down very fast. Does anybody have an idea, what I could do, to increase the performance? By the way, this raincode is taken and rewritten form the "amazing weather script": http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=341869&page=1

Quote:

function toggle_rain()
{
rain_on += 1;
rain_on %= 2;

VECTOR rain_origin;
var i_temp;

if (rain_on)
rain_handle = snd_loop(rain_wav, 50, 0);
else
snd_stop(rain_handle);


while (rain_on)
{
for(you_temp_1 = ent_next(NULL); you_temp_1; you_temp_1 = ent_next(you_temp_1))
if(you_temp_1.rain == 1)
if(you_temp_1.z <= 0)
ent_remove(you_temp_1);

//rain area 1
i_temp = 0;
while (i_temp < 90) // that's a "while without wait" loop
{
rain_origin.x = camera.x + 1000 - random(2000);
rain_origin.y = camera.y + 1000 - random(2000);
rain_origin.z = camera.z + 500;

rain_pointer=ent_create(rain_tga, rain_origin, NULL);
rain_pointer.rain = 1;
i_temp += 1;

set(rain_pointer, PASSABLE | TRANSLUCENT | BRIGHT /*| UNLIT*/ ) ; // remove the comment to increase the brightness of the rain sprites
rain_pointer.alpha = 20 + random(75);
rain_pointer.ambient = 40 + random(60);
}

//rain area 2
i_temp = 0;
while (i_temp < 20) // that's a "while without wait" loop
{
rain_origin.x = camera.x + 400 - random(800);
rain_origin.y = camera.y + 400 - random(800);
rain_origin.z = camera.z + 600;

rain_pointer=ent_create(rain_tga, rain_origin, NULL);
rain_pointer.rain = 1;
i_temp += 1;

set(rain_pointer, PASSABLE | TRANSLUCENT | BRIGHT /*| UNLIT*/ ) ; // remove the comment to increase the brightness of the rain sprites
rain_pointer.alpha = 20 + random(75);
rain_pointer.ambient = 40 + random(60);
}




//if (c_content(my.x, 0) == CONTENT_SOLID)
//{
//my.alpha = 0;
//}

for(you_temp_1 = ent_next(NULL); you_temp_1; you_temp_1 = ent_next(you_temp_1))
if(you_temp_1.rain == 1)
{
you_temp_1.z -= (25 + random(30)) * time_step;

//Winddirection
//you_temp_1.x += (2 + random(10)) * time_step;
//you_temp_1.y += (2 + random(10)) * time_step;
}

wait (1);
}
}


thanks


Version: A8 free
OS: Windows 10
Re: Performance problems with rain effect [Re: gameplan] #403220
06/16/12 17:46
06/16/12 17:46
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Do not use entity effects for rain, use particles and try to improve the visuals.

Re: Performance problems with rain effect [Re: gameplan] #403222
06/16/12 17:50
06/16/12 17:50
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I've converted this script from AUM a long time ago, you can download it from my website:
download link
But I want to warn you, that this effect very slow, I would recommend you to use particles.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Performance problems with rain effect [Re: 3run] #403227
06/16/12 18:47
06/16/12 18:47
Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
G
gameplan Offline OP
Member
gameplan  Offline OP
Member
G

Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
Thanks so far. Hm, is there a possibility to control the angle of particles? The reason for my second rain-effect attemd is, as I mentioned above, that the rainsprites stay allways in normal direction to the view. So, if you look up, the raindrops lie horizontal.

Last edited by gameplan; 06/16/12 18:47.

Version: A8 free
OS: Windows 10
Re: Performance problems with rain effect [Re: gameplan] #403228
06/16/12 18:49
06/16/12 18:49
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Particles are 2D, they have no angles. BUT you can set BEAM flag, so they will stay in normal direction as raindrops should, BEAM flag is available if you own COMMERCIAL version or higher.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Performance problems with rain effect [Re: 3run] #403229
06/16/12 18:56
06/16/12 18:56
Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
G
gameplan Offline OP
Member
gameplan  Offline OP
Member
G

Joined: Aug 2011
Posts: 133
Germany, Supergeheimes Hinter-...
Thanks, I downloaded your scrpit. Did you solve the problem, that the raindrops will remove from videomemory? This is the reason, why I implemented the for-loop, to detect every entity (you_temp_1.rain == 1) as a raindrop. So I am able to remove it correctly.


Version: A8 free
OS: Windows 10
Re: Performance problems with rain effect [Re: gameplan] #403233
06/16/12 19:37
06/16/12 19:37
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Every raindrop gets removed, I don't think that "ent_remove" removes the pointer to it, but the sprite itself is removed. Use F11 for debug.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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