PDA

View Full Version : Real Rain Simulation



Rodrix
04-13-2006, 12:28 AM
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. :)

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

Jan
04-13-2006, 02:14 AM
Check out ATIs GDC 2006 presentations about their "Toy Shop" demo. There they explain how they did rain effects.

Jan.

Fastian
04-13-2006, 02:14 AM
Point sprites coupled with motion blur should look good. Otherwise, if you can add support for lines (Texture mapped polygons should be great :) ), 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.

Fastian
04-13-2006, 02:19 AM
two posts exactly at the same time.... What a coincidence :)

Rodrix
04-13-2006, 02:00 PM
Hi guys! Thanks for answering!
Seems you two got telephaty! :D

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

Rodrix
04-13-2006, 02:20 PM
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?

knackered
04-13-2006, 04:15 PM
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.

zed
04-13-2006, 11:53 PM
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.

Rodrix
04-14-2006, 01:10 AM
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 :) ), could you explain yourself better?

Thanks!
Cheers,
Rod

knackered
04-14-2006, 04:59 AM
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.

Rodrix
04-14-2006, 03:51 PM
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 ;) ) 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
04-14-2006, 07:35 PM
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.

AlexN
04-14-2006, 11:36 PM
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.

Rodrix
04-15-2006, 08:28 AM
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...

zed
04-15-2006, 03:35 PM
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)

Rodrix
04-15-2006, 05:11 PM
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

zed
04-15-2006, 11:39 PM
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

Rodrix
04-16-2006, 12:40 AM
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

Rodrix
04-16-2006, 12:50 AM
Ohhh the problem is another!!!


My graphics card doesnt not have the necessary capabilities! :( 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

zed
04-16-2006, 03:39 PM
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 :)

Rodrix
04-17-2006, 12:11 AM
:-(.. still not working...

The zip appears to be the same as before.
But I think that the real problem is that my card doesn't support the 'AltiVec' Extension.... (Checked the log)
What is that?! And is it essential for creating your rain?

Thanks so much!
Rodrix

PfhorSlayer
04-17-2006, 04:58 AM
"AltiVec" is the name of the vector processing unit in Macintosh G4/G5 computers. It has nothing to do with what you're trying to do. Where are you even seeing that? It has nothing to do with your graphics card...

Rodrix
04-17-2006, 09:27 AM
When I run the program the console leaves the following text:

[...]
..[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 So since it read "unsupported opengl extensions --
the graphics card doesnt have the necessary capabilitys" and it marked me:
"------ CPU info ----------
RDTSC: 1
MMX: 1
MMXExt: 1
3DNow: 1
3DNowExt: 1
SSE: 1
SSE2: 1
AltiVec: 0 "

I supposed that this was the missing extension... :confused:

Roderic (Ingenu)
04-17-2006, 09:46 AM
Originally posted by Rodrix:
I supposed that this was the missing extension... :confused: It's not, it's the Vector Unit of the PowerPC processors.

zed
04-17-2006, 04:44 PM
PfhorSlayer + Ingenu are correct AltiVec: has nothing to do with it.
i assume the problem is that youre using an ati card (though i cant see anything im doing that wouldnt make it work on ati)
email me at billybolluxbouncingballs at yahoo.co.uk and we'll sort it out
zed

Humus
04-17-2006, 07:22 PM
You have forgot a few .0 in the end of some float point numbers. Like 200 - 50 should read 200.0 - 50.0

zed
04-17-2006, 09:55 PM
prolly did, theyre relaxing the spec aint they WRT this.
anyways the shader is not necessary (as the rain doesnt use it)
just use a vertex shader of gl_Vertex = ftransform;
and a fragemnt shader of gl_Color.xyz = vec3(1.0,1.0,1.0);

mate i have deja vu of this live bottom episode i saw last week (where richie goes 'its not worth the wait')
the rain thing i wrote is a quick hack with no trickery at all, a simple particle system.