I have recently been really interested in the game Recore, a Unity game that is getting a fair bit of coverage on the Unity Blog about how they do stuff in the game, especially a game that launched in a quite janky fashion (they have patched it since and the 30mins to an hour I have played so far has been pretty fun). Along with some projects I am working on at the moment, this has spurred me on to have a look of graphics cheats to get the same effect, but cheaper, so the game can look stunning, but also run well.
When looking at performance, one of the areas my mates and I have noticed issues is with dynamic shadows in Unity. We have found these can be quite expensive and actually a lot of areas to do with real time lighting can be expensive. With environments you can bake these down into lightmaps which helps, but with characters moving around, this is not quite as easy. As an alternative to unity’s “out of the box” solution, we can use a fancy feature called Projectors.
Before we start, lets do a quick test. I have taken the my JRPG test scene and removed all but one soldier and one hero.
Currently I have one directional light and that is applying Soft Shadows which is producingthe following performance stats.
Now if I switch the directional light to No Shadows.
You can see the batches, tris and verts have dropped a fair bit.
Before we go on, if you don’t know what the stuff in this window means, you can look at the Unity Docs.
Cool, so we saved some batches, some rendering passes and cut down the number of verts drawn. But we don’t have any shadows.
What about blob shadows? You know little round blobs that are put at the players feet. This was an interesting discovery. The Unity manual actually mentions a built in Standard Assets projector that projects a blob shadow, but for the life of me, I can’t find it anywhere. So I did some digging around the asset store and found this nifty little package. Which is actually a better solution (as blob shadows are a bit cheap right?).
This goes one further and creates a render texture of the target that is projected. If you want to go into more detail, the package comes with full source, but TL:DR it produces the same effect. Here is what our scene looks like with our new solution
Despite my projector placement been not quite perfect…. moving on.
Let’s have a look at the stats:
As you can see, we have less batches and less verts and tris versus Unity’s inbuilt dynamic lighting.
So, on the surface level, it seems that using the render texture projector combo saves us some performance. COOL! We still need to test this further on target devices, but hey, it is a start!
I guess my point here is that whilst Unity’s out of the box stuff is cool, it may not be the most performant, so it is worth having a look at alternative methods… especially when it comes to graphics techniques!