EDAN30 Photorealistic Computer Graphics. Ray tracing. Michael Doggett Department of Computer Science Lund university. Copyright 2011 Michael Doggett

Similar documents
Ray Tracing and Sampling

Lab Sessions Photorealistic Rendering (Advanced Computer Graphics)

COMP371 COMPUTER GRAPHICS

Photorealism: Ray Tracing

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

HIGH PERFORMANCE RAY TRACING: IMPLICATIONS FOR SYSTEM ARCHITECTURES. Computer Graphics. Erik Brunvand, University of Utah 9/2/15&

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

EDAN30 Photorealistic Computer Graphics

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

Photon Mapping. Michael Doggett Department of Computer Science Lund university

Lecture 10: Ray tracing

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

Sung-Eui Yoon ( 윤성의 )

Ray tracing. EECS 487 March 19,

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

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

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

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

Ray Tracing. Local Illumination. Object Space: Global Illumination. Image Space: Backward Ray Tracing. First idea: Forward Ray Tracing

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

CS 325 Computer Graphics

Ray Tracing. Kjetil Babington

Supplement to Lecture 16

Ray Tracer Due date: April 27, 2011

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

Lighting and Shading

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

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

Intro to Ray-Tracing & Ray-Surface Acceleration

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

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

Shading, Advanced Rendering. Week 7, Wed Feb 28

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

Implementation Issues

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

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

03 RENDERING PART TWO

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

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

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

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

EDAN30 Photorealistic Computer Graphics. Seminar 1, Whitted Ray Tracing (And then some!) Magnus Andersson, PhD student

Photon Mapping. Due: 3/24/05, 11:59 PM

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required:

CPSC GLOBAL ILLUMINATION

Shadows. COMP 575/770 Spring 2013

Ray Tracing. Outline. Ray Tracing: History

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

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

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

COMPUTER GRAPHICS COURSE. Rendering Pipelines

The Rendering Equation. Computer Graphics CMU /15-662

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

COMP environment mapping Mar. 12, r = 2n(n v) v

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

Introduction to Visualization and Computer Graphics

Korrigeringar: An introduction to Global Illumination. Global Illumination. Examples of light transport notation light

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

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

Rendering. Mike Bailey. Rendering.pptx. The Rendering Equation

Shadow Rendering EDA101 Advanced Shading and Rendering

Raytracing. COSC 4328/5327 Scott A. King

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

RASTERISED RENDERING

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Overview: Ray Tracing & The Perspective Projection Pipeline

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

Simple Nested Dielectrics in Ray Traced Images

COMP30019 Graphics and Interaction Ray Tracing

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Computer Graphics and Image Processing Ray Tracing I

Computer Graphics. - Ray Tracing I - Marcus Magnor Philipp Slusallek. Computer Graphics WS05/06 Ray Tracing I

782 Schedule & Notes

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

Ray-Tracing. Misha Kazhdan

Lecture 11. More Ray Casting/Tracing

Indirect Illumination

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Monte Carlo Ray Tracing. Computer Graphics CMU /15-662

Stochastic Path Tracing and Image-based lighting

The Rendering Equation and Path Tracing

Lecture 18: Primer on Ray Tracing Techniques

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

Shading 1: basics Christian Miller CS Fall 2011

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

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

Lecture 19: All Together with Refraction

MIT Ray Tracing Ray Tracing

Global Illumination. COMP 575/770 Spring 2013

Lecture 11: Ray tracing (cont.)

Raytracing CS148 AS3. Due :59pm PDT

Photorealistic 3D Rendering for VW in Mobile Devices

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

CS5620 Intro to Computer Graphics

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

Reflections and Refractions in Ray Tracing

Transcription:

EDAN30 Photorealistic Computer Graphics Ray tracing Michael Doggett Department of Computer Science Lund university Copyright 2011 Michael Doggett

Outline Recursive ray tracing Whitted ray tracing, An improved illumination model for shaded display, Turner Whitted, CACM June 1980 Copyright 2011 Michael Doggett

What is ray tracing? Another rendering algorithm Fundamentally different from polygon rendering! Rasterization (OpenGL, DirectX) Renders one triangle at a time Z-buffer stores nearest pixels Local lighting (per-vertex or per-pixel)! Ray tracing Renders one pixel at a time [Kind of] Sorts the geometry per pixel Global lighting equation (reflections, shadows) Copyright 2008 Tomas Akenine-Möller!3

Why ray tracing? Simple concept Higher quality rendering Global lighting equation Accurate shadows, reflections, refraction, etc Soft shadows, more realistic materials and lighting All computations done per pixel No interpolation Base for many advanced algorithms Global illumination, e.g., path tracing, photon mapping A disadvantage: can take longer to render images! Copyright 2008 Tomas Akenine-Möller!4

Original goal: Add reflections Copyright 2008 Tomas Akenine-Möller!5

Side by side comparison (1980 s) Images courtesy of Eric Haines Copyright 2008 Tomas Akenine-Möller!6

Newer example [Image courtesy of ARTVPS www.artvps.com] Copyright 2008 Tomas Akenine-Möller!7

Card Ray Tracer #include <stdlib.h> // card > aek.ppm! #include <stdio.h>! #include <math.h>! typedef int i;typedef float f;struct v{f x,y,z;v operator+(v r){return v(x+r.x,y+r.y,z+r.z);}v operator*(f r){return v(x*r,y*r,z*r);}f operator% (v r){return x*r.x+y*r.y+z*r.z;}v(){}v operator^(v r){return v(y*r.z-z*r.y,z*r.x-x*r.z,x*r.y-y*r.x);} v(f a,f b,f c){x=a;y=b;z=c;}v operator!() {return*this*(1/sqrt(*this%*this));}};i G[]={247570,280596,280600,249748,18578,18577,23118 4,16,16};f R(){return(f)rand()/RAND_MAX;}i T(v o,v d,f&t,v&n){t=1e9;i m=0;f p=-o.z/d.z;if(. 01<p)t=p,n=v(0,0,1),m=1;for(i k=19;k--;)for(i j=9;j--;)if(g[j]&1<<k){v p=o+v(-k,0,-j-4);f b=p %d,c=p%p-1,q=b*b-c;if(q>0){f s=-bsqrt(q);if(s<t&&s>.01)t=s,n=!(p+d*t),m=2;}}return m;}v S(v o,v d){f t;v n;i m=t(o,d,t,n);if(! m)return v(.7,.6,1)*pow(1-d.z,4);v h=o+d*t,l=! (v(9+r(),9+r(),16)+h*-1),r=d+n*(n%d*-2);f b=l %n;if(b<0 T(h,l,t,n))b=0;f p=pow(l%r*(b>0), 99);if(m&1){h=h*.2;return((i)(ceil(h.x) +ceil(h.y))&1?v(3,1,1):v(3,3,3))*(b*.2+.1);}return v(p,p,p)+s(h,r)*.5;}i main(){printf("p6 512 512 255 ");v g=!v(-6,-16,0),a=!(v(0,0,1)^g)*.002,b=! (g^a)*.002,c=(a+b)*-256+g;for(i y=512;y--;)for(i x=512;x--;){v p(13,13,13);for(i r=64;r--;){v t=a*(r()-.5)*99+b*(r()-.5)*99;p=s(v(17,16,8)+t,! (t*-1+(a*(r()+x)+b*(y+r())+c)*16))*3.5+p;} printf("%c%c%c",(i)p.x,(i)p.y,(i)p.z);}} courtesy Andrew Kensler from http://www.cs.utah.edu/%7eaek/code/ Copyright 2011 Michael Doggett

To be physically correct, follow photons from light source Not what we do for a simple ray tracer Though this is almost what we do for more advanced techniques (photon mapping) Image plane Light source Not effective, not many rays will arrive at the eye Copyright 2008 Tomas Akenine-Möller!9

Instead: follow photons backwards from the eye Rationale: find photons that arrive through each pixel How does one find the visible object at a pixel? With intersection testing Ray, r(t)=o+td, against geometrical objects r - ray, o - origin, d - direction, t - parameter Use object that is closest to camera! Valid intersections have t > 0 t is a signed distance Image plane For fast intersection testing, use a spatial data structure! Closest intersection point Copyright 2008 Tomas Akenine-Möller!10

trace() and directillumination() We now know how to find the visible object at a pixel How about finding the color of the pixel? Basic ray tracing is essentially only two functions with recursive calls trace() and directillumination() trace(): finds the first intersection with an object Calls directillumination(), and then trace() directionillumination(): computes the direct lighting at that intersection point Copyright 2008 Tomas Akenine-Möller!11

Whitted-style ray tracer: A very simple type of ray tracing light Image plane trace() Point is in shadow directillumination() trace() trace() directillumination() First call trace() to find first intersection directillumination() computes direct illumination from light sources trace() then calls trace() for reflection and refraction directions directillumination() applies the BRDF of the surface, and so on... Copyright 2008 Tomas Akenine-Möller!12

trace() in detail Color trace(ray R) { bool hit; Intersection is; Color col,col_tmp; hit=intersectscene(r,is); if(hit) { col=directillumination(is); if(is indicates reflective object) { col_tmp=trace(reflected ray); col = weighttogether(col,col_tmp); } if(is indicates transmissive object) { col_tmp=trace(refracted ray); col = weighttogether(col,col_tmp); } } else col=background_color; return col; } [recursion should also be terminated.. could be done after fixed depth] Copyright 2008 Tomas Akenine-Möller!13

directillumination() computes direct lighting For now, we will use the simple standard lighting equation that we used so far Diffuse + Specular Could use other models for the BRDF (Bidirectional Reflection Distribution Function) More realistic materials Copyright 2008 Tomas Akenine-Möller!14

directillumination() in detail Color directillumination(const Intersection &is) { Color col(0,0,0); for each light L { // create shadow ray; is is in shadow // use intersectscene for this... if(not inshadow(l,is)) { col+=diffuseandspecular(l,is); } } return col; } Copyright 2008 Tomas Akenine-Möller!15

In directillumination(), we need a function inshadow() Compute distance from intersection point, p, to light source: t max Then use intersection testing: Point is in shadow if 0 < t < t max is true for at least one object Copyright 2008 Tomas Akenine-Möller!16

Who calls trace() to begin with? Someone need to spawn rays One or more per pixel A simple routine, computeimage(), computes rays, and calls trace() for each ray. Use camera parameters to compute rays Resolution, FOV, camera direction & position & up Copyright 2008 Tomas Akenine-Möller!17

When does recursion stop? Recurse until ray does not hit anything? Does not work for closed models One solution is to allow for max N levels of recursion N=3 is often sufficient (sometimes 10 is sufficient) Another is to look at material parameters E.g., if specular material color is (0,0,0), then the object is not reflective, and we don t need to spawn a reflection ray More systematic: send a weight, w, with recursion Initially w=1, and after each bounce, w*=o.specular_color(); and so on. Will give faster rendering, if we terminate recursion when weight is too small (say <0.01) We will return to this issue in future lectures... Copyright 2008 Tomas Akenine-Möller!18

Quick recap: Reflection Image courtesy of Illuminate Labs Copyright 2008 Tomas Akenine-Möller!19

Refraction [Image courtesy of slartybartfast at ompf.org] Copyright 2008 Tomas Akenine-Möller!20

Refraction [ Glasses by Gilles Tran 2006] Copyright 2008 Tomas Akenine-Möller!21

Refraction: need a transmission vector, t n, i, t are unit vectors η 1 & η 2 are refraction indices n η 1 Known as Heckbert s method see http://www.cs.cmu.edu/~ph/refr.ps.gz c 1 =cos(θ 1 )=-n. i Decompose i into: i par =-c 1 n, i perp =i+c 1 n t=sin(θ 2 )m - cos(θ 2 )n, where m=i perp / i perp =(i+c 1 n)/sin(θ 1 ) i perp i t Use Snell s law: sin(θ 2 )/sin(θ 1 )= η 1 /η 2 = η t = ηi + (ηc 1 - c 2 ) n, where c 2 =cos(θ 2 ) θ 2 θ 1 i par -i η 2 Simplify: c 2 =sqrt[ 1 η 2 (1-c 1 2) ] Copyright 2008 Tomas Akenine-Möller!22

Some refraction indices, η Measured with respect to vacuum Air: 1.0003 Water: 1.33 Glass: around 1.45 1.65 Diamond: 2.42 Salt: 1.54 Note 1: the refraction index varies with wavelength, but we often only use one index for all three color channels, RGB Or use 3 slightly different! diffraction! Note 2: can get Total Internal Reflection (TIR) Means no transmission, only reflection Occurs when c 2 is imaginary (see previous slide) Copyright 2008 Tomas Akenine-Möller!23

Diffraction Diffraction Copyright 2008 Tomas Akenine-Möller!24

Next Lecture Tomorrow - Sampling and Object intersection Reading Textbook : Chapter 1: Getting started, Chapter 3.1 & 3.3 : A Simple Ray Tracer Paper : An improved illumination model for shaded display, Turner Whitted, CACM June 1980 2011 Michael Doggett

2011 Michael Doggett