CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi

Slides:



Advertisements
Similar presentations
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Advertisements

Graphics Pipeline.
Lecture 14 Illumination II – Global Models
3D Graphics Rendering and Terrain Modeling
Part I: Basics of Computer Graphics
Christian Lauterbach COMP 770, 2/11/2009
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 15: Ray Tracing/Global Illumination Ravi Ramamoorthi Slides.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
1/12/09 1 Introduction Computer Graphics COMP 770 (236) Spring 2009 Instructor: Dinesh Manocha.
3D Graphics Processor Architecture Victor Moya. PhD Project Research on architecture improvements for future Graphic Processor Units (GPUs). Research.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 2: Basic Ray Tracing Ravi Ramamoorthi Some slides courtesy.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
Computer Graphics Shadows
Computer Graphics Mirror and Shadows
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Advanced Rendering University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
Foundations of Computer Graphics (Spring 2012) CS 184, Lectures 16, 18: Nuts and bolts of Ray Tracing Acknowledgements:
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.
CS559: Computer Graphics Lecture 36: Animation Li Zhang Spring 2008 Slides from Brian Curless at U of Washington.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CS559: Computer Graphics Lecture 28: Ray Tracing Li Zhang Spring 2010 Slides are from Ravi Ramamoorthi’s graphics class at Columbia U.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
RENDERING : Global Illumination
CS559: Computer Graphics Lecture 27: Animation, Depth & Motion Blur, Ray Tracing Li Zhang Spring 2010 Slides from Brian Curless at U of Washington.
CS559: Computer Graphics Lecture 27: Animation, Depth & Motion Blur, Ray Tracing Li Zhang Spring 2010 Slides from Brian Curless at U of Washington.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
Advanced Computer Graphics
Computer Graphics CSE 167 [Win 17], Lectures 16, 17:
- Introduction - Graphics Pipeline
Photorealistic Rendering vs. Interactive 3D Graphics
Week 2 - Friday CS361.
Lecture 36: Animation Li Zhang Spring 2008
Ray Tracing Forward Ray Tracing
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
Understanding Theory and application of 3D
Models and Architectures
© University of Wisconsin, CS559 Fall 2004
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
(c) 2002 University of Wisconsin
Visibility Computations
Ray-tracing Algorithm and Hardware
Models and Architectures
COMP 575/770 Review Session May 4, 2016.
Image synthesis using classical optics
CS5500 Computer Graphics May 29, 2006
Models and Architectures
CSCE 441: Computer Graphics Ray Tracing
GR2 Advanced Computer Graphics AGR
Presentation transcript:

CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi Computer Graphics CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi http://viscomp.ucsd.edu/classes/cse167/wi17

Effects needed for Realism (Soft) Shadows Reflections (Mirrors and Glossy) Transparency (Water, Glass) Interreflections (Color Bleeding) Complex Illumination (Natural, Area Light) Realistic Materials (Velvet, Paints, Glass) And many more

Image courtesy Paul Heckbert 1983

Ray Tracing Different Approach to Image Synthesis as compared to Hardware pipeline (OpenGL) Pixel by Pixel instead of Object by Object Easy to compute shadows/transparency/etc

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Ray Tracing: History Appel 68 Whitted 80 [recursive ray tracing] Landmark in computer graphics Lots of work on various geometric primitives Lots of work on accelerations Current Research Real-Time raytracing (historically, slow technique) Ray tracing architecture

Ray Tracing History

Ray Tracing History

Outline in Code Image Raytrace (Camera 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] = FindColor (hit) ; } return image ;

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Ray Casting Produce same images as with OpenGL Visibility per pixel instead of Z-buffer Find nearest object by shooting rays into scene Shade it as in standard OpenGL

Ray Casting Virtual Viewpoint Virtual Screen Objects Multiple intersections: Use closest one (as does OpenGL) Ray intersects object: shade using color, lights, materials Ray misses all objects: Pixel colored black

Comparison to hardware scan-line Per-pixel evaluation, per-pixel rays (not scan-convert each object). On face of it, costly But good for walkthroughs of extremely large models (amortize preprocessing, low complexity) More complex shading, lighting effects possible

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Shadows Light Source Virtual Viewpoint Virtual Screen Objects Shadow ray to light is blocked: object in shadow Shadow ray to light is unblocked: object visible

Shadows: Numerical Issues Numerical inaccuracy may cause intersection to be below surface (effect exaggerated in figure) Causing surface to incorrectly shadow itself Move a little towards light before shooting shadow ray

Mirror Reflections/Refractions Generate reflected ray in mirror direction, Get reflections and refractions of objects Virtual Viewpoint Virtual Screen Objects

Recursive Ray Tracing For each pixel Trace Primary Eye Ray, find intersection Trace Secondary Shadow Ray(s) to all light(s) Color = Visible ? Illumination Model : 0 ; Trace Reflected Ray Color += reflectivity * Color of reflected ray

Problems with Recursion Reflection rays may be traced forever Generally, set maximum recursion depth Same for transmitted rays (take refraction into account)

Turner Whitted 1980

Effects needed for Realism (Soft) Shadows Reflections (Mirrors and Glossy) Transparency (Water, Glass) Interreflections (Color Bleeding) Complex Illumination (Natural, Area Light) Realistic Materials (Velvet, Paints, Glass) Discussed in this lecture Not discussed but possible with distribution ray tracing Hard (but not impossible) with ray tracing; radiosity methods

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Ray/Object Intersections Heart of Ray Tracer One of the main initial research areas Optimized routines for wide variety of primitives Various types of info Shadow rays: Intersection/No Intersection Primary rays: Point of intersection, material, normals Texture coordinates Work out examples Triangle, sphere, polygon, general implicit surface

Ray-Sphere Intersection

Ray-Sphere Intersection Substitute Simplify

Ray-Sphere Intersection 2 real positive roots: pick smaller root Both roots same: tangent to sphere One positive, one negative root: ray origin inside sphere (pick + root) Complex roots: no intersection (check discriminant of equation first) Solve quadratic equations for t

Ray-Sphere Intersection 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: B A C

Ray-Triangle Intersection One approach: Ray-Plane intersection, then check if inside triangle Plane equation: Combine with ray equation: B A C

Ray inside Triangle Once intersect with plane, still need to find if in triangle Many possibilities for triangles, general polygons (point in polygon tests) We find parametrically [barycentric coordinates]. Also useful for other applications (texture mapping) A B C P α β γ

Ray inside Triangle A B C P α β γ

Other primitives Much early work in ray tracing focused on ray-primitive intersection tests Cones, cylinders, ellipsoids Boxes (especially useful for bounding boxes) General planar polygons Many more Many references. For example, chapter in Glassner introduction to ray tracing (see me if interested)

Ray-Tracing Transformed Objects We have an optimized ray-sphere test But we want to ray trace an ellipsoid… Solution: Ellipsoid transforms sphere Apply inverse transform to ray, use ray-sphere Allows for instancing (traffic jam of cars) Mathematical details worked out in class

Transformed Objects Consider a general 4x4 transform M Will need to implement matrix stacks like in OpenGL Apply 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 Distance to intersection if used may need recalculation Normals n transform as M-tn. Do all this before lighting

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Acceleration Testing each object for each ray is slow Fewer Rays Adaptive sampling, depth control Generalized Rays Beam tracing, cone tracing, pencil tracing etc. Faster Intersections Optimized Ray-Object Intersections Fewer Intersections We just discuss some approaches at high level; chapter 13 briefly covers

Acceleration Structures Bounding boxes (possibly hierarchical) If no intersection bounding box, needn’t check objects Bounding Box Ray Spatial Hierarchies (Oct-trees, kd trees, BSP trees)

Acceleration Structures: Grids

Acceleration and Regular Grids Simplest acceleration, for example 5x5x5 grid For each grid cell, store overlapping triangles March ray along grid (need to be careful with this), test against each triangle in grid cell More sophisticated: kd-tree, oct-tree bsp-tree Or use (hierarchical) bounding boxes Try to implement some acceleration in HW 4

Outline History Basic Ray Casting (instead of rasterization) Comparison to hardware scan conversion Shadows / Reflections (core algorithm) Ray-Surface Intersection Optimizations Current Research

Interactive Raytracing Ray tracing historically slow Now viable alternative for complex scenes Key is sublinear complexity with acceleration; need not process all triangles in scene Allows many effects hard in hardware NVIDIA OptiX ray-tracing API like OpenGL

Raytracing on Graphics Hardware Modern Programmable Hardware general streaming architecture Can map various elements of ray tracing Kernels like eye rays, intersect etc. In vertex or fragment programs Convergence between hardware, ray tracing [Purcell et al. 2002, 2003] http://graphics.stanford.edu/papers/photongfx