maandag 11 oktober 2010

Still thirsty...?

Second blog post! And again I am going to talk about water!

My previous post I talked about the vehicle behavior for our new game. I got it almost up and running. Although I still need to tweak and enhance a couple of things, but I am fairly happy with it. We’ve also got some animated water in it. It flows and has a sin wave deforming the 3d model. I think it looks nice, although Director still doesn’t support any fancy features like render to texture or shaders. The 3d engine is almost 10 years old and we have to work with the features available. So we throw everything over the CPU and hope we still have some left for the rest of the game :S Nevertheless, I hope you can see all effects and play it for yourself as soon as possible.

For now I wanted to talk about some other water effect: rain! Which is cool! I like making special effects! Don’t get me started about particles and the likes as I can talk about and tweak them for days. A nice side effect is that I can avoid talking about mathematical stuff in my games. I suck at math, so I’ll leave that for Stijn ;)

If you take a look at our previous games you see that most (if not all) have a very sunny and bright setting. Most of the artists here prefer it that way. I think it has something to do with the Dutch weather… Sometimes though, we do need a visual weather effect like snow or rain. Until now we mostly got away with it, by completely ignoring it and tweak the colors, lights and fog settings of our 3d world. We never got around to actually build and implement a visual rain effect. This bothered me a bit and for this game I scheduled time to actually build and implement a system that could handle this (and snow). Normally when I build these kind of systems I make sure they are modular and can be implemented in all of our games.

After some research I decided to make a system that would display a rain effect in 2d. It is a bit of a shame, I know, but I had to do this because Director simply isn’t fast enough. Ideally I would want to use some readymade particle systems (either my own system or Directors built in ones), but they simple aren’t flexible or fast enough. Placing billboarding sprites in the 3d world with an animated textures wasn’t a real option either as I think it will cost too much time for an artist to place all sprites. Creating a system that would automatically place rain sprites in the world could be possible (there are a number of solutions for this), but I didn’t opt for this as it would simply be not fast enough as well. Director doesn’t do batch rendering (combing models with the same shader to be processed as one) and, furthermore, needs to send all mesh data of the 3d models to the GPU each frame. We’re losing quite some CPU power here, so I had to think of something else.

5 Rain layers in front of the camera.
I ended up displaying a large plane in front of the camera with a tile-able texture of rain. Each frame I would ‘scroll’ the texture. This already looks okay. However, because it is 2d and displayed on top of the 3d world I needed to think of something that would actually add more depth and looks like the rain is ‘in ‘ the world. I cloned the plane a couple of times a placed them further away from the camera. This created a denser rain and much more depth at the same time. Furthermore, I linked the rotation and banking of the vehicle to these planes. So when the vehicle moves forward the rain rotates towards the camera. Creating the effect of rain coming towards you. When turning the vehicle we turn the planes as well which makes it even more look like the rain is actually inside the 3d world. The effect looks very decent. Even though I display the rain in ways nature never could as it simply just looks better. The only thing I want to do, if time and schedule permits me, is think of a way the camera can actually move ’through’ the rain. Perhaps I can clone the exact same set of models again and move the camera through the first set, based upon speed of the vehicle and reset it when the camera has reached the boundary of the first set. I think some testing would quickly show it this could
work…


Rain effect in action!

















The last thing I normally do when I design and build system like these is add a sh*tload of parameters and settings. I think it is important to have a very flexible system so I can display all kinds of rain setups. However, I simply don’t have the time (or want to) create all kinds of setups myself. With all these settings the artists or (level)designers can create almost all types of rain or snow they want.

Until next time…

- Pieter

Geen opmerkingen:

Een reactie plaatsen