This stuff (advanced lighting) has been lying around for a few months now collecting dust, been to busy with other stuff so I decided I’ll spend a few days rounding off the new lighting system I developed as well as finishing the port for TGEA otherwise I’ll never do it – This technique should not be confused with the new advanced lighting that comes with T3D as they are radically different from one another.
The first part of the video (inside the cave) is done with the up to date lighting system, the rest of the video is old recompressed prototype footage so the quality will be low. I don’t have time to make proper video captures…
Here’s a few screenshots from a scene I used to so some testing with.
This lighting system is intended for shader model 3.0 (SM3) and upward GPUs. Theoretically I could make it work for SM2 but the performance would be decrepit. This is what I like to call ‘Real Lighting’ because everything happens in real-time so to speak, no pre-calculated light and shadow textures. Every texel gets lit on demand. ALL lighting and transform computations takes place on the GPU, even all the light data for each light resides on the GPU. Shaders can easily compute the light/shadow factors by using a abstraction shader library I developed to extract the relevant data from textures. Lighting is full HDR and shadow fidelity is not affected by the complexity of geometry. This has advantages like proper specular relfections, high quality normal (bump) mapping. Everything in the scene gets lit uniformly by the light sources. In other word being it a ShapeBase, TSStatic or Interioninstance object they all get lit by the same lighting dynamics and they all cast shadows. There are no proprietary shadow algorithm for any of the above mentioned object types. Shadow computation is independent from object type and are done in the shaders. So there are no ugly, inaccurate out of date projected shadows casting through walls etc. All objects are also shadow receivers. All shadow data are embedded/abstracted in the lighting solution one gets by using the shader lighting library.
“So are the shadows screenspace shadows?” I’ve been asked this questions many times by people who has seen the lighting system in action. No it isn’t. I can see how this can easily be confused for screenspace shadows. Keep in mind that with this technique all the lighting and shadow data is available to the shaders, so shadow factors are already factored into any pixel shader’s (which does lighting calculations) fragment output. Screenspace shadows (or shadow masks as some people like to call them) is a post effect and usually takes a Gaussian blurred greyscale shadow buffer and modulates it with the final scene to overlay the shadows. This usually requires additional shadow render passes which is just nasty. The biggest drawback in each implementation of screenspace shadows I came across is that the shadow masks simply ignore light color values. Imagine a green light shining on a spot from the left and a red light shining on the same spot from the right. If an object now stands on the right edge of the spot blocking of some of the red light we should see a green shadow silhouette on the spot because although some of the red light don’t reach the spot the green light still does. Shadows masks seems to modulate over all colors regardless.
Last but not least one needs a proper light manager to determine exactly which lights to render and which not. I won’t go into details here. All I can say is that the manager is very effective in collecting only visible lights, no occluded lights get rendered and there are no lights ‘popping’ in the scene. The implementation is rather effective and optimized, the demo video never dropped below 60 fps with DOF, SSAO, bloom and volumetric lighting enabled.
If there are people interested in the details of the technique described on this page then they should post questions and I’ll answer them. I’ll update this blog at a later stage and clarify the details a bit.
