Computer Graphics and Image Processing Ray Tracing I

Similar documents
Intro to Ray-Tracing & Ray-Surface Acceleration

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

Ray Tracing Foley & Van Dam, Chapters 15 and 16

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

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

1999, Denis Zorin. Ray tracing

CS 563 Advanced Topics in Computer Graphics Lecture 2: Bare-Bones Raytracer. by Emmanuel Agu

COMPLETION OF Z-buffer Graphics Pipeline

CS 4204 Computer Graphics

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

Supplement to Lecture 16

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

Ray casting. Ray casting/ray tracing

Ray Tracing. Outline. Ray Tracing: History

Lecture 11: Ray tracing (cont.)

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

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

Assignment 6: Ray Tracing

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

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

Lecture 11. More Ray Casting/Tracing

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

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

INFOGR Computer Graphics

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

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

Computer Graphics Ray Casting. Matthias Teschner

Ray Tracing. Shandong University

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

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

Computer Graphics Global Illumination

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

Photorealism: Ray Tracing

Viewing and Ray Tracing. CS 4620 Lecture 4

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

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

Viewing and Ray Tracing

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

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

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

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

Ray Tracing I. Internet Raytracing Competition

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 3: Ray Tracing (Introduction) Welcome!

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

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

Computer Graphics Global Illumination

CPSC GLOBAL ILLUMINATION

Ray Tracer Due date: April 27, 2011

Sung-Eui Yoon ( 윤성의 )

Ray Tracing. Kjetil Babington

Photorealism. Photorealism: Ray Tracing. Ray Tracing

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

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

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

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

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

Shading, Advanced Rendering. Week 7, Wed Feb 28

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

To Shading and Beyond. CS 6965 Fall 2011

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

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

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

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

Last week. Machiraju/Zhang/Möller

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

Ray-Tracing. Misha Kazhdan

Questions??? Announcements Assignment 3 due today

The University of Calgary

Intersecting Simple Surfaces. Dr. Scott Schaefer

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

Lecture 10: Ray tracing

Ray Tracing I. History

Ray Tracing I: Basics

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

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

Raycasting. Chapter Raycasting foundations. When you look at an object, like the ball in the picture to the left, what do

COMP371 COMPUTER GRAPHICS

3D Rendering and Ray Casting

CS 543: Computer Graphics Lecture 10 (Part II): Raytracing (Part II) Emmanuel Agu

3D Rendering and Ray Casting

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Hidden Surface Elimination Raytracing. Pre-lecture business. Outline for today. Review Quiz. Image-Space vs. Object-Space

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

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

Ray Tracing CSCI 4239/5239 Advanced Computer Graphics Spring 2018

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Ray Tracing. Brian Curless CSEP 557 Fall 2016

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

Ray Casting. Connelly Barnes CS 4810: Graphics

Topics and things to know about them:

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

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

Geometric Queries for Ray Tracing

Particle systems, collision detection, and ray tracing. Computer Graphics CSE 167 Lecture 17

Input Nodes. Surface Input. Surface Input Nodal Motion Nodal Displacement Instance Generator Light Flocking

CEng 477 Introduction to Computer Graphics Fall 2007

782 Schedule & Notes

CS 4620 Midterm, March 21, 2017

Ray tracing. EECS 487 March 19,

Transcription:

Computer Graphics and Image Processing Ray Tracing I Part 1 Lecture 9 1 Today s Outline Introduction to Ray Tracing Ray Casting Intersecting Rays with Primitives Intersecting Rays with Transformed Primitives 2

INTRODUCTION TO RAY TRACING Images thanks to Henrik and Tim Babb 3 Ray Tracing Image Gallery T. Whitted,1979 (44 mins on VAX) A Dirty Lab M. Borbely, 2000 Internet Ray Tracing Competition Winner Terragen, thanks to T1g4h 4

Introduction to Ray Tracing Polygon Rendering Visible polygons are projected onto a view plane Polygons made more realistic with texture mapping and shading Considers only a single light reflection per pixel (no reflections of scene on water, ) No refraction, no proper shadows Ray Tracing Calculate the path of light rays Trace a light ray through several reflections, refractions, Proper shadows where light rays do not hit a surface directly Much slower than polygon rendering, but can be photorealistic! 5 How to Trace Rays? 1. Trace light rays starting from a light source Physically accurate Essentially unlimited number of rays Only a small fraction actually reaches the eye Very, very slow for CGI, but possible ( Monte-Carlo) 2. Trace only the light rays that hit the eye backwards Not as accurate, but much faster!!! Can follow the ray backwards through as many reflections and refractions as we like For each object-ray intersection, we can calculate reflected light using an illumination model 6

RAY CASTING Image thanks to Henrik Comanche, 1992 7 Looking through the View Plane What do we see through pixel (c,r) for all c and r? Trace rays from eye into scene Describe each point p on ray going through eye in direction D by: p = eye + t d (one point for each t) eye d Hill textbook, Fig. 14.1 8

Setting Up the View Plane Given: Camera position eye View coord. system axes (u, v, n) View plane width 2W View plane height 2H View plane distance from eye N (usually N = 1) Number of pixel rows nrows and pixel columns ncols in view plane Wanted: ray (startpoint, direction) from eye through every pixel startpoint is always eye Center of view plane: center = eye N n 9 n Constructing Rays Wanted: ray (startpoint, direction) from eye through every pixel Corners of the view plane in world coords: bottomleft = centre - Wu - Hv bottomright = centre + Wu - Hv topleft = centre - Wu + Hv topright = centre + Wu - Hv Go through all pixels, with column 0 and row 0 at bottomleft Ray direction d = pixelpos - eye 2c 2r d= Nn+ W 1 u+ H 1 v ncols nrows 10

Ray Casting Algorithm define scene = ({ objects }, { lights }) define camera (eye, u, v, n) for (int r = 0; r < nrows; r++) { for (int c = 0; c < ncols; c++) { construct ray going through (c, r) find closest intersection of ray with an object (smallest t) find intersection point P get the surface normal at P pixel(c, r) = the color at P as seen by the eye } } 11 INTERSECTING RAYS WITH PRIMITIVES 12

Ray-Object Intersection Define each object as an implicit function f: f(p) = 0 for every point p on the surface of the object (if p is not on surface, then f(p) 0) Examples for simple objects ( primitives ): Sphere (center at origin, radius 1) f(p) = x 2 + y 2 + z 2 1 = p 2 1 Cylinder (around z-axis, radius 1) f(p) = x 2 + y 2 1 Where a ray (eye + d t) meets the object: f(eye + d t) = 0 solve for t and get intersection point eye + d t 13 Ray-Plane Intersection Implicit function for plane (normal n, distance a from origin): p n a = 0 Intersection when (eye + t d) n a = 0 i.e. eye n t= a d n If d n=0 then ray parallel to plane (ignore plane) If t negative then ray directed away from plane (no intersection that can be seen) 14

Ray-Triangle Intersection Normal n = (B-A) (C-A) Implicit function for corresponding plane: (p-a) n = 0 Intersection with plane when (eye + t d - A) n = 0 i.e. eye-a) n t= ( d n Is the ray-plane intersection at p=(eye + t d) inside the triangle? Calculate scalars for three cross products (normals for the plane): ((B-A) (p-a)) n and ((C-B) (p-b)) n and ((A-C) (p-c)) n If they all have the same sign (e.g. all positive) then p is inside the triangle Each tests if p is on the inside or outside of one of the edges If p on the inside of an edge, then normal is directed towards us 15 C A B Ray-Sphere Intersection Implicit function for sphere (center at origin, radius 1): p p 1 = 0 Intersection when (eye + t d) (eye + t d) 1 = 0 i.e. d d t 2 + 2 eye d t+ eye eye 1= 0 Solve quadratic equation for t t 1,2 2 B± B 4AC = 2A with A=d d B=2 eye d C= eye eye-1 If (B 2-4AC)<0 then ray misses sphere If (B 2-4AC)=0 then ray grazes sphere (treat as miss) If (B 2-4AC)>0 then one t for entry and one t for exit point (use smaller t for intersection, closer to eye) 16

Ray-Cylinder Intersection Implicit function for cylinder (one end at origin, radius 1, length 1): x 2 + y 2 1 = 0 and 0 z 1 Intersection when 0 eye z + t d z 1 and (eye x + t d x ) (eye x + t d x ) + (eye y + t d y ) (eye y + t d y ) 1 = 0 i.e. 2 2 2 (d + d ) t + 2( eyed + eye d ) t+ eye x y + eye Solve quadratic equation for t (same as for sphere) Check if 0 eye z + t d z 1 (otherwise miss) x x 1= 0 Note: cylinder is open at the ends and hollow on the inside y y 2 x 2 y 17 INTERSECTING RAYS WITH TRANSFORMED PRIMITIVES 18

Transformed Primitives Problem: How to intersect with transformed primitives? (e.g. scaled and translated unit sphere) Primitive Space M World Space M -1 Solution: intersection of ray with transformed primitive is the same as intersection with inversely transformed ray and primitive Intersect with transformed ray (eye t + d t t) i.e. eye t = M -1 eye and d t = M -1 d t for the intersection is the same in world and primitive space 19 Transformed Primitives T - 1 % S x cx S c % % S z cz 1 0 Note this 1 y 1 y r ( t) = M + M t = S + c t 2004 Lewis Hitchner, Richard Lobb & Kevin Novins

Transformed Primitives G p ij = r ij G M*G p ij = r ij M*G r ij = s + c ij t r ij = s + c ij t G = M -1 (M*G) 2004 Lewis Hitchner, Richard Lobb & Kevin Novins SUMMARY 22

Summary 1. Ray tracing is slow, but can give us photorealistic images Tracing the light rays that hit the eye backwards Trace each light ray through several reflections, refractions, 2. Ray casting: simple form of ray tracing Trace one ray per screen pixel Trace only until it hits an object (i.e. only one reflection) 3. Calculate ray-object intersections by putting ray equation into implicit object function and solving for t References: Introduction to Ray Tracing: Hill, Chapters 12.1-12.3 Ray-Object Intersection: Hill, Chapter 12.4 23 Quiz 1. What is ray tracing? Give a brief general description. 2. Give pseudo-code for the ray casting algorithm. 3. What is the general approach when looking for a ray-object intersection? 4. What is the common approach when looking for intersections with transformed primitives? 24