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

Similar documents
Ray Tracing COMP575/COMP770

A Little Background. Motivation. Motivation

Viewing and Ray Tracing. CS 4620 Lecture 4

Viewing and Ray Tracing

Ray Tracing: shading

Ray Tracing. CS 4620 Lecture 5

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

Animation and Ray Tracing

Ray Tracing. CPSC 453 Fall 2018 Sonny Chan

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

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

Supplement to Lecture 16

Shadows. COMP 575/770 Spring 2013

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Assignment 2 Ray Tracing

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Introduction to Ray-tracing Objectives

CS770/870 Spring 2017 Ray Tracing Implementation

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon

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

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

Lecture 11: Ray tracing (cont.)

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

Photorealism: Ray Tracing

CS 4620 Midterm, March 21, 2017

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

Topics and things to know about them:

lecture 18 - ray tracing - environment mapping - refraction

Shadows in the graphics pipeline

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

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

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Assignment 6: Ray Tracing

Ray tracing Tutorial. Lukas Herzberger

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

CS559 Computer Graphics Fall 2015

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

Computer Graphics Ray Casting. Matthias Teschner

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

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

The University of Calgary

Computer Graphics Tick 2

Computer Graphics Tick 1

Lighting and Shading

Computer Graphics and Image Processing Ray Tracing I

CS 4620 Program 4: Ray II

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

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Distribution Ray Tracing

CS 465 Program 5: Ray II

Raytracing CS148 AS3. Due :59pm PDT

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

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

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

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

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

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

Intro to Ray-Tracing & Ray-Surface Acceleration

Photorealism. Photorealism: Ray Tracing. Ray Tracing

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

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Agenda. Ray(tracing(algorithm( Code(structure( Ray(intersec;ons Sphere Triangle Hints Transforma;ons Debugging How(to(start

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

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

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

Questions??? Announcements Assignment 3 due today

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

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

CS 130 Exam I. Fall 2015

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

Ray Tracing Acceleration. CS 4620 Lecture 22

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

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

CS-184: Computer Graphics. Administrative

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Ray Tracing Acceleration. CS 4620 Lecture 20

Sung-Eui Yoon ( 윤성의 )

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

CS 354R: Computer Game Technology

Pipeline Operations. CS 4620 Lecture 10

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

CS 4620 Midterm 1. Tuesday 22 October minutes

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Project 1 Simple Ray Tracer

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

CMSC427 Final Practice v2 Fall 2017

CS Simple Raytracer for students new to Rendering

Ray Tracing: Whence and Whither?

CS 4620 Program 3: Pipeline

Review for Ray-tracing Algorithm and Hardware

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

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

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

Ray Tracing. Shandong University

Transcription:

Ray tracing idea Ray Tracing CS 465 Lecture 3 2007 Doug James 1 2007 Doug James 2 Ray tracing algorithm Plane projection in drawing for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image [CS 417 Spring 2002] 2007 Doug James 3 2007 Doug James 4 1

Plane projection in photography This is another model for what we are doing applies more directly in realistic rendering Generating eye rays Use window analogy directly [CS 417 Spring 2002] 2007 Doug James 5 2007 Doug James 6 Vector math review Ray: a half line Vectors and points Vector operations addition scalar product More products dot product cross product Bases and orthogonality 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 ad doesn t change ray (a > 0) 2007 Doug James 7 2007 Doug James 8 2

Ray-sphere intersection: algebraic Condition 1: point is on ray Ray-sphere intersection: algebraic Solution for t by quadratic formula: Condition 2: point is on sphere assume unit sphere; see Shirley or notes for general Substitute: 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 this is a quadratic equation in t 2007 Doug James 9 2007 Doug James 10 Ray-sphere intersection: geometric Ray-box intersection Could intersect with 6 faces individually Better way: box is the intersection of 3 slabs 2007 Doug James 11 2007 Doug James 12 3

Ray-slab intersection 2D example 3D is the same! Intersecting intersections Each intersection is an interval Want last entry point and first exit point Shirley fig. 10.16 2007 Doug James 13 2007 Doug James 14 Ray-triangle intersection Ray-triangle intersection Condition 1: point is on ray In plane, triangle is the intersection of 3 half spaces 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: 2007 Doug James 15 2007 Doug James 16 4

Inside-edge test Ray-triangle intersection Need outside vs. inside Reduce to clockwise vs. counterclockwise vector of edge to vector to x Use cross product to decide 2007 Doug James 17 2007 Doug James 18 Image so far Intersection against many shapes 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); if (s.intersect(ray, 0, +inf) < +inf) image.set(ix, iy, white); The basic idea is: hit (ray, tmin, tmax) { tbest = +inf; hitsurface = null; for surface in surfacelist { t = surface.intersect(ray, tmin, tmax); if t < tbest { tbest = t; hitsurface = surface; return hitsurface, t; this is linear in the number of shapes but there are sublinear methods (acceleration structures) 2007 Doug James 19 2007 Doug James 20 5

Image so far With eye ray generation and scene intersection for 0 <= iy < ny for 0 <= ix < nx { ray = camera.getray(ix, iy); c = scene.trace(ray, 0, +inf); image.set(ix, iy, c); trace(ray, tmin, tmax) { surface, t = hit(ray, tmin, tmax); if (surface!= null) return surface.color(); else return black; Shading Compute light reflected toward camera Inputs: eye direction light direction (for each of many lights) surface normal surface parameters (color, shininess, ) More on this in the next lecture 2007 Doug James 21 2007 Doug James 22 Image so far Shadows trace(ray ray, tmin, tmax) { surface, t = hit(ray, tmin, tmax); if (surface!= null) { point = ray.evaluate(t); normal = surface.getnormal(point); return surface.shade(ray, point, normal, light); else return black; Surface is only illuminated if nothing blocks its view of the light. With ray tracing it s easy to check just intersect a ray with the scene! shade(ray, point, normal, light) { v_e = normalize(ray.direction); v_l = normalize(light.pos - point); // compute shading 2007 Doug James 23 2007 Doug James 24 6

Image so far Shadow rounding errors Don t fall victim to one of the classic blunders: shade(ray, point, normal, light) { shadray = (point, light.pos - point); if (shadray not blocked) { v_e = normalize(ray.direction); v_l = normalize(light.pos - point); // compute shading return black; 2007 Doug James 25 What s going on? hint: at what t does the shadow ray intersect the surface you re shading? 2007 Doug James 26 Multiple lights Solution: shadow rays start a tiny distance from the surface Important to fill in black shadows Just loop over lights, add contributions Ambient shading black shadows are not really right one solution: dim light at camera alternative: all surface receive a bit more light just add a constant ambient color to the shading Do this by moving the start point, or by limiting the t range 2007 Doug James 27 2007 Doug James 28 7

Image so far shade(ray, point, normal, lights) { result = ambient; for light in lights { if (shadow ray not blocked) { result += shading contribution; return result; Ray tracer architecture 101 You want a class called Ray point and direction; evaluate(t) possible: tmin, tmax Some things can be intersected with rays individual surfaces the whole scene often need to be able to limit the range (e.g. shadow rays) Once you have the visible intersection, compute the color this is an object that s associated with the object you hit its job is to compute the color 2007 Doug James 29 2007 Doug James 30 Architectural practicalities Return values surface intersection tends to want to return multiple values t, surface or shader, normal vector, maybe surface point in many programming languages (e.g. Java) this is a pain typical solution: an intersection record a class with fields for all these things keep track of the intersection record for the closest intersection be careful of accidental aliasing (which is very easy if you re new to Java) Efficiency in Java the (or, a) key to being fast is to minimize creation of objects what objects are created for every ray? try to find a place for them where you can reuse them. Shadow rays can be cheaper (any intersection will do, don t need closest) but: Get it Right, Then Make it Fast 2007 Doug James 31 8