1. What is ray tracing
-
basic concept
-
Each pixel of the screen sends a ray to the scene. After colliding with the scene object, it will display different colors, and then adjust the color performance of the pixel accordingly.
-
BVH algorithm greatly enhances the efficiency of light tracing; (detection of collision triangle → detection of collision model bounding box)
-
-
The difference between ray tracing and rasterization
light chasing | rasterization |
---|---|
Start with pixels and rays; | Start with objects and triangles; |
Rendering is slow, but realistic; | Render blocks, but not realistic enough; |
Real physical lighting; | Use some tricks to simulate light behavior; |
Easy to open; | Requires some development attempts to achieve real results; |
2. Hybrid rendering
-
basic concept
- Because ray tracing is expensive, we use ray tracing where we need it.
-
application
-
Diffuse light: we will use rasterization to achieve;
-
Reflection: Reflections on blurred surfaces use rasterization, and reflections on smooth surfaces use light tracing;
-
Ambient Occlusion (AO): Choose SSAO or Light Tracing depending on the situation;
-
Shadow: The shadow selection of the core light uses light tracing;
-
Global Light (GI): The consumption is very high, when using it, consider turning off other light tracing;
-
3. The use of ray tracing
1) Scene basic settings
-
project settings
-
Turn on light tracing and texture LOD;
-
The platform is set to DirectX 12;
-
-
Restart the engine after the setting is successful
-
You will see that the graphics calculation has been switched to DirectX 12 in the upper right corner;
-
In the display, there is an extra column for ray chasing Dug;
-
2) Ambient Occlusion - AO
-
concept
- An algorithm to calculate whether ambient light is blocked by surrounding objects;
-
two options
-
Light chase AO
- When the screen ray collides with the model surface, the real occlusion relationship can be calculated;
-
Rasterized AO: SSAO
-
Based on the ready-made depth data, the operation is fast;
-
The biggest disadvantage is that it is impossible to distinguish between the foreground and the background. When the object is occluded, the background object will be removed, and this part of the AO will be ignored;
-
-
-
AO opening and setting
-
When the red frame is enabled, use ray tracing AO. When not enabled, use SSAO;
-
Pixel-by-pixel is the accuracy of AO; radius is the length of the light tracing ray; both values directly affect performance;
-
3) Reflection
-
three options
-
light reflection
-
The rougher the surface, the larger the reflective horn and the greater the consumption;
-
-
Screen Space Reflection: Post-processing of images
-
Objects outside the screen cannot be recognized, so the borders of the screen and some special places will be distorted;
-
The reflection distance will also be affected by the screen distance, which has a large limitation;
-
-
reflection probe
- Environment capture or HDR textures;
-
-
Turning on and setting reflection
-
Select type in reflection;
-
Maximum roughness: SSR is used for surfaces exceeding the value. This threshold has a great impact on performance, and the recommended value is 0.2;
-
Maximum number of bounces: Reflected reflections, the more times, the greater the performance consumption;
-
Pixel-by-pixel: control accuracy and affect performance;
-
Shadow settings and semi-transparent object settings also affect performance and can be turned on as needed;
-
4) Shadow-Shadow
-
two options
-
Light chasing shadow: it will match the radius of the light source, and a real virtual shadow will appear;
-
Rasterized shadows: using waterfall shadow maps (Shadow map)
-
-
Turn on and set
-
Turn on light tracing shadows for the main light source
-
Sampling accuracy of light tracing shadows
-
5) Global Light - GI
-
two options
-
Light Chasing GI: Environmental objects scatter real secondary light;
-
Rasterization GI: use construction + light map method;
-
-
Turn on and set
-
Choose whether to enable it in the type;
-
The number of bounces and pixel-by-pixel have a great impact on the accuracy;
-
6) Translucent-Translucent
-
two options
-
Light chasing translucency: produce real reflection and refraction;
-
Rasterized translucency: used with SSR or reflection probes;
-
-
Turn on and set
-
When the scene has no transmission, choose rasterization, which can save a few frames of performance
-
-
Translucent Material
-
When using rasterization, there are usually sorted textures, it is best to turn off double sided;
-
Calculation of the refractive index (approximate value): from air to glass, the refractive index of the two is divided;
-
Material instance
-
4. Performance optimization
1) Material optimization
-
Principle: When ray tracing, turn off some material calculations in reflection to increase running performance;
-
Core node: RayTracingQualitySwitchReplace
-
Normal: the data called by the shader during normal rendering;
-
RayTraced: the data called by the shader in light tracing reflection;
-
2) Global instruction optimization
-
指令1:r.RayTracing.Reflections.TestPathRoughness 1
-
Principle: The reflectance threshold of the light-tracking test, when the threshold is 1, the test uses SSR;
-
-
Command 2: r.RayTracing.Reflections.MaxRayDistance 100
-
Principle: The farthest distance of the ray, the default is -1 (infinity). When lowered, the performance improves, and the reflection will be incomplete;
-
-
指令3:r.RayTracing.Reflections.ScreenPercentage 50
-
Principle: Set the resolution percentage of the reflection. When it is lowered, the performance is improved, and the reflection will cause jitter;
-
-
Command 4: r.RayTracing.Reflections.Hybrid 1
-
Principle: Turn on the reflection hybrid algorithm. When it is turned on, the performance is improved, and SSR will be used instead of light tracing reflection at the beginning of the second reflection;
-
-
指令5:r.RayTracing.Reflections.ReflectionCaptures 1
-
Principle: Probe reflection is superimposed on the basis of light tracing reflection. When turned on, all reflections can be set to 1 time, and the dark areas with more than 2 times will be replaced by probe reflections.
-
3) Global light GI optimization
-
Mode changed from "Brute Force" to "Final Gathering"
-
Reduced sampling accuracy of skylight
-
指令:r.RayTracing.GlobalIllumination.NextEventEstimationSamples 1
- Principle: The number of samples is reduced
- Principle: The number of samples is reduced
4) GPU viewer-visualizer
-
Shortcut key: Ctrl+Shift+
-
Interface and Operation
-
When clicked, the consumption of this block will be located