The ReShade Ray Traced Global Illumination Shader (“RTGI”) is our most well-known effect, featured since its inception in various news articles and has since then been adopted by NVIDIA in their NVIDIA FreeStyle and Ansel driver modules as “SSRTGI” for use on select games.
RTGI adds fully dynamic, realistic and immersive ray traced lighting to video games, bridging the gap between offline generated images and real time solutions in terms of lighting quality.
Main benefits of RTGI
RTGI uses innovative methods to accelerate beyond Hi-Z or similar ray marching acceleration structures, even outperforming hardware-accelerated ray tracing on meshes reconstructed from the depth input.
Ray Tracing provides a faithful simulation of light transport and achieves highest quality lighting out of screen space data, vastly outperforming simplified approaches like SSAO, HBAO+ or SSDO.
By operating on depth data alone, RTGI is fully compatible with non-RTX video cards and has no inherent hardware requirements. Using potatoes and toasters not recommended though.
Lighting is what makes games video games look realistic or not. The best methods to compute lighting tend to require a lot of processing power, so there is always a balance between the desired level of realism and the performance budget. The spectrum reaches from the simple but extremely fast phong lighting all the way to spectral path traced offline renderers like Disney’s Hyperion which would take days to compute a single frame on consumer hardware.
Developers of video games continuously advance the pareto frontier of realistic and real time capable lighting. There are two main approaches:
- Ray Tracing simulates the behavior of light in the real world very accurately. The main challenge lies in figuring out ways to compute it quickly enough.
- Rasterization tries to find clever ways to get approximate results using a fraction of the cost (the shortcut). The challenge lies in finding the shortcuts.
As full Ray Tracing remains a challenge to perform in real time, most games are based on rasterization, with RT being supplemented as of recently. Given at most a handful of light sources, a very successful and mostly accurate solution is shadow mapping. This solves path from the primary light source(s) to the receivers – but the light does not stop there! It bounces around in the scene, being reflected many times until it is fully absorbed.
Ordinary methods like SSAO or non-RT SSGI assume simple conditions that mostly hold, but the best solution to compute that leftover part of light interaction is to ray trace it! This is where RTGI comes in.
In the comparison below, RTGI completes the lighting by emulating the light bouncing off the sun exposed wall and illuminating the rest of the image, even creating diffuse shadows:
One of the most important steps to create realistic lighting without leaving performance on the table is properly configuring the radius and quality of the effect. The main sliders which control the quality are Number of Rays and Number of Steps per Ray.
Light can hit a surface from many directions, and it is unfeasible to check them all. Ray Tracing (or more accurately: Path Tracing) computes several possible light paths to determine the amount of incoming light. Kind of like a survey to figure out the ratio of a coin toss. Each ray is one stochastic sample, hence more rays result in a lower error, which presents as a lower amount of noise. This is also called Monte Carlo Integration.
Of course, the integration noise is filtered away before blending the lighting with the scene, but a high amount of noise can overwhelm the filter or result in flickering when the amount of usable lighting information is very low.
Let’s look at at the unfiltered, raw lighting:
The number of steps along each ray determine how accurately RTGI computes object intersections. RTGI traces against screen-space data and tests true object locations at several points along the ray. If an object is significantly smaller than the spacing between each point along the ray, RTGI might not detect the hit location accurately enough or miss it entirely.
A low amount of steps results in bigger steps for a constant ray length, which in turn results in small objects losing contact shadows and more diffuse lighting. This has no influence on the amount of noise, as the amount of samples (= rays) remains constant.
The Ray Length controls how far RTGI searches for incoming light. This is closely related to the amount of steps, as longer rays mean longer steps.
As RTGI uses screen-space information, excessively long rays may travel offscreen. This results in a lower tracing quality, as the ray might be stopped after 5 steps, even though RTGI is configured to perform 40 steps.
To shape the lighting, first decide whether short radius, precise shadowing is wanted or large scale, smooth lighting which really ties the room together. Set the Amount of Steps per Ray fairly high, the Amount of Steps to a medium setting and tweak the Ray Length to your preferences.
Then, decrease the amount of steps until small details start to erode. Finally, adjust the amount of steps for the desired quality and motion stability / performance balance.
Since the depth data that ReShade provides only contains the geometry that is closest to the camera, it is unknowable to RTGI how thick objects are on the side opposite the camera (the dark side of the moon, so to speak). This is a limitation of all screen-space lighting effects and SSAO generally uses an arbitrary fade parameter or assumes infinite thickness. Without anything else to go on, the best guess for RTGI is a fixed value with a few heuristics, controlled via the Z-Thickness parameter.
Its setting has a big influence on the look of the overall lighting, as it is elementary for proper visuals that rays may pass behind objects. If an object extends far behind the visible side, it blocks the ray and passing light. Too high values usually result in misplaced shadows and a dark halo around the object, too low values result in too faint lighting but is generally desirable as it looks much less out of place.