1 Ray Tracing Lecture 10 © Jeff Parker, Nov 2009.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

GR2 Advanced Computer Graphics AGR
13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
1 05/10/2014 Computer Graphics Lecture 10 Global Illumination 1: Ray Tracing and Radiosity Taku Komura.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Lecture 14 Illumination II – Global Models
Computer Graphics In4/MSc Computer Graphics Lecture Notes #15 Illumination III View Independent Rendering.
3D Graphics Rendering and Terrain Modeling
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Ray Tracing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of.
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 10: Global Illumination Ravi Ramamoorthi Some images courtesy.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Photorealism Reflection, Refraction Bump maps
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
Ray Tracing 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CSC418 Computer Graphics n Raytracing n Shadows n Global Illumination.
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.
Image by Eric Veach and Leonidas Guibas
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Today More raytracing stuff –Soft shadows and anti-aliasing More rendering methods –The text book is good on this –I’ll be using images from the CDROM.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
-Global Illumination Techniques
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
Ray Tracing. 2 Introduction OpenGL is based on a pipeline model in which primitives are rendered one at time ­No shadows (except by tricks or multiple.
Ray-tracing.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CS 480/680 Computer Graphics Compositing and Blending Dr. Frederick C Harris, Jr.
CSCE 441: Computer Graphics Ray Tracing
In the name of God Computer Graphics. Last Time Some techniques for modeling Today Global illumination and raytracing.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Radiosity Radiosity.
1. Ray Casting Surface intersection Visible surface detection Ray Tracing Bounce the ray Collecting intensity Technique for global reflection and transmission.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
David Luebke3/12/2016 Advanced Computer Graphics Lecture 3: More Ray Tracing David Luebke
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CS552: Computer Graphics Lecture 33: Illumination and Shading.
11/29/01CS 559, Fall 2001 Today Photorealistic rendering Algorithms for producing high-quality images Ways of deciding which algorithm for use.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
CS552: Computer Graphics Lecture 36: Ray Tracing.
Basic Ray Tracing CMSC 435/634.
Shading Revisited Some applications are intended to produce pictures that look photorealistic, or close to it The image should look like a photograph A.
Introduction to Computer Graphics with WebGL
Ray Tracing Ed Angel Professor Emeritus of Computer Science
3D Graphics Rendering PPT By Ricardo Veguilla.
© University of Wisconsin, CS559 Fall 2004
Introduction to Computer Graphics with WebGL
CS5500 Computer Graphics May 29, 2006
CSCE 441: Computer Graphics Ray Tracing
GR2 Advanced Computer Graphics AGR
CS Advanced Computer Graphics
CSC418 Computer Graphics Raytracing Shadows Global Illumination.
Presentation transcript:

1 Ray Tracing Lecture 10 © Jeff Parker, Nov 2009

2 Introduction OpenGL is based on a pipeline model in which primitives are rendered one at time No shadows (except by tricks or multiple renderings) No reflections (though we can use multiple renderings) No refraction – thus no caustics Global approaches Rendering equation Ray tracing Radiosity

3 Image Credits Ed Angel - University of New Mexico Allan Watt's text, 3D Computer Graphics Brian Salomon, UNC G. Scott Owen Paul Bourke Gilles Tran and others, as credited

Currently We have rasterization with Phong lighting Strictly local illumination model: Ambient Diffuse Specular Shadows can be accomplished: Shadow maps Shadow volumes Can generate reflections using environment mapping but: Approximate Expensive with many reflective objects Hard to capture complex interreflections

5 Illumination Direct Illumination A surface point receives light from all visible lights Global Illumination Even if point is in shadow, Rays may pass through translucent material Light rays will bounce off other material in scene Want to sum all light that hits an object Beyond Radiosity: The Light of Mies van der Rohe

6 Example Eric Veach and Leonidas Guibas Image by Eric Veach and Leonidas Guibas

Timeline [Appel 68] “Some techniques for shading machine renderings of solids” Basic Ray Casting – designed for pen plotters: provides Perspective Accurate shadows [Whitted 80] “An Improved Illumination Model for Shaded Display” Reflection Refraction Shadows Hidden Surface Removal

8 Perspective Ray Tracing provides natural perspective The schemes used to develop perspective were tracing rays (Albrecht Durer)

9 Albrecht Durer Two alternatives

10 Ray Tracing Track the path of light between light source and the eye

11 Ray Tracing Track the path of light between light source and the eye Where do we start – at light or at eye?

12 Steps in Ray Casting Shot a ray from the eye through each pixel of the screen Calculate which objects in the scene the ray hits If the ray misses all objects, display background color

13 Ray Casting Shot a ray from the eye through each pixel of the screen Calculate which objects in the scene the ray hits If it hits an object, we know basic color Now check to see if surface is illuminated or in shade

14 Shadow Ray Shoot a "shadow" ray from intersection point towards light If shadow ray hits object before it hits light, point is in shadow This is Appel's original Algorithm – called Ray Casting today Only uses local illumination – does not track light bouncing off intermediate surfaces

15 Ray Casting cast ray Intersect all objects: select minimal t Color = ambient term For every light Cast shadow ray color += local shading term

16 In practice Run the first few steps of the following applet rt_java/raytrace.html

Whitted Raytracing (1980)

Turner Witted “An Improved Illumination Model for Shaded Display” First global illumination model. An object’s color is influenced by lights and other objects in the scene First to simulate specular reflection and refractive transmission 1986 –Amiga Juggler home.comcast.net/~erniew/juggler.html#avi

19 Reflected Ray If the object is shiny, we send a third "reflection" ray If this hits an object, the color of the object will be reflected in the original screen point To see if the new point is in the shade, send shadow ray The new object may be shiny…

20 Full Algorithm We have sketched the first steps. Will need to recurse… Need to modify the path of refracted light May wish to add specular highlights …

What does it offer? Hidden Surface Removal Shading due to direct Illumination Global specular interaction effects Reflections Refraction of light Shadow Computation Shadows are hard-edged

22 Diffuse Surfaces Theoretically scattering at each point of intersection generates an infinite number of new rays that should be traced In practice, we only trace the transmitted and reflected rays but use the Phong model to compute shade at intersection Radiosity works best for perfectly diffuse (Lambertian) surfaces

23 POV Ray Persistence of Vision Raytracer POV Ray Images by Gilles Tran

24 POV Ray

25 POV Ray

Match point in image with it's construction

27 Ray Tree

28 In practice Run the more steps of the following applet – move objects rt_java/raytrace.html

29 Raytracing trace ray Intersect all objects color = ambient term For every light cast shadow ray color += local shading term If mirror color += colorrefl * trace reflected ray If transparent color += colortrans * trace transmitted ray

Raytracing Is Simple Paul Heckbert wrote a raytracer that fits on a business card Prints something like a 32x32 P3.ppm file to standard out. typedef struct{double x,y,z}vec;vec U,black,amb={.02,.02,.02};struct sphere{ vec cen,color;double rad,kd,ks,kt,kl,ir}*s,*best,sph[]={0.,6.,.5,1.,1.,1.,.9,.05,.2,.85,0.,1.7,-1.,8.,-.5,1.,.5,.2,1.,.7,.3,0.,.05,1.2,1.,8.,-.5,.1,.8,.8, 1.,.3,.7,0.,0.,1.2,3.,-6.,15.,1.,.8,1.,7.,0.,0.,0.,.6,1.5,-3.,- 3.,12.,.8,1., 1.,5.,0.,0.,0.,.5,1.5,};yx;double u,b,tmin,sqrt(),tan();double vdot(A,B)vec A,B;{return A.x*B.x+A.y*B.y+A.z*B.z;}vec vcomb(a,A,B)double a;vec A,B;{B.x+=a* A.x;B.y+=a*A.y;B.z+=a*A.z;return B;}vec vunit(A)vec A;{return vcomb(1./sqrt( vdot(A,A)),A,black);}struct sphere*intersect(P,D)vec P,D;{best=0;tmin=1e30;s= sph+5;while(s-- >sph)b=vdot(D,U=vcomb(-1.,P,s->cen)),u=b*b-vdot(U,U)+s->rad*s ->rad,u=u>0?sqrt(u):1e31,u=b- u>1e-7?b-u:b+u,tmin=u>=1e-7&&u ir;d= -vdot(D,N=vunit(vcomb(-1.,P=vcomb(tmin,D,P),s->cen )));if(d sph)if((e=l - >kl*vdot(N,U=vunit(vcomb(-1.,P,l->cen))))>0&&intersect(P,U)==l)color=vcomb(e,l- >color,color);U=s->color;color.x*=U.x;color.y*=U.y;color.z*=U.z;e=1-eta* eta*(1-d*d);return vcomb(s->kt,e>0?trace(level,P,vcomb(eta,D,vcomb(eta*d-sqrt (e),N,black))):black,vcomb(s- >ks,trace(level,P,vcomb(2*d,N,D)),vcomb(s->kd, color,vcomb(s->kl,U,black))));}main(){printf("%d %d\n",32,32);while(yx<32*32) U.x=yx%32-32/2,U.z=32/2- yx++/32,U.y=32/2/tan(25/ ),U=vcomb(255., trace(3,black,vunit(U)),black),printf("%.0f %.0f %.0f\n",U);}/*minray!*/

31 When does it end? Diffuse surface – will not transmit or bounce Recursion depth: Stop after a number of bounces Ray contribution: Stop if reflected / transmitted contribution becomes too small No reflectionOne reflectionTwo reflections

32 Computation Would like to handle all physical interactions Ray tracing paradigm is not computational Most rays do not affect what we see Scattering produces many (infinite) additional rays Alternative: Ray Casting Various techniques to speed up Ray Tracing

Depth one and two 33

Adding levels 34

Adding… 35

Aliasing 36

37 Ray Casting a Sphere Ray is parametric Sphere is quadric Resulting equation is a scalar quadratic equation which gives entry and exit points of ray (or no solution if ray misses)

Ray intersects Sphere Equations of Sphere and Ray Plug the values for (x, y, z) from parameterized ray into Sphere, and solve for t

What does it mean? Equations of Sphere and Ray There are three cases: no roots (discriminent is negative), 2 roots, one root What does each mean?

Finer Points If we have a solution with a negative t, we reject it (why? What does it mean?) If we have a solution with a very small positive t, we reject it (why?) Hint – this can arise with a reflection ray

Epsilon Move intersection by epsilon along surface normal

What does it mean? The general conics can be described as quadratics The general case of ray/conic intersection is similar General polygons, the workhorse of modern graphics, are harder

43 Ray Tracing Quadrics Constructive Solid Geometry Primitives are solids Build objects with set operations Union, intersection, set difference

Ray Plane Intersection Equations of Ray and Plane Plug the values for P from parameterized ray into Plane, and solve for t

Ray Plane Intersection Solve this again with explicit values.

Intersections Spheres Polygons Boxes (AA and oriented) Quadrics Parameteric patches Subdivision surfaces Surfaces of revolution Fractals …

47 Polyhedra Generally we want to intersect with closed objects such as polygons and polyhedra rather than planes Hence we have to worry about inside/outside testing For convex objects such as polyhedra there are some fast tests

48 Ray Tracing Polyhedra If ray enters an object, it must enter a front facing polygon and leave a back facing polygon Polyhedron is formed by intersection of planes Ray enters at furthest intersection with front facing planes Ray leaves at closest intersection with back facing planes If entry is further away than exit, ray must miss the polyhedron

49 Problems for Ray Tracing Aliasing Finding all the intersections The technique we outlined had you intersect ray with all objects – time consuming

Aliasing 50

51 Aliasing Three types of solutions Super sampling Adaptive Sampling Stochastic Sampling

52 Finding All Intersections The technique we outlined had you intersect ray with all objects – time consuming Major alternatives Describe scene as collection of objects Try to bundle rays Carve space up into regions – two approaches Volumetric Pixels (voxels) and keep track of which voxels each object hits Split space via half planes

53 Intersections with Objects To reduce the number of computations, we may put bounding boxes around complex objects in the scene If we miss bounding box, we miss contents Early Reject

54 Dividing Space Alternatives Do we work parallel to axis or to objects or to ray? Carve space up into regions – two approaches Volumetric Pixels (voxels) and keep track of which voxels each object hits Split space via half planes: Two alternatives Binary Space Partitioning (BSP) Trees k-Dimensional (kd) Trees

55 Grid

56 Grid Divide scene deltaX need not be deltaY

57 Precompute In advance, figure out which grid boxes each object hits Each grid box keeps list of objects

58 For each box along a ray The ray hits this box This box hits these objects Test ray against each object Return the closest intersection, if any

59 Multiple Visits An object may hit multiple boxes We may encounter the same object multiple times Only test for intersections once: mark the object

60 Grid If intersection is not within the grid box boundaries, continue There may be a better intersection in a later box

61 Grid BSP Trees – in this case, we check almost all, but we check in order

62 KD Trees

63 Summary Ray Tracing provides a way to generate rich images Was too expensive for many uses Faster machines and software Offline processing Much work has gone into speeding it up Demo The Cathedral

64 Resources Persistence of Vision (POV-RAY) – free ray tracer. Descriptions in HLL Radiance – another package radsite.lbl.gov/radiance/HOME.html Internet Ray Tracing Competition – many winners used POV-RAY SIGGRAPH Educational Material Applet that traces a simple scene tml Examples pl887.pairlitesite.com/teach/cs384g-04-fall/projects/ray/ray_examples/