Ray Tracing Geometry CSE 681.

Slides:



Advertisements
Similar presentations
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Advertisements

Tangent Vectors and Normal Vectors. Definitions of Unit Tangent Vector.
Chapter 12 – Vectors and the Geometry of Space
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Christian Lauterbach COMP 770, 2/11/2009
CS485/685 Computer Vision Prof. George Bebis
COMP322/S2000/L221 Relationship between part, camera, and robot (cont’d) the inverse perspective transformation which is dependent on the focal length.
CSE 681 Object Intersection. CSE 681 Object Representation Implicit forms F(x,y,z) = 0 Explicit forms Analytic form x = F(y,z) testing generating Parametric.
Stockman MSU/CSE Math models 3D to 2D Affine transformations in 3D; Projections 3D to 2D; Derivation of camera matrix form.
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.
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.
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 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Introduction to 3D Graphics Lecture 2: Mathematics of the Simple Camera Anthony Steed University College London.
Basic Ray Tracing CMSC 435/634.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
RENDERING : Global Illumination
Orthonormal Basis Cartesian Coordinate System – Unit vectors: i, j, k – Normalized to each other – Unique representation for each position!! – Convenient!
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CSE 681 Object Intersection. CSE 681 Object Representation Implicit forms F(x,y,z) = 0 Explicit forms Analytic form x = F(y,z) testing generating Parametric.
CSE 681 Brief Review: Vectors. CSE 681 Vectors Direction in space Normalizing a vector => unit vector Dot product Cross product Parametric form of a line.
A Photograph of two papers The Model: 2 papers – 8cm x 8cm and 5cm x 5cm The Camera – Simple pinhole – No focusing capability The Scene – Arrangements.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Geometrical Optics.
Analytic Geometry in Three Dimensions
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Geometric Optics Figure Mirrors with convex and concave spherical surfaces. Note that θr = θi for each ray.
Visible Surface Detection
Rendering Pipeline Fall, 2015.
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
Chapter 33 Lenses and Optical Instruments
Reflection & Mirrors.
Introduction to Computer Graphics with WebGL
Ray Tracing Ed Angel Professor Emeritus of Computer Science
Lenses & Optical Instruments
Mathematics of the Simple Camera
MIT EECS 6.837, Cutler and Durand
3D Viewing cgvr.korea.ac.kr.
Ray Tracing Forward Ray Tracing
CSCE 441 Computer Graphics 3-D Viewing
Scene Modeling for a Single View
CENG 538 Advanced Graphics and UIs
Intersecting Simple Surfaces
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Tracing Geometry CSE 681.
© University of Wisconsin, CS559 Fall 2004
A Photograph of two papers
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics with WebGL
Geometric Camera Models
Computer Graphics Lecture 20
By the end of Week 3: You would learn how to solve many problems involving lines/planes and manipulate with different coordinate systems. These are.
Object Intersection CSE 681.
Object Intersection CSE 681.
Lecture 13 Clipping & Scan Conversion
Image synthesis using classical optics
Orthogonal Base Cartesian Coordinate System Works in general:
Chapter 25 Reflection and Mirrors
GR2 Advanced Computer Graphics AGR
Ray Tracing Geometry CSE 681.
Ray Tracing Geometry CSE 681.
MIRRORS Chrome text with reflection (Advanced)
Presentation transcript:

Ray Tracing Geometry CSE 681

The Camera Model Based on a simpile pin-hole camera model Simplest lens model Pure geometric optics – based on similar triangles Perfect image if hole infinitely small Inverted image pin-hole camera simplified pin-hole camera CSE 681

Basic Ray Tracing Algorithm for every pixel { cast a ray from the eye for every object in the scene find intersections with the ray keep it if closest } compute color at the intersection point CSE 681

Construct a Ray 3D parametric line r(t) = eye + t (p-eye) r(t): ray equation eye: eye (camera) position p: pixel position t: ray parameter r(t) p t=0 Question: How to calculate the pixel position P? CSE 681

What are given? Camera (eye) position View direction or center of interest Camera orientation (which way is up?) specified by an “up” vector Field of view + aspect ration Distance to the image plane Pixel resolutions in x and y “up” vector eye ray CSE 681

Camera Setup v n w u We need to have a ‘view “up” vector v n w View direction u We need to have a ‘view coordinate system, i.e., compute the u, v, w vectors u v w w image plane Eye + w goes through the image plane center Use info about camera to construct 3D camera coordinate system CSE 681

Camera Setup v n w u w: known u = w x “up” v = u x w “up” vector v n w View direction u w: known u = w x “up” v = u x w “up” may not be perpendicular to w x: cross product CSE 681 CSE 681

Pixel Calculation Coordinate (in u,v,n space) of upper left corner of screen Eye + w v yres u w xres Using camera coordinate system vectors, form location of upper left corner of screen in world space Assume virtual screen is one unit away (D=1) in w direction Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v CSE 681

Pixel Calculation Coordinate (in u,v,n space) of upper left corner of screen Eye + w v yres u w xres How do we calculate PixelWidth and PixelHeight? Assume virtual screen is one unit away (D=1) in w direction Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v CSE 681 CSE 681

Camera Setup (yres/2) * pixelHeight Tan(q/2) = yres*pixelHeight/2D Side view of camera Given theta (either half angle or full angle of view can be specified), D Compute extent of virtual frame buffer Then using pixel resolution, computer pixel height and width Tan(q/2) = yres*pixelHeight/2D pixelHeight = 2*Tan(qy/2) *D/yres D pixelWidth = 2*Tan(qx/2) *D/xres CSE 681

Screen Placement How do images differ if the resolution doesn’t change? Q: if same pixel resolution, what’s different about the images generated when using different distances for virtual frame buffer? A: nothing So use D = 1 to simplify computations CSE 681

Pixel Calculation Tan(q/2) = yres*pixelHeight/2D pixelHeight = 2*Tan(qy/2) *D/yres pixelWidth = 2*Tan(qx/2) *D/xres Pixel AspectRatio = pixelWidth/pixelHeight Aspect ratio is width to height ratio Coordinate (in u,v,n space) of upper left corner of screen = ? CSE 681

Pixel Calculation Coordinate (in u,v,n space) of upper left corner of screen = ? v u w Tan(q/2) = yres*pixelHeight/2 pixelHeight = 2*Tan(qy/2) /yres pixelWidth = 2*Tan(qx/2) /xres Using camera coordinate system vectors, form location of upper left corner of screen in world space Assume virtual screen is one unit away (D=1) in w direction Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v CSE 681

Pixel Calculation Coordinate (in u,v,n space) of upper left pixel center = ? Then back off half a pixel width and height to compute pixel center Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v + (pixelWidth/2)*u - (pixelHeight/2)*v CSE 681

Interate through pixel Centers scanlineStart = Eye + w - (xres/2)*PixelWidth*u + (yres/2)*PixelHeight *v + (pixelWidth/2)*u - (pixelHeight/2)*v Update by pixel width and pixel height to go to adjacent pixel on scanline and next scanline, respectively There will pixelCenter += pixelWidth * u scanlineStart -= pixelHeight * v CSE 681

Pixel loops ScenlineStart = [from previous slide] For each scanline { pixelCenter = scanlineStart For each pixel across { form ray from camera through pixel …. pixelCenter += pixelWidth*u } scanlineStart -= pixelHeight*v Update by pixel width and pixel height to go to adjacent pixel on scanline and next scanline, respectively There will CSE 681

Process Objects For each pixel { Form ray from eye through pixel distancemin = infinity For each object { If (distance=intersect(ray,object)) { If (distance< distancemin) { closestObject = object distancemin = distance } Color pixel according to intersection information Keep closest intersection Need intersection function for each object type processed Later, we’ll build ‘intersection structure’ CSE 681

After all objects are tested If (distancemin > infinityThreshold) { pixelColor = background color else pixelColor = color of object at distancemin along ray d ray object eye CSE 681

Ray-Sphere Intersection - geometric Knowns C, r Eye Ray t= |C-eye| k d+k = (C-eye) · Ray s t2= (k+d) 2 + s2 d r C r2 = k2+ s2 If s > r, then no intersection If s == r, then ray just grazes intersection eye t d = (k+d) - k CSE 681

Ray-Sphere Intersection - algebraic x2 + y2 + z2 = r2 P(t) = eye + t*Ray Substitute definition of p into first equation: (eye.x+ t *ray.x) 2 + (eye.y+ t *ray.y)2 + (eye.z+ t *ray.z) 2 = r2 Analytic equation of sphere and parametric form for ray Use quadratic equation to solve for u If term inside radical is <0, no intersection If term == 0, ray just grazes sphere Expand squared terms and collect terms based on powers of u: A* t 2 + B* t + C = 0 CSE 681

Ray-Sphere Intersection (cont’d) For a sphere with its center at c A sphere with center c = (xc,yc,zc) and radius R can be represented as: (x-xc)2 + (y-yc)2 + (z-zc)2 – R2 = 0 For a point p on the sphere, we can write the above in vector form: (p-c).(p-c) – R2 = 0 (note ‘.’ is a dot product) Solve p similarly CSE 681

Quadratic Equation When solving a quadratic equation at2 + bt + c = 0 Discriminant: And Solution: CSE 681

Ray-Sphere Intersection b2 – 4ac <0 : No intersection b2 – 4ac >0 : Two solutions (enter and exit) b2 – 4ac = 0 : One solution (ray grazes the sphere) CSE 681

Determine Color Use z-component of normalized normal vector FOR LAB #1 Clamp to [0.3..1.0] objectColor*Nz ray What’s the normal at a point on the sphere? Simple illumination example Just use z coordinate for normalized normal vector, clamped from below to 0.3, eye CSE 681