Graphics Reference
In-Depth Information
converting from clip space into screen space [0 , 1] range, as we can see below:
P cs =( P vs + Reflect ( V vs , N vs ))
M proj ,
P ss = P cs
P cs w
[0 . 5
0 . 5] + [0 . 50 . 5] .
Once we have a screen-space reflection vector, we can run the Hi-Z traversal
to ray-march along the acceleration structure using O , D ,and t .
We'll first look at the pseudo code in Listing 4.2. The algorithm uses the
Hi-Z buffer we constructed earlier to accelerate the ray marching. To visualize
the algorithm in Listing 4.2 step by step, follow Figure 4.12.
Once the ray-tracing algorithm has run, we have our new coordinate in screen
space that is our ray intersection point. Some ideas are borrowed from displace-
ment mapping techniques found in the literature [Hien and Lim 09, Hrkalovic and
Lundgren 12, Oh et al. 06, Drobot 09, Szirmay-Kalos and Umenhoffer 06]. One
major difference is that we start on the root level while displacement techniques
start on the leaf level for marching a ray. Ray-marching with a view-space Z-buffer
is a bit more involved because we have to manually interpolate the Z-coordinate
as it is not possible to interpolate it in screen space.
level =0 // starting level to traverse from
while level not below N // ray trace until we descend below the
// root level defined by N, demo used 2
minimumPlane = getCellMinimumDepthPlane (...)
// reads from the Hi Z texture using our ray
boundaryPlane = getCellBoundaryDepthPlane (...)
// gets the distance to next Hi Z cell boundary in ray
// direction
closestPlane = min ( minimumPlane , boundaryPlane )
// gets closest of both planes
ray = intersectPlane (...)
// intersects the closest plane , returns O + D ￿ tonly.
if intersectedMinimumDepthPlane
// if we intersected the minimum plane we should go down a
// level and continue
descend a level
if intersectedBoundaryDepthPlane
// if we intersected the boundary plane we should go up a
// level and continue
ascend a level
color = getReflection ( ray ) // we are now done with the Hi Zray
// marching so get color from the intersection
Listing 4.2. Pseudo code for implementing the Hi-Z ray tracing.
Search WWH ::




Custom Search