Legendary Renderer Update
First of all, thank you for coming to read my blog post, I appreciate it! I have been working on some nice features this week, 3 really good quality features indeed. The features are presented below for your enjoyment.
This Week's Features
Features I have completed this week!
Depth Pre-Pass
Depth Pre-Pass is a technique where instead of drawing the scene with all lighting etc to the depth and screen buffers, you draw the depth in its own pass and compare it with depth testing in the main pass with ZTest EQUAL and Depth Write OFF.
By doing this, you can optimise cases where heavy shaders are drawn first even if they aren't visible, because you have depth already available to do hardware depth testing and discard fragments with a further depth before their expensive effects are calculated.
I'm now excited to work on Parallax Occlusion Mapping to show how much of a performance boost Depth Pre-Pass can have.
Per-Pixel Motion Blur
This technique is very fun, because it involves a bunch of transformations and calculation of the velocity of each pixel based on the camera's view and projection matrices for the current and previous frame, this means zooming the camera will correctly have motion blur, as will moving or rotating it.
I render this in the depth prepass stage via MRTs (multiple render targets), but this is unneccessary because I can calculate velocity for the camera in a post process shader by reconstructing world position from depth using the current and previous frame view projection matrices.
Eventually I want to take object velocity into account, which includes skinned meshes, but for now I won't mess about getting that to work.
Glass Rendering
I have begun working on glass rendering, this isn't physically based (yet) but it looks really nice so far. I would like to modernise my renderer first before I attempt to allow refraction that can refract other glass, and eventually I'd like to also have a blur for rough glass to have less sharp refractions.
I'm not sure if it's worth explaining that currently there is only one layer of glass, so if there's glass on top of glass, only the closest glass renders refraction, and other glass does not show up behind the refracted surface. I will fix this with order independent translucency eventually.
Future plans
The next steps I want to take
Screen-Space Ambient Occlusion
There's a good article on that here on normal oriented hemisphere AO, it's one of the nicer techniques around for ambient occlusion that isn't locked away in some Nvidia middleware dll.
A bonus, as I have now got depth and normal buffers before the scene is rendered with lighting I can correctly integrate the AO into the light calculation, making sure it's only visible in shadowed areas, pretty fancy if I do say so myself.
Subsurface Scattering
I need to research implementations of SSS, because I've not got a clue how the light transport approximations work. I had the idea to render a flattened version of a subsurface material mesh with all lights applied to it to a render target and blur it, then draw the material with the texture used as a kind of lightmap, but I'm not sure yet how to do that, I'll need to migrate my render pipeline over to using renderer lists I'm guessing before I can individually render meshes with stages in between to correctly have a lightmap per-mesh.
Forward+
A major issue at the moment is the fact that I have no optimisations for lights, I render all lights for all objects, something which I'd rather not do, thankfully the Catlike Coding website where I sourced some of the foundations for Legendary Renderer will soon have a tutorial up on Forward+ lighting, something I'm eagerly awaiting, this will be a huge improvement to my renderer and should provide the performance ceiling that can allow me to make more features without negatively impacting performance.
Final Thoughts
This blog post took some time to write in a way that makes sense, and I'd like to thank you if you read up until this point, feel free to email me here: sam[at]legend286.co.uk
Thanks so much for checking out my blog, and make sure you take a look at my portfolio here.