PDA

View Full Version : Snow and Rain Effects



Cer3brus
12-04-2009, 10:50 AM
Does anyone know any good snow/rain effect tutorials?
Articles reffering DelphiX would be prefferable
;D

WILL
12-04-2009, 02:30 PM
Does anyone know any good snow/rain effect tutorials?
Articles reffering DelphiX would be prefferable
;D


I may have my old Snow Demo laying around somewhere. It was simple and used DelphiX actually. I think I added wind to it, but really it's nothing at all to add. Just add some x-axis movement to it. Really falling snow is just random left or right as it drops slowly along the y-axis each 1 pixel.

Rain on the other had I imagine would require a faster falling rate and no drift (x-axis) rate other than that or the wind. You may have to represent each rain 'drop' as a line and of course having some transparency would help the effect along too.

Lemme see if I can find that demo. (There is one already up somewhere on PGD for FPC and NDS in a Christmas Demo though! :))

Wizard
12-04-2009, 09:04 PM
Thanks Will, I'm also interested in creating snow/rain in my game built with unDelphiX ;D A demo on how to do it will be of much help :yes:

NecroDOME
13-04-2009, 09:25 AM
I suggest using a particle effect will do the job.

WILL
13-04-2009, 05:21 PM
Here is my snow demo.

Snow Demo (Delphi/UnDelphiX) (http://www.pascalgamedevelopment.com/will/Snow_Demo_DelphiX.zip)

...and here is the Nintendo DS version that Legolas made from it...

Snow Demo (FPC/Nintendo DS) (http://www.pascalgamedevelopment.com/will/Snow_Demo_NDS.zip)

Enjoy! ;)

Wizard
13-04-2009, 05:27 PM
Both these downloads contain the file snowdemo.nds, not the unDelphiX file(s). Thanks! ;D

Cer3brus
14-04-2009, 08:12 AM
Wizard's right, the zips only contain the .nds files.
I ran the file through an emulator, though, the effect looks very good!!

WILL
14-04-2009, 04:09 PM
You're right, sorry don't know what happened there. Been a while since I looked at those files.

Anyhow, I've updated the link: Snow Demo (Delphi/UnDelphiX) (http://www.pascalgamedevelopment.com/will/Snow_Demo_DelphiX.zip)

Wizard
14-04-2009, 05:14 PM
Thanks Will, I like the way the snow builds up on the ground 8)

pjpdev
14-04-2009, 05:17 PM
The effect looks great, I can definitely use this sometime in the future...

WILL
14-04-2009, 08:19 PM
Thanks Will, I like the way the snow builds up on the ground 8)


np :) Actually over time it starts to look a bit... toothy. I'd normalize the ground layer every X particle of snow that hits to smoothen it out a bit more... I've never really experimented with it much, but it's something to look at...

Wizard
15-04-2009, 03:32 PM
Will, I implimented your snow demo into my game and everything works as I want it to. Except for the fps dropping from 200 fps to around 50... I checked your demo and it runs at around 16 fps...So my question is: Does the particle system as a rule eat up the fps or do you think it could be something else? I checked and rechecked my code. :(

WILL
15-04-2009, 04:27 PM
Will, I implimented your snow demo into my game and everything works as I want it to. Except for the fps dropping from 200 fps to around 50... I checked your demo and it runs at around 16 fps...So my question is: Does the particle system as a rule eat up the fps or do you think it could be something else? I checked and rechecked my code. :(


Before I say something else, how many particles are you using?

Wizard
15-04-2009, 04:40 PM
The same as in your demo MAX_SNOW = 500. What I did change is the screen_height & screen_width. And you're right when i decrease the Max_Snow the fps increases, but then it doesn't look so dense...

WILL
16-04-2009, 10:58 AM
I'm not entirely convinced that it's the number of pixels --I mean I could probably spit out about 2000 in OpenGL without breaking a sweat-- but, I do remember that DelphiX used to access video memory rather slowly so...

Wizard
16-04-2009, 11:57 AM
No problem, thanks anyway ;D

NecroDOME
16-04-2009, 02:23 PM
About speed, if you use instancing within DirectX you can spit out 20k without breaking sweat. And it's not that hard to accomplish!

Wizard
16-04-2009, 02:47 PM
This is the 1st time I hear about instancing within DirectX. Must I have a look at clooties translations or do you have a sample?

NecroDOME
16-04-2009, 02:53 PM
msdn (DirectX SDK) has a nice example http://msdn.microsoft.com/en-us/library/bb174602(VS.85).aspx
If you take a look at Constants Instancing and Shader Instancing the differences are really small. You don't need to do extra-fancy stuff.

Wizard
24-04-2009, 09:14 PM
I found a solution to the speed problem I had once I introduced snow in my game.

Instead of


DXImageList.Items[9].Draw(DXDrawGame.Surface,0,0,0);
use


DxdrawGame.Surface.BltFast(0, 0, BackImage.ClientRect,1, BackImage);

bltFast increased the fps to what it is set at in my game, which is 200 fps ;)

btw using BLTFast drawing only works if the image being drawn is exactly the same as clientHeight and clientWidth, if it overlaps it will not work :yes: