Light Prototype: Faking Dynamic Global Illumination in Unity - Part 1
published Friday, 1 April 2011, 12:00 by ZPSHicks
Join me in my first attempt to push lighting in Unity to meet our high ambitions for making Interstellar Marines as realistic and dynamic as possible.
Unity 3 have given us Deferred lighting so in this light prototype we'll see if I can create a lighting scheme close to Running Man while being completely dynamic appose to completely static.
When we created Running Man in Unity 2.6 we relied on baking all lights into static lightmaps for performance; No doubt baked light looks fantastic, as it allows for calculating advanced and accurate global illumination as well as ambient occlusion, but with the obvious downsides of forcing lighting to be completely static as well as increasing the size of our builds (Mb) due to all the scene lightmaps.
Sure we would all love to have real-time Global Illumination like CryEngine 3 ... but experience tells me that we can get 80% of the way by faking it and the last 20% is a real nice to have at the moment, I guess we just have to wait till Unity integrates real-time GI in Unity. :)
This prototype is created with what is available in Unity 3.3:
- Spot Lights
- What I'll generally use to create primary light sources as spotlights provides a lot of control and is perfect for casting shadows on key environment elements and dynamic meshes.
- Point Lights
- Used to simulate in-direct lighting from primary light sources as well as setting up very crude bounce light areas in the environment.
- Ambient Light (Render Settings)
- I'll use this option to apply a discrete color value to the scene to simulating a general base-ambiance in the environment, which then dependent on which colors that dominates the lighting scheme and how much light is available. The idea is to adjust this value on the fly to help simulate the global ambience in a given scene.
- Screen Space Ambient Occlusion (Image-Effect)
- I'll rely on applying a bit of detail to the lighting setup by using the SSAO image-effect on the camera. In Running Man SSAO was pre-calculated during bake-time which made it completely static.
- Bloom and Flares
- The goal is not to polish the hell out of this light prototype so other tricks such as using color correction image-effects, particles etc. is not part of this first journey into creating advanced dynamic lighting in Unity. But we got to have a bit of glow on the light fixtures - its so easy to setup and looks great.
Step 1: Setting up primary light
Step 2: Setting up primary ambient light
Step 3: Setting up secondary ambient lights
Step 4: Setting up Scene Ambient Light
Step 5: Setting up Screen Space Ambient Occlusion
Step 6: Setting up Bloom and Flares
Step 7: Final result
When looking at the combined effect that all the above steps achieves, then its great to think about that all this is completely dynamic and do not have to bake/render for hours each time you need to change something in the scene.
Faking Dynamic Global Illumination in Unity
- Deferred lighting is calculated based on how many pixels the light influence pr. frame, so be sure to set resolution if you native default resolution is too high!
- This Prototype is not optimized for optimal performance so if you're "playing" on a small notebook, please do not expect the best frame-rates in the world!
I hope you've enjoyed this small preview into our efforts of making everything dynamic in Interstellar Marines, including lighting. In 'Light Prototype - Faking Dynamic Global Illumination in Unity - Part 2' I'll reveal more interesting ideas on how we're faking global Illumination in Unity for Deadlock.
For the love of the game!
Not to hype or sell CryEngine 3 in any way .. but if you want to know more about the real-time global illumination in Crysis 2, take a look at this PDF - You just gotta respect the wizards at Crytek for what they have achieved with CryEngine 3.