MC930/MO603 Ray Casting. Light is bouncing photons.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

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.
3D Graphics Rendering and Terrain Modeling
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
Computação Gráfica Coordenadas baricêntricas. Interp. shading for ray tracing Suppose we know colors or normals at vertices –How do we compute the color/normal.
Light Issues in Computer Graphics Presented by Saleema Amershi.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Christian Lauterbach COMP 770, 2/11/2009
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Alla Sheffer Advanced Rendering Week.
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 TRACING.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
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.
Week 13 - Wednesday CS361.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
Computer graphics & visualization Ray-Tracing – A Quick review.
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.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
-Global Illumination Techniques
1 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
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.
Recursion and Data Structures in Computer Graphics Ray Tracing 1.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
Alex YAU Important Notes Website for Assignment #2 You.
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
CS 376 Introduction to Computer Graphics 04 / 02 / 2007 Instructor: Michael Eckmann.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
MIT EECS 6.837, Cutler and Durand 1 Ray Casting II.
CSCE 441: Computer Graphics Ray Tracing
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann.
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
Photorealistic Rendering vs. Interactive 3D Graphics
Intersecting Simple Surfaces
3D Graphics Rendering PPT By Ricardo Veguilla.
Sign name list.
© University of Wisconsin, CS559 Fall 2004
Image synthesis using classical optics
CS5500 Computer Graphics May 29, 2006
GR2 Advanced Computer Graphics AGR
Simple Texture Mapping
Presentation transcript:

MC930/MO603 Ray Casting

Light is bouncing photons

Forward Ray tracing Rays are the paths of these photons This method of rendering by following photon paths is called ray tracing Forward ray tracing follows the photon in direction that light travels (from the source) BIG problem with this approach: –Only a tiny fraction of rays will reach the image –Extremely slow Ideal Scenario: –we'd like to magically know which rays will eventually contribute tothe image, and trace only those

Backward ray tracing

Basic ideas: –Each pixel gets light from just one direction - the line through the image point and focal point –Any photon contributing to that pixel’s color has to come from this direction –So head in that direction and find what is sending light this way –If we hit a light source - we’re done –If we find nothing - we’re done –If we hit a surface - see where that surface is lit from At the end we’ve done forward ray tracing, but only for the rays that contribute to the image

Ray casting This version of ray tracing is often called ray casting The algorithm is: loop y loop x shoot ray from eye point through pixel (x,y) into scene intersect with all surfaces, find first one the ray hits shade that point to compute pixel (x,y)’s color (perhaps simulating shadows) A ray is p+td: p is ray origin, d the direction –t=0 at origin of ray, t>0 in positive direction of ray –typically assume ||d||=1 –p and d are typically computed in world space This is easily generalized to give recursive ray tracing...

Recursive ray tracing We’ll distinguish four ray types: –Eye rays: orginate at the eye –Shadow rays: from surface point toward light source –Reflection rays: from surface point in mirror direction –Transmission rays: from surface point in refracted direction –Trace all of these recursively. More on this later.

Writing a simple ray caster

Ray surface intersections Ray equation: (given origin p and direction d) x(t) = p+td Compute Intersections: –Substitute ray equation for x –Find roots –Implicit: f(p + td) = 0 –» one equation in one unknown – univariate root finding –Parametric: p + td - g(u,v) = 0 –»three equations in three unknowns (t,u,v) – multivariate root finding –For univariate polynomials, use closed form soln. otherwise use numerical root finder

The devil´s in the details

Ray sphere intersection Ray-sphere intersection is an easy case A sphere’s implicit function is: x2+y2+z2-r2=0 if sphere at origin The ray equation is: x = px+tdx y = py+tdy z = pz+tdz Substitution gives: (px+tdx)2 + (py+tdy)2 + (pz+tdz)2 - r2 = 0 A quadratic equation in t. Solve the standard way: A = dx2+dy2+dz2 = 1 (unit vec.) B = 2(pxdx+pydy+pzdz ) C = px2+py2+pz2 - r2 Quadratic formula has two roots: t=(-B±sqrt(B2-4C))/2 –which correspond to the two intersection points –negative discriminant means ray misses sphere

Ray polygon intersection Assuming we have a planar polygon –first, find intersection point of ray with plane –then check if that point is inside the polygon Latter step is a point-in-polygon test in 3-D: –inputs: a point x in 3-D and the vertices of a polygon in 3-D –output: INSIDE or OUTSIDE –problem can be reduced to point-in-polygon test in 2-D Point-in-polygon test in 2-D: –easiest for triangles –easy for convex n-gons –harder for concave polygons –most common approach: subdivide all polygons into triangles –for optimization tips, see article by Haines in the book Graphics Gems IV

Ray plane intersection

Projecting a polygon 3D to 2D

Interp. shading for ray tracing Suppose we know colors or normals at vertices –How do we compute the color/normal of a specified point inside? Color depends on distance to each vertex –Want this to be linear (so we get same answer as scanline algorithm such as Gouraud or Phong shading) –But how to do linear interpolation between 3 points? –Answer: barycentric coordinates Useful for ray-triangle intersection testing too!

Barycentric coordinates in 1D Linear interpolation between colors C0 and C1 by t We can rewrite this as Geometric intuition: We are weighting each vertex by ratio of distances (or areas) a b a and b are called barycentric coordinates C0CC1

Barycentric coordinates in 2D Now suppose we have 3 points instead of 2 Define three barycentric coordinates: a, b, g How to define a, b, and g ? C0 C1 C2

Para um triangulo efine barycentric coordinates to be ratios of triangle areas

Calculando area de um triângulo in 3-D –Area(ABC) = parallelogram area / 2 = ||(B-A) x (C-A)||/2 –faster: project to xy, yz, or zx, use 2D formula in 2-D –Area(xy-projection(ABC)) = [(bx-ax)(cy-ay) – (cx-ax)(by-ay)]/2 project A,B,C to xy plane, take z component of cross product –positive if ABC is CCW (counterclockwise) A B C

Usando álgebra That short formula Area(ABC) = [(bx-ax)(cy-ay) – (cx-ax)(by-ay)]/2 Where did it come from? The short & long formulas above agree. Short formula better because fewer multiplies. Speed is important! Can we explain the formulas geometrically? cy ay by ax bxcx

Computing area from geometry Area(ABC) =[(bx-ax)(cy-ay) – (cx-ax)(by-ay)]/2 is a sum of rectangle areas, divided by 2. +/2= ? ! ! cy ay by ax bx cx (bx-ax)(cy-ay)(cx-ax)(by-ay) It works:-).

Usando coordeandas baricêntricas Can use barycentric coordinates to interpolate any quantity –Gouraud Shading (color interpolation) –Phong Shading (normal interpolation) –Texture mapping ((s,t) texture coordinate interpolation)