Questions??? Announcements Assignment 3 due today

Similar documents
Geometric Queries for Ray Tracing

8.1 Geometric Queries for Ray Tracing

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

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

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

COMP371 COMPUTER GRAPHICS

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

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

CPSC GLOBAL ILLUMINATION

Photorealism: Ray Tracing

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Lecture 11: Ray tracing (cont.)

Intro to Ray-Tracing & Ray-Surface Acceleration

Supplement to Lecture 16

Shading, Advanced Rendering. Week 7, Wed Feb 28

Raytracing CS148 AS3. Due :59pm PDT

CS5620 Intro to Computer Graphics

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

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

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

Topics and things to know about them:

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required:

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required: Watt, sections , (handout) Further reading:

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

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

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

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

1999, Denis Zorin. Ray tracing

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

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

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

Ray Tracing. Outline. Ray Tracing: History

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

CS 488. More Shading and Illumination. Luc RENAMBOT

A Little Background. Motivation. Motivation

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

Visualisatie BMT. Rendering. Arjan Kok

Computer Graphics I Lecture 11

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

Homework #2. Shading, Ray Tracing, and Texture Mapping

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

CS 325 Computer Graphics

Sung-Eui Yoon ( 윤성의 )

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

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

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

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

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

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

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Ray-tracing Cont. Ray-tracing

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

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

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Raytracing. COSC 4328/5327 Scott A. King

Photorealism. Photorealism: Ray Tracing. Ray Tracing

Comp 410/510 Computer Graphics. Spring Shading

Ray tracing Tutorial. Lukas Herzberger

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

Ray Tracing COMP575/COMP770

CS 130 Exam I. Fall 2015

Virtual Reality for Human Computer Interaction

Ray Tracer Due date: April 27, 2011

COMP environment mapping Mar. 12, r = 2n(n v) v

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

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

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Computer Graphics Ray Casting. Matthias Teschner

Simple Lighting/Illumination Models

CS770/870 Spring 2017 Ray Tracing Implementation

Photorealism CS 460/560. Shadows Ray Tracing Texture Mapping Radiosity. Computer Graphics. Binghamton University. EngiNet. Thomas J.

CPSC / Texture Mapping

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

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

Ray Tracing. Shandong University

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

Viewing and Ray Tracing

3D Rendering and Ray Casting

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

Review for Ray-tracing Algorithm and Hardware

CS 130 Exam I. Fall 2015

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Interpolation using scanline algorithm

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

DH2323 DGI13. Lab 2 Raytracing

Computer Graphics. Shi-Min Hu. Tsinghua University

Assignment 6: Ray Tracing

Lighting and Shading

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Viewing and Ray Tracing. CS 4620 Lecture 4

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

Photorealism. Ray Tracing Texture Mapping Radiosity

3D Rendering and Ray Casting

Ray Tracing I. Internet Raytracing Competition

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

Transcription:

Announcements Assignment 3 due today Questions??? Remember that you have late days (if you haven t used them yet ) Problem set 3 out at the end of the day Movie for Assignment 2 at the end of class 1

Ray Casting Forward & Backward Ray Tracing Ray Casting Ray-Surface Intersection Testing Barycentric Coordinates Watt 1.4 and 12 11/5/02

Global vs. Local Rendering Models We ve been talking about local rendering models. The color of one object is independent of its neighbors (except for shadows) Missing scattering of light between objects, real shadowing Global Rendering Models Raytracing specular highlights Radiosity diffuse surfaces, closed environments 3

Light is Bouncing Photons Light sources send off photons in all directions Model these as particles that bounce off objects in the scene Each photon has a wavelength and energy (color and intensity) When photons bounce, some energy is absorbed, some reflected, some transmitted If we can model photon bounces we can generate images Technique: follow each photon from the light source until: All of its energy is absorbed (after too many bounces) It departs the known universe It strikes the image and its contribution is added to appropriate pixel 4

Forward Ray Tracing Rays are the paths of these photons This method of rendering by following photon paths is called ray tracing Forward ray tracing follows the photon in direction that light travels (from the source) BIG problem with this approach: Only a tiny fraction of rays reach the image Extremely slow Ideal Scenario: We'd like to magically know which rays will eventually contribute to the image, and trace only those 5

Backward Ray Tracing The solution is to start from the image and trace backwards - backward ray tracing Start from the image and follow the ray until the ray finds (or fails to find) a light source 6

Basic ideas: Backward Ray Tracing Each pixel gets light from just one direction - the line through the image point and focal point Any photon contributing to that pixel s color has to come from this direction So head in that direction and find out what is sending light this way If we hit a light source - we re done If we find nothing - we re done If we hit a surface - see where that surface is lit from At the end we ve done forward ray tracing, but ONLY for the rays that contribute to the image 7

Ray Casting This version of ray tracing is often called ray casting The algorithm is loop y loop x shoot ray from eye point through pixel (x,y) into scene intersect with all surfaces, find first one the ray hits shade that point to compute pixel (x,y) s color (perhaps simulating shadows as we discussed earlier) A ray is p+td: p is ray origin, d the 3D direction t=0 at origin of ray, t>0 in positive direction of ray typically assume d =1 p and d are typically computed in world space This is easily generalized to give recursive ray tracing... 8

Recursive Ray Tracing We ll distinguish four ray types: Eye rays: originate at the eye Shadow rays: from surface point toward light source Reflection rays: from surface point in mirror direction Transmission rays: from surface point in refracted direction Trace all of these recursively. More on this later. 9

Writing a Simple Ray Caster (no bounces) Raycast() // generate a picture for each pixel x,y color(pixel) = Trace(ray_through_pixel(x,y)) Trace(ray) // fire a ray, return RGB radiance // of light traveling backward along it object_point = Closest_intersection(ray) if object_point return Shade(object_point, ray) else return Background_Color Closest_intersection(ray) for each surface in scene calc_intersection(ray, surface) return the closest point of intersection to viewer (also return other info about that point, e.g., surface normal, material properties, etc.) Shade(point, ray) // return radiance of light leaving // point in opposite of ray direction calculate surface normal vector use Phong illumination formula (or something similar) to calculate contributions of each light source 10

Ray-Surface Intersections Ray equation: (given origin p and direction d) x(t) =p+td Surfaces can be represented by: Implicit functions: f(x) = 0 Parametric functions: x = g(u,v) Compute Intersections: Substitute ray equation for x Find roots Implicit: f(p +td) =0» one equation in one unknown univariate root finding Parametric: p + td -g(u,v) = 0» three equations in three unknowns (t,u,v) multivariate root finding For univariate polynomials, use closed form solution otherwise use numerical root finder 11

The Devil s in the Details Solving these intersection equations can be tough... General case: non-linear root finding problem Simple surfaces can yield a closed-form solution But generally a numerical root-finding method is required» Expensive to calculate» Won t always converge» When repeated millions of times, special cases WILL occur The good news: Ray tracing is simplified using object-oriented techniques» Implement one intersection method for each type of surface primitive» Each surface handles its own intersection Some surfaces yield closed form solutions:» quadrics: spheres, cylinders, cones, ellipsoids, etc» polygons» tori, superquadrics, low-order spline surface patches 12

Ray-Sphere Intersection Ray-sphere intersection is an easy case A sphere s implicit function is x 2 +y 2 +z 2 -r 2 =0 if sphere at origin The ray equation is: x=p x +td x y=p y +td y z=p z +td z Substitution gives: (p x +td x ) 2 +(p y +td y ) 2 +(p z +td z ) 2 -r 2 =0 A quadratic equation in t. Solve the standard way: A = d x2 +d y2 +d z2 =1(unit vec.) At 2 +Bt+C=0 B=2(p x d x +p y d y +p z d z ) C=p x2 +p y2 +p z2 -r 2 13

Ray-Sphere Intersection continued Quadratic formula has two roots: t=(-b±sqrt(b 2-4C))/2 Real roots correspond to the two intersection points Negative determinant means ray misses sphere Determinant = 0 means ray grazes sphere ( B 2 4C < 0) We also need the normal, for sphere centered at N = x l r y m r i i,, z i n ÿ r ( l, m, n) 14

Ray-Polygon Intersection Assuming we have a planar polygon first, find intersection point of ray with plane that contains polygon then check if that point is inside the polygon Intersection of ray with polygon the easy way (faster way in a minute): ax + by + cy + d = 0 x y z t = = = x y z = 1 1 1 + it + + ax 1 jt kt + by1 + cz1 + d ai + bj + ck ai + bj + ck = 0 ray/plane parallel 15

Ray-Polygon Intersection Assuming we have a planar polygon first, find intersection point of ray with plane that contains polygon then check if that point is inside the polygon Latter step is a point-in-polygon test in 3-D: inputs: a point x in 3-D and the vertices of a polygon in 3-D output: INSIDE or OUTSIDE problem can be reduced to point-in-polygon test in 2-D Point-in-polygon test in 2-D: easiest for triangles easy for convex n-gons harder for concave polygons most common approach: subdivide all polygons into triangles for optimization tips, see article by Haines in the book Graphics Gems IV 16

Ray: x=p+td Ray-Plane Intersection again where p is ray origin, d is ray direction. we ll assume d =1 (this simplifies the algebra later) x(t)=(x,y,z) is point on ray if t>0 Plane: (x-q) n=0 where q is reference point on plane, n is plane normal. (some assume n =1; we won t) x is point on plane if what you re given is vertices of a polygon» compute n with cross product of two (non-parallel) edges» use one of the vertices for q rewrite plane equation as x n+d=0» equivalent to the familiar formula Ax+By+Cz+D=0, where (A,B,C)=n, D=-q n» fewer values to store Steps: substitute ray formula into plane equation, yielding 1 equation in 1 unknown (t). solution: t =-(p n+d)/(d n)» note: if d n=0 then ray and plane are parallel - REJECT» note: if t<0 then intersection with plane is behind ray origin - REJECT compute t, plug it into ray equation to compute point x on plane 17

Projecting A Polygon from 3-D to 2-D Point-in-polygon testing is simpler and faster if we do it in 2-D The simplest projections to compute are to the xy, yz, orzx planes If the polygon has plane equation Ax+By+Cz+D=0, then» A is proportional to projection of polygon in yz plane» B is proportional to projection of polygon in zx plane» C is proportional to projection of polygon in xy plane» Example: the plane z=3 has (A,B,C,D)=(0,0,1,-3), so C is the largest and xy projection is best. We should do point-in-polygon testing using x and y coords. In other words, project into the plane for which the perpendicular component of the normal vector n is largest to maintain accuracy Optimization: We should optimize the inner loop (ray-triangle intersection testing) as much as possible We can determine which plane to project to, for each triangle, as a preprocess 18

Digression before we get to point-in-polygon testing: Interpolated Shading for Ray Tracing Suppose we know colors or normals at vertices How do we compute the color/normal of a specified point inside? Color depends on distance to each vertex Want this to be linear (so we get same answer as scanline algorithm such as Gouraud or Phong shading) But how to do linear interpolation between 3 points? Answer: barycentric coordinates Useful for ray-triangle intersection testing too! 19

Barycentric Coordinates in 1-D Linear interpolation between colors C 0 and C 1 by t C = (1 t )C 0 + tc 1 We can rewrite this as C = αc 0 + βc 1 where α + β =1 C is between C 0 and C 1 α, β [0,1] Geometric intuition: We are weighting each vertex by ratio of distances (or areas in the 2d case) C C 0 C1 β α α and β are called barycentric coordinates 20

Barycentric Coordinates in 2-D Now suppose we have 3 points instead of 2 C 1 C C 2 C 0 Define three barycentric coordinates: α, β, γ C = where α + β + γ = 1 αc0 + βc1 + γc2 C0C1C2 C is inside How to define α, β, and γ? α, β, γ [0,1] 21

Barycentric Coordinates for a Triangle Define barycentric coordinates to be ratios of triangle areas C 0 γ C 1 C β α C 2 α = β = γ = Area Area Area Area Area Area ( CC1C2) ( C0C1C2) ( C0CC2) ( C0C1C2) ( C0C1C) ( C C C ) 0 1 2 = 1 α β 22

Computing Area of a Triangle in3-d C A B Area(ABC) = parallelogram area / 2 = (B-A) x (C-A) /2 faster: project to xy, yz, orzx, use2dformula in2-d Area(xy-projection(ABC)) = [(b x -a x )(c y -a y ) (c x -a x )(b y -a y )]/2 project A,B,C to xy plane, take z component of cross product positive if ABC is CCW (counterclockwise) Explained on next slide 23

24 Computing Area of a Triangle - Algebra That short formula, Area(ABC) = [(b x -a x )(c y -a y ) (c x -a x )(b y -a y )]/2 Where did it come from? 2 ) / ( 2 / 1 1 1 ) ( 2 1 y x y x y x y x y x y x y y x x y y x x y y x x y y y x x x a b b a c a a c b c c b b a b a a c a c c b c b c b a c b a ABC Area + + = ÿ ÿ + + = = a x b x c x c y a y b y The short & long formulas above agree. Short formula better because fewer multiplies. Speed is important! Can we explain the formulas geometrically?

Computing Area of a Triangle - Geometry Area(ABC) =[(b x -a x )(c y -a y ) (c x -a x )(b y -a y )]/2 is a sum of rectangle areas, divided by 2. (b [ x -a x )(c y -a y ) (c x -a x )(a y -b y ) ]? + /2 = /2 = c y a y a x b x c x b y c y /2 = a y =! =! since triangle area = base*height/2 b y a x b x c x it works! 25

Uses for Barycentric Coordinates Point-in-triangle testing! point is in triangle iff α, β, γ >0 note similarity to standard point-in-polygon methods that use tests of form a i x+b i y+c i <0 for each edge i N 1 γ α β N 2 Can use barycentric coordinates to interpolate any quantity Gouraud Shading (color interpolation) Phong Shading (normal interpolation) Texture mapping ((s,t) texture coordinate interpolation) N 0 26

Radiosity We ll return to ray tracing in the next lecture but for the moment, here s a digression on another global rendering method. Simple scene with diffuse surfaces White wall should show effect of being near red wall Compute light reflected between each pair of patches 27

Radiosity Examples http://www.autodesk.com/us/lightscape/examples/html/index.htm 28

Radiosity Closed environment (office, factory) Compute interaction between all patches (over which intensity is assumed to be constant) View independent Difficult to do specular highlights Most impressive images to date 29

Raytracing Examples http://www.med.osaka-u.ac.jp/pub/cl-comp/saito/raytr/saturn-img.html 30

Raytracing Examples http://www.povray.org/ 31

Raytracing Examples http://www.povray.org/ 32

Raytracing Examples http://www.povray.org/ 33

Radiosity Examples http://www.autodesk.com/us/lightscape/examples/html/index.htm 34

Radiosity Examples http://www.autodesk.com/us/lightscape/examples/html/index.htm 35

Radiosity Examples http://www.autodesk.com/us/lightscape/examples/html/index.htm 36

Announcements Assignment 3 due today Questions??? Remember that you have late days (if you haven t used them yet ) Problem set 3 out at the end of the day Movie for Assignment 2 at the end of class 37

38