Realistic Windy Snow With Motion Blur
#21
Posted 13 January 2010 - 10:38 PM
#22
Posted 13 January 2010 - 11:32 PM
Information about object: snowflake Sprite: spr_snowflake Solid: false Visible: true Depth: 0 Persistent: false Parent: <no parent> Mask: <same as sprite> Create Event: execute code: alarm[0] = random(10)+1 //A bunch of variables that have to do with random directions dir_speed = 0; dir = 0; dirr = 0.1; dirs = 0.05; dirp = 32; size = 0.02; distance = sqrt(random(0.95)+0.05); image_xscale = size/distance; image_yscale = size/distance; grav = 0.1; vspeed = 0.1; stretch = 1/256/size; vx = view_xview; vy = view_yview; ospeed = speed; odirection = direction; Alarm Event for alarm 0: execute code: alarm[0] = room_speed/8; dir_speed = (1-dirr)*dir_speed + dirr*(random(dirp)-dirp/2);//Directional Randomness dir += dir_speed; motion_add(dir,dirs); hspeed += windspeed;//Wind vspeed += grav;//Gravity speed = speed * 0.95;//Friction ospeed = speed; odirection = direction; xv = (vx-view_xview)/distance-vx+view_xview; yv = (vy-view_yview)/distance-vy+view_yview; x += xv; y += yv; image_angle = point_direction(0,0,hspeed+xv*distance,vspeed+yv*distance); image_xscale = image_yscale*point_distance(0,0,hspeed+xv*distance,vspeed+yv*distance)*stretch + image_yscale; image_alpha = image_yscale/image_xscale; speed = speed/distance; vx = view_xview; vy = view_yview; speed = ospeed; direction = odirection; Other Event: Outside Room: execute code: speed = ospeed; direction = odirection; x = ((((x - view_xview) mod view_wview) + view_wview) mod view_wview) + view_xview; y = ((((y - view_yview) mod view_hview) + view_hview) mod view_hview) + view_yview;
[edit]
I did not do much tweaking. but realize that the alarm method is pretty good to effect changes to the particles. Especially if there is a lot of code involved.
And the outside room to wrap instead of the end step. though it breaks the scrolling...
Edited by icuurd12b42, 13 January 2010 - 11:39 PM.
#23
Posted 14 January 2010 - 04:55 AM
I can see that the wrapping code is better off in the outside room event (but as you said it breaks view scrolling so it's not a perfect solution) however the rest of the code kills the whole depth functionality. You might as well take out all the depth code completely if you're going to mutilate it like that.
I can see where you're going with the alarm system, you just didn't do it correctly.
Done correctly however, the snow will remain fully functional with only a slight loss of quality.
Edited by petenka, 14 January 2010 - 04:56 AM.
#24
Posted 14 January 2010 - 06:29 AM
Interesting optimization there Icuurd.
I can see that the wrapping code is better off in the outside room event (but as you said it breaks view scrolling so it's not a perfect solution) however the rest of the code kills the whole depth functionality. You might as well take out all the depth code completely if you're going to mutilate it like that.
I can see where you're going with the alarm system, you just didn't do it correctly.
Done correctly however, the snow will remain fully functional with only a slight loss of quality.
>>I did not do much tweaking.
You are in a better position to tweak it
It's a very good snow example... It would be nice if you had it done in a 3d type FPS setup... As you draw the snow in 2d with perspective, right before the 2d hud, the effect is very compatible. It would be a good thing to show.
In GM8, you can use the suposedly now working outside view event, even in 3d, because view0 is usually used for 3d (to set the port while having a large room/mao). Since it's always at 0,0, the event would still work for the 2d snow. When doing particles with instances, you want GM to handle stuff with as little GML (every step) as possible
#25
Posted 14 January 2010 - 06:33 PM
When I do rain effects I found you can go even further -- don't really have to keep the integrity of every drop. If some drops dissapper/jump, the human eye doesn't really notice. Obviously with snow moving slower it is more important to have particle integrity, but you still might be able to get away with some imperfections. Again that might help in some optimization.
#26
Posted 18 January 2010 - 07:59 PM
Just download and run the installer,
open your screensaver dialog,
and select Snow as your new screensaver.
It runs at 60 fps with 2000 snowflakes
Download link:
http://www.upurload....7951429681c.exe
EDIT: Modified the screensaver to support resolutions other than 1028x1024.
Edited by petenka, 27 January 2010 - 04:02 PM.
#27
Posted 18 January 2010 - 08:21 PM
#28
Posted 18 January 2010 - 08:28 PM
Mind telling me what the specs are on that piece of scrap metal you call a computer?very lovely, but i only got around 9 FPS, which is a bit un-acceptable for use in a game...
Running it on a 2.5 GHz computer with an integrated graphics card nets me 60 fps for the screensaver and 45 fps for the example.
Edited by petenka, 19 January 2010 - 01:15 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











