Viewing and Ray Tracing. CS 4620 Lecture 4

Similar documents
Viewing and Ray Tracing

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

Ray tracing idea. Ray Tracing. Ray tracing algorithm. Plane projection in drawing. CS 465 Lecture 3

Ray Tracing. CS 4620 Lecture 5

Ray Tracing COMP575/COMP770

A Little Background. Motivation. Motivation

Animation and Ray Tracing

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

Intro to Ray-Tracing & Ray-Surface Acceleration

Ray Tracing: shading

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

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

CS 4620 Midterm, March 21, 2017

Ray Tracing. CPSC 453 Fall 2018 Sonny Chan

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

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

Ray Casting. Connelly Barnes CS 4810: Graphics

Lecture 11: Ray tracing (cont.)

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

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

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

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

Ray Tracing. Outline. Ray Tracing: History

Computer Graphics and Image Processing Ray Tracing I

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

3D Rendering and Ray Casting

3D Viewing. CS 4620 Lecture 8

3D Rendering and Ray Casting

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

Shadows in the graphics pipeline

Assignment 6: Ray Tracing

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

Questions??? Announcements Assignment 3 due today

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

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Supplement to Lecture 16

Ray tracing Tutorial. Lukas Herzberger

Geometric Queries for Ray Tracing

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

Sung-Eui Yoon ( 윤성의 )

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

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Shadows. COMP 575/770 Spring 2013

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

CS4620/5620: Lecture 14 Pipeline

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Photorealism: Ray Tracing

CS6670: Computer Vision

Pipeline Operations. CS 4620 Lecture 14

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

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

Last week. Machiraju/Zhang/Möller

1999, Denis Zorin. Ray tracing

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

CPSC GLOBAL ILLUMINATION

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

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

Review for Ray-tracing Algorithm and Hardware

Project 1 Simple Ray Tracer

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

Ray Casting. 3D Rendering. Ray Casting. Ray Casting. Ray Casting. Ray Casting

Assignment 2 Ray Tracing

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

Topics and things to know about them:

Computer Graphics Ray Casting. Matthias Teschner

Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Ray Tracing Acceleration. CS 4620 Lecture 20

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

CS 130 Exam I. Fall 2015

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Pipeline Operations. CS 4620 Lecture 10

CHAPTER 3. Single-view Geometry. 1. Consequences of Projection

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

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

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

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

Ray Tracer Due date: April 27, 2011

8.1 Geometric Queries for Ray Tracing

CS770/870 Spring 2017 Ray Tracing Implementation

Graphics 2009/2010, period 1. Lecture 8: ray tracing

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

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

Barycentric Coordinates and Parameterization

Ray Tracing: Whence and Whither?

DH2323 DGI13. Lab 2 Raytracing

CV: 3D to 2D mathematics. Perspective transformation; camera calibration; stereo computation; and more

CS 465 Program 5: Ray II

Interpolation using scanline algorithm

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

Introduction to Ray-tracing Objectives

CS Simple Raytracer for students new to Rendering

Graphics Pipeline. CS535 Fall Daniel G. Aliaga Department of Computer Science Purdue University

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

lecture 19 Shadows - ray tracing - shadow mapping - ambient occlusion Interreflections

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

Rasterization. COMP 575/770 Spring 2013

CS 130 Exam I. Fall 2015

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Transcription:

Viewing and Ray Tracing CS 4620 Lecture 4 2014 Steve Marschner 1

Projection To render an image of a 3D scene, we project it onto a plane Most common projection type is perspective projection 2014 Steve Marschner 2

Two approaches to rendering 2014 Steve Marschner 3

Two approaches to rendering for each object in the scene { for each pixel in the image { if (object affects pixel) { do something object order or rasterization 2014 Steve Marschner 3

Two approaches to rendering for each object in the scene { for each pixel in the image { if (object affects pixel) { do something object order or rasterization for each pixel in the image { for each object in the scene { if (object affects pixel) { do something image order or ray tracing 2014 Steve Marschner 3

Two approaches to rendering for each object in the scene { for each pixel in the image { if (object affects pixel) { do something object order or rasterization for each pixel in the image { for each object in the scene { if (object affects pixel) { do something We will do this first image order or ray tracing 2014 Steve Marschner 3

Ray tracing idea Start with a pixel what belongs at that pixel? Set of points that project to a point in the image: a ray 2014 Steve Marschner 4

Ray tracing idea Start with a pixel what belongs at that pixel? Set of points that project to a point in the image: a ray 2014 Steve Marschner 4

Ray tracing idea 2014 Steve Marschner 5

Ray tracing idea 2014 Steve Marschner 5

Ray tracing idea 2014 Steve Marschner 5

Ray tracing idea 2014 Steve Marschner 5

Ray tracing algorithm for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image 2014 Steve Marschner 6

Generating eye rays planar projection Ray origin (varying): pixel position on viewing window Ray direction (constant): view direction viewing window pixel position viewing ray 2014 Steve Marschner 7

Generating eye rays perspective Ray origin (constant): viewpoint Ray direction (varying): toward pixel position on viewing window viewpoint viewing window pixel position viewing ray 2014 Steve Marschner 8

Software interface for cameras Key operation: generate ray for image position class Camera { Ray generateray(int col, int row); args go from 0, 0 to width 1, height 1 Modularity problem: Camera shouldn t have to worry about image resolution better solution: normalized coordinates class Camera { Ray generateray(float u, float v); args go from 0, 0 to 1, 1 2014 Steve Marschner 9

Specifying views in Ray 1 <camera type="perspectivecamera"> <viewpoint>10 4.2 6</viewPoint> <viewdir>-5-2.1-3</viewdir> <viewup>0 1 0</viewUp> <projdistance>6</projdistance> <viewwidth>4</viewwidth> <viewheight>2.25</viewheight> </camera> <camera type="perspectivecamera"> <viewpoint>10 4.2 6</viewPoint> <viewdir>-5-2.1-3</viewdir> <viewup>0 1 0</viewUp> <projdistance>3</projdistance> <viewwidth>4</viewwidth> <viewheight>2.25</viewheight> </camera> 2014 Steve Marschner 10

Pixel-to-image mapping One last detail: exactly where are pixels located? j j = 2.5 v = 1t i j =.5 u = 0 l u = 1 r v = 0b i =.5 i = 3.5 u = =(i l + +0.5)/n (r l)(i x + 0.5)/n x v = =(j b + +0.5)/n (t b)(j y + 0.5)/n y 2014 Steve Marschner 11

Ray intersection 2014 Steve Marschner 12

Ray: a half line Standard representation: point p and direction d this is a parametric equation for the line lets us directly generate the points on the line if we restrict to t > 0 then we have a ray note replacing d with αd doesn t change ray (α > 0) 2014 Steve Marschner 13

Ray-sphere intersection: algebraic Condition 1: point is on ray Condition 2: point is on sphere assume unit sphere; see Shirley or notes for general Substitute: this is a quadratic equation in t 2014 Steve Marschner 14

Ray-sphere intersection: algebraic Solution for t by quadratic formula: simpler form holds when d is a unit vector but we won t assume this in practice (reason later) I ll use the unit-vector form to make the geometric interpretation 2014 Steve Marschner 15

Ray-sphere intersection: geometric 2014 Steve Marschner 16

Ray-triangle intersection Condition 1: point is on ray Condition 2: point is on plane Condition 3: point is on the inside of all three edges First solve 1&2 (ray plane intersection) substitute and solve for t: 2014 Steve Marschner 17

Ray-triangle intersection In plane, triangle is the intersection of 3 half spaces 2014 Steve Marschner 18

Ray-triangle intersection In plane, triangle is the intersection of 3 half spaces 2014 Steve Marschner 18

Ray-triangle intersection In plane, triangle is the intersection of 3 half spaces 2014 Steve Marschner 18

Ray-triangle intersection In plane, triangle is the intersection of 3 half spaces 2014 Steve Marschner 18

Deciding about insideness Need to check whether hit point is inside 3 edges easiest to do in 2D coordinates on the plane Will also need to know where we are in the triangle for textures, shading, etc. next couple of lectures Efficient solution: transform to coordinates aligned to the triangle 2014 Steve Marschner 19

Barycentric coordinates A coordinate system for triangles algebraic viewpoint: geometric viewpoint (areas): Triangle interior test: [Shirley 2000] 2014 Steve Marschner 20

Barycentric coordinates A coordinate system for triangles geometric viewpoint: distances linear viewpoint: basis of edges 2014 Steve Marschner 21

Barycentric coordinates Linear viewpoint: basis for the plane [Shirley 2000] in this view, the triangle interior test is just 2014 Steve Marschner 22

Barycentric ray-triangle intersection Every point on the plane can be written in the form: a + (b a)+ (c a) for some numbers β and. If the point is also on the ray then it is p + td for some number t. Set them equal: 3 linear equations in 3 variables p + td = a + (b a)+ (c a) solve them to get t, β, and all at once! 2014 Steve Marschner 23

Barycentric ray-triangle intersection p + td = a + (b a)+ (c a) (a b)+ (a c)+ td = a p 2 3 a b a c d 4 5 = a p t 2 4 x 3 2 3 2 a x b x a x c x d y a y b y a y c y d 5 4 5 = 4 x 3 a x p y a y p 5 z a z b z a z c z d t z a z p Cramer s rule is a good fast way to solve this system (see text Ch. 2 and Ch. 4 for details) 2014 Steve Marschner 24

Ray intersection in software All surfaces need to be able to intersect rays with themselves. class Surface { abstract boolean intersect(intersectionrecord result, Ray r); ray to be intersected was there an intersection? information about first intersection class IntersectionRecord { float t; Vector3 hitlocation; Vector3 normal; 2014 Steve Marschner 25

Image so far With eye ray generation and sphere intersection Surface s = new Sphere((0.0, 0.0, 0.0), 1.0); for 0 <= iy < ny for 0 <= ix < nx { ray = camera.getray(ix, iy); hitsurface, t = s.intersect(ray, 0, +inf) if hitsurface is not null image.set(ix, iy, white); 2014 Steve Marschner 26

Ray intersection in software Scenes usually have many objects Need to find the first intersection along the ray that is, the one with the smallest positive t value Loop over objects ignore those that don t intersect keep track of the closest seen so far Convenient to give rays an ending t value for this purpose (then they are really segments) 2014 Steve Marschner 27

Intersection against many shapes The basic idea is: intersect (ray, tmin, tmax) { tbest = +inf; firstsurface = null; for surface in surfacelist { hitsurface, t = surface.intersect(ray, tmin, tbest); if hitsurface is not null { tbest = t; firstsurface = hitsurface; return hitsurface, tbest; this is linear in the number of shapes but there are sublinear methods (acceleration structures) 2014 Steve Marschner 28