Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections 14.7.1 and 14.7.2.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Lecture 14 Illumination II – Global Models
3D Graphics Rendering and Terrain Modeling
Light Issues in Computer Graphics Presented by Saleema Amershi.
Christian Lauterbach COMP 770, 2/11/2009
Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Ray Tracing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of.
MC930/MO603 Ray Casting. Light is bouncing photons.
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Now Playing: Melody Day Caribou from Andorra Released August 21, 2007.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
Photorealism Reflection, Refraction Bump maps
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest.
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Ray Tracing 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Now Playing: Quicksand Under Carpet New Radiant Storm King from Leftover Blues: Released 2004.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Presentation by Dr. David Cline Oklahoma State University
CSE 681 Ray Tracing Geometry. The Camera Model Based on a simpile pin-hole camera model –Simplest lens model –Pure geometric optics – based on similar.
Computer graphics & visualization Ray-Tracing – A Quick review.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
-Global Illumination Techniques
1 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Basic Ray Tracing CMSC 435/634.
Ray Tracing. 2 Introduction OpenGL is based on a pipeline model in which primitives are rendered one at time ­No shadows (except by tricks or multiple.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CS 480/680 Computer Graphics Compositing and Blending Dr. Frederick C Harris, Jr.
MIT EECS 6.837, Cutler and Durand 1 Ray Casting II.
CSCE 441: Computer Graphics Ray Tracing
In the name of God Computer Graphics. Last Time Some techniques for modeling Today Global illumination and raytracing.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Introduction to Computer Graphics with WebGL
Ray Tracing Ed Angel Professor Emeritus of Computer Science
MIT EECS 6.837, Cutler and Durand
Ray Tracing Forward Ray Tracing
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Tracing Geometry CSE 681.
Ray Tracing Geometry CSE 681.
Ray Casting II MIT EECS Frédo Durand and Barb Cutler
Introduction to Computer Graphics with WebGL
Ray Tracing.
Image synthesis using classical optics
GR2 Advanced Computer Graphics AGR
Presentation transcript:

Ray Tracing I

Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and

References Hill Chapter 14 Specialized books: Online resources

Outline Introduction Camera and Ray Generation Ray-Sphere Intersection Ray-Plane Intersection Writing a Ray Tracer Shadows Recursive Ray Tracing

BRDF Dan Lemmon - Global Illumination: A Brief Overview

Phong Illumination

Phong vs. Reality

Arnold Ray Tracer

Global Illumination in Games

Ray Casting For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest

Durer’s Ray casting machine Albrecht Durer, 16 th century

Durer’s Ray casting machine Albrecht Durer, 16 th century

Arthur Appel, 1968 “On calculating the illusion of reality”, 1968 Cast one ray per pixel (ray casting). For each intersection, trace one ray to the light to check for shadows Only a local illumination model Developed for pen-plotters V V L L

Ray Casting Image by Henrik Wann Jensen

Turner Whitted, 1980 “An Improved Illumination Model for Shaded Display”, 1980 First global illumination model. An object’s color is influenced by lights and other objects in the scene First to simulate specular reflection and refractive transmission V T L R L R T R R

Ray Tracing Original Ray-traced image by Whitted Image computed using the Dali ray tracer by Henrik Wann Jensen

Ray Tracing Image computed using the Dali ray tracer from Henrik Wann Jensen Model Stephen Duck

Outline Introduction  Camera and Ray Generation Ray-Sphere Intersection Ray-Plane Intersection Writing a Ray Tracer Shadows Recursive Ray Tracing

Cameras For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest

Ray Representation A parametric line:  Origin  Direction (normalized is better) p(t) = origin + t * direction origin direction p(t)

Pinhole Camera Box with a tiny hole Inverted image Pure geometric optics

Simplified Pinhole Camera Eye-image pyramid (frustum)

Durer’s Ray Casting Machine Albrecht Durer, 16 th century

Perspective Camera Eye point Look-At Point Up Vector Horizontal FOV (degrees) Look-At Up Eye

Perspective Ray Generation

Outline Introduction Camera and Ray Generation  Ray-Sphere Intersection Ray-Plane Intersection Writing a Ray Tracer Shadows Recursive Ray Tracing

Implicit Sphere Equation Implicit sphere equation: ||P|| 2 = r 2 Assume sphere is centered at the origin - easy to translate origin direction

Ray-Sphere Intersection Implicit sphere equation: ||P|| 2 = r 2 Parametric ray equation: p(t) = O + t d with || d || = 1 Intersection means both are satisfied origin direction

Ray-Sphere Intersection

This is just a quadratic at 2 + bt + c = 0, where  a = 1  b = 2 d  O  c = O  O – r 2 With discriminant and solutions

Ray-Sphere Intersection Three cases, depending on sign of b 2 – 4ac Which root (t+ or t-) should you choose?  Closest positive! (usually t-)

Ray-Sphere Intersection So easy that all ray-tracing images have spheres!

Geometric Ray-Sphere Intersection Try to shortcut (easy reject) E.g., if the ray is facing away from the sphere Geometric considerations can help In general, early reject is important r S

Geometric Ray-Sphere Intersection What geometric information is important?  Inside / outside  Closest point  Direction O r S d

Geometric Ray-Sphere Intersection Check if the ray’s origin is outside the sphere  ||O|| 2 > r 2  If inside, it intersects  If on the sphere, it does not intersect Avoid degeneracy with epsilon test (later) O r S d

Geometric Ray-Sphere Intersection If the ray’s origin is outside the sphere Find the closest point P to the sphere center  t P = OS d  If t P < 0: Ray points away from the sphere, no hit O r S d tPtP P

Geometric Ray-Sphere Intersection Else find squared distance e 2  Pythagoras: e 2 = OS 2 - t P 2  if e 2 > r 2 : Ray misses sphere, no hit O r S d P tPtP e

Geometric Ray-Sphere Intersection t’ 2 + e 2 = r 2 If ray starts outside sphere: t = t P - t’ If ray starts inside sphere: t = t P + t’ O r S d P tPtP e t t’

Geometric vs. Algebraic Algebraic was simpler (and more generic) Geometric is more efficient  Timely tests  In particular for outside and pointing away

Normal Simply (I(t)-S) / r O r S d t n I(t)

Precision Problems In ray tracing, the origin of (secondary) rays is often on the surface of objects Theoretically, t = 0 for these rays In practice, calculation imprecision creeps in, and the origin of the new ray is slightly beneath the surface This could lead to a situation where a surface area is shadowing itself…

 to the rescue… Check if t is within some epsilon tolerance:  if abs(t) < eps // eps = 0.01 point is on the sphere  else point is inside/outside  Choose the epsilon 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

Outline Introduction Camera and Ray Generation Ray-Sphere Intersection  Ray-Plane Intersection Writing a Ray Tracer Shadows Recursive Ray Tracing

Implicit Plane Equation Given a point A on the plane and the normal n, any point P on the plane must satisfy: n A P v

Implicit Plane Equation Suppose n = [a, b, c] T and P=[x, y, z] T : Every plane perpendicular to n = [a, b, c] T has an implicit equation: The value d = 0 gives a plane through the origin Different values of d give parallel planes

Implicit Plane Equation Implicit plane equation ax + by + cz + d = 0 Plane defined by  P 0 = [x, y, z, 1] T  n = [a, b, c, 0] T

Line-Plane Intersection Insert parametric equation of the line into the implicit equation of the plane Origin Direction P(t)

Additional House Keeping Verify that intersection is closer than previous Verify that it is in the allowed range  t<0: intersection is behind the camera O d p(t)

Headed towards plane? Dot product with normal if t n = 0: Ray parallel to plane; no intersection if t n < 0: Normal is pointing away from ray (may be culled)* if t n > 0: Ray hits plane *Reverse plane normal so that ray intersects:

Intersection Calculation Ray expression: Substitute into plane equation: Solve for t: If t < 0: ray intersects plane behind O

The Algorithm

Normal Use the normal to the plane from the implicit equation Normal Origin Direction P(t)

Outline Introduction Camera and Ray Generation Ray-Sphere Intersection Ray-Plane Intersection  Writing a Ray Tracer Shadows Recursive Ray Tracing

Object-Oriented Design We want to be able to add primitives easily  Inheritance and virtual methods Even the scene is derived from Object3D Object3D bool intersect(Ray, Hit, tmin) Plane bool intersect(Ray, Hit, tmin ) Sphere bool intersect(Ray, Hit, tmin) Triangle bool intersect(Ray, Hit, tmin) Group bool intersect(Ray, Hit, tmin)

Ray ////////// class Ray { ////////// Ray () {} Ray (const Vec3f &dir, const Vec3f &orig) {_dir =dir; _orig=orig;} Ray (const Ray& r) {*this=r;} const Vec3f &origin() {return _orig;} const Vec3f &direction() {return &dir;} Vec3f pointAtParameter (float t) {return _orig+t*_dir;} private: Vec3f _dir; Vec3f _orig; };

Hit Stores intersection point and various information ///////// class Hit { ///////// float _t; Vec3f _color; Material *_material; Vec3f _normal; };

Shaders ( Material Class) Functions executed when light interacts with a surface Constructor:  Set shader parameters Inputs:  Incident radiance (lights)  Incident & reflected viewing directions Output:  Reflected radiance

Outline Introduction Camera and Ray Generation Ray-Sphere Intersection Ray-Plane Intersection Writing a Ray Tracer  Shadows Recursive Ray Tracing

Ray Tracing with Shadows Image Henrik Wann Jensen

Outline Introduction Camera and Ray Generation Ray-Sphere Intersection Ray-Plane Intersection Writing a Ray Tracer Shadows  Recursive Ray Tracing

Turner Whitted, 1980 “An Improved Illumination Model for Shaded Display”, 1980 First global illumination model. An object’s color is influenced by lights and other objects in the scene First to simulate specular reflection and refractive transmission V T L R L R T R R

Does it ever end? Stopping criteria:  Recursion depth: Stop after a number of bounces  Ray contribution: Stop if reflected / transmitted contribution becomes too small 1 recursion0 recursion2 recursions