Graphics Reference
In-Depth Information
#define LINEAR MARCH COUNT 32
for ( int i =0; i < LINEAR_MARCH_COUNT ;++ i )
{
// Read scene depth with current ray .
float d = depthBuffer . SampleLevel ( pointSampler , ray . xy ,0);
// Check if ray is greater than the scene , it means we
// intersected something so end.
if ( ray . z > d )
break ;
// Else advance the ray by a small step and continue the
// loop . Step is a vector in screen space .
ray += step ;
}
Listing 4.1. A simple linear ray marching to illustrate the concept of walking a depth
buffer until an intersection is found. We can quickly see that this technique is fetch
bound. The ALU units are not doing a lot of work as there are too few ALU instructions
to hide the latency of the global memory fetches the shader has to wait to complete.
So let's take a close look at some major problems for this kind of a technique.
1. It takes small-sized steps, it conducts many fetches, and latency starts to
bottleneck quickly.
2. It can miss small details in the case that the step it takes is larger than the
small detail next to the ray.
3. It produces staircase artifacts and needs a refinement such as a secant or
binary search.
4. It is only fast for short travels; ray-marching an entire scene will stall the
cores and result in slow performance.
Our goal is to introduce an algorithm that can solve all four points.
All of those points can be solved by introducing an acceleration structure,
which can then be used to accelerate our rays, basically traversing as much dis-
tance as the ray can possibly take without risking missing any details at all. This
acceleration structure will allow the ray to take arbitrary length steps, and espe-
cially large ones as well whenever it can. It's also going to conduct fewer fetches
and thereby perform faster. The acceleration structure is going to produce great
results without needing an extra refinement pass, although it doesn't hurt to do
a final secant search between the previous pixel and the current pixel because
an acceleration structure is usually a discrete set of data. Since we gain major
speedups by using an acceleration structure, we will also be able to travel longer
and ray-march an entire scene with much better performance.
Search WWH ::




Custom Search