Game Development Community

dev|Pro Game Development Curriculum

Precipitation for TSE

by Tom Spilman · 02/28/2006 (1:01 am) · 23 comments

www.sickheadgames.com/images/shbug_03.pngSo over the last few months when i wasn't working on Torsion i've been poking at the TGE Precipitation object to TSE-ize it.


Originally i started with the intention to completely replace Precipitation. I looked at the few alternative methods, but in the end each had serious limitations. Most lacked collision which would have been a huge step backwards for anything but flight sim type games. The original TGE Precipitation system was really pretty darn good and really just needed some additional features and optimizations.


www.sickheadgames.com/stuff/garagegamesimages/precip3t.png
The first thing done was to move it all over to vertex buffers. It now uses an "optimally sized" volatile VB in a fill-render-fill pattern until all the particles are drawn. This is very optimal as we're sending lots of big batches to the card and not holding on to one fat exclusive VB. This means high performance and little video card resource usage.

Next i looked at what could be done with a shader. Again i looked at all the techniques out there and ended up with a widely compatible conservative approach. I reduced the vertex format to just a position and uv set and moved vertex coloring and alpha fade to the shader.

Still the really cool shader tricks are yet to come. With DX10 level cards you'll be able to process a VB and have it output new VB with more verts. In this way you could pass just the position, velocity, and camera pos up to the video card and have it build the particle completely. Also features like texture fetching from a vertex buffer would allow Precip to pass z buffer of the scene rendered from the averaged velocity vector to detect collision. This is the future of million particle systems running purely on the GPU.

www.sickheadgames.com/stuff/garagegamesimages/precip1t.pngAfter fixing a few bugs i turned my focus to new features and improvements:
  • Both drops and splashes can be animated or not.
  • Finally you can set the drops/splashes per side in the datablock.
  • The simulation stops when the object is zoned away or not in the view frustum.
  • Optional tinting of the particle by the ambient sun light.
  • You can pass precip thru the glow buffer.
  • Have the precip reflect in water or other dynamic reflective surfaces.
  • Moved the mWindEffectsPrecipitation out of Sky.
  • Options for precip to collide with players and vehicle types.
  • Can now set a fade distance for precip particles.
  • New setTurbulence() script function which works like modifyStorm.
A big new feature is volumetric precipitation. By disabling the followCam property you are free to position and rotate the precip object anywhere you want. This means you can put glowing rain flowing upwards inside a room or have a precip object attached to a moving shape:
www.sickheadgames.com/stuff/garagegamesimages/precip2t.png www.sickheadgames.com/stuff/garagegamesimages/precip4t.png

Still i'm not done with Precipitation. As soon as the 1.4 and MBU merges are done i want to make another pass tuning performance on the system. I've also got a few more features i'd like to see:
  • Ripple particles.
  • Shadows and lights effect particle color.
  • Add randomized gusts sky wind system.
Anyway... i'm 26 hours without sleep now. How about a demo for you to play with:
Download TSE Precipitation Demo
(Select the walkthru from the menu and hit ALT+C to get the free camera to fly around)

PS. We've started a new contract TSE project yesterday. We'll be looking for 3 other individuals with specific skills to fill out some lucrative contract positions. I'll post a new plan on that later this week, but keep an eye on the help wanted forum.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.

Page «Previous 1 2
#1
02/28/2006 (1:40 am)
Nice one Tom. Is this done on a bounty btw? or just for yourself? I'd love to try it in Air Ace see how it works.

I could also then use it as a basis for a cloud renderer (an essential part of Air Ace platform really, so I better get to it sometime soon).

Phil.
#2
02/28/2006 (1:52 am)
@Phil - Thanks. Yea it's for a TSE bounty. A zip with the source code is posted up on the mantis bounty page.
#3
02/28/2006 (2:45 am)
Thanks Tom, did you do two versions btw? Just wondering why there are 2 zips in there, or did someone else implement a version already?

Phil.
#4
02/28/2006 (3:22 am)
Hell yes. This is freakin awsome. Amazing work, Tom.

-Jase
#5
02/28/2006 (3:49 am)
Oh yes, great job Tom!
#6
02/28/2006 (4:13 am)
We got our hands on this a few days ago, and let me tell you, it's rocking. Way to go Tom!
#7
02/28/2006 (4:33 am)
Great work Tom!
#8
02/28/2006 (5:42 am)
wow that looks cool... nice job Tom!
#9
02/28/2006 (9:21 am)
Thanks everyone!

@Phil - No the second zip is a newer version of it.
#10
02/28/2006 (9:34 am)
Very Nice, I was recently playing around with precipitation, and I can think of all sorts of ways to make use of this.
#11
02/28/2006 (10:04 am)
Hey Tom, I'm also waiting on DX10, first thing I thought of when I heard about DX10 was WOW I cant wait to start playing with particles. If I knew about this bounty page I woulda been working on some of this stuff.
#12
02/28/2006 (11:35 am)
Supa sweet.

As a nitpick cause it seems like you're going for perfection, I noticed that from underwater everything gets refracted except the particles....
#13
02/28/2006 (11:42 am)
Wow!! Nice work, man.

Only thing that caught my eye in your above description was a very nitpicky realism check: on a rainy day in actual reality I've never seen water smooth enough to be reflective. (Grew up in Oregon == rain expert). :-)

Great work though!! Damn!
#14
02/28/2006 (11:45 am)
@Jeff - The issue is that the scene graph inherited from TGE is rather inflexible for cases like this. It has a fixed order for rendering and that means either transparent objects are rendered before or after the reflection pass is done. Each case causes something to break, so i left it alone for now. I believe GG has an overhaul of the scene graph planned and i hope that addresses the need for flexible render ordering.
#15
02/28/2006 (3:26 pm)
Wow this is cool. Great work!

Edit: This code can handle *tons* of rain. Really kick ass way of rendering everything. Now all we need is to get the particle engine doing something similar, as ATM it can't run alot of particles.
#16
02/28/2006 (4:36 pm)
DX 10 isn't going to do much good unless your running Windows Vista AND have a DX 10 compatible card, fyi.
#17
03/01/2006 (12:39 am)
Exactly Robert. I forgot to mention it, but it will be at least 2 years before you can count on DX10 features being present in the majority of systems. A lot rides on how many people decide it's worth upgrading to Vista.

Still a Vista optimized rendering path could be made for the various TSE particle systems.
#18
03/01/2006 (4:15 am)
This reminds me of one of the few little miracles I have seen in real life.
I was standing ontop of a hill looking down into a valley during sunset.
Slowly it began to sprinkle and the rain started to catch the sunlight.
It looked as if the valley was filled with gold flecks, it's something I'll never forget.
Killer work!

Ari
#19
03/09/2006 (7:52 am)
This is really awesome! Nice work, we can definantly need this for our game project. thank you so much :)
#20
11/13/2008 (11:34 am)
is there any pogress on this? or is it close now?

or would there be a way for me to implement your glow participation?

above people speak about 2 zip files, but they are no longer avaialbe

so i was just wondering what ever happened to this awesome idea
Page «Previous 1 2