2 registered members (Ayumi, 1 invisible),
584
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Performance problems with rain effect
#403215
06/16/12 17:04
06/16/12 17:04
|
Joined: Aug 2011
Posts: 133 Germany, Supergeheimes Hinter-...
gameplan
OP
Member
|
OP
Member
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=2But 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 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]
#403222
06/16/12 17:50
06/16/12 17:50
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
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.
|
|
|
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-...
gameplan
OP
Member
|
OP
Member
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: 3run]
#403229
06/16/12 18:56
06/16/12 18:56
|
Joined: Aug 2011
Posts: 133 Germany, Supergeheimes Hinter-...
gameplan
OP
Member
|
OP
Member
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
|
|
|
|