Researching a replacement for dynamic shadows continued…

I am still playing Nier: Automata so you will get a few of these pics for a bit.

A while back, I posted an article about researching a replacement for dynamic shadows.

On projects I have worked on we often default to using dynamic shadows to make stuff look good, but they can kill our performance on mobile. In order to hit the 60 FPS mark (or sometimes even 30) theya re one of the things we turn off. We then replace them with blob shadows, which are OK, but are still not as performant as we may like I found this advanced technique called graphics command buffers and a sample that includes decals in deferred shading. Decals are quite a nice way of creating blob shadows.
I have since knocked up a super quick test bed to see the difference between real time shadows, projectors and decal textures.
Realtime shadows:
And here are there corresponding BASIC stats:
Real time shadows:
Projector Blob Shadows:
Decal blob shadows:
Again, this is only a cursory test, but so far the decal blob shadows are edging out on the number of tri, batches and overall framerate. Of course this is needed to be taken with a pinch of salt and needs to be profiled more in other scenarios, however as a starting point it looks promising.
My next step is to see if I can create real time shadows using render textures and combine it with the decal techinque.
There is a warning here though that at time of writing this technique only supports deferred rendering and not ALL mobile gpus support it. However, I will press on and get a better overview of what hardware is affected, and come up with an alternative for that.

Researching a replacement for Dynamic shadows

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!