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

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

Ray Tracing. Outline. Ray Tracing: History

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

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

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

Ray Casting. Outline. Outline in Code

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

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

Lecture 11: Ray tracing (cont.)

Ray-Tracing. Misha Kazhdan

Sung-Eui Yoon ( 윤성의 )

CS Simple Raytracer for students new to Rendering

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

CS 184: Assignment 4 Simple Raytracer

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

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

Photorealism: Ray Tracing

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

CPSC GLOBAL ILLUMINATION

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

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

Lecture 11. More Ray Casting/Tracing

Intro to Ray-Tracing & Ray-Surface Acceleration

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

Ray Tracing. Last Time? Reading for Today. Reading for Today

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

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

Questions??? Announcements Assignment 3 due today

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

Assignment 6: Ray Tracing

Computer Graphics and Image Processing Ray Tracing I

Supplement to Lecture 16

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

Ray tracing Tutorial. Lukas Herzberger

03 RENDERING PART TWO

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

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

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

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Viewing and Ray Tracing. CS 4620 Lecture 4

Viewing and Ray Tracing

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

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

Ray Tracer Due date: April 27, 2011

Raytracing CS148 AS3. Due :59pm PDT

Ray-tracing Cont. Ray-tracing

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

A Little Background. Motivation. Motivation

The feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):

COMPLETION OF Z-buffer Graphics Pipeline

1999, Denis Zorin. Ray tracing

Review for Ray-tracing Algorithm and Hardware

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

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

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

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

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

CS5620 Intro to Computer Graphics

CMSC427 Final Practice v2 Fall 2017

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

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Computer Graphics Ray Casting. Matthias Teschner

Models and Architectures

Geometric Queries for Ray Tracing

COMP371 COMPUTER GRAPHICS

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

Last week. Machiraju/Zhang/Möller

Lighting and Shading

Ray Tracing Foley & Van Dam, Chapters 15 and 16

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

Ray Casting. Connelly Barnes CS 4810: Graphics

Parallelization. Memory coherency helps when distributing rays to various threads/processors

Indirect Illumination

Shading, Advanced Rendering. Week 7, Wed Feb 28

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

COMS 4160: Problems on Transformations and OpenGL

Computer Graphics Lecture 11

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Comp 410/510 Computer Graphics. Spring Shading

CS 4204 Computer Graphics

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Ray Tracing COMP575/COMP770

Assignment 2 Ray Tracing

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

CS452/552; EE465/505. Intro to Lighting

Today. Part 1: Ray casting Part 2: Lighting Part 3: Recursive Ray tracing Part 4: Acceleration Techniques

Virtual Reality for Human Computer Interaction

3D Rendering and Ray Casting

Ray Tracing. Shandong University

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

CS-184: Computer Graphics. Administrative

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

3D Rendering and Ray Casting

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

CS 184: Assignment 2 Scene Viewer

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

Transcription:

Foundations of omputer Graphics Online Lecture 10: Ray Tracing 2 Nuts and olts amera Ray asting Outline amera Ray asting (choose ray directions) Ravi Ramamoorthi Outline in ode Image Raytrace (amera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = Findolor (hit) ; return image ; Virtual Viewpoint Ray asting Virtual Screen Objects Ray Multiple misses intersects intersections: all object: objects: shade Pixel Use using colored closest color, black one lights, (as does materials OpenGL) Finding Ray Direction Goal is to find ray direction for given pixel i and j Many ways to approach problem Objects in world coord, find dirn of each ray (we do this) amera in canonical frame, transform objects (OpenGL) asic idea Ray has origin (camera center) and direction Find direction given camera params and i and j Similar to glulookt derivation glulookt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) amera at eye, looking at center, with up direction being up Eye Up vector amera params as in glulookt Lookfrom[3], Lookt[3], up[3], fov From earlier lecture on deriving glulookt enter 1

onstructing a coordinate frame? We want to associate w with a, and v with b ut a and b are neither orthogonal nor unit norm nd we also need to find u onstructing a coordinate frame We want to position camera at origin, looking down Z dirn Hence, vector a is given by eye center The vector b is simply the up vector Up vector Eye From basic math lecture - Vectors: Orthonormal asis Frames enter anonical viewing geometry anonical viewing geometry -w αu βv -w αu βv anonical viewing geometry -w αu βv Foundations of omputer Graphics Online Lecture 10: Ray Tracing 2 Nuts and olts Ray-Object Intersections Ravi Ramamoorthi 2

Outline amera Ray asting (choosing ray directions) Outline in ode Image Raytrace (amera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = Findolor (hit) ; return image ; Substitute P 0 Substitute Substitute Simplify Simplify 3

Solve quadratic equations for t 2 real positive roots: pick smaller root oth roots same: tangent to sphere One positive, one negative root: ray origin inside sphere (pick + root) omplex roots: no intersection (check discriminant of equation first) Intersection point: Normal (for sphere, this is same as coordinates in sphere frame of reference, useful other tasks) Ray-Triangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: Ray-Triangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: Ray-Triangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: Ray-Triangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: ombine with ray equation 4

Ray inside Triangle Once intersect with plane, need to find if in triangle Many possibilities for triangles, general polygons We find parametrically [barycentric coordinates]. lso useful for other applications (texture mapping) α β P γ Ray inside Triangle β α P γ Other primitives Much early work in ray tracing focused on ray-primitive intersection tests ones, cylinders, ellipsoids oxes (especially useful for bounding boxes) General planar polygons Many more Ray Scene Intersection Intersection (ray, scene) { mindist = infinity; hitobject = NULL ; For each object in scene { // Find closest intersection; test all objects t = Intersect (ray, object) ; if (t > 0 && t < mindist) // closer than previous closest object mindist = t ; hitobject = object ; return IntersectionInfo(mindist, hitobject) ; // may already be in Intersect() Outline amera Ray asting (choosing ray directions) Ray-Tracing Transformed Objects We have an optimized ray-sphere test ut we want to ray trace an ellipsoid Solution: Ellipsoid transforms sphere pply inverse transform to ray, use ray-sphere llows for instancing (traffic jam of cars) Same idea for other primitives 5

Transformed Objects onsider a general 4x4 transform M (matrix stacks) pply inverse transform M -1 to ray Locations stored and transform in homogeneous coordinates Vectors (ray directions) have homogeneous coordinate set to 0 [so there is no action because of translations] Do standard ray-surface intersection as modified Transform intersection back to actual coordinates Intersection point p transforms as Mp Normals n transform as M -t n. Do all this before lighting Foundations of omputer Graphics Online Lecture 10: Ray Tracing 2 Nuts and olts Lighting alculations Ravi Ramamoorthi Outline amera Ray asting (choosing ray directions) Outline in ode Image Raytrace (amera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = Findolor (hit) ; return image ; Shadows Light Source Shadows: Numerical Issues Numerical inaccuracy may cause intersection to be below surface (effect exaggerated in figure) ausing surface to incorrectly shadow itself Move a little towards light before shooting shadow ray Virtual Viewpoint Virtual Screen Objects Shadow ray to to light is is unblocked: object visible in shadow 6

Similar to OpenGL Lighting Model Lighting model parameters (global) mbient r g b ttenuation const linear quadratic Per light model parameters Directional light (direction, RG parameters) Point light (location, RG parameters) Some differences from HW 2 syntax Material Model Diffuse reflectance (r g b) Specular reflectance (r g b) Shininess s Emission (r g b) ll as in OpenGL Shading Model Global ambient term, emission from material For each light, diffuse specular terms Note visibility/shadowing for each light (not in OpenGL) Evaluated per pixel per light (not per vertex) Foundations of omputer Graphics Online Lecture 10: Ray Tracing 2 Nuts and olts Recursive Ray Tracing Ravi Ramamoorthi Outline amera Ray asting (choosing ray directions) Mirror Reflections/Refractions Virtual Viewpoint Virtual Screen Generate reflected ray in mirror direction, Get reflections and refractions of objects Objects 7

asic idea For each pixel Trace Primary Eye Ray, find intersection Trace Secondary Shadow Ray(s) to all light(s) olor = Visible? Illumination Model : 0 ; Trace Reflected Ray olor += reflectivity * olor of reflected ray Recursive Shading Model Highlighted terms are recursive specularities [mirror reflections] and transmission (latter is extra) Trace secondary rays for mirror reflections and refractions, include contribution in lighting model Getolor calls RayTrace recursively (the I values in equation above of secondary rays are obtained by recursive calls) Problems with Recursion Reflection rays may be traced forever Generally, set maximum recursion depth Same for transmitted rays (take refraction into account) Some basic add ons rea light sources and soft shadows: break into grid of n x n point lights Use jittering: Randomize direction of shadow ray within small box for given light source direction Jittering also useful for antialiasing shadows when shooting primary rays More complex reflectance models Simply update shading model ut at present, we can handle only mirror global illumination calculations 8