So the shader itself is the software that runs on one of those units, which work very closely to a CPU, the difference is that a shader is a program that runs on a graphics primitive in different Render pipeline stages: vertices, primitives, triangles, fragments or pixels. While these categories are nothing more than abstractions that we make, for the shader unit everything is data and that means it can run all kinds of programs.
So why not use a processor? Well, due to the fact that there are issues, GPUs, being designed to work in parallel, perform much better when resolving certain contexts than what a CPU does, and the same way it does. in the case of GPUs.
Microsoft, DirectX Ray Tracing and its shaders
When Redmond first spoke about the ray tracing implementation at the Games Developer Conference in 2018, there were a few months left until the NVIDIA RTX 20 launched and by that time he was completely unknown, at least publicly, units to be accelerated. Ray Tracing such as RT cores from NVIDIA and ray acceleration units from AMD.
What was Microsoft’s proposal to extend its multimedia API? Well, add a series of additional steps, which are defined in the following diagram:
Understanding the scheme is simple:
- Blocks in blue are shader programs that run at the GPU level.
- Blocks in green are executed in the CPU, driver, in tandem with the GPU.
- Diamonds in gray are conditions that can occur when lightning passes through the scene.
However, in this diagram there is an element which is not included and it is for the moment one of the biggest problems which exist with regard to Ray Tracing: the path of the acceleration structure. And what is it? We covered this in our ray tracing tutorials, but it never hurts to remember it.
Data structures to speed up ray tracing
In order to speed up, and therefore run faster, ray tracing algorithms, what is done is to map the position of objects in the scene in a data structure, which has the shape of a binary tree than the GPU would have to go.
In order for you to understand the process of walking through the data structure, what is done is start from the root which represents the whole scene and is specified in levels until you reach the last level. In each level, what is done is to make a request to the RT Core or the equivalent unit to calculate if there is an intersection, if there is one then it goes down to the next level, if there is no there is none then this path stops completely. This is done until it reaches the end of the tree, where the radius-box intersection is no longer made and the radius-polygon intersection is performed.
If you have been perceptive, you will have seen that in the diagram of the previous section among the types of shaders we have those of intersection, but not those responsible for traversing the BVH tree, that is to say of traversing them , although it is understood that this task is performed by unit shaders although there is no specific type of shader for it.
What are Traversal Shaders and where do they come from?
In the DirectX Ray Tracing documentation we can find among the future the so-called Traversal Shaders, which will be added in the future in the pipeline for Ray Tracing in a later version of the Microsoft API, but the best is us put in the situation.
The exercise of iterating through the data structure so far despite being a shader program, this one is generic and is controlled by the graphics driver, so programmers don’t have to do because it is understood that the traversal shader This gives control of the application code to iterate through the traversal process of the data structure node by node.
And what benefits does this bring to performance? The main one is that we can define scenarios in which one or more rays are separated before making the intersection, which is not possible for the moment. A very clear example would be when facing objects very far from the camera in which the lighting details cannot be as appreciated as at close range. It must be taken into account that in the current version of the Redmond API we can define with regard to indirect lighting whether an object emits rays or not via the Ray Generation Shader, but we cannot create scenarios where we can exclude rays by flight. , especially with the distance.
Traversal Shaders to build the spatial data structure
Intel’s graphics R&D division presented in 2020 a document titled Lazy construction of acceleration structures with traversal shaders and those of you who are somewhat proficient in Shakespeare’s language will have deduced that it consists of building the same spatial data structures using Traversal Shaders. These can therefore not only be used to control the course, but also to build it.
The first thing that stands out is Lazy Build, which we could translate to be educated as a version with little effort. And what does it consist of? Well, what this technique is looking for is that the time to build the data structure is reduced. For this, it is based on previous information from previous images added to a visibility algorithm and if that sounds confusing to you, let’s define what visibility means when we talk about 3D rendering.
It must be assumed that when a GPU renders what it does is calculate the visibility between a point in space and the first visible surface in a given direction or to simplify: the visibility between two elements. Before we continue, we need to take one thing into account. While reading this, you have surely imagined yourself looking at two objects. Well the thing is not like that, we are talking about how one object would see another if it could see, but from the simplest definition it refers to the camera, which is the view from which we render.
In hybrid rendering which combines rasterization with ray tracing, which is now used by all games, the visibility of the camera is not calculated from said algorithm, but rather with the raster algorithm. The idea in the future is that visibility to the camera is achieved from Ray Tracing, so that with this information the GPU ends up building a data structure of the entire scene across the Traversal Shaders.
Table of Contents