Lecture 11: Ray tracing (cont.)

Similar documents
Lecture 10: Ray tracing

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

Today. Acceleration Data Structures for Ray Tracing. Cool results from Assignment 2. Last Week: Questions? Schedule

Ray-tracing Acceleration. Acceleration Data Structures for Ray Tracing. Shadows. Shadows & Light Sources. Antialiasing Supersampling.

Advanced Ray Tracing

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Ray Tracing. Outline. Ray Tracing: History

Logistics. CS 586/480 Computer Graphics II. Questions from Last Week? Slide Credits

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

Supplement to Lecture 16

CPSC GLOBAL ILLUMINATION

Ray Tracing. Foley & Van Dam, Chapters 15 and 16

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Computer Graphics Ray Casting. Matthias Teschner

Spatial Data Structures

Questions from Last Week? Extra rays needed for these effects. Shadows Motivation

CS 431/636 Advanced Rendering Techniques

Ray Casting. Outline in Code. Outline. Finding Ray Direction. Heckbert s Business Card Ray Tracer. Foundations of Computer Graphics (Fall 2012)

Computer Graphics. Bing-Yu Chen National Taiwan University

Photorealism: Ray Tracing

Spatial Data Structures

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Spatial Data Structures

Sung-Eui Yoon ( 윤성의 )

1999, Denis Zorin. Ray tracing

Ray Tracing. Shandong University

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling

Ray Casting. To Do. Outline. Outline in Code. Foundations of Computer Graphics (Spring 2012) Heckbert s Business Card Ray Tracer

Acceleration Data Structures

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Intro to Ray-Tracing & Ray-Surface Acceleration

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Spatial Data Structures

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

Spatial Data Structures

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Ray casting. Ray casting/ray tracing

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

COMP30019 Graphics and Interaction Ray Tracing

Parallel Physically Based Path-tracing and Shading Part 3 of 2. CIS565 Fall 2012 University of Pennsylvania by Yining Karl Li

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Accelerating Ray-Tracing

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Computer Graphics and Image Processing Ray Tracing I

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

Shading, Advanced Rendering. Week 7, Wed Feb 28

The Traditional Graphics Pipeline

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Questions??? Announcements Assignment 3 due today

Geometric Queries for Ray Tracing

Lecture 2 - Acceleration Structures

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

Hidden Surface Elimination: BSP trees

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

Visible Surface Detection Methods

Ray Tracing. Last Time? Reading for Today. Reading for Today

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

Last Time? Ray Casting. Administrivia: Lab & Office Hours. Notes on Assignments. Ray Casting. Overview of Today

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

The feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):

Topics and things to know about them:

VIII. Visibility algorithms (II)

Point Cloud Filtering using Ray Casting by Eric Jensen 2012 The Basic Methodology

CEng 477 Introduction to Computer Graphics Fall 2007

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Lecture 11. More Ray Casting/Tracing

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics

CS-184: Computer Graphics. Administrative

Advanced 3D-Data Structures

Interpolation using scanline algorithm

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Viewing and Ray Tracing. CS 4620 Lecture 4

CPSC / Texture Mapping

COMPUTER GRAPHICS COURSE. Ray Tracing

Ray Casting. 3D Rendering. Ray Casting. Ray Casting. Ray Casting. Ray Casting

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

Programming projects. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Transcription:

Interactive Computer Graphics Ray tracing - Summary Lecture 11: Ray tracing (cont.) Graphics Lecture 10: Slide 1 Some slides adopted from H. Pfister, Harvard Graphics Lecture 10: Slide 2 Ray tracing - Summary Ray tracing - Summary trace ray Intersect all objects color = ambient term For every light cast shadow ray col += local shading term If mirror col += k_refl * trace reflected ray If transparent col += k_trans * trace transmitted ray trace ray Intersect all objects color = ambient term For every light cast shadow ray col += local shading term If mirror col += k_refl * trace reflected ray If transparent col += k_trans * trace transmitted ray Graphics Lecture 10: Slide 3 Graphics Lecture 10: Slide 4 1

Ray tracing - Summary Intersection calculations primary ray primary ray For each ray we must calculate all possible intersections with each object inside the viewing volume For each ray we must find the nearest intersection point We can define our scene using Solid models sphere cylinder Surface models plane triangle polygon secondary rays Graphics Lecture 10: Slide 5 Graphics Lecture 10: Slide 6 Rays Rays are parametric lines Rays can be defined an origin p 0 direction d Equation of ray: Ray tracing: Intersection calculations The coordinates of any point along each primary ray are given by: p 0 is the current pixel on the viewing plane. d is the direction vector and can be obtained from the position of the pixel on the viewing plane p 0 and the viewpoint p v : Graphics Lecture 10: Slide 7 Graphics Lecture 10: Slide 8 2

Ray tracing: Intersection calculations The viewing ray can be parameterized by µ: µ > 0 denotes the part of the ray behind the viewing plane µ < 0 denotes the part of the ray in front of the viewing plane For any visible intersection point µ > 0 Intersection calculations: Spheres µ < 0 µ > 0 For any point on the surface of the sphere p 0 where r is the radius of the sphere Graphics Lecture 10: Slide 9 Graphics Lecture 10: Slide 10 Intersection calculations: Spheres To test whether a ray intersects a surface we can substitute for q using the ray equation: Intersection calculations: Spheres The quadratic equation has the following solution: Setting and expanding the dot product produces the following quadratic equation: Solutions: if the quadratic equation has no solution, the ray does not intersect the sphere if the quadratic equation has two solutions (µ 1 < µ 2 ): µ 1 corresponds to the point at which the rays enters the sphere µ 2 corresponds to the point at which the rays leaves the sphere Graphics Lecture 10: Slide 11 Graphics Lecture 10: Slide 12 3

Precision Problems In ray tracing, the origin of (secondary) rays is often on the surface of objects Theoretically, µ = 0 for these rays Practically, calculation imprecision creeps in, and the origin of the new ray is slightly beneath the surface Result: the surface area is shadowing itself ε to the rescue... Check if t is within some epsilon tolerance: if abs(µ) < ε point is on the sphere else point is inside/outside Choose the ε tolerance empirically Move the intersection point by epsilon along the surface normal so it is outside of the object Check if point is inside/outside surface by checking the sign of the implicit (sphere etc.) equation Graphics Lecture 10: Slide 13 Graphics Lecture 10: Slide 14 Problem Time Given: the viewpoint is at p v = (0, 0, -10) the ray passes through viewing plane at p i = (0, 0, 0). Spheres: Sphere A with center p s = (0, 0, 8) and radius r = 5 Sphere B with center p s = (0, 0, 9) and radius r = 3 Sphere C with center p s = (0, -3, 8) and radius r = 2 Calculate the intersections of the ray with the spheres above. Solution The direction vector is d = (0, 0, 10) / 10 = (0, 0, 1) Sphere A: Δp = (0, 0, 8), so µ = 8 ± sqrt(64 64 + 25) = 8 ± 5 As the result, the ray enters A sphere at (0, 0, 3) and exits the sphere at (0, 0, 13)). Sphere B: Δp = (0, 0, 9), so µ = 9 ± sqrt(81 81 + 9) = 9 ± 3 As the result, the ray enters B sphere at (0, 0, 6) and exits the sphere at (0, 0, 12)). Sphere C has no intersections with ray. Graphics Lecture 10: Slide 15 Graphics Lecture 10: Slide 16 4

Intersection calculations: Cylinders Intersection calculations: Cylinders A cylinder can be described by a position vector p 1 describing the first end point of the long axis of the cylinder a position vector p 2 describing the second end point of the long axis of the cylinder a radius r The axis of the cylinder can be written as and can be parameterized by 0 α 1 To calculate the intersection of the cylinder with the ray: Since write we can p 2 p 1 q Δp Graphics Lecture 10: Slide 17 Graphics Lecture 10: Slide 18 Intersection calculations: Cylinders Intersection calculations: Cylinders Solving for α yields: Using the fact that we can use the same approach as before to the quadratic equation for µ: Substituting we obtain: If the quadratic equation has no solution: no intersection If the quadratic equation has two solutions: intersection Graphics Lecture 10: Slide 19 Graphics Lecture 10: Slide 20 5

Intersection calculations: Cylinders Assuming that µ1 µ2 we can determine two solutions: If the value of α1 is between 0 and 1 the intersection is on the outside surface of the cylinder If the value of α2 is between 0 and 1 the intersection is on the inside surface of the cylinder Intersection calculations: Plane Objects are often described by geometric primitives such as triangles planar quads planar polygons To test intersections of the ray with these primitives we must whether the ray will intersect the plane defined by the primitive Graphics Lecture 10: Slide 21 Graphics Lecture 10: Slide 22 Intersection calculations: Plane The intersection of a ray with a plane is given by where p 1 is a point in the plane. Subtracting p 1 and multiplying with the normal of the plane n yields: Solving for µ yields: Intersection calculations: Triangles To calculate intersections: test whether triangle is front facing test whether plane of triangle intersects ray test whether intersection point is inside triangle If the triangle is front facing: Graphics Lecture 10: Slide 23 Graphics Lecture 10: Slide 24 6

Intersection calculations: Triangles To test whether plane of triangle intersects ray calculate equation of the plane using Intersection calculations: Triangles A point is inside the triangle if calculate intersections with plane as before To test whether intersection point is inside triangle: Calculate α and β by taking the dot product with a and b: Graphics Lecture 10: Slide 25 Graphics Lecture 10: Slide 26 Ray tracing: Pros and cons Pros: Easy to implement Extends well to global illumination shadows reflections / refractions multiple light bounces atmospheric effects Cons: Speed! (seconds per frame, not frames per second) Speedup Techniques Why is ray tracing slow? How to improve? Too many objects, too many rays Reduce ray-object intersection tests Many techniques! Graphics Lecture 10: Slide 27 Graphics Lecture 10: Slide 28 7

Acceleration of Ray Casting Goal: Reduce the number of ray/primitive intersections Conservative Bounding Region First check for an intersection with a conservative bounding region Early reject Graphics Lecture 10: Slide 29 Graphics Lecture 10: Slide 30 Bounding Regions Conservative Bounding Regions What makes a good bounding region? Graphics Lecture 10: Slide 31 Graphics Lecture 10: Slide 32 8

Regular Grid Create Grid Find bounding box of scene Choose grid resolution (n x, n y, n z ) grid x need not = grid y Graphics Lecture 10: Slide 33 Graphics Lecture 10: Slide 34 Insert Primitives into Grid Primitives that overlap multiple cells? Insert into multiple cells (use pointers) For Each Cell Along a Ray Does the cell contain an intersection? Yes: return closest intersection No: continue Graphics Lecture 10: Slide 35 Graphics Lecture 10: Slide 36 9

Preventing Repeated Computation Perform the computation once, "mark" the object Don't re-intersect marked objects Don't Return Distant Intersections If intersection t is not within the cell range, continue (there may be something closer) Graphics Lecture 10: Slide 37 Graphics Lecture 10: Slide 38 Adaptive Grids Subdivide until each cell contains no more than n elements, or maximum depth d is reached Primitives in an Adaptive Grid Can live at intermediate levels, or be pushed to lowest level of grid Graphics Lecture 10: Slide 39 Graphics Lecture 10: Slide 40 10

Binary Space Partition (BSP) Tree Recursively partition space by planes Every cell is a convex polyhedron Binary Space Partition (BSP) Tree Simple recursive algorithms Example: point finding Graphics Lecture 10: Slide 41 Graphics Lecture 10: Slide 42 Binary Space Partition (BSP) Tree Trace rays by recursion on tree BSP construction enables simple front-to-back traversal Grid Discussion Regular + easy to construct + easy to traverse may be only sparsely filled geometry may still be clumped Adaptive + grid complexity matches geometric density more expensive to traverse (especially BSP tree) Graphics Lecture 10: Slide 43 Graphics Lecture 10: Slide 44 11