Loading in 5 sec....

CS 551/651: Advanced Computer GraphicsPowerPoint Presentation

CS 551/651: Advanced Computer Graphics

- 48 Views
- Uploaded on
- Presentation posted in: General

CS 551/651: Advanced Computer Graphics

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

CS 551/651: Advanced Computer Graphics

Accelerating Ray Tracing

David Luebke 111/17/2014

- Ray R = O + tD
x = Ox + t * Dx

y = Oy + t * Dy

z = Oz + t * Dz

- Sphere at (l, m, n) of radius r is:
(x - l)2 + (y - m)2 + (z - n)2 = r 2

- Substitute for x,y,z and solve for t…

David Luebke 211/17/2014

- Works out as a quadratic equation:
at2 + bt + c = 0

where

a = Dx2 + Dy2 + Dz2

b =2Dx(Ox - l) + 2Dy(Oy - m) + 2Dz(Oz - n)

c = l2 + m2 + n2 + Ox2 + Oy2 + Oz2 - 2(l Ox + m Oy + n Oz + r2)

David Luebke 311/17/2014

- If solving for t gives no real roots: ray does not intersect sphere
- If solving gives 1 real root r, ray grazes sphere where t = r
- If solving gives 2 real roots (r1, r2), ray intersects sphere at t = r1& t = r2
- Ignore negative values
- Smallest value is first intersection

David Luebke 411/17/2014

- Find intersection point Pi = (xi, yi, zi) by plugging t back into ray equation
- Find normal at intersection point by subtracting sphere center from Pi and normalizing:
(When might we need the normal? When not?)

David Luebke 511/17/2014

- Polygons are the most common model representation (Why?)
- Basic approach:
- Find plane equation of polygon
- Find intersection of ray and plane
- Does polygon contain intersection point?

David Luebke 611/17/2014

y

N

P2

P1

d

x

- Find plane equation of polygon:ax + by + cz + d = 0
- How?
N = [a, b, c]

d = N P1

(How to find N ?)

David Luebke 711/17/2014

- Find intersection of ray and plane:
t = -(aOx + bOy + cOz + d) / (aDx + bDy + cDz)

- Does poly contain intersection point Pi ?
- Book’s algorithm:
- Draw line from Pi to each polygon vertex
- Measure angles between lines (how?)
- If sum of angles between lines is 360°, polygon contains Pi

- Book’s algorithm:

David Luebke 811/17/2014

- Often want to find whether a ray hits an axis-aligned box (Why?)
- One way:
- Intersect the ray with the pairs of parallel planes that form the box
- If the intervals of intersection overlap, the ray intersects the box.

David Luebke 911/17/2014

- Light buffer (Haines/Greenberg, 86)
- Precompute lists of polygons surrounding light source in all directions
- Sort each list by distance to light source
- Now shadow ray need only be intersected with appropriate list!

ShadowRay

Light Buffer

Occluding Polys

Current Intersection Point

David Luebke 1011/17/2014

- Why are the shadows sharp?
- A: Infinitely small point light sources
- What can we do about it?
- A: Implement area light sources
- How?

David Luebke 1111/17/2014

- Could trace a conical beam from point of intersection to light source:
- Track portion of beam blocked by occluding polygons:

30% blockage

David Luebke 1211/17/2014

- Too hard! Approximate instead:
- Sample the light source over its area and take weighted average:

50% blockage

David Luebke 1311/17/2014

- Disadvantages:
- Less accurate (50% vs. 30% blockage)
- Oops! Just quadrupled (at least) number of shadow rays

- Moral of the story:
- Soft shadows are very expensive in ray tracing

David Luebke 1411/17/2014

David Luebke 1511/17/2014