Hey guys, It's Will from Skunkape. I wanted to share with you a little about foliage rendering. DENIZEN is a game about a forest, so it is very important I have high quality foliage! DENIZEN is also a game that I want lots of people to play, so I am trying to make rendering performance as fast as possible to provide a smooth experience on older and less expensive hardware.
I think fast frame time is extremely important. It directly influences how much fun a game is because if it is too slow the game will feel unresponsive. Even an amazing game will be unpleasant to play at less than 60 frames per second (16 milliseconds) therefore I consider performance to be the most important consideration to make in designing a game.
Some well known bottlenecks to frame performance are mesh complexity, texture resolution and screen resolution. But modern GPUs are very good at processing meshes. The thing that really destroys performance is actually draw calls.
Put simply a draw call is when the GPU has to change state. It has to do this for lots of different reasons. Two very common ones are when two meshes use different shaders, but also when two meshes are affected by different lights. The best way to increase performance is to limit the number of times the GPU must change state by combining as much geometry as possible into a single mesh. This gif visualizes the rendering process of a frame:
All those steps happen 60 times per second every second! Notice how each object that uses the same material is rendered at once. Without taking steps to combine these meshes beforehand each seperate mesh is drawn one at a time, exponentially increasing frame time. I could take additional steps to optimize further by combining all the textures used by materials that use the same shader. For instance the foliage if combined could be rendered in one draw call rather than five.
The other factor that really slowed down our performance was when we had a large number of animating plants. Even though we were able to render them all in a single draw call, the animation itself presented significant overhead. However we did not want to give up our animating foliage, because that would have adversely affected the atmosphere of the game. Our solution is to have a large amount of static foliage with strategically placed animated foliage. This saves us a great deal of performance while preserving that subtle lifelike motion.
As you can see the dense groundcover does not move at all. It is completely static, recieves most of it's lighting from lightmaps and costs us basically nothing. The larger plants you can see moving incur overhead from their animation and the realtime lighting they require. However as long as the number of animating plants is reasonable, this performance overhead is an acceptable price to pay for the increased immersion.
Thanks for reading about our foliage, and stay tuned for more in the future!
To recieve major updates on DENIZEN, and be notified when a playable build is available,