HOW WE OPTIMIZE FORESTS IN UNSPOKIN
For an Artist, the end of an production seems very similar each time. It is all about optimization. When we pitched our game idea it was always set in a lush environment with dense forests and a vibrant and alive landscape.
It was one of the goals we were determined to achieve as a student project. Achieving a certain atmosphere and mood is quite a type of design I was used to in game development as most of the projects I have done involved some sort of realism to it. But this time it was all about art style, composition and framing.
Most of our promotional art done by our Art Director had a thick forest surrounding the scene. Through dense woods and natural environments seem to be the bane of game art optimization due to the amount of trees, bushes, grass and ground cover needed to achieve that. The Witcher 3 did that splendidly but did run into some frame rate issues (http://www.pcgamer.com/the-witcher-3-performance-tips-and-crash-advice/) when it was released.
However CD Projekt Red did a superb job in optimizing it. I was researching in how they did it and if there were any tips I could learn. The sad truth was that is lies all within their proprietary engine and having the engineers a phone call away if something needed to tweaked.
I had to look deeply into how I could make Unity run with thick forests and vistas. However I managed to run into three problems that I was the architect of. These were:
- Thinking automatic tools will get you all the way
- Not adhering to the theme
- Not understanding population rules for games
1: The SpeedTree curse
I had convinced my group early on in production that SpeedTree was the way to go in creating these immense forests. On paper it really is The industry standard across the board from Games to Film and TV. Their Games credit list includes titles like The Witcher 3, Middle Earth: Shadow of Mordor and Destiny (http://speedtree.22slides.com/games). The problem we encountered seem to be very Unity specific. After many hours researching the Unity forums it seemed that several had the same problems with SpeedTree in Unity and batching. When we ran the Frame Debugger in the scene we saw that it draws every LOD level at the same time and every LOD level has submeshes that needs to drawn. So one tree could end up creating 8-10 draw calls. Times that with the amount of trees we had in the scene did not equal a good frame rate. And the obvious choice, in consideration of the schedule, was to recreate the trees in Maya. Luckily we could use the SpeedTree model as a base.
The trunks would now batch together which was a real reduction in draw calls. But the canopies was not batching. With help from Andrew Carvalho and Stefano from Scend we saw that it was the shader itself that was not letting the trees batch. However the SpeedTree shader in Unity is made for making leaves look good and it really does a good job at that. So we were torn between frame rate or looks.
2: Population for the theme
The theme of our game is a dying world. Trees are being cut down and nature itself is slowly regressing and perishing. I had been populating trees to make it the world idyllic and magical.
After a critique session at Ubisoft, Douglas Gregory told us that there is a disconnect with the world. There are no tree stubs or fallen trees in the world. It does not come across as a dying land.
And I wholeheartedly believe that a world and landscape that adheres to a mood and atmosphere is stronger than a magical and fairy tale setting without any grounding. This bring s me to problem number three.
3: Trees and how the grow.
Growing up in a land full of trees and mountains I feel I am very familiar with how a forest behaves. But as in many parts of game development, the real world might not work as a piece of entertainment. I wanted the audience to look at the forest and say that looks like a real one. But the sad truth was that 95% of them won’t notice. Luckily Armand from Scend stumbled upon an article over at 80.lv (https://80.lv/articles/tips-on-creating-a-perfect-forest/) regarding forest population rules in games. And two big things I could take away from that was that not every tree need a canopy and the importance of dead and fallen trees and stumps. Implementing these rules helped a lot where we could elude the idea of a thick and large forest with trunks that did not have any leaves on them. On top of that we added dead and fallen trees to give it a static life. Since we cannot take every population rules from real life and implement them we take the important ones. It is enough to reference them once or twice and it gives the sense of a forest.
An example of the effects after these problems were fixed was that we increased our frames from 22-25 frames in a dense area to 55-60 frames. Most of these fixes are not very technical and as what goes under the hood is often a different ballpark for an artist. That is not to say that an artist should have a general knowledge in how a game renders its visuals.
The landscape also adheres a lot more to the mood and atmosphere which is what we want in the end.