Leveling up Lighting - Shadow Volumes

 
Blog_1.gif

Hey, hope you’re all having a good week.

Last Friday we shared a new element that we’ve added to Röki’s lighting aresnal…Shadow Volumes.

As you may or may not be aware, Röki isn’t rendered in the traditional 3D way. Our game environment receives no lighting (but does receive shadows), but appears with the exact colors we specify when we create it (in the swatch texture). The characters are similarly unlit, but in their case are tinted by ‘Unlit lights‘ that we place in the scene to bed them into the background.

We’ve written about the underlying system before, if you want more detail you can read about it here.

There was a lot of interest in the shadow volumes after we shared them so we said we’d rustle up a quick blog-post about why we added them and how we created them.

WHY SHADOW VOLUMES?

Our existing lighting system is working well, it allows us to bed the characters into the scenes and we can have smooth interpolation of lighting on our characters as they move around the scene. It’s great for soft broad changes as you move around (see a before and after of how it beds characters into out scenes below).

Lighting_Wipe.gif

So why add a new elements. Well Tom created a scene with some hard defined shadow areas. We tried to light the characters to reflect this with our standard ‘unlit lights‘ and it was kinda tricky. As I said, they’re good for broad soft lighting changes but any sudden change of lighting was not easy to achieve.

We didn’t want to rule out having these stark and dramatic shadow areas in our scenes so went about thinking about how we might achieve the desired effect by building upon our lighting system.

HOW DO THEY WORK?

In fact the result was actually pretty simple. It builds on a couple of existing things we already have in the game: trigger volumes and pick-up fades.

We use trigger volumes for all kinds of things in Röki. They are essentially an intelligent box. The box can tell if a certain objects enters its volume, if something does, it can then trigger an action. We use these for gameplay, but we realized we could also use them for some kind of shadow volume.

Shadow_Blog_Image.jpg

The other elements we had already was simple time-based shader transitions. We’d done these for fading out objects when you pick the up (rather than them vanishing with an unsightly ‘pop').

Blog_4.gif

We realized that in combining these two elements we could use the trigger volume to talk to the character’s shader, telling the character to ‘go dark‘ when they enter, and ‘go back to normal‘ when they exit. We would use the simple fade to soften the transition into shadow when entering the volume, and to gently come out of shadow when they exit the volume, to avoid an instant ‘pop’.

The only thing left to do was to add an extra ‘shadow volume‘ colour parameter to our character shader. This would be used to tint the character’s shader darker when they enter the shadow area. This change in the character’s shader would be driven by the volume interactions and the fade.

Blog_3.gif

And that’s all the ingredients we used. It does build on the underlying system, but is in itself pretty simple. So to recap:-

  • Character enters a trigger volume, game recognizes this and sends and tell the character to ‘Enter Shadow‘

  • This then tells the character’s shader material to begin fading up the shadow colour (over a short specified time, currently 0.25 seconds but tweakable).

  • The shadow colour (specified in the volume itself) is multiplied over the top of the underlying character colour. As the shadow colour is faded in, the shadow appears stronger on the character.

  • When the character leave the shadow volume the same thing happens in reverse.

As stated above we set it up so each volume had it’s own shadow colour. This allows for different shadow colour for different scenes, or even within the same scene (some might want blue tinted shadows and others green for example).

Blog_2.gif

FURTHER TWEAKS

We’re gonna work with the system and see how it feels but have had a few suggestions already on how to improve it further that we’ll take a look at.

For now we achieved what we wanted, the ability to have Tove and her pals walk into dark shadow with a nice transition (and no ‘pop‘).

This is quite a good example of how you can achieve something quite quickly with elements from elsewhere in your game. Pretty neat, Until next time gang.

Cheers,

Alex

























 
Alex Kanaris-Sotiriou