Game Development Community

Torque 3D Development - Wetness & Precipitation

by Brett Seyler · 01/19/2009 (2:17 pm) · 46 comments

static.garagegames.com/static/pg/blogs/jason-hetu/Torque-3D_Development-Blog-Header.png
After last week's pricing / licensing stuff, I'm looking to get us back on the dev train. Probably no better way that introduce you all to Gerhard Botha.

Gerhard's blog drew a lot of attention from TGEA users last Fall. With just 8 posts in about 3 weeks, Gerhard woke a lot of people up to what was possible with TGEA and modern rendering techniques.

My first thought on reading Gerhard's blog was "brilliant!" Using shader model 3.0 and adding multiple render passes, he demonstrates what's possible at the high end of Torque performance with good hardware. This is something GG has never really done before for Torque demos because we've been so concerned about supporting lower-end hardware and backward compatibility. Given a chance to take those 'cuffs off and stretch Torque's legs, I couldn't resist asking Gerhard to contribute to Torque 3D.


68.233.5.139/~transfer/brett/gerhard-map-rounded-bordere.png

I got in touch with Gerhard after his first TGEAE post and asked if he'd be interested in working with us directly on Torque 3D. At the time, we had our own plans for improving Torque's rendering capability and performance, so I was anxious to get his feedback and to see if he thought his ideas were compatible with out own.

Today both Gerhard and Ruan West (his partner-in-crime artist who I'll profile later) are working pedal-to-the-metal on Torque 3D. Their work will culminate in a number of high-end demos (and perhaps one that encompasses them all) that we'll be showing at GDC.


68.233.5.139/~transfer/brett/gerhard2-rounded-bordered.png

Gerhard's Bio

"I am the head of software development in South Africa for an England based company developing software and hardware solutions for fatigue testing and structural analysis for the automotive and aerospace industries. My weekend hobby is the development of plugins for 3D Studio Max as well as the development of advanced gaming features and shaders for Torque. I am currently working on some AI and advanced shaders for Torque 3D which includes:

www.rustycode.com/matt/bp.jpg Screen Space shaders (Ambient Occlusion (SSAO), Bloom, Depth of field, Geometry smoothing. Motion blur)
www.rustycode.com/matt/bp.jpg GPU cloth dynamics.
www.rustycode.com/matt/bp.jpg GPU simulated water effects.
www.rustycode.com/matt/bp.jpg GPU soft particles.
www.rustycode.com/matt/bp.jpg GPU soft/rigid body dynamics.
www.rustycode.com/matt/bp.jpg Dynamically destructible objects.
www.rustycode.com/matt/bp.jpg Computational intelligence algorithms for AI usage.
www.rustycode.com/matt/bp.jpg Multi-pass deferred CustomMaterial shaders."



It's one thing to talk about all this stuff of course. It's quite another to see it. Below is just the barest glimpse at what's to come.




More development blogs to come. This is post #7.

Torque 3D development blogs:




About the author

Since 2007, I've done my best to steer Torque's development and brand toward the best opportunities in games middleware.

#21
01/19/2009 (7:49 pm)
This is the news i been waiting to hear about T3D, I'm ready to buy NOW LOL
Great work can't wait to see the other post
#22
01/19/2009 (7:55 pm)
Quality effects like this will be worth paying more for T3D.

#23
01/19/2009 (8:02 pm)
Looks great. Is that tied into a weather system at all?
#24
01/19/2009 (8:03 pm)
All that water was from me drooling. Good job.
#25
01/19/2009 (8:26 pm)
Native SSAO? Yeaaa!!! T3D :')
#26
01/19/2009 (11:23 pm)
Looks great. What will really suck is if features like this get ripped out of the indie version, and we have to pay thousands for the commercial version if we want to make use of these features.
#27
01/20/2009 (3:37 am)
Wow, awesome effects. Great going there. :-)
#28
01/20/2009 (7:12 am)
wow, simpley WOW. i so look forward to T3D. Very Awesome stuff.
#29
01/20/2009 (9:35 am)
It would be awesome if rain drops could hit the camera leaving fading tiny droplets on the screen.
#30
01/21/2009 (1:45 am)
Excellent :)

The shaders looks awesome indeed.

Now we just need paging terrain and virtual file system (pak) and im sold :o
#31
01/21/2009 (6:35 am)
Now this is what I'm talking about... Nice work Gerhard. One thing, I notice in the video the awesomeness of the wetness and precipitation flowing of the walls, but there were no drips of water coming off of the ledges (like a drip of water coming off of your finger tip or the focet) I don't know if it already implemented or if it is something completely different with the working you've been working on. Again awesome!
#32
01/21/2009 (6:41 am)
I agree with Husam Saoudi it would be nice if you had FX water Splash effect and a FX blood splash effect for when you get shot.

PS: Can you post this video on your website so we can download it.

thanks

#33
01/21/2009 (6:58 pm)
Looks great, relatively simple effect going for the wet shader (simply a normal map that moves across the texture below it) but it looks good. It's also nice to see some of the things to expect. Keep up the good work, look forward to more info on the price. 1,000 doesn't sound bad, but that's because I'd be willing to pay it (pending I had it) because I plan on making more games, but for those that want it for casual purposes...can't say much for them.
#34
01/21/2009 (11:04 pm)
I dont think it's that simple glen, i think the shader is using refraction to morph whatever is behind it. it's probably a custom shader on the backbuffer.
#35
01/23/2009 (1:26 am)
hmm ya there's no way its a normal map as you would have to apply it to every object in the first place. how would he get ripples with a normal map anyway. :P

i think what sean said is right but i don't know much about this stuff other then its cool. :P there would be no way i could do some of the stuff Gerhard is doing he way to far ahead of everyone.
#36
01/23/2009 (9:50 pm)
"I dont think it's that simple glen, i think the shader is using refraction to morph whatever is behind it. it's probably a custom shader on the backbuffer."

could be, but even then it would be rather simple, refraction and moving one texture over another isn't very complex. :) Granted, I couldn't code it, but it's still a simple shader :D

(pay no attention to the Glen behind the curtain) ^_^
#37
01/25/2009 (3:55 pm)
@Ben, Brandon, Glen:
This is simply an ambitious demonstration of how to use multiple passes with CustomMaterials. The intention for the wetness shading is more for water streaks running down walls from something like a leaking water pipe etc. You can see this kind of effect in games like Alone In The Dark...
The shader simply grabs what is on the backbuffer and refracts it through a normalsmap of which the UV coordinates is offset based on the time elapsed. With regard to how it handles complex scenes, the refraction pass itself is rather fast but the frame rate is obviously influenced by the amount of geometry that needs to be rendered. The video capture was done with screenspace ambient occlusion, Depth of field and Bloom active at a resolution of 1280x720 on a 9800. So I'd say it can handle complex scenes rather well.
The idea and method is simple and it is rather easy to use, the dirty work went into the multi-pass CustomMaterial pipeline. Consider that you are rendering transparent/refractive objects over a processed background which includes depth of field and SSAO data. If your background is DOF blurred and has atmospheric modulation then you cannot have crisp shiny water flowing over it, refracting a pre-processed (no DOF and SSAO) background etc, the water would be like a screenspace shader eraser, the same goes for particles, the list of complexities to deal with goes on!

@Matt:
Sometimes I wish I was abducted by aliens as this would be a good excuse to get away from work. Then again, I don't think the boss would believe me! ;)

@Jaimi, J.C.:
Any pass in the CustomMaterial pass chain can dynamically be switched on or off. A CustomMaterial can define a boolean state which has to evaluate to true or false for it to execute. Like,

new CustomMaterial(FlowingWaterDL)
{
condition = "$Weather::isRaining=true";
...
...
...
};

So if the specified console variable - in this example the global script variable ""$Weather::isRaining" - verifies to false the pass will not render and be skipped and rendering will continue on to the next pass, if any (or not if you specified the pass chain to halt on a false evaluation). This would allow you to tie the wetness pass into a script defined weather system...

@Andy, Chris:
I can give you some insight into the AI stuff but as Brett has mentioned this is some of the lower priority stuff on my schedule for now. The basic idea is to use computational intelligence techniques for the AI. I'm not going to go into reasoning/justification here apart from the fact that I'm rather familiar with the field. As an example I have completed and implemented the swarm intelligence tier of the AI. What this does is allow an AI bot or 'Agent' to behave in a more natural human/animal like fashion which is rather impossible to achieve for instance in state based AI coding (It would just simply explode out of control). Members of the swarm can propagate information through the swarm. An agent can then decide to exploit the information available in the swarm or keep on exploring (finding new info by itself) its surroundings. It may for instance choose to use/exploit the knowledge of the swarm when it is in trouble. It also allows for group/flocking behavior when many agents are grouped together. The whole scheme is fitness based where you have a fitness evaluation function (which by the way can be dynamic) which determines an agent's fitness. This evaluation for instance can be based on an agent's probability to survive. As the agent roams the world it constantly evaluates its fitness. If for instance it has the player in line of sight with no cover between itself and the player its fitness would evaluate to a weak value. The agent is not initially aware of cover points, it has to discover them first. As the agent moves closer to a cover point its fitness evaluation would become stronger and become strongest if it actually puts the cover point between itself and the player. The shared knowledge of the swarm however may provide it with information of a better location and it may decide to make a dash for it, but this is where genetic and neural-net decision making algorithms come into play on the tiers above the swarm tier. Each agent has a small set of invisible 'particles' roaming it's immediate surroundings evaluating the fitness based on the 2D/3D spatial domain and the agent will always move toward the global best evaluation inside this particle swarm, but enough said for now. This should give you some idea but a lot of details are left out. If you need more info feel free to read up on particle swarm optimizations (PSO's) and genetic algorithms (used for evolving an agent's behavior) as well as neural networks (used for generalized decision making). BTW, the AI is currently optimized for multi-core performance as well. I may post a video based on the current implementation.
#38
02/03/2009 (10:54 pm)
Great stuff Gerhard, and thanks for the explanation.
#39
04/15/2009 (10:18 am)
the ripples should definitely not be clipped - this way you have the illusion of water falling off the edge
#40
04/15/2009 (10:19 am)
how would you network a swarm ? (doesn't need to be high fidelity)