21.11.2014 Views

Hybrid ray tracing and path tracing of bezier ... - IIIT Hyderabad

Hybrid ray tracing and path tracing of bezier ... - IIIT Hyderabad

Hybrid ray tracing and path tracing of bezier ... - IIIT Hyderabad

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>IIIT</strong> <strong>Hyderabad</strong><br />

HYBRID RAY TRACING AND<br />

PATH TRACING OF BEZIER SURFACES<br />

USING A MIXED HIERARCHY<br />

Rohit Nigam, P. J. Na<strong>ray</strong>anan<br />

CVIT, <strong>IIIT</strong> <strong>Hyderabad</strong>, <strong>Hyderabad</strong>, India


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Bezier Surfaces<br />

• Bezier Surfaces are the most basic form <strong>of</strong> parametric<br />

surfaces<br />

• A Bezier Surface can be described as:<br />

Q(u,v) = [U][M][P][M] T [V] T<br />

where [U] = [u 3 u 2 u 1] <strong>and</strong> [V] = [v 3 v 2 v 1], 0 ≤ u,v ≤ 1<br />

[M] is the Bezier Basis Matrix<br />

[P] is the set <strong>of</strong> 16 Control Points defining the patch


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Bezier Surface : Motivation<br />

• Advantages<br />

‣ Provide compact <strong>and</strong> effective representation.<br />

‣ Remain curved <strong>and</strong> smooth at arbitrary level <strong>of</strong> zooming.<br />

‣ Memory efficient, in comparison with triangular mesh.<br />

• Rendering <strong>of</strong> Parametric Surfaces<br />

– Eisenacher et al.(2009) : View Dependent Adaptive Subdivision<br />

– Geimer et al.(2005) : Newton Iteration<br />

– Pabst et al.(2006) : Bezier Clipping + Newton Iteration


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Previous work on Ray Tracing<br />

<strong>of</strong> Bezier Surfaces<br />

1<br />

2 3<br />

BVH Nodes<br />

P1 P2 P3 P4 P5 P6 Subpatches at<br />

Leaf<br />

• Based on the flatness criteria, each patch is divided into<br />

subpatches.<br />

• BVH for given surfaces<br />

– Bounding boxes <strong>of</strong> subpatches at leaf nodes.<br />

• For each <strong>ray</strong> intersecting a subpatch<br />

– Generate initial values for Newton Iteration


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Limitation <strong>of</strong> the Model for GPUs<br />

• GPU Access time:<br />

– High for global memory<br />

– Comparatively less for shared memory <strong>and</strong> registers<br />

When subdividing based on flatness criteria, we need to<br />

– Store subpatches starting index<br />

– Store total number <strong>of</strong> subpatches<br />

– Store initial [u,v] pair for each potential intersection.<br />

Thus more global memory operations result in lower<br />

throughput.<br />

• Need to check every subpatch at leaf node


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Our Approach<br />

• Create a mixed hierarchy, consisting <strong>of</strong> two hierarchical<br />

structures.<br />

– Each Patch is divided into fixed size subpatches, hierarchically,<br />

using De Casteljau algorithm.<br />

– The top level BVH tree is constructed from the original patches.<br />

– Leaf nodes represent the original Bezier Surfaces.<br />

– Make subtree for each patch from the subdivided patches.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

BVH for<br />

Patches<br />

BVH Nodes<br />

Patches<br />

1 2 3 4<br />

Subtree Nodes<br />

Subpatch<br />

Hierarchy<br />

Sub-patches


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Mixed Hierarchy Structure<br />

• Create the first level BVH using the Bounding Boxes <strong>of</strong><br />

the original surface patches.<br />

• Create 2 nd level BVH by alternately subdividing along u<br />

<strong>and</strong> v parameters.<br />

– A subdivision depth <strong>of</strong> 6 was found empirically sufficient for our<br />

scenes.<br />

– Fixed depth makes it possible to store skip pointers, used for<br />

traversing the subtree <strong>and</strong> subpatch numbers to get initial<br />

values.<br />

– A subtree at lower level leads to early termination at this stage,<br />

reducing the (Ray, Bounding Box) intersections.<br />

– Subdivision also leads to tighter bounds, which further reduces<br />

the potential (Ray,Patch) intersections.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

GPU Traversal <strong>of</strong><br />

Mixed Hierarchy Structure<br />

• A ‘traverse’ kernel traverses the first level <strong>of</strong> the BVH.<br />

– Lists out Potential (Ray,Patch) intersections.<br />

– We make use <strong>of</strong> atomic operations, to provide scalability.<br />

• ‘Recheck’ kernel parallely processes the generated<br />

(<strong>ray</strong>,patch) list.<br />

– This leads to further pruning <strong>of</strong> the list with tighter subpatch<br />

bounding boxes.<br />

– We make use <strong>of</strong> ‘t’ values computed here, to not traverse<br />

subpatch nodes with higher values.<br />

– This leads to reduced computation <strong>and</strong> in cases <strong>of</strong> false<br />

positive, a little less accurate initial values.<br />

– Lists out the reduced potential (Ray,Patch) intersections.<br />

– Generates the initial values for each intersection.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Newton Iteration<br />

• We represent a <strong>ray</strong> as intersection <strong>of</strong> two planes, (n 1 ,d 1 )<br />

<strong>and</strong> (n 2 ,d 2 )<br />

The <strong>ray</strong> patch intersection equation becomes<br />

Q(u,v) represents the point on the patch.<br />

• We use Newton Iteration to solve for (u,v)<br />

Here J is the inverse Jacobian matrix <strong>of</strong> R.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

<strong>Hybrid</strong> Ray Tracing<br />

Divide the Ray list between CPU <strong>and</strong> GPU<br />

GPU algorithm comprises<br />

<strong>of</strong> three kernels:<br />

Traverse : Generate<br />

Potential Ray-Patch<br />

Intersections<br />

Recheck : Further prune<br />

intersections <strong>and</strong> get initial<br />

values<br />

Newton : Apply Newton<br />

iteration to get hit-point<br />

CPU stage comprises <strong>of</strong>:<br />

1. Divide CPU Raylist into<br />

2c threads, where c is<br />

number <strong>of</strong> cores.<br />

2. Intersect with main BVH<br />

3. If intersects, intersect<br />

with 2 nd level subtree.<br />

4. Apply Newton iteration<br />

to get hit-point


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

<strong>Hybrid</strong> Ray Tracing


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Path Tracing<br />

• We extend our <strong>ray</strong> <strong>tracing</strong> approach to Global<br />

Illumination effects.<br />

• We use Cook’s approach <strong>of</strong> Monte Carlo based<br />

Stochastic Sampling, to sample the image at<br />

appropriate non-uniformly spaced points.<br />

• Each pixel is sampled for a user defined samples per<br />

pixel<br />

• We apply our data parallel approach to this massive <strong>ray</strong><br />

list to generate the desired effects.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Path Tracing<br />

Bigguy in a box: 10000 spp, 512x512 resolution<br />

Rendered in 28.5 minutes


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Results (Primary Rays, 1024x1024)<br />

Model<br />

Patche<br />

s<br />

Ray-Patch<br />

Intersections<br />

Total Frame Time(ms)<br />

CPU GPU <strong>Hybrid</strong><br />

Teapot 32 126589 74 8.71 8.01<br />

Bigguy 3570 142779 110 14.59 13.18<br />

Killeroo 11532 147116 193 22.38 20.43<br />

2 Killeroos 23064 317494 356 42.29 38.58<br />

9 Bigguys 32130 570136 2092 77.05 75.9


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Results (Primary +Secondary)<br />

Model<br />

Patche<br />

s<br />

Total Frame Time(ms)<br />

CPU GPU <strong>Hybrid</strong><br />

Teapot 32 137 17.05 15.61<br />

Bigguy 3570 232 39.45 34.92<br />

Killeroo 11532 351 58.3 52.19<br />

2 Killeroos 23064 726 106.03 94.55<br />

9 Bigguys 32130 3107 196.79 191.81


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

Conclusion<br />

• A mixed hierarchy model is proposed to speed up Ray<br />

Tracing process.<br />

• GPU benefits greatly from fixed depth subtree.<br />

• A hybrid model is proposed, to fully utilize compute<br />

power <strong>of</strong> CPU <strong>and</strong> GPU.<br />

• We demonstrate the capability <strong>of</strong> our method by<br />

performing global illumination for Bezier patches.


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

THANK YOU


<strong>IIIT</strong> <strong>Hyderabad</strong>


<strong>IIIT</strong> <strong>Hyderabad</strong><br />

<strong>Hybrid</strong> Ray Tracing<br />

• Divide the Ray list between CPU <strong>and</strong> GPU<br />

‣ Ratio decided based on compute capabilities<br />

• GPU algorithm comprises <strong>of</strong> three kernels:<br />

‣ Traverse : Generate Potential Ray-Patch Intersections<br />

‣ Recheck : Further prune intersections <strong>and</strong> get initial values<br />

‣ Newton : Apply Newton iteration to get hit-point<br />

• CPU stage comprises <strong>of</strong>:<br />

1. Divide CPU Raylist into 2c threads, where c is number <strong>of</strong> cores.<br />

2. Intersection with main BVH<br />

3. If intersects, further intersection with 2 nd level subtree.<br />

4. Finally, apply Newton iteration <strong>and</strong> generate hit-point<br />

• CPU benefits from early <strong>ray</strong> termination.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!