chapter 11: advanced rendering part 1 e. angel and d. shreiner: interactive computer graphics 6e ©...
TRANSCRIPT
![Page 1: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/1.jpg)
Chapter 11: Advanced RenderingPart 1
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20121
Mohan SridharanBased on Slides by Edward Angel and Dave Shreiner
![Page 2: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/2.jpg)
Introduction
• OpenGL is based on a pipeline model in which primitives are rendered one at time:– No shadows (except by tricks or multiple renderings).– No multiple reflections.
• Global approaches:– Rendering equation.– Ray tracing.– Radiosity.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20122
![Page 3: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/3.jpg)
Ray Tracing
• Follow rays of light from a point source.
• Can account for reflection and transmission.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20123
![Page 4: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/4.jpg)
Computation
• Should be able to handle all physical interactions.
• Most rays do not affect what we see. However, scattering produces many (infinite) additional rays.
• Ray tracing paradigm is not computationally efficient.
• Alternative: ray casting.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20124
![Page 5: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/5.jpg)
Ray Casting
• Only rays that reach the eye matter.• Reverse direction and cast rays.
• Need at least one ray per pixel.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20125
![Page 6: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/6.jpg)
Ray Casting Quadrics
• Constructive Solid Geometry:– Primitives are solids.– Build objects with set operations.– Union, intersection, set difference.
• Ray casting has become the standard way to visualize quadrics which are implicit surfaces in CSG systems.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20126
![Page 7: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/7.jpg)
Ray Casting a Sphere
• Ray is parametric.
• Sphere is quadric.
• Resulting equation is a scalar quadratic equation which gives entry and exit points of ray (or no solution if ray misses).
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20127
![Page 8: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/8.jpg)
Shadow Rays
• Even if a point is visible, it will not be lit unless we can see a light source from that point.
• Cast shadow or “feeler” rays.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20128
![Page 9: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/9.jpg)
Reflection
• Follow shadow rays off reflecting or transmitting surfaces.
• Process is recursive.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
20129
![Page 10: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/10.jpg)
Reflection and Transmission
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201210
![Page 11: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/11.jpg)
Ray Trees
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201211
![Page 12: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/12.jpg)
Ray Tree
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201212
![Page 13: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/13.jpg)
Diffuse Surfaces
• Theoretically the scattering at each point of intersection generates infinite number of new rays that should be traced.
• In practice, we only trace transmitted and reflected rays, and use Phong model to compute shade at point of intersection.
• Radiosity works best for perfectly diffuse (i.e., Lambertian) surfaces.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201213
![Page 14: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/14.jpg)
Building a Ray Tracer
• Best expressed recursively, can remove recursion later.• Image based approach:
– For each ray …
• Find intersection with closest surface:– Need whole object database available.– Complexity of calculation limits object types.
• Compute lighting at surface.
• Trace reflected and transmitted rays.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201214
![Page 15: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/15.jpg)
When to stop
• Some light will be absorbed at each intersection:– Track amount left.
• Ignore rays that go off to infinity:– Put large sphere around problem.
• Count steps.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201215
![Page 16: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/16.jpg)
Recursive Ray Tracer
color c = trace(point p, vector d, int step){ color local, reflected, transmitted; point q; normal n; if(step > max) return(background_color); q = intersect(p, d, status);
if(status==light_source) return(light_source_color);
if(status==no_intersection) return(background_color);
n = normal(q); r = reflect(q, n); t = transmit(q,n);
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201216
![Page 17: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/17.jpg)
Recursive Ray Tracer
local = phong(q, n, r);
reflected = trace(q, r, step+1);
transmitted = trace(q,t, step+1);
return(local+ reflected+ transmitted);
}
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201217
![Page 18: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/18.jpg)
Computing Intersections
• Implicit Objects:– Quadrics.
• Planes.
• Polyhedra.
• Parametric Surfaces.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201218
![Page 19: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/19.jpg)
Implicit Surfaces
Ray from p0 in direction d:
p(t) = p0 +t d
General implicit surface: f(p) = 0
Solve scalar equation: f(p(t)) = 0
General case requires numerical methods.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201219
![Page 20: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/20.jpg)
Quadrics
General quadric can be written as: pTAp + bTp +c = 0
Substitute equation of ray: p(t) = p0 +t d
to get quadratic equation!
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201220
![Page 21: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/21.jpg)
Sphere and Plane
(p – pc) • (p – pc) – r2 = 0
p(t) = p0 +t d
p0 • p0 t2+ 2 p0 • (d – p0) t + (d – p0) • (d – p0) – r2 = 0
p • n + c = 0
p(t) = p0 +t d
t = -(p0 • n + c)/ d • n
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201221
![Page 22: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/22.jpg)
Polyhedra
• Generally we want to intersect with closed objects such as polygons and polyhedra rather than planes.
• Hence we have to worry about inside/outside testing.
• For convex objects such as polyhedra there are some fast tests.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201222
![Page 23: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/23.jpg)
Ray Tracing Polyhedra
• If ray enters an object, it must enter a front facing polygon and leave a back facing polygon.
• Polyhedron is formed by intersection of planes.
• Ray enters at furthest intersection with front facing planes.
• Ray leaves at closest intersection with back facing planes.
• If entry is further away than exit, ray misses the polyhedron.
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201223
![Page 24: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/24.jpg)
Ray Tracing Polyhedra
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201224
![Page 25: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/25.jpg)
Ray Tracing a Polygon
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201225
![Page 26: Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides](https://reader035.vdocuments.mx/reader035/viewer/2022062421/56649d345503460f94a0b7f9/html5/thumbnails/26.jpg)
Ray Tracing a Polygon
E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley
201226