Sign in to follow this  

Proper rain - how feasible?

This topic is 3936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am wanting to develop a rain system. Basically it would have at least two levels of detail. The closer particles would be proper shaded objects, not sure exactly what type to use yet, but they would be lit and would have collision detection so as to make correct splashes on the ground, ripples on water etc. and also to prevent the particles from falling through into undercover areas. As you go a little further away, the particles are rendered as perhaps streaks, and at some point in the distance you would stop running any collision detection. I would want this to run along with a decently detailed animated scene with stencil shadowing (soft shadows would be nice!), water shaders, reflections from wet surfaces, at least bump mapping etc. The target system for this to run on would be something quite high end by todays standards (ie. core2duo, nvidia 8800, 2gb RAM... its a project not a commercial application and as long as it runs on my system it is fine). So, I was wondering if such a project would be feasible, would it be able to run properly in real-time with a sufficient amount of particles to simulate heavy rainfall? Obviously how it runs depends on how well it is optimized, but I was hoping someone here could let me know if it is possible at all to begin with, since I have not really seen anyone implement proper rain before in real-time. Most implementations seem to just have a scrolling texture, so you cannot transition properly between indoor and outdoor areas. Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I believe nVidia already has a demo of this out running in real time. Check their developer site. It is quite possible but few people want that level of realism for something that doesn't effect gameplay (currently) at all.

Share this post


Link to post
Share on other sites
A realistic rainfall is relatively easy to implement in Direct3D 10. Here's how:


  • Use pixel shader for the physics of the rain particles. This way, you have a comprehensive control over the wind, gravity and other variables as needed, in hardware.

  • For the raindrops colliding with solid objects (and not going thru them), render a floating-point depth map in "rain space" - that is, generally from orthogonally upward direction relative to your scene. Then, in vertex shader, test if the rain particles are deeper than the local map values and communicate this to the pixel shader that is responsible for the physics of the rainfall calculations.

  • To manifest the particles that represent the raindrops, use geometry shader to construct the drops and stretch them according to the velocity you calculated on the pixel shader. You can also calculate blending factors in the geometry shader to implement a motion blur effect to the drops, and communicate the velocity back to the pixel shader for post-processing.

  • In the post-position pixel shader, refract the rest of the scene with the normals of the raindrops, and blur along the velocity vectors as needed.

  • To simulate raindrops hitting to water surface, use a general water integration algorithm for the surface and seed it with the collision points of the water particles.

  • To simulate raindrops hitting on a solid object, explode the particle geometry using the geometry shader. Communicate the collision to the geometry shader from the vertex shader.



Stencil shadowing after this is easy as the raindrops are represented by real geometry. The other effects mentioned have nothing to do with rain simulation.

Please ask for more help if needed.

Share this post


Link to post
Share on other sites
I guess you missed ATI's Toy Shop Demo from last year then? Pretty much representing the 'state of the art' in rendering rain, splashes and other related environmental effects - in realtime.

You can download the demo or mpeg/QT movies from the link above and there is a pdf from GDC06 that describes the techniques used, that might be useful to check out.

Share this post


Link to post
Share on other sites
You may notice they never transition from indoor to outdoor in the ATI Toyshop demo. That is because they are not actually using individual particles with collision detection instead using a scrolling texture (IIRC).

I mean, the effect looks awesome and makes for a very nice looking demo. However, if you had any indoor/outdoor combined areas you couldn't use it properly in a game.

That is an interesting write up Nik02, I'll take a look into it.

Share this post


Link to post
Share on other sites
It is probably worth noting that you could use the physics calculations performed in the GPU to affect the gameplay, since with D3D10-level hardware the downloading of even large amounts of data via the PCI Express bus is very much viable.

In the case of simulating rainfall, I present an example:

You could accumulate the water levels in a texture. This accumulation of water could be used to fill, among other things, a pool of water. Now, if the pool was covered (and modeled as such in the physics shader), the water wouldn't accumulate to it.

It could greatly influence gameplay if the player's actions would cause the covering of the pool, thus enabling game events to determine if the pool was full of water or not. This would potentially affect the player's ability to cross the pool, for example. You could also create a model of a turbine that would spin based on the torque generated by the collisions of the water drops (in other words, flow pressure) against its rotor, and use the resulting spin motion to drive game logic in some way.

This is just a simple example; any kinds of physics can now be calculated on the GPU and a plenty of clock cycles still remain for the actual visual rendering on D3D10 hardware.

Share this post


Link to post
Share on other sites
Quote:
Original post by draculr
You may notice they never transition from indoor to outdoor in the ATI Toyshop demo. That is because they are not actually using individual particles with collision detection instead using a scrolling texture (IIRC).


True, however I think it could be worked around, all you'd need to do is crop the rain textured polygons to the environment. As you said this only really needs to happen locally, so it shouldn't be that intensive. If performance becomes an issue i'm sure there are ways to preprocess the environment to avoid costly intersection tests during runtime. Even a quite rough 'shell' using mininal number of planes/polygons, perhaps hidden within the environment areas that transition between outside/inside (e.g a roof) to avoid seeing the texture edges, should work.

Of course thats not to say you shouldn't also investigate using particles, especially for close up or atmosphereic details such as bouncing off geometry.

Oh you might want to look at some of the BioShock videos on game sites. Although its set in a completly submerged city, their water effects are looking quite nice, might give some more inspiration.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I believe nVidia already has a demo of this out running in real time. Check their developer site. It is quite possible but few people want that level of realism for something that doesn't effect gameplay (currently) at all.


And Doom3 introduced different gameplay than what had been done in the prevoius 5 years, how exactly?

Share this post


Link to post
Share on other sites
Nik02, that water accumulation idea would be great! I wonder how much effort would be needed to get that implemented.

The nvidia demo seems to do it properly, looks like they are rendering ~5million particles.

Share this post


Link to post
Share on other sites
Quote:
Original post by draculr
Nik02, that water accumulation idea would be great! I wonder how much effort would be needed to get that implemented.

The nvidia demo seems to do it properly, looks like they are rendering ~5million particles.


I might implement a proof of concept demo for the "applied physics" I've talked about, once I get some free time from work in the near future. I don't think hydrodynamic simulations are all that difficult, even though you need fast hardware for the actual calculations with stuff like this.

The water accumulation idea is just a small example of what can be done. Really, there's no practical limits to the complexity of physical simulations - other than real-time performance.

As for the NVidia demo, they've concentrated on the graphical appearance instead of game-style interactivity. That said, the waterfall demo uses some very cool techniques anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
That said, the waterfall demo uses some very cool techniques anyway.

Actually I don't think their "rain" demo shares any techniques with their "Cascades" demo, although both are fairly cool :) That said, I'd recommend checking out the SIGGRAPH paper upon which the rain demo is based (and written by the same guy I believe).

Share this post


Link to post
Share on other sites

This topic is 3936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this