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

Similar documents
Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Ray Tracing Acceleration Data Structures

Advanced Ray Tracing

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

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

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

Accelerated Raytracing

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

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

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

Ray Tracing Foley & Van Dam, Chapters 15 and 16

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

Sung-Eui Yoon ( 윤성의 )

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

Acceleration Data Structures

Lecture 11: Ray tracing (cont.)

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

Intersection Acceleration

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

Computer Graphics. Bing-Yu Chen National Taiwan University

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

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

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

CPSC GLOBAL ILLUMINATION

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

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

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

CS 431/636 Advanced Rendering Techniques

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

Advanced 3D-Data Structures

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

Lecture 17: Solid Modeling.... a cubit on the one side, and a cubit on the other side Exodus 26:13

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Ray Tracing with Spatial Hierarchies. Jeff Mahovsky & Brian Wyvill CSC 305

Accelerating Ray-Tracing

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

Ray Tracing Acceleration. CS 4620 Lecture 22

Distribution Ray-Tracing. Programação 3D Simulação e Jogos

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

Graphics 2009/2010, period 1. Lecture 8: ray tracing

Accelerating Ray Tracing

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

CS535 Fall Department of Computer Science Purdue University

Spatial Data Structures. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 457 Autumn 2017

Computer Graphics Ray Casting. Matthias Teschner

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

Distribution Ray Tracing

Ray Intersection Acceleration

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

The Traditional Graphics Pipeline

Distributed Ray Tracing

VIII. Visibility algorithms (II)

Anti-aliasing and Monte Carlo Path Tracing

Ray Genealogy. Raytracing: Performance. Bounding Volumes. Bounding Volume. Acceleration Classification. Acceleration Classification

COMP 175: Computer Graphics April 11, 2018

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

Ray tracing. EECS 487 March 19,

The Traditional Graphics Pipeline

Computer Graphics. - Ray-Tracing II - Hendrik Lensch. Computer Graphics WS07/08 Ray Tracing II

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

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

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

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

Speeding up your game

The Traditional Graphics Pipeline

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

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

Hidden Surface Elimination: BSP trees

COMP371 COMPUTER GRAPHICS

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

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

Ray Tracing: Intersection

Global Illumination The Game of Light Transport. Jian Huang

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

Reading. Distribution Ray Tracing. BRDF, revisited. Pixel anti-aliasing. ω in. Required: Shirley, section Further reading:

EECS 487: Interactive Computer Graphics

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

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

More Hidden Surface Removal

Ray Tracing Acceleration. CS 4620 Lecture 20

Implicit Surfaces & Solid Representations COS 426

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

Ray Tracing. Outline. Ray Tracing: History

Solid Modeling. Ron Goldman Department of Computer Science Rice University

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

CS 563 Advanced Topics in Computer Graphics Culling and Acceleration Techniques Part 1 by Mark Vessella

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

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

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

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Transcription:

Ray Tracing III Wen-Chieh (Steve) Lin National Chiao-Tung University Shirley, Fundamentals of Computer Graphics, Chap 10 Doug James CG slides, I-Chen Lin s CG slides

Ray-tracing Review For each pixel, trace a primary ray (eye ray) to the first visible surface. For each intersection trace secondary rays: Shadow rays: in directions L to light sources Reflected ray: in direction R Refracted ray (transmitted ray): in direction T L L R R V V DCP4516 Introduction to Computer Graphics 2 T

Ray-tracing Review (cont.) Every surface intersection spawns 1 reflected ray 1 transmitted ray L R 1 shadow ray per light Shaded color of Vi = Valid(Li) x PhongModel + ReflectedRay + TransmittedRay L R T V V Valid(Li) = 1, if visible to the light source 0, otherwise DCP4516 Introduction to Computer Graphics 3

Ray Tracing Preliminary Assessment Global illumination method Image-based Pros: Relatively accurate shadows, reflections, refractions Cons: Slow Aliasing Inter-object diffuse reflections DCP4516 Introduction to Computer Graphics 4

Ray Tracing Acceleration Faster intersections Faster ray-object intersections Object bounding volume Efficient intersectors Fewer ray-object intersections Hierarchical bounding volumes (boxes, spheres) Spatial data structures Fewer rays Stochastic sampling DCP4516 Introduction to Computer Graphics 5

Spatial Data Structures Data structures to store geometric information Sample applications Collision detection / Location queries Chemical simulations Rendering Spatial data structures for ray tracing Object-centric data structures (bounding volumes) Space subdivision (grids, octrees, BSP trees) Speed-up of 10x, 100x, or more DCP4516 Introduction to Computer Graphics 7

Bounding Volumes Wrap complex objects in simple ones Does ray intersect bounding box? No: does not intersect enclosed objects Yes: calculate intersection with enclosed objects Common types Boxes, axis-aligned Boxes, oriented Spheres DCP4516 Introduction to Computer Graphics 8

Axis-aligned Bounding Box The ray is only tested for intersection with the surfaces if it hits the bounding box Box orientation aligned with axes DCP4516 Introduction to Computer Graphics 9

Intersection Condition Ray intersects box if the intervals [t xmin, t xmax ] and [t ymin, t ymax ] overlap t ymax t xmax x e tx d x min t xmin y max t x min x min x x d e t ymin x min x max y min t=0 t= t ymin t xmin t ymax t xmax DCP4516 Introduction to Computer Graphics 10

Intersection Condition (cont.) Ray intersects box if the intervals [t xmin, t xmax ] and [t ymin, t ymax ] overlap Note that ray direction affects the order of t xmin, t xmax, t ymin, t ymax along t-axis t ymin t xmin t ymax t xmax y max y min x min x max t= t=0 t ymin t xmin t ymax t xmax DCP4516 Introduction to Computer Graphics 11

Intersection Condition (cont.) Think about how to deal with vertical and horizontal rays? y max t xmin t xmax y min x min x max DCP4516 Introduction to Computer Graphics 12

Selection of Bounding Volumes Effectiveness depends on: Probability that ray hits bounding volume, but not enclosed objects (tight fit is better) Expense to calculate intersections with bounding volume and enclosed objects Reduce calculation of bounding volumes Use heuristics good bad DCP4516 Introduction to Computer Graphics 13

Bounding Volume Hierarchy (BVH) With simple bounding volumes, ray casting still has requires O(n) intersection tests Idea: use tree data structure Larger bounding volumes contain smaller ones etc. Sometimes naturally available (e.g. human figure) Sometimes difficult to compute Often reduces complexity to O(log(n)) Sub-linear ray-object intersection DCP4516 Introduction to Computer Graphics 14

Hierarchical Bounding Boxes Hierarchy made by partitioning the set of objects in a box and placing a box around each partition Convenient to use a binary tree that are roughly balanced and less overlap between siblings DCP4516 Introduction to Computer Graphics 15

Ray Intersection Algorithm using BVH Recursively descend tree If ray misses bounding volume, no intersection If ray intersects bounding volume, recurse with enclosed volumes and objects Overall effectiveness depends on model and constructed hierarchy DCP4516 Introduction to Computer Graphics 16

Spatial Subdivision Bounding volumes enclose objects, recursively Alternatively, divide space For each segment of space keep list of intersecting surfaces or objects Basic techniques Regular grids (uniform partition) Octrees (axis-aligned, non-uniform partition) BSP trees (recursive Binary Space Partition, planes) DCP4516 Introduction to Computer Graphics 17

Uniform Spatial Subdivision 3D array of cells (voxels) that tile space Each cell points to all intersecting surfaces Intersection algorithm steps from cell to cell DCP4516 Introduction to Computer Graphics 18

Caching Intersection points Objects can span multiple cells Multiple objects can be in one cell For A need to test intersection only once For B need to cache intersection and check next cell for closer one If not, C could be missed (white ray) A B DCP4516 Introduction to Computer Graphics 19 C

Assessment of Regular Grids Poor choice when world is non-homogeneous Cells at empty space are wasted Size of grid Too large: too many surfaces per cell Too small: too many empty cells to traverse Need an appropriate traversal order Can use alg. like Bresenham s for efficient traversal Non-uniform spatial subdivision more flexible Can adjust to objects that are present DCP4516 Introduction to Computer Graphics 20

BSP Trees Split space with any line (2D) or plane (3D) Applications Painters algorithm for hidden surface removal Ray casting Inherent spatial ordering given viewpoint Left subtree: in front, right subtree: behind Problem: finding good space partitions Proper ordering for any viewpoint Balance tree DCP4516 Introduction to Computer Graphics 21

Building a BSP Tree Use hidden surface removal as intuition Using line 1 or line 2 as root is easy Line 1 3 2 1 1 A D C Line 3 Line 2 B A C D a BSP tree using 2 as root 3 B the subdivision of space it implies 2 Viewpoint DCP4516 Introduction to Computer Graphics 22

Splitting of surfaces Using line 3 as root requires splitting Line 1 3 Line 2a 2b 2a Line 3 Line 2b 1 Viewpoint DCP4516 Introduction to Computer Graphics 23

Painter s Algorithm with BSP Trees Building the tree May need to split some polygons Slow, but done only once Traverse back-to-front or front-to-back Order is viewer-direction dependent What is front and what is back of each line changes Determine order on the fly DCP4516 Introduction to Computer Graphics 25

BSP for Ray-Tracing Similar to the BSP used in painter s algorithm, but uses axis-aligned cutting planes for easier ray intersection DCP4516 Introduction to Computer Graphics 27

Quadtrees Generalization of binary trees in 2D Node (cell) is a square Recursively split into 4 equal sub-squares Stop subdivision based on number of objects Ray intersection has to traverse quadtree More difficult to step to next cell DCP4516 Introduction to Computer Graphics 29

Octrees Generalization of quadtree in 3D Each cell may be split into 8 equal sub-cells Internal nodes store pointers to children Leaf nodes store list of surfaces Adapts well to inhomogeneous scenes DCP4516 Introduction to Computer Graphics 30

Comparison of Spatial Data Structure on Ray-Tracing Hierarchical bounding volumes Natural for hierarchical objects Better for dynamic scenes Regular grids Easy to implement Require a lot of memory Poor results for inhomogeneous scenes Octrees Better on most scenes (more adaptive) DCP4516 Introduction to Computer Graphics 31

Other Spatial Subdivision Techniques Relax rules for quadtrees and octrees k-dimensional tree (k-d tree) Split at arbitrary interior point Split one dimension at a time Binary space partitioning tree (BSP tree) In 2 dimensions, split with any line In k dims. split with k-1 dimensional hyperplane Useful for painter s algorithm and ray tracing DCP4516 Introduction to Computer Graphics 32

Demos BSP Tree construction http://symbolcraft.com/graphics/bsp/index.html Interactive ray tracing via space subdivision http://www.cs.utah.edu/~reinhard/egwr/ Interactive ray tracing with good hardware http://www.cs.utah.edu/vissim/projects/raytracing/ DCP4516 Introduction to Computer Graphics 33

Constructive Solid Geometry (CSG) Generate complex shapes with simple building blocks (boxes, spheres, cylinders, cones,...) Particularly applicable for machined objects Efficient with ray tracing Subtract From To get DCP4516 Introduction to Computer Graphics 34

CSG Trees Set operations yield tree-based representation Use these trees for ray/objects intersections Think about how! DCP4516 Introduction to Computer Graphics 35

Implicit Functions for Booleans Solid as implicit function, F(x,y,z) F(x, y, z) < 0 interior F(x, y, z) = 0 surface F(x, y, z) > 0 exterior For CSG, use F(x, y, z) 2 {-1, 0, 1} F A and B (p) = max (F A (p), F B (p)) F A union B (p) = min (F A (p), F B (p)) F A B (p) = max (F A (p), - F B (p)) DCP4516 Introduction to Computer Graphics 36

Distributed Ray Tracing Used for Anti-aliasing Generates more realistic effects Soft shadows Fuzzy reflections Soft focus / Depth of field DCP4516 Introduction to Computer Graphics 37

Antialiasing by Supersampling We can approximate the average color of a pixel s area by firing multiple rays and averaging the result DCP4516 Introduction to Computer Graphics 38

Sampling Strategies Regular sampling Random sampling Jittering or stratified sampling (randomly perturbs a regular grid) DCP4516 Introduction to Computer Graphics 39

Soft Shadows Treat the light as an area rather than a point Approximate area light source with a distributed set of N point lights r = c + ξ 1 a + ξ 2 b Uniform random numbers in [0,1) a c b DCP4516 Introduction to Computer Graphics 40

Depth of Field Real camera collects light at a non-zero size lens rather than a point Simulate soft focus effects by randomly placing the eye point in a square region DCP4516 Introduction to Computer Graphics 41

Glossy Reflection Randomly sample on a square perpendicular to r r' r u u v v a v ' a 2 a u a 2 0, ' 1 a a v u DCP4516 Introduction to Computer Graphics 42

Motion Blur Looks like squash and stretch!! T. Porter, Pixar, 1984 16 samples/pixel Cook, Stochastic Sampling in Computer Graphics, TOG, 1986 DCP4516 Introduction to Computer Graphics 43

Motion Blur In real camera, aperture is open for some time interval during objects move Simulated by firing rays randomly within a time interval [T 0, T 1 ] T T ( T T 0) 0 1 DCP4516 Introduction to Computer Graphics 44

Raytracing Example I www.povray.org DCP4516 Introduction to Computer Graphics 45

Raytracing Example II www.povray.org DCP4516 Introduction to Computer Graphics 46

Raytracing Example II Saito, Saturn Ring DCP4516 Introduction to Computer Graphics 47

Raytracing Example IV www.povray.org DCP4516 Introduction to Computer Graphics 48