Legendary Renderer Update 3

A rather lengthy post discussing features I have worked on recently for my Unity custom Render Pipeline, Legendary Renderer.

Legendary Renderer Update 3
Transmissive shadows

This month I've focused on transmissive shadows (coloured shadows from stained glass for example) and cached static geometry shadows from point and spot lights. Let's dive into some implementation details for the transmissive shadows first!

Transmissive Shadows

Colourful lighting for all!

For trasmissive shadows I render 3 passes of transparency geometry to a single atlas texture making up the 4 cascades of the directional light (as I'm using cascaded shadowmapping for those)

The transmissive shadows

For trasmissive shadows to work, I need 3 passes, first of all an alpha pass, this is used as a mask.

First I clear the atlas texture before rendering to [0,0,0,0] which is Unity's Color.clear.

Then I render the first pass which outputs [0,0,0,1] RGBA which creates a mask where transparency is drawing into the render target, this mask is used to hide the transmissive shadows (via lerp) from affecting the light's colour when there's no transparent shadows present in a given pixel. I can't show this as there's no visualisation in the unity frame debugger.

The opaque pass is next, which just renders white[1,1,1,0] with no alpha, to the atlas where the transmissive shadow pixels are.

Opaque pass

Finally, the transmissive shadows, these render multiplicatively in order to be able to have them perfectly combine when multiple layers overlap, however there are some caveats in my implementation which means only a single layer can render without any artifacts or parts of shadows from objects showing in the wrong places. However I don't expect anyone would need multiple layers so this is good enough for now.

The cascades rendered with the transmissive colour

During this pass I also render the depth information of the transparency geometry, so that I can use that to mask away the transmissive shadows from behind the caster, as otherwise volumetrics end up broken due to the shadows casting from translucency towards the sun, in front of where they should be.

Cached Shadows

Shadows that run faster, are always better...

This section of the post will be pretty brief, as the implementation of this technique is very simple.

First, I determine whether to update the cached shadows, this happens if the number of visible lights in a given frame changes at all from the previous frame, if so I update all light cached shadowmaps.

I also can update cached shadows on a per-light basis, if the light moves at all in the previous frame. This only updates the light that moved!

Next, I copy the static shadow atlas to the main shadow atlas, then render the dynamic geometry shadows on top, which means the only texture I need to sample, filter and project is the dynamic shadowmap.

The performance gained by this technique is hard to measure accurately, however raw numbers were +3ms of frame time decrease when cached shadowmapping was enabled, which is great!

Final notes

What's coming next, and some information about my plans for legend286.co.uk

So, moving forward from this, I have learned a bit while implementing these features. Overall I'd say the pace of my development is not quite as speedy as I'd like but it should be where I want it to be soon enough.

I am returning to University in September, which is only next month, and I'm resitting my 2nd year of Computer Science, still on the Game Programming branch as that's the most interesting course for me. I just hope I can manage the workload while also raising my son who'll have his 1st birthday in September as well!

I've had my website up for some time, not in its current form for that long however, and I would like to talk about some future plans for the site, including a way in which people who like my work can support me financially.

I am going to start making video tutorials showing how to implement similar things yourself within Unity, however I will also be doing tutorials on general graphics stuff, and some other stuff that I'm not ready to reveal yet. I plan to post on here every time there's a new video out, and I will endeavour to make these videos easy to follow and focusing on fun topics within Graphics Programming and Tool Development areas.

Some planned stuff includes me creating a tutorial for how to make your own shadow mapping inside Unity, which will cover rendering to shadow maps, projection and filtering and other stuff which is quite technical. I would also like to make tutorials showing how I did some of the features in Legendary Renderer, such as the volumetric effects.

Finally, my plan for allowing people to support me if they like what I do, as you may notice the website now supports email subscription, and will send out newsletters whenever I post, which should help me expand the site into more than just my place to write about my work.

The whole plan is to allow people to pay what they think it's worth for the information I am providing, and mainly it will be the  tutorial videos that are "behind a paywall" but the minimum I am going to charge is £1, which will give access to the majority of the content I post here.

Hope you enjoyed the rather lengthy read, I will be posting more frequently but if I don't post for a while I've probably been busy working on features that are more complex.