Chapter 5:Global Illumination
So, as requested, I will talk a little bit about one of the most appraised features of the CryEngine 3 - Dynamic Global Illumination. Personally, I believe there is not a whole lot to talk about, because basically most of you guys know the Editor and probably tried out all the GI functionality, so I cannot really tell you any news in that regard, and for the ones who are really into the technology behind it, you can read about everything you need to know in here
If you are completely new to this topic, just skip to "What is Global Illumination".
Well let's begin with the most important thing for the ones who are somewhat familiar with the feature - glossy reflections do not work.
Let's say that again, glossy reflections definetely do not work in the current version of the Crysis 2 SDK. If by some accident, I am deeply wrong about this, I would happily be lectured.
And, as it seems, the chance of getting some huge improvements on Global Illumination when the SDK ships are, by any means, very low. I might be wrong, but I'm pretty sure with this prediction.
Now that is because the head behind the technology, Anton Kaplanyan, left Crytek after they launched Crysis 2. Reading his twitter one finds out that he surely did not leave brokenhearted; Crytek seemingly had some special views on working conditions and (not granting any) royalties.
Well I prefer to actually talk about the tech than some internal conflicts at Crytek, but as it seems the approach used for approximating GI will not stay CryEngine 3 exclusive, because Kaplanyan released code samples on Nvidia (to be found here: Diffuse Global Illumination
and some engine junkies already worked it out. Check out this video
Interestingly enough, they also implemented "realtime glossy reflections"
, in the comments they explain that it's basically the approach Crytek uses. Well wanted
Enough of the negative talk, let's get to the feature.What is global illumination?
Global Illumination means that light is not restricted by the radius of a light source, but will actually reflect of surfaces to create Indirect Lighting and Color Bleeding.
The first picture is without GI, the second one with GI enabled (exxagerated effect)
You can clearly notice the light bounces off the wall to illuminate the rest of the cube in a yellow light.
In CryEngine only the sun light actually bounces off surfaces, so if we want to work with Global Illumination, we have to concentrate on outside areas with a more or less dominant sun/moon light. Global Illumination is enabled from "Very High" and up.
Basic Control is given with adjusting the "Global Illumination Multiplier" in the "Time of Day"-Tool, which I am sure most of you are familiar with. Should be easy to find.
Another thing artists can modify are the reflection/color bleeding values for their objects in the "Shader Params" of the Material.
I recommend to leave it as is in gray or at least grayscale (the brighter the more color bleeding, black values won't reflect anything) because the reflection will be calculated with the color value given by the diffuse map, so changing this settings to anything but grayscale is only useful in special situations - Exampleshot
Let's get to the Cvars, they are the most important modifier.
Best thing would be to just click on the console with your right mouse button and enter "e_gi" to search. Now one can easily modify the whole look of it.
In the following list, I will not progress in the order you see when you open your Console Variables, but rather in a way that I can progress from one to another without having to explain everything twice.IMPORTANT - HOW IT WORKS
How it works and where the magic starts. Basically an image is created from the perspective of the sun of the area where the player/camera actually is. This image has depth, color and slope information and it is used to calculate where and in which direction light is reflected.
Now obviously this is not calculated for the whole map but only for the area in front of the camera and the area's size is determined by e_GIMaxDistance Standardvalue="100"
. By setting the MaxDistance to 1000, Global Illumination will be calculated for an area 10 times as wide and long. Examples?
Look at these distances: 50
The offset of the GI in front of the camera can be adjusted by e_GIOffset Standardvalue=".2"
, which translates to 20%. One can tweak image results with that, but I didn't find anything better than 0.2.
Increasing the area with e_GIMaxDistance however, will not translate into worse performance, because the resolution of the image will stay the same. So, even though we have a much greater area affected by indirect lighting, locally details will get lost in a dramatic way.
To encounter this problem one could, in theory (
) set e_GISRMSize Standardvalue="384"
to a higher value, BUT it won't get you much beyond 512. Sizes like 32, 128, 256 are the ones where you see a difference.
in this calculated area, all the small irradiance volumes (cheap lightsources), which are used to create the effect of colorbleeding and indirect light are stored in a "Light Propagation Volume".
This "LPV" can be cascaded just like Shadowmaps are cascaded - different cascades store different sizes of lights which are reflected. e_GINumCascades Standardvalue="1"
- By Default however, there is only one cascade with 1 size of irradiance volumes. Got complicated?
If you turn up the Number of Cascades (up to a maximum of 6) you will get 6 different sizes of reflected light areas. In Effect this means more detail.
We can further adjust these cascades withe_GICascadesRatio Standardvalue="2"
- the given value will determine how much bigger the different reflected light areas in each seperate cascade are. So if you have 4 cascades and CascadesRatio set to 1, each Cascade will have 1 time the rate of the one before so in total... every cascade is the same. You will notice a massive overcast of light.
Got all of that? Now we'll get to the ones, which are easy to understand, yet still effective.e_GIIterations Standardvalue="10"
- with this value you can control how far the light reflection "reaches out". So if you have light bouncing off a wall and you have a very high value, the light will reach the wall to the opposite, 30 m away. The shorter the iterations the colors will "bleed". This value has no impact on performance. e_GIPropagationAmp Standardvalue="3.3"
- this value will determine how much the intensity of the reflected light decreases over distance. The lower the value, the earlier does it fade out.e_GISecondaryOcclusion Standardvalue="0"
- Important if one wants to have good and accurate results. Set to "1" to enable occlusion of the reflected light. If disabled, the indirect light will pass through everything (as far as set before with e_GIIterations). If enabled, objects will stop the light from passing.
If you want to open those in different tabs, Off
Got all of that? The next ones are almost self-explanatory.e_GI Standardvalue="1"
- Set to "1" to enable this effect.e_GIAmount Standardvalue=".6"
- Defines the multiplier of the Global Illumination Indirect Light. No real need to give examples I guess. It's best to modify the Global Illumination Multiplier in the Time-of-Day-Tool, instead of tweaking this value if one wants to change the lighting for an actual level (for good).e_GIBlendRatio Standardvalue=".25"
- In theory this defines the overlapping between different cascades, but in practice I don't see any change. If there really is any, I'd be happy to hear about it.e_GICache Standardvalue="7"
- The given value will determine how often the reflective shadow maps are updated, which basically determine the look of the illumination.
"7" means every 7 frames.
Ever noticed how parts of the lighting were still building up when you quickly turned around ingame? Yeah - here is the reason!
If you want "Realtime all the time" set it to "1" and watch your framerates and your CPU melt. Well unless you have an i7 or anything like that.
But if you love to move solids in the editor and always watch how slow the GI reacts to it, actually the lowest value
I would recommend is "3", that feels very smooth even if playing with about 30 FPS. Of course, if you have a very high framerate, you won't feel the difference between 3 and 4 frames anyway...e_GIGlossyReflections Standardvalue="0"
- Setting this to 1 will overwrite the other settings and excecute a e_Gi config that results in short bleeding and indirect light. Ignore this cVar because it won't bring you glossyreflections.
EDIT: Since 3.4.0 it does:
And from what i see it works nice:
Wow that was a lot of writing. I hope I helped some of you guys!
So after all this tweaking and everything... is it any good?
At first I was rather disappointed, but after working with it for quite some time I think it definetely is an effect that can in many situation, clearly improve visuals.
In others, it sometimes makes the image feel unnatural.
Let's begin with the good examples. I took some shots in Crysis 2.
First two are with GI, the third one has GI disabled.
Problems with the GI however evolve around 1 central problem:The dependence on a grid.
While it wouldn't run if it wasn't for the insane performance one gets with this nested grids (cascades) filled with hundreds of cheap lights /irradiance volumes, the issues with it are quite evident. If a wall does not fit the grid, the lights will simply bleed through.
An example would be these stairs.
GI ON / OFF. (secondary occlusion does not help)
another problem -
the indirect lighting is constained to 6 axis and therefore some angles are just not perfect.So overall...?Dynamic Global Illumination in CryEngine 3Pros in comparison [color=#FF8080]to Unreal Engine 3 Approach
- No precomputing (very huge)
- No tweaking of hundreds of parameters necessary, results are visible instantly
- Every (dynamic) object can potentially reflect light
- memory friendly
- no visual flaws with overlapping realtime and precomputed direct/indirect shadowsPros in comparison [color=#FF8080]to Frostbite Engine 2.0 Approach
- No precomputing (Frostbite Engine needs to precompute and analyze all static geometry)
- faster iteration possible
- light bounces off all potential objects (in Frostbite only static geometry reflects light)
- memory friendlyCons in comparison [color=#FF8080]to Unreal Engine 3 Approach
- only sun computed, in contrast to all static light
- visual quality dramatically lower, depending on the time spent precomputing
- needs more processing power
- did not work on consoles for Crysis 2Cons in comparison [color=#FF8080]to Frostbite Engine 2.0 Approach
- only sun computed, in contrast to all
- visual quality dramatically lower
- updating is not in realtime, unless one really wants to sacrifice a lot of performance
- did not scale on consoles for Crysis 2
It's hard to come to a conclusion, because Crytek really sacrificed a lot just to have "Realtime All The Time". That brings some real improvements as well as some huge drawbacks.
First of all the engine's ability to look great in-doors as well as outdoors, which was really advertised with the introduction of deferred rendering, suffers a little in comparison to others on the market. Lighting-quality-wise they are behind both outdoor and indoor.
Still, one cannot deny that for the performance and the obvious pluses like a completely dynamic solution, the results look pretty good.
And, when combined with EnvironmentalProbes and SSR, results can look very convincing
(male bust is without EnvProbes, the coloring is partly from SSR and partly from GI)Liked the read? Want more? Give me some feedback! Don't hate!
Want something to be featured? Say it!
I am happy with every little "thanks" I get because it shows somebody appreciates that i put quite some hours into the articles and the research behind them