Real Rain Simulation

Hi guys!
How are you doing?!

Has anyone watched the movie Sin City?
There is an awesome shot where the camera points to the sky and you can see the actual raindrops falling in cone perspective towards the camera.
I want to do that. :slight_smile:

However I have already tried with a particle system but havent’ gotten good results for rain. I am working with a point sprite particle system which works great for snow, but for rain I have no idea what texture should I use. With all the textures that I have tried, It doesn’t look like rain at all.

Any suggestions?! Are point sprites appropiate?! I am totally lost, and haven’t found any 3d real-time rain simulation tutorial or article…

Thanks in advance,
Cheers!
Rod

Check out ATIs GDC 2006 presentations about their “Toy Shop” demo. There they explain how they did rain effects.

Jan.

Point sprites coupled with motion blur should look good. Otherwise, if you can add support for lines (Texture mapped polygons should be great :slight_smile: ), that should do the trick.

I would also suggest looking at ATI GDC 2006 presentations. They have a nice rainy night demo with pretty decent/convincing rain effects.

two posts exactly at the same time… What a coincidence :slight_smile:

Hi guys! Thanks for answering!
Seems you two got telephaty! :smiley:

The demo is awesome! It’s something absolutely unbelivable (at least for me). However I didn’t find the explanation… Maybe I missed some links?!

Although I did learn that they use particles made of lines…

Any more data?

Thanks!
Rod

Ohhh… I found the paper!

…This seems hard!
However they aren’t using particle systems, so that means rain cannot be viewed from top.
You say motion blur would do the trick?

I’ve done a rain vertex shader, which animates a cloud of line segments falling down and being blown by the wind, wrapping them round at all 6 edges of the frustum so you see every line that is being processed at once. You can fly infinitely through the cloud in any direction, look up, look down, whatever you want. The only CPU work is a single uniform update per frame.
But then, I’m a genius.

and modest to boot.
ive just read the pdf’s (great ati use them now instead of the ppt they once used)
the actual rain technique looks pretty basic (though the other effects like rain on windows etc look great)
ild do it differently.
ild use particles for the closest 100,000 drops or so (even though in reality rain moves faster that u cant see the indivual drops, i have a feeling thisll look better from an asetic point)
hmmm i might implement this myself.

Zed, my CPU already gets slow at 5000 particles,
I don’t think 100,000 particles is possible…
at least with point sprites. What do you think?

I already implemented my rain with a particle system, and I tried using a texture that contains three white lines with glow that simulate rain (aka three rain drops). The rain looks ok from front, although it looks akward if viewed from bottom to top (I see lines instead of drops because of the automatic billboarding of point sprites). And if I apply wind, or particles move more randomly, the fact that the rain drop lines are static, and they don’t follow the actual movement line makes them look real bad.

If instead I use a single water drop texture (round drop, instead of line), it doesn’t look like real rain, it looks like cheap water balls falling from the sky.

Any suggestions on how to handle the texture?!

Knackered… or Mr.Genius (and very modest :slight_smile: ), could you explain yourself better?

Thanks!
Cheers,
Rod

Man alive, I’m no genius - that was sarcasm - it’s easy to implement what I described.
You shouldn’t be doing any CPU work at all. You shouldn’t even need to use any branching in the vertex shader. It’s all linear arithmetic. Unfortunately I can’t explain how it’s done, as all my work is owned by the company I work for, but what I can say is it’s simple and looks amazingly cool and renders amazingly fast…obviously if you’re going to be using consumer cards you’ll have to address the lack of decent line drawing support.

Originally posted by knackered:
it’s easy to implement what I described.
You shouldn’t be doing any CPU work at all. You shouldn’t even need to use any branching in the vertex shader. It’s all linear arithmetic. Unfortunately I can’t explain how it’s done…

:confused: :confused: :confused:

I am not that experienced enough to catch up what knacekered explained about the vertex shader… anybody more experienced than me (and that doesn’t have legal concerns :wink: ) could explain me in simpler words the idea he meant to transmit?

Knackered: do you work in a big company? And do they use this effect in a game?

Thanks everyone!
Cheers
Rod

Zed, my CPU already gets slow at 5000 particles,
I don’t think 100,000 particles is possible…
at least with point sprites. What do you think?
it shouldnt do,
i just wrote a test app 100,000 raindrops in 5 minutes @50fps in immediatemode with gl_lines (watch out for lines being the same thickness no matter how far away from the camera, better to use something else),
though actually from testing 100,000 is overkill u only need 10,000->20,000 for some decent looking rain.
cpu hit is minor at such small numbers, the only potentual hit is the collision detection (which im not doing) but then again the ati doesnt look like its doing it as well as aint knackered method.

You submit to the vertex shader a set of initial positions for the rain, and you maintain a velocity and time variable for the vertex shader. Animate the rain by using initial position + velocity * time, and wrap the coordinates so that they stay on screen. You could do this in either 2d or 3d…try different coordinate systems to see which one fits what you need (does the rain track camera rotation, movement, etc.)

You can fade out distant rain by using blending and altering color values based on distance, and if lines aren’t giving you good quality then you can try thin screen aligned quads, perhaps even texture mapped with blending to give it a smooth look.

Thanks guys! I am trying to get a better idea now.

And for the aligned mapped quads with blending approach, which textures should I use?
Should I approach for textures that have multiple lines, a single line, or textures that have drawn a single drop and then use motion blur?

Thanks!

P.S: Zed: my particle system does use collision detection. That may be the cause of why 5000 is already slow…

u mentioned looking up into the rain, now i assume the fullscreen quad approach doesnt work attempting this, whereas with particles it does (ill upload a simple rain test i made if u wish)

ZED wrote: u mentioned looking up into the rain, now i assume the fullscreen quad approach doesnt work attempting this, whereas with particles it does (ill upload a simple rain test i made if u wish)
Zed that would be deeply appreciated!
Thanks so much in advance!

Cheers,
Rod

get here u will need sdl installed,
http://www.filefactory.com/?e62e77
20,000 raindrops
speed will depend on cpu speed (take a minute to startup)
s to turn off splashs

Zed,
First of all, thanks!
But I installed SDL and the program does not run because it says “Error 38- No options.txt”. There is no such file in the zip.

Should I create that file and fill it with what?!

Thanks so much!!! :eek: )
Cheers,
Rod

Ohhh the problem is another!!!

My graphics card doesnt not have the necessary capabilities! :frowning: Are you using anything special rather than vertex shaders? Or is it just that my card doesn’t support vertex shaders? Reading the error log i think it has to do with an extension coded as “AltiVec” (???). Is this essential for the rain simulation?

Thanks!,
Rod

  couldn't create the_log_file.log
couldn't create the_errorlog_file.log
entering main
Saturday 15 April 2006 02:50:48
..[3] starting program
..[3] initializing SDL video
SDL window initialized
setting up game options
**ERROR**[42] no options.txt file
..[48] initializing bogus SDL openGL window
..[3365] freeing sdl surface
------ CPU info ----------
RDTSC:    1
MMX:      1
MMXExt:   1
3DNow:    1
3DNowExt: 1
SSE:      1
SSE2:     1
AltiVec:  0
..[3373] initializing SDL window
..[3374] video mem: 250MB
asking for videomode 1024x768@32
..[3376] compiled with SDL version 1:2:9
..[3377] running with SDL version 1:2:7
resizing window from (1024,768) to (1024,768)
..[3537] initializing rendermanager
initializing openGL
-- unsupported opengl extensions --
the graphics card doesnt have the necessary capabilitys

sorry try this
http://www.filefactory.com/?7283a0

note youll get errors and such since ive removed stuff to make the download small (eg a 220mb terrain file :slight_smile: