Lecture 11. More Ray Casting/Tracing

Similar documents
Ray casting. Ray casting/ray tracing

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

Ray Tracing Foley & Van Dam, Chapters 15 and 16

1999, Denis Zorin. Ray tracing

Ray Tracer I: Ray Casting Due date: 12:00pm December 3, 2001

Ray Tracer Due date: April 27, 2011

Loop Boundary - ignore edge vertex near boundary rule. use the same edge vertex rule. Deadline changed to Friday night(7/20) 11:59p Selection - extra

Quadric Surfaces. Philippe B. Laval. Today KSU. Philippe B. Laval (KSU) Quadric Surfaces Today 1 / 24

Quadric Surfaces. Philippe B. Laval. Spring 2012 KSU. Philippe B. Laval (KSU) Quadric Surfaces Spring /

Computer Graphics Ray Casting. Matthias Teschner

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

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

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

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

What you will learn today

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

Intro to Ray-Tracing & Ray-Surface Acceleration

CPSC GLOBAL ILLUMINATION

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

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

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

Ray surface intersections

Section 12.2: Quadric Surfaces

4 = 1 which is an ellipse of major axis 2 and minor axis 2. Try the plane z = y2

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

Assignment 6: Ray Tracing

Fog and Cloud Effects. Karl Smeltzer Alice Cao John Comstock

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

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

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

Computer Graphics and Image Processing Ray Tracing I

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

Ray Tracing. Outline. Ray Tracing: History

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

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

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

Ray Tracing Acceleration. CS 4620 Lecture 20

Intersecting Simple Surfaces. Dr. Scott Schaefer

Lecture 11: Ray tracing (cont.)

Cylinders and Quadric Surfaces A cylinder is a three dimensional shape that is determined by

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

Solid Modeling. Ron Goldman Department of Computer Science Rice University

Advanced Ray Tracing

Ray Tracing I. History

Ray Tracing Part 1. CSC418/2504 Introduction to Computer Graphics. TA: Muhammed Anwar & Kevin Gibson

1.6 Quadric Surfaces Brief review of Conic Sections 74 CHAPTER 1. VECTORS AND THE GEOMETRY OF SPACE. Figure 1.18: Parabola y = 2x 2

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

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

Sung-Eui Yoon ( 윤성의 )

Key Idea. It is not helpful to plot points to sketch a surface. Mainly we use traces and intercepts to sketch

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

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

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

From Vertices To Fragments-1

12.6 Cylinders and Quadric Surfaces

Ray Tracing I. Internet Raytracing Competition

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

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

Functions of Several Variables

Quadric Surfaces. Six basic types of quadric surfaces: ellipsoid. cone. elliptic paraboloid. hyperboloid of one sheet. hyperboloid of two sheets

CS 4204 Computer Graphics

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

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

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Geometric Queries for Ray Tracing

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Assignment 2 Ray Tracing

Computer Graphics. Ray Tracing Part 1. by Brian Wyvill. University of Calgary. cpsc/enel P 1 C B,C A,B A V1 B. d r

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

Illumination Models III: Ray Tracing (View Dependent Global Illumination)

Spatial Data Structures

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

Homework 3: Shading, Raytracing, and Image Processing

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Distributed Ray Tracing

Ray Tracing Acceleration. CS 4620 Lecture 22

Ray Tracing. Shandong University

TNM079 Modeling & Animation Lecture 6 (Implicit surfaces)

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

Supplement to Lecture 16

CMSC427 Final Practice v2 Fall 2017

Shadows. COMP 575/770 Spring 2013

Topics and things to know about them:

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

Questions??? Announcements Assignment 3 due today

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

Computer Graphics. - Ray Tracing I - Marcus Magnor Philipp Slusallek. Computer Graphics WS05/06 Ray Tracing I

Raytracing CS148 AS3. Due :59pm PDT

Lecture 8 Ray tracing Part 1: Basic concept Yong-Jin Liu.

TDA361/DIT220 Computer Graphics, January 15 th 2016

CS 465 Program 5: Ray II

Photorealism: Ray Tracing

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):

Shading, Advanced Rendering. Week 7, Wed Feb 28

CS348B Lecture 2 Pat Hanrahan, Spring Greeks: Do light rays proceed from the eye to the light, or from the light to the eye?

Ray tracing. EECS 487 March 19,

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

Transcription:

Lecture 11 More Ray Casting/Tracing

Basic Algorithm For each pixel { } Shoot a ray from camera to pixel for all objects in scene Compute intersection with ray Find object with closest intersection Display color using object + light property

! 2001, Denis Zorin Pixel rays u v v " u Virtual world coordinates of pixel (i,j): image center + displacements. Image center: c + vn u v w N w i u M h j h vn c j) (i, pixel " # $ % & ' ( ) # $ % & ' ( * * # $ % & ' ( # $ % & ' ( * ) * * + 2 2 1 2 2 1

Basic Algorithm For each pixel { } Shoot a ray from camera to pixel for all objects in scene Compute intersection with ray Find object with closest intersection Display color using object + light property

Infinite cylinder-ray intersections v a p a r Infinite cylinder along y axis of of radius r axis has equation x 2 + z 2 - r 2 = 0. The equation for a more general cylinder of radius r oriented along a line p a + v a t: (q - p a - (v. a (q p a ) ) v a ) 2 - r 2 = 0 where q = (x,y,z) is a point on the cylinder.! 2001, Denis Zorin

Infinite cylinder-ray intersections To find intersection points with a ray p c+bt + vt, substitute q = p c+bt + vt and solve: (c - pa + bt - (va (c - pa + bt) va)) 2 - r 2 = 0 (p - p a + vt - (v a. (p - p a + vt))v a ) 2 - r 2 = 0 reduces to with A B# # 2 At % bv ' (v ( v )v & b C # " cp ' (" cp ( v where "p c = c- p- p a a 2 $ Bt $ C %(v b ' (v b ( v )v ) ( (" cp ' (" cp ( v )v )& a # % & 2 2 )v ' r a a a 2 a 0 a a! 2001, Denis Zorin

Cylinder caps A finite cylinder with caps can be constructed as the intersection of an infinite cylinder with a slab between two parallel planes, which are perpendicular to the axis. To intersect a ray with a cylinder with caps:! intersect with the infinite cylidner;! check if the intersection is between the planes;! intersect with each plane;! determine if the intersections are inside caps;! out of all intersections choose the on ewith minimal t! 2001, Denis Zorin

Cylinder-ray intersections POV -ray like cylinder with caps : cap centers at p 1 and p 2, radius r. Infinite cylinder equation: p a = p 1, v a = (p 2 - p 1 )/ p 2 - p 1 The finite cylinder (without caps) is described by equations: (q - p a - (v. a ( q p a ))v a ) 2 - r 2 = 0 and (v. a ( q- p 1 )) > 0 and p 2 (v a. (q- p 2 )) < 0 r The equations for caps are: (v a. ( q- p 1 )) = 0, (q- p 1 ) 2 < r 2 bottom cap (v a. ( q- p 2 )) = 0, (q- p 2 ) 2 < r 2 top cap! 2001, Denis Zorin p 1

Cylinder-ray intersections Algorithm with equations: Step 1: Find solutions t 1 and t 2 of At 2 + Bt + C = 0 if they exist. Mark as intersection candidates the one(s) that are nonnegative and for which (v a. ( q i - p 1 )) > 0 and (v a. ( q i - p 2 )) < 0, where q i =p+v t i Step 2: Compute t 3 and t 4, the parameter values for which the ray intersects the upper and lower planes of the caps. If these intersections exists, mark as intersection candidates those that are nonegative and (q 3 - p 1 ) 2 < r 2 (respectively (q 4 - p 2 ) 2 < r 2 ). In the set of candidates, pick the one with min. t.! 2001, Denis Zorin

General quadrics A general quadric has equation Ax 2 + By 2 + Cz 2 + Dxy + Eyz + Fxz + Gx + Hy +Iz + J =0 Intersections with general quadrics are computed in a way similar similar way: to For cones ray c+bt, and cylinders: for a ray p+ take v t, take x = c x +b = p xx t, + y v= x t, c y y +b= y t, p y z + = vc yz t, +by z t= p z + v z t, and solve the equation for t; if there are solutions, take the smaller nonnegative one. Infinite cones and cylinders are special cases of general quadrics.! 2001, Denis Zorin

General quadrics Nondegenerate quadrics Ellipsoid x 2 /a 2 + y 2 /b 2 + z 2 /c 2 + 1= 0 One-sheet hyperboloid x 2 /a 2 - y 2 /b 2 + z 2 /c 2 + 1= 0 Two-sheet hyperboloid x 2 /a 2 - y 2 /b 2 + z 2 /c 2-1= 0! 2001, Denis Zorin

General quadrics Nondegenerate quadrics Hyperbolic parabolid x 2 /a 2 - z 2 /c 2-2y= 0 Elliptic parabolid x 2 /a 2 + z 2 /c 2-2y= 0 cone x 2 /a 2 - y 2 /b 2 + z 2 /c 2 = 0! 2001, Denis Zorin

General quadrics Degenerate quadrics! planes (no quadratic terms),! pairs of parallel planes (e.g. x 2-1 = 0)! pairs of intersecting planes ( e.g. (x-1) x 2 2 = 0)! elliptic cylinders (e.g. x 2 +z 2-1=0)! hyperbolic cylinders (e.g. x 2 -z 2-1=0)! parabolic cylinders (e.g. x 2 -z = 0) Possible to get imaginary surfaces (that is, with no points)! Example: x 2 + 1 = 0! 2001, Denis Zorin

Transformations Two options: Apply transformation to the object and then intersect with ray Apply the inverse of the transformation to the ray and then intersect with untransformed object easier intersection comp. instances

Basic Algorithm For each pixel { } Shoot a ray from camera to pixel for all objects in scene Compute intersection with ray Find object with closest intersection Display color using object + light property

Closest Intersection Each object intersection routine should return a t value. One should keep track of the smallest nonnegative t entry among all objects. By the time all objects are processed we should know the object id and the position of point on primitive.

Basic Algorithm For each pixel { } Shoot a ray from camera to pixel for all objects in scene Compute intersection with ray Find object with closest intersection Display color using object + light property

Color Color - Light and Material Properties For each pixel - compute value for each color component separately if no light - flat shading: pixel gets color of object if there s light - many more things to consider... solid/image texture

http://www.geocities.com/jamisbuck/raytracing.html Ray Casting vs. Ray Tracing Ray Casting only finds visible surfaces given a point of view. Ray Tracing allows for more rays to be shot from the visible surface point to compute lighting effects ; shadows, reflection, refraction Ray Tracing can be defined as a recursion... a TREE! secondary rays!

Lighting and Shadows One needs to include contribution from all light sources How to do with ray tracing: Shoot rays to all light sources!

Lighting and Shadows We have : the point of intersection. We can compute normals using object information + transformation. From that point - shoot (shadow) rays to each (point) light source n

Shadow Algorithm At intersection point p for all light sources s: Shoot a ray from pε to s. If the ray hits an object else No need to compute closest intersection, position etc. in shadow i.e. no contribution from that light add contribution from light using normal and light/object properties

Plus, the change in sign in V!! Refraction (for dielectrics) Reflection

Ray tracing For each pixel shoot a ray R from camera; pixel = TraceRay(R) The recursive ray tracing procedure: RGBvalue TraceRay(Ray R) shoot rays to all light sources; for all visible sources, compute RGB values r i shoot reflected ray R refl ; r refl =TraceRay(R refl ) shoot refracted ray R trans ;r trans = TraceRay(R trans ) compute resulting RGB value from r i, r refl, r trans using the lighting model! 2001, Denis Zorin

One Lighting Model (From POV-Ray!) Given M visible light sources from a point with colors: <ri,gi,bi> for i=1:m Object color <m r,mg,mb,mf> And the lighting parameters: For red only: final color = M i=1 (1 m f )r i (k diff m r (N, L i ) + k spec m r (R, L i ) p )+ (1 m f )k amb m r r amb + Li :direction to light source i, Ni : normal, Ri : reflected direction k refl r refl + m f m r r trans

Infinite trace? maximum depth generate reflected ray only if specular color of object at intersection point is non-zero

Efficiency Issues Approximately 95% of the time in ray tracing is spend on intersection tests Three basic approaches for speed-up To compute fewer intersections : adaptive depth control, adaptive sampling To use generalized rays - beams, cones To compute intersections faster - bounding boxes (boolean), hierarchical bbs, spatial subdivision

Constructive Solid Geometry CSG: Using set operations for solid shapes http://escience.anu.edu.au/lecture/cg/surfacemodeling/csg_tree.en.html http://www.cs.utah.edu/~shirley/fcg/figures/ray/ If only an image is needed - need not change the models

Constructive Solid Geometry Find all intersections with a model, instead of just the closest. find intervals where a ray is inside the object Do set operations on intervals http://www.cs.utah.edu/~shirley/fcg/figures/ray/

Other Effects Distribution Ray Tracing Antialiasing - using samples within a pixel

Other Effects Distribution Ray Tracing Antialiasing - using samples within a pixel Soft Shadows

Other Effects Distribution Ray Tracing Antialiasing - using samples within a pixel Soft Shadows Depth of Field

Other Effects Distribution Ray Tracing Antialiasing - using samples within a pixel Soft Shadows Depth of Field Motion Blur - rays shot within a time interval

Hw Notes

Hw7 Download and experiment with POV-Ray Starting point: Create a base Shape class with virtual functions to compute intersections. Derive each shape from this class Implement sphere, polygon, cylinder,box, quadric with corresponding intersection functions. easy to add bounding boxes, new shapes, etc.

Hw Notes : General Organization Two main parts : Rendering engine + modules to manage parameters (objects,camera, lights, etc) Use a base Shape Class with virtual functions to compute intersections. Derive each shape from this class Create a ray data structure: origin, direction, color Vector class Parser

Hw Notes: Transformations Two Approaches: Can transform each object before rendering Transform the ray to object s coord system When intersecting a ray with a transformed object, apply inverse of the transformation to the ray. (i.e. multiply origin and direction of ray with inverse transformation matrix) Can store the inverse of the transformation matrix with the object

Hw Notes: Ray Tracing Note that your homework is far from a complete ray tracer. You need at least A Lighting Model based on object properties, including reflection, refraction Recursive ray tracing. ( for hw we only use cameraobject, object-light source) Possibly a speed up - e.g. bounding boxes A simple lighting model is provided with the hw description, feel free to implement that or anything else from this list for extra credit.