CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.

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.
Lecture 14 Illumination II – Global Models
Shadow Rendering Techniques A point is in the shadow of a light source if it can not be “seen” by the light source, i.e. the line segment that connects.
Graphics Graphics Korea University cgvr.korea.ac.kr Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
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.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
Christian Lauterbach COMP 770, 2/11/2009
Ray Tracing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
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.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
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 Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
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.
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.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
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.
Presentation by Dr. David Cline Oklahoma State University
Computer graphics & visualization Ray-Tracing – A Quick review.
COMP 175: Computer Graphics March 24, 2015
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
-Global Illumination Techniques
Ray Tracing Sang Il Park SEjong University With lots of slides stolen from Jehee Lee, Doug James, Steve Seitz, Shree Nayar, Alexei Efros, Fredo Durand.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Global Illumination Models THE WHITTED IMAGE - BASIC RECURSIVE RAY TRACING Copyright © 1997 A. Watt and L. Cooper.
111/17/ :21 Graphics II Global Rendering and Radiosity Session 9.
Basic Ray Tracing CMSC 435/634.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
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 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
In the name of God Computer Graphics. Last Time Some techniques for modeling Today Global illumination and raytracing.
Local Illumination and Shading
Illumination 2013, Fall. Ray Casting Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Radiosity Radiosity.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
Distributed Ray Tracing. Can you get this with ray tracing?
Distributed Ray Tracing. Can you get this with ray tracing?
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.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.
Computer Graphics: Illumination
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Advanced Computer Graphics
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
Illumination 2016, Fall.
Lighting.
Advanced Computer Graphics
GR2 Advanced Computer Graphics AGR
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting

Review We have a model for determining the brightness (radiance) of a ray rooted at a point on a surface and oriented towards the cameraDirect illumination only –Ambient term –Diffuse term –Specular term We have a model for determining the brightness (radiance) of a ray rooted at a point on a surface and oriented towards the cameraDirect illumination only –Ambient term –Diffuse term –Specular term

Combining Everything Simple analytic model: diffuse reflection +diffuse reflection + specular reflection +specular reflection + emission +emission + “ambient”“ambient” Simple analytic model: diffuse reflection +diffuse reflection + specular reflection +specular reflection + emission +emission + “ambient”“ambient” Surface

The Final Combined Equation Single light source: N L R V Viewer  

What influences these terms? Influencing factors Light positionLight position Sample point positionSample point position Camera positionCamera position Surface angle with respect to light vectorSurface angle with respect to light vector Surface angle with respect to camera vectorSurface angle with respect to camera vector Influencing factors Light positionLight position Sample point positionSample point position Camera positionCamera position Surface angle with respect to light vectorSurface angle with respect to light vector Surface angle with respect to camera vectorSurface angle with respect to camera vector

Direct illumination questions Camera moves from one position to anotherCamera moves from one position to another –Angle between light and surface unchanged –Angle between camera and surface changes A tracking camera follows object as it moves in sceneA tracking camera follows object as it moves in scene –Angle between light and surface changes –Angle between camera and surface unchanged An object moves from on position to anotherAn object moves from on position to another –Both angles have changed Camera moves from one position to anotherCamera moves from one position to another –Angle between light and surface unchanged –Angle between camera and surface changes A tracking camera follows object as it moves in sceneA tracking camera follows object as it moves in scene –Angle between light and surface changes –Angle between camera and surface unchanged An object moves from on position to anotherAn object moves from on position to another –Both angles have changed

Provides a way to measure radiance at a point in a specific direction What points?What points? –Vertices  What do you do for points between vertices? Provides a way to measure radiance at a point in a specific direction What points?What points? –Vertices  What do you do for points between vertices? Direct Illumination This becomes a problem of “shading” and we’ll discuss it later

Provides a way to measure radiance at a point in a specific direction What points?What points? –Other points to sample? Provides a way to measure radiance at a point in a specific direction What points?What points? –Other points to sample? Direct Illumination This is a form of ray casting. We’ll talk about it next

Direct Illumination Provides a way to measure radiance at a point in a specific direction What points?What points? What directions?What directions? –Towards the camera –No secondary effects Provides a way to measure radiance at a point in a specific direction What points?What points? What directions?What directions? –Towards the camera –No secondary effects

Overview Direct (Local) Illumination Emission at light sourcesEmission at light sources Scattering at surfacesScattering at surfaces Global illumination ShadowsShadows RefractionsRefractions Inter-object reflectionsInter-object reflections Direct (Local) Illumination Emission at light sourcesEmission at light sources Scattering at surfacesScattering at surfaces Global illumination ShadowsShadows RefractionsRefractions Inter-object reflectionsInter-object reflections Direct Illumination

Global Illumination We’ve glossed over how light really works And we will continue to do so… One step better Global Illumination The notion that a point is illuminated by more than light from local lights; it is illuminated by all the emitters and reflectors in the global sceneThe notion that a point is illuminated by more than light from local lights; it is illuminated by all the emitters and reflectors in the global scene We’ve glossed over how light really works And we will continue to do so… One step better Global Illumination The notion that a point is illuminated by more than light from local lights; it is illuminated by all the emitters and reflectors in the global sceneThe notion that a point is illuminated by more than light from local lights; it is illuminated by all the emitters and reflectors in the global scene

The ‘Rendering Equation’ Jim Kajiya (Current head of Microsoft Research) developed this in 1986 I(x, x’) = total intensity from point x’ to x g(x, x’) = 0 when x/x’ are occluded = 1/d 2 otherwise (d = distance between x and x’)  (x, x’) = intensity emitted by x’ to x  (x, x’,x’’) = intensity of light reflected from x’’ to x through x’ S = all points on all surfaces Jim Kajiya (Current head of Microsoft Research) developed this in 1986 I(x, x’) = total intensity from point x’ to x g(x, x’) = 0 when x/x’ are occluded = 1/d 2 otherwise (d = distance between x and x’)  (x, x’) = intensity emitted by x’ to x  (x, x’,x’’) = intensity of light reflected from x’’ to x through x’ S = all points on all surfaces

x'x' xx g(x, x') 1 or 1/d 2 depending on visibility

x'x' xx  (x, x') emissivityemissivity

x'x' xx  (x', x'')  (x, x', x'')

The ‘Rendering Equation’ The light that hits x from x’ is the direct illumination from x’ and all the light reflected by x’ from all x’’ To implement: Must handle recursion effectivelyMust handle recursion effectively Must support diffuse and specular lightMust support diffuse and specular light Must model object shadowingMust model object shadowing The light that hits x from x’ is the direct illumination from x’ and all the light reflected by x’ from all x’’ To implement: Must handle recursion effectivelyMust handle recursion effectively Must support diffuse and specular lightMust support diffuse and specular light Must model object shadowingMust model object shadowing

The ‘Rendering Equation’ What’s really hard about computing this? The integral… How can one compute  (x, x') for all points x and x'?How can one compute  (x, x') for all points x and x'? Approximate!!!Approximate!!! What’s really hard about computing this? The integral… How can one compute  (x, x') for all points x and x'?How can one compute  (x, x') for all points x and x'? Approximate!!!Approximate!!!

Approximating the Rendering Equation Don’t integrate over all points, just a subset Ray TracingRay Tracing –Considered a Monte Carlo approximation  Monte Carlo == Random “sampling” of real answer Consider pulling colored balls from an urn to approximate the ratio of its contents Don’t integrate over all points, just a subset Ray TracingRay Tracing –Considered a Monte Carlo approximation  Monte Carlo == Random “sampling” of real answer Consider pulling colored balls from an urn to approximate the ratio of its contents by Gilles Tran

Approximating the Rendering Equation Group “all points” into sets and consider all sets RadiosityRadiosity –Considered a finite- element approximation  What are the models that approximate light transfer from one finite element to another? Consider electing the President from the sum of the states rather than the sum of all people Group “all points” into sets and consider all sets RadiosityRadiosity –Considered a finite- element approximation  What are the models that approximate light transfer from one finite element to another? Consider electing the President from the sum of the states rather than the sum of all people

Ray Casting A simple form of Ray Tracing View plane Eye position Simplest method is ray casting Simplest method is ray casting Rays through view plane

Ray Casting To create each sample … Construct ray from eye position through view planeConstruct ray from eye position through view plane Find first surface intersected by ray through pixelFind first surface intersected by ray through pixel Compute color sample based on surface radianceCompute color sample based on surface radiance To create each sample … Construct ray from eye position through view planeConstruct ray from eye position through view plane Find first surface intersected by ray through pixelFind first surface intersected by ray through pixel Compute color sample based on surface radianceCompute color sample based on surface radiance

Ray Casting For each sample … Construct ray from eye position through view planeConstruct ray from eye position through view plane Find first surface intersected by ray through pixelFind first surface intersected by ray through pixel Compute color sample based on surface radianceCompute color sample based on surface radiance For each sample … Construct ray from eye position through view planeConstruct ray from eye position through view plane Find first surface intersected by ray through pixelFind first surface intersected by ray through pixel Compute color sample based on surface radianceCompute color sample based on surface radiance Samples on view plane Eye position Rays through view plane

Ray Casting Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; } Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; }

Ray Casting Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; } Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; }

Constructing Ray Through a Pixel right back Up direction P0P0 towards View Plane P V Ray: P = P 0 + tV

Constructing Ray Through a Pixel 2D Example d  towards P0P0 right right = towards x up  = frustum half-angle d = distance to view plane P1 = P 0 + d*towards – d*tan(  )*right P2 = P 0 + d*towards + d*tan(  )*right P1 P2 2*d*tan(  P P = P1 + (i/width + 0.5) * (P2 - P1) = P1 + (i/width + 0.5) * 2*d*tan (  )*right V = (P - P 0 ) / ||P - P 0 || V Ray: P = P 0 + tV

Ray Casting Simple implementation: Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; } Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j); Intersection hit = FindIntersection(ray, scene); image[i][j] = GetColor(hit); } return image; }

Ray-Scene Intersection Intersections with geometric primitives SphereSphere TriangleTriangle Groups of primitives (scene)Groups of primitives (scene) Intersections with geometric primitives SphereSphere TriangleTriangle Groups of primitives (scene)Groups of primitives (scene)

Ray-Sphere Intersection Ray: P = P 0 + tV Sphere: |P - C| 2 - r 2 = 0 P0P0 V C P r P’

Ray-Sphere Intersection Ray: P = P 0 + tV Sphere: |P - C| 2 - r 2 = 0 Substituting for P, we get: |P 0 + tV - C| 2 - r 2 = 0 Solve quadratic equation: at 2 + bt + c = 0 where: a = |V| 2 = 1 b = 2 V (P 0 - C) c = |P 0 - C| 2 - r 2 P = P 0 + tV P0P0 V C P r P’ If ray direction is normalized!

Ray-Sphere Intersection P0P0 V C P r N = (P - C) / ||P - C|| N Need normal vector at intersection for lighting calculations

Ray-Scene Intersection Intersections with geometric primitives SphereSphere »Triangle Groups of primitives (scene)Groups of primitives (scene) Intersections with geometric primitives SphereSphere »Triangle Groups of primitives (scene)Groups of primitives (scene)

Ray-Triangle Intersection First, intersect ray with plane Then, check if point is inside triangle First, intersect ray with plane Then, check if point is inside triangle P P0P0 V

Ray-Plane Intersection Ray: P = P 0 + tV Plane: P N + d = 0 Substituting for P, we get: (P 0 + tV) N + d = 0 Solution: t = -(P 0 N + d) / (V N) N P P0P0 VP = P 0 + tV

Ray-Triangle Intersectio Check if point is inside triangle parametrically P P0P0 Compute  P =  (T 2 -T 1 ) +  (T 3 -T 1 ) Check if point inside triangle. 0   1 and 0   1  V   T1T1 T2T2 T3T3

Other Ray-Primitive Intersections Cone, cylinder, ellipsoid: Similar to sphereSimilar to sphereBox Intersect 3 front-facing planes, return closestIntersect 3 front-facing planes, return closest Convex polygon Same as triangle (check point-in-polygon algebraically)Same as triangle (check point-in-polygon algebraically) Concave polygon Same plane intersectionSame plane intersection More complex point-in-polygon testMore complex point-in-polygon test Cone, cylinder, ellipsoid: Similar to sphereSimilar to sphereBox Intersect 3 front-facing planes, return closestIntersect 3 front-facing planes, return closest Convex polygon Same as triangle (check point-in-polygon algebraically)Same as triangle (check point-in-polygon algebraically) Concave polygon Same plane intersectionSame plane intersection More complex point-in-polygon testMore complex point-in-polygon test

Ray Casting – direct illumination Trace primary rays from camera Direct illumination from unblocked lights onlyDirect illumination from unblocked lights only Trace primary rays from camera Direct illumination from unblocked lights onlyDirect illumination from unblocked lights only

Shadows Shadow term tells if light sources are blocked Cast ray towards each light source L iCast ray towards each light source L i S i = 0 if ray is blocked, S i = 1 otherwiseS i = 0 if ray is blocked, S i = 1 otherwise 0 < S i < 1  soft shadows (hack)0 < S i < 1  soft shadows (hack) Shadow term tells if light sources are blocked Cast ray towards each light source L iCast ray towards each light source L i S i = 0 if ray is blocked, S i = 1 otherwiseS i = 0 if ray is blocked, S i = 1 otherwise 0 < S i < 1  soft shadows (hack)0 < S i < 1  soft shadows (hack)

Recursive Ray Tracing – second-order effects Also trace secondary rays from hit surfaces Global illumination from mirror reflection and transparencyGlobal illumination from mirror reflection and transparency Also trace secondary rays from hit surfaces Global illumination from mirror reflection and transparencyGlobal illumination from mirror reflection and transparency

Mirror reflections Trace secondary ray in mirror direction Evaluate radiance along secondary ray and include it into illumination modelEvaluate radiance along secondary ray and include it into illumination model Trace secondary ray in mirror direction Evaluate radiance along secondary ray and include it into illumination modelEvaluate radiance along secondary ray and include it into illumination model Radiance for mirror reflection ray IRIR

Transparency Trace secondary ray in direction of refraction Evaluate radiance along secondary ray and include it into illumination modelEvaluate radiance along secondary ray and include it into illumination model Trace secondary ray in direction of refraction Evaluate radiance along secondary ray and include it into illumination modelEvaluate radiance along secondary ray and include it into illumination model Radiance for refraction ray ITIT

Transparency Transparency coefficient is fraction transmitted K T = 1 for translucent object, K T = 0 for opaqueK T = 1 for translucent object, K T = 0 for opaque 0 < K T < 1 for object that is semi-translucent0 < K T < 1 for object that is semi-translucent Transparency coefficient is fraction transmitted K T = 1 for translucent object, K T = 0 for opaqueK T = 1 for translucent object, K T = 0 for opaque 0 < K T < 1 for object that is semi-translucent0 < K T < 1 for object that is semi-translucent Transparency Coefficient KTKT

Refractive Transparency For thin surfaces, can ignore change in direction Assume light travels straight through surfaceAssume light travels straight through surface For thin surfaces, can ignore change in direction Assume light travels straight through surfaceAssume light travels straight through surface N L ii T rr rr ii ii T

Refractive Tranparency N L ii T rr rr ii For solid objects, apply Snell’s law:

Summary Ray casting (direct Illumination) Usually use simple analytic approximations for light source emission and surface reflectanceUsually use simple analytic approximations for light source emission and surface reflectance Recursive ray tracing (global illumination) Incorporate shadows, mirror reflections, and pure refractionsIncorporate shadows, mirror reflections, and pure refractions Ray casting (direct Illumination) Usually use simple analytic approximations for light source emission and surface reflectanceUsually use simple analytic approximations for light source emission and surface reflectance Recursive ray tracing (global illumination) Incorporate shadows, mirror reflections, and pure refractionsIncorporate shadows, mirror reflections, and pure refractions More on global illumination later! All of this is an approximation so that it is practical to compute All of this is an approximation so that it is practical to compute