[Excerpted from Unity Blog: AWESOME REALTIME GI ON DESKTOPS AND CONSOLES by JESPER MORTENSEN, NOVEMBER 5, 2015 IN ASSET STORE, TECHNOLOGY]
We've teamed up with Alex Lovett again and built The Courtyard, a demo that puts the Precomputed Realtime GI features in Unity 5 to good use. He previously built the Shrine Arch-viz demo. This time, however, the goal was to build a demo aimed at game developers requiring realtime frame rates. Check out this video:
Alex built the demo in about 8 weeks using Unity 5.2 off the shelf without any additional packages from the Asset Store - everything was built from scratch.
There is no baked lighting in this scene
The demo relies on Precomputed Realtime GI and realtime lighting throughout. It has a full time-of-day cycle, emissive geometry, about 100 animated spotlights that come alive at night, as well as a number of floodlights on stands and an optional player flashlight. The time-of-day cycle uses an animated skybox that is synchronized with the sun in order to capture the subtle lighting changes. In the playable demo we are now making available to you (see below), a UI has been added that allows you to control all of these lighting features in-game.
The scene was created to be especially demanding in terms of lighting. A significant part of it is lit only by bounced light, and when the sun has set it is lit almost entirely by bounced light.
The realtime GI system works by precomputing all of the possible paths that light can take between static objects in the scene. This makes it possible to tweak the lighting in realtime, without interruption, because the system already has all the information it needs to quickly calculate the consequences of lighting changes. However, this means that static objects should not be modified, because doing so would require precomputing all the paths again. Given this, it makes sense to author levels in stages: geometry then lighting (and then repeat if necessary). Haphazardly moving static geometry around and adjusting lighting at the same time will require many lighting builds. We are working on more progressive and interactive lighting workflows for Unity 5.x. More details on this will follow in a separate blog post.
The Realtime GI system in Unity 5 is powered by Geomerics Enlighten and is designed for use in games. All the lighting computations are performed asynchronously on CPU worker threads; because games are usually GPU bound, the extra CPU work has very little impact on overall framerate. Also, only the areas where the lighting has changed are recomputed.
What about performance?
The Realtime GI did not need much tweaking to fit within the desired runtime performance/memory budget. However, the post-effects stack is quite deep and includes Filmic Vignette, Bloom, Tonemapping, Lens Distort, Screen Space Ambient Occlusion, Color Correction Curves, Noise And Grain, Color Grading Properties and Antialiasing. Despite this the level runs at 60fps on a fast desktop with a decent GPU.
There were however a few tweaks applied to realtime GI.
Fast Environment Lighting
The realtime GI system is capable of using a skybox directly to drive the environment lighting inputs. However, using this feature requires downloading the skybox textures from the GPU in order to update the CPU based realtime GI system. This is not ideal when the environment lighting changes every frame as it does in this demo when the time-of-day simulation is running. Instead, the environment lighting is derived from the current time and converted to a lighting gradient and ambient intensity that is used to drive the realtime GI system.
Fast Emissive Lighting
In a vein similar to the environment lighting the realtime GI system is capable of driving emissive objects directly from the emissive shader properties. It will by default render out an emissive map in realtime lightmap space using the emission material property or, alternatively, a customized shader meta pass can be added. This will require a texture download from the GPU before the data can be consumed by the realtime GI system. In order to avoid this, there are script bindings available to set the emissive property directly on the object as a fixed color (DynamicGI.SetEmissive) and allow the realtime GI system to apply the emission directly on the GI simulation. This bypasses the GPU completely and provides a way to light the scene nearly for free.
How does it scale with larger worlds?
Clearly this is not a massive world - so how does it scale? In order to keep the memory footprint low and the lighting responsiveness high it makes sense to dice up larger worlds so that parts of them can be streamed in and out while the player navigates the world. The Realtime GI system works with LoadLevelAdditive and UnloadLevel. Of course some care needs to be taken when unloading levels since levels that are not directly visible may still affect the bounced lighting significantly. We are looking into adding some scripting hooks for enabling bounce fade between levels before unloading, so that lighting pops can be avoided, thereby allowing for more aggressive streaming. Another thing that we are looking into is providing scripting control for prioritizing update frequency for instances within the level for more fine-grained control beyond level streaming.
Using additive loading, or the Multi-Scene Editing feature currently scheduled for release in Unity 5.3 on December 8, will allow you to easily build scalable worlds lit by beautiful Realtime GI.
How do I get this demo?
You can download a prebuilt player here for OSX and Win64 and finally for Linux. In addition you can download the Project from the Asset Store. The project works with Unity 5.2.2p2 and later. The controls are described in a text file in the player zip file.
The demo runs best on a desktop machine. The timings listed here were achieved with an Intel i7-4790 3.6GHz machine with 16GB RAM, NVIDIA GeForce GTX 780 GPU, running on Windows 10.
Alex Lovett (aka @heliosdoublesix) creative-directed, art-directed, built, lit, animated, audio-directed and delivered this demo while tirelessly stress testing GI features in Unity.
Thomas Pasieka and Plamen 'Paco' Tamnev modelled the props.
Music Marks composed the music for the video preview.
Dave Dexter composed the audio for the playable.
Silvia Rasheva supported the demo as a producer.
Morgan McGuire fixed some reflection issues.
Jesper Mortensen, Kuba Cupisz and Kasper Storm Engelstoft supported Alex during development, and used the collaboration to further improve the lighting system in Unity for all artists out there.
Special shout-out to Plamen 'Paco' Tamnev for fixing some last minute issues for us.
-text excerpted from the Unity blog by JESPER MORTENSEN, NOVEMBER 5, 2015 IN ASSET STORE, TECHNOLOGY [link]