MIT EECS 6.837, Cutler and Durand

Slides:



Advertisements
Similar presentations
Transformations in Ray Tracing MIT EECS 6.837, Durand and Cutler.
Advertisements

Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Transformations.
3D Graphics Rendering and Terrain Modeling
MIT EECS 6.837, Durand and Cutler Transformations.
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.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
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 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
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.
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.
1. 2 Plan Introduction Overview of the semester Administrivia Iterated Function Systems (fractals)
1 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
MIT EECS 6.837, Durand and Cutler Transformations.
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.
Computer Graphics Lecture 08 Fasih ur Rehman. Last Class Ray Tracing.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Projective Transformations.
MIT EECS 6.837, Cutler and Durand 1 Ray Casting II.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Line Clipping & Line Rasterization.
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.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Clipping & Line Rasterization.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Advanced Computer Graphics
Visible Surface Detection
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
CS262 – Computer Vision Lect 4 - Image Formation
Computer Graphics.
Image-based Lighting Computational Photography
Introduction to Computer Graphics with WebGL
Ray Tracing Ed Angel Professor Emeritus of Computer Science
Ray Tracing Forward Ray Tracing
CSCE 441 Computer Graphics 3-D Viewing
Hank Childs, University of Oregon
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Tracing Geometry CSE 681.
CS451Real-time Rendering Pipeline
Ray Tracing Geometry CSE 681.
© University of Wisconsin, CS559 Fall 2004
Merle Norman Cosmetics, Los Angeles
Viewing/Projections I Week 3, Fri Jan 25
Transformations.
CSCE 441: Computer Graphics Hidden Surface Removal
Ray Casting II MIT EECS Frédo Durand and Barb Cutler
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics with WebGL
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Ray Tracing.
Lecture 13 Clipping & Scan Conversion
GR2 Advanced Computer Graphics AGR
Simple Texture Mapping
Presentation transcript:

MIT EECS 6.837, Cutler and Durand Ray Casting Courtesy of James Arvo and David Kirk. Used with permission. MIT EECS 6.837 Frédo Durand and Barb Cutler Some slides courtesy of Leonard McMillan MIT EECS 6.837, Cutler and Durand 1

Administrative • Assignment 1 –Due Wednesday September 17 2 MIT EECS 6.837, Cutler and Durand

Calendar • 1st quiz –Tuesday October 07th • 2nd quiz --Thursday Nov 20th • Week Dec 1-5 project presentation • Last day of class: December 9: best projects & final report due 3 MIT EECS 6.837, Cutler and Durand

Questions? 4 MIT EECS 6.837, Cutler and Durand

Overview of the semester • Ray Tracing –Quiz 1 • Animation, modeling, IBMR –Choice of final project • Rendering pipeline –Quiz 2 • Advanced topics 5 MIT EECS 6.837, Cutler and Durand

Overview of today • Introduction • Camera and ray generation • Ray-plane intersection • Ray-sphere intersection 6 MIT EECS 6.837, Cutler and Durand

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 7 MIT EECS 6.837, Cutler and Durand

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 8 MIT EECS 6.837, Cutler and Durand

Ray Casting e.g. diffuse shading: dot product N.L a.k.a. Lambertian For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest e.g. diffuse shading: dot product N.L a.k.a. Lambertian 9 MIT EECS 6.837, Cutler and Durand

Ray Tracing • Secondary rays (shadows, reflection, refraction) • In a couple of weeks 10 MIT EECS 6.837, Cutler and Durand

Ray representation? 11 MIT EECS 6.837, Cutler and Durand

Ray representation •Two vectors: –Origin –Direction (normalized is better) •Parametric line –P(t) = origin + t * directionorigindirection 12 MIT EECS 6.837, Cutler and Durand

Ray Tracing Original Ray-traced image by Whitted • Image computed using the Dali ray tracer by HenrikWannJensen • Environment map by Paul Debevec Image removed due to copyright considerations. Image removed due to copyright considerations. 13 MIT EECS 6.837, Cutler and Durand

Ray casting For every pixel Construct a ray from the eye For every object in the scene Find intersectionwith the ray Keep if closest Shade depending on light and normalvector Finding the intersection and normal is the central part of ray casting 14 MIT EECS 6.837, Cutler and Durand

Overview of today •Introduction •Camera and ray generation •Ray-plane intersection •Ray-sphere intersection 15 MIT EECS 6.837, Cutler and Durand

Cameras For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest 16 MIT EECS 6.837, Cutler and Durand

Pinhole camera •Box with a tiny hole •Inverted image •Similar triangles • Perfect image if hole infinitely small •Pure geometric optics • No depth of field issue 17 MIT EECS 6.837, Cutler and Durand

Simplified pinhole camera • Eye-image pyramid (frustum) • Note that the distance/size of image are arbitrary 18 MIT EECS 6.837, Cutler and Durand

Camera description – Eye point e – Orthobasisu, v, w – Image distances – Image rectangle (u0, v0, u1, v1) – Deduce c (lower left) – Deduce a and b – Screen coordinates in [0,1]*[0,1] – A point is then c + x a +y 19 MIT EECS 6.837, Cutler and Durand

Alternative perspective encoding • 4x4 matrix & viewing frustum • More about that next week 20 MIT EECS 6.837, Cutler and Durand

Orthographic camera •Parallel projection •No foreshortening •No vanishing point perspective orthographic 21 MIT EECS 6.837, Cutler and Durand

Orthographic camera description 22 MIT EECS 6.837, Cutler and Durand

Orthographic camera description •Image size •Up vector •Direction •Image center 23 MIT EECS 6.837, Cutler and Durand

Orthographic ray generation •Direction is constant •Origin = center + (x-0.5)*size*up + (y-0.5)*size*horizontal 24 MIT EECS 6.837, Cutler and Durand

Other weird cameras •E.g. fish eye, omnimax, panorama 25 MIT EECS 6.837, Cutler and Durand

Overview oftoday •Introduction •Camera and ray generation •Ray-plane intersection •Ray-sphere intersection 26 MIT EECS 6.837, Cutler and Durand

Ray Casting First we will study ray-plane intersection For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest First we will study ray-plane intersection 27 MIT EECS 6.837, Cutler and Durand

Recall: Ray representation •Two vectors: –Origin –Direction (normalized) •Parametric line –P(t) = origin + t * directionorigindirection 28 MIT EECS 6.837, Cutler and Durand

3D plane equation •Implicit plane equation •Gradient of H? H(p) = Ax+By+Cz+D= 0 •Gradient of H? 29 MIT EECS 6.837, Cutler and Durand

3D plane equation • Implicit plane equation • Gradient of H? H(p) = Ax+By+Cz+D= 0 • Gradient of H? • Plane defined by –P0(x,y,z,1) –n(A, B, C, 1) 30 MIT EECS 6.837, Cutler and Durand

Explicit vs. implicit? • Plane equation is implicit –Solution of an equation –Does not tell us how to generate a point on the plane –Tells us how to check that a point is on the plane • Ray equation is explicit –Parametric –How to generate points –Harder to verify that a point is on the ray 31 MIT EECS 6.837, Cutler and Durand

Plane-point distance • Plane Hp=0 • If n is normalized d=HP • Signed distance! 32 MIT EECS 6.837, Cutler and Durand

Explicit vs. implicit? • Plane equation is implicit –Solution of an equation –Does not tell us how to generate a point on the plane –Tells us how to check that a point is on the plane • Ray equation is explicit –Parametric –How to generate points –Harder to verify that a point is on the ray • Exercise: explicit plane and implicit ray 33 MIT EECS 6.837, Cutler and Durand

Line-plane intersection •Insert explicit equation of line intoimplicit equation of plane 34 MIT EECS 6.837, Cutler and Durand

Additional house keeping •Verify that intersection is closer than previous •Verify that it is in the allowed range (in particular not behind the camera, t<0) 35 MIT EECS 6.837, Cutler and Durand

Normal •For shading (recall, diffuse: dot product between light and normal) •Simply the normal to the plane 36 MIT EECS 6.837, Cutler and Durand

Overview of today •Introduction •Camera and ray generation •Ray-plane intersection •Ray-sphere intersection 37 MIT EECS 6.837, Cutler and Durand

Overview of today • Sphere equation (implicit): • (assume centered at origin, easy to translate) 38 MIT EECS 6.837, Cutler and Durand

Overview of today • Sphere equation (implicit): • Ray equation (explicit): P(t) = R+tD with ||D|| = 1 • Intersection means both are satisfied 39 MIT EECS 6.837, Cutler and Durand

Ray-Sphere Intersection 40 MIT EECS 6.837, Cutler and Durand

Ray-Sphere Intersection •This is just a quadratic 0, where a = 1 b = 2D.R c = R.R –r2 •With discriminant •and solutions 41 MIT EECS 6.837, Cutler and Durand

Ray-Sphere Intersection •Discriminant •Solutions •Three cases, depending on sign of •Which root (� should you choose? –Closest positive! (usually t-) 42 MIT EECS 6.837, Cutler and Durand

Ray-Sphere Intersection • So easy that all ray-tracing images have spheres! 43 MIT EECS 6.837, Cutler and Durand

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 44 MIT EECS 6.837, Cutler and Durand

Geometric ray-sphere intersection • What geometric information is important? –Inside/outside –Closest point –Direction 45 MIT EECS 6.837, Cutler and Durand

Geometric ray-sphere intersection • Find if the ray’s origin is outside the sphere – –If inside, it intersects –If on the sphere, it does not intersect (avoid degeneracy) 46 MIT EECS 6.837, Cutler and Durand

Geometric ray-sphere intersection •Find if the ray’s origin is outside the sphere •Find the closest point to the sphere center – –If no hit 47 MIT EECS 6.837, Cutler and Durand

Geometric ray-sphere intersection •Find if the ray’s origin is outside the sphere •Find the closest point to the sphere center –If tP<0, no hit •Else find squared distance d2 –Pythagoras: –… if no hit 48 MIT EECS 6.837, Cutler and Durand

Geometric ray-sphere intersection • Find if the ray’s origin is outside the sphere • Find the closest point to the sphere center–If no hit • Else find squared distance –if no hit If outside t = • If inside 49 MIT EECS 6.837, Cutler and Durand

Geometric vs. algebraic •Algebraic was more simple (and more generic) •Geometric is more efficient –Timely tests –In particular for outside and pointing away 50 MIT EECS 6.837, Cutler and Durand

Normal • Simply Q/||Q|| 51 MIT EECS 6.837, Cutler and Durand

Precision •What happens when –Origin is on an object? –Grazing rays? •Problem with floating-point approximation 52 MIT EECS 6.837, Cutler and Durand

The evil ε •In ray tracing, do NOT report intersection for rays starting at the surface (no false positive) –Because secondary rays –Requires epsilons 53 MIT EECS 6.837, Cutler and Durand

The evil ε: a hint of nightmare • Edges in triangle meshes –Must report intersection (otherwise not watertight) –No false negative 54 MIT EECS 6.837, Cutler and Durand

Assignment 1 • Write a basic ray caster • We provide –Orthographic camera –Spheres –Display: constant color and distance • We provide –Ray –Hit –Parsing –And linear algebra, image 55 MIT EECS 6.837, Cutler and Durand

Object-oriented design • We want to be able to add primitives easily –Inheritance and virtual methods • Even the scene is derived from Object3D! 56 MIT EECS 6.837, Cutler and Durand

Ray 57 ////////// 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; }; 57 MIT EECS 6.837, Cutler and Durand

Hit •Store intersection point & various information 58 ///////// class Hit{ float _t; Vec3f _color; //Material *_material; //Vec3f _normal; }; 58 MIT EECS 6.837, Cutler and Durand

Tasks • Abstract Object3D • Sphere and intersection • Scene class • Abstract camera and derive Orthographic • Main function 59 MIT EECS 6.837, Cutler and Durand

Thursday: More Ray Casting • Other primitives –Boxes –Triangles –IFS? • Antialiasing 60 MIT EECS 6.837, Cutler and Durand