CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann.

Slides:



Advertisements
Similar presentations
Computer Graphics In4/MSc Computer Graphics Lecture Notes #15 Illumination III View Independent Rendering.
Advertisements

Modeling the Interaction of Light Between Diffuse Surfaces Cindy M. Goral, Keenth E. Torrance, Donald P. Greenberg and Bennett Battaile Presented by: Chris.
Illumination Models Radiosity Chapter 14 Section 14.7 Some of the material in these slides may have been adapted from University of Virginia, MIT, Colby.
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
Computer Graphics - Class 10
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Alla Sheffer Advanced Rendering Week.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
CSCE 641 Computer Graphics: Radiosity Jinxiang Chai.
CS 376 Introduction to Computer Graphics 03 / 26 / 2007 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
The Radiosity Method Donald Fong February 10, 2004.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 21: Radiosity
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
CSCE 641 Computer Graphics: Radiosity Jinxiang Chai.
1 Dr. Scott Schaefer Radiosity. 2/38 Radiosity 3/38 Radiosity Physically based model for light interaction View independent lighting Accounts for indirect.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
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.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Radiosity What we can do with scan line conversion and ray tracing What we can’t do Radiosity.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
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.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
-Global Illumination Techniques
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
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.
CS 376 Introduction to Computer Graphics 04 / 20 / 2007 Instructor: Michael Eckmann.
CS 445 / 645: Introductory Computer Graphics Light.
Global Illumination Models THE WHITTED IMAGE - BASIC RECURSIVE RAY TRACING Copyright © 1997 A. Watt and L. Cooper.
CS 325 Introduction to Computer Graphics 03 / 24 / 2010 Instructor: Michael Eckmann.
Graphics Lecture 13: Slide 1 Interactive Computer Graphics Lecture 13: Radiosity - Principles.
Introduction to Radiosity Geometry Group Discussion Session Jiajian (John) Chen 9/10/2007.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 14 / 2010 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 02 / 22 / 2010 Instructor: Michael Eckmann.
Radiosity Jian Huang, CS594, Fall 2002 This set of slides reference the text book and slides used at Ohio State.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Global Illumination: Radiosity, Photon Mapping & Path Tracing Rama Hoetzlein, 2009 Lecture Notes Cornell University.
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Monte-Carlo Ray Tracing and
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.
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
CSCE 441: Computer Graphics Ray Tracing
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Radiosity Radiosity.
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
CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
CS 376 Introduction to Computer Graphics 04 / 13 / 2007 Instructor: Michael Eckmann.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Global Illumination: Radiosity, Photon Mapping & Path Tracing
Illumination and Shading
CS 480/680 Computer Graphics Shading.
Presentation transcript:

CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Spring 2007 Today’s Topics Questions? bump mapping remark radiosity ray-sphere intersections using a geometric method which will result in tests that can be done in order reducing the computations done overall. review ray-polygon intersections

Bump mapping remark When calculating N', the perturbed normal: N' = P' u x P' v we do: N' = ( P u + B u n ) x ( P v + B v n ) which after we do the math is (P u x P v ) + B v (P u x n) + B u (n x P v ) + B u B v (n x n) The partial derivatives of P are computed to be vectors in the direction of slope (in the u direction and the v direction) The partial derivatives of B are computed to be scalars

RayTracing / Radiosity Ray Tracing is a type of direct llumination method in image space. Direct illumination in image space because the scene that we're rendering is made up of surfaces and lights and we compute the colors of the pixels one at a time. –If the view moves --- have to ray trace again –If the world moves --- have to ray trace again Ray tracing results in some realism but with a few drawbacks + Handles both diffuse and specular reflections as well as refractions –Compute intensive –Shadows are too crisp Radiosity is a type of global illumination method that works in object space. + If the view moves, we DO NOT have to rerun the radiosity algorithm = view independent –Only diffuse, no specular reflection (therefore no mirrorlike surfaces) + Shadows are softer, more realistic +/- Color bleeds from surfaces to nearby surfaces Radiosity and Ray tracing can be combined to produce a more realistic image than either one separately.

Radiosity What follows is an overview of radiosity We won't go into as much detail as ray tracing I can point you to some sources if you wish to learn more about radiosity

Radiosity Light reflects off of surfaces and onto other surfaces. The amount of reflected light that hits a surface is determined by –how much it is attenuated and –how much is absorbed before reflection. When some light is reflected off of surface S, the color of the surface S colors that reflected light to some extent. This reflected light then hits other surface(s). This effect causes color bleeding from one surface to another. Example image of radiosity “color bleeding”. Radiosity is a method of rendering a scene by considering the global illumination of the scene (as opposed to the way ray tracing does it) –scene is divided into patches (generally the smaller the better) –a patch will emit (if it's a light source) and reflect light uniformly over its surface

Radiosity Radiosity assumes –surfaces are diffuse emitters and diffuse reflectors –the emitting and reflecting is done uniformly over a “patch” –all light energy in the scene will be conserved --- either absorbed or reflected The radiosity of a surface is computed to be the sum of the light energy emitted (if a light source) and the (incident) light energy hitting the surface (coming from elsewhere). Attenuation is taken care of by –Form Factors (which represents the fraction of the light that is transferred from one surface to another) and –Reflectivity values (which represents the fraction of the light that is reflected from a surface)

Radiosity The Form Factor (the fraction of light that arrives at one surface from another) is computed based on –areas of the 2 surfaces involved –angles between the light travelling from one surface to the other and the surface normals –see text if you would like details A form factor is defined between all directed pairs of patches. F jk is the form factor from patch j to k it is the light energy incident on patch k divided by the total light energy leaving patch j

Radiosity The radiosity equation for a patch k, in a scene with n patches is: B k = E k + p k * Sum n j=1 [ B j F jk ] B k is the radiosity of patch k E k is the light emitted from patch k p k is the reflectivity fraction for patch k (the fraction of incident light that is reflected in all directions) F jk is the form factor from patch j to k

Radiosity For all n patches in the scene you have a radiosity equation that is based on the radiosity of all the n patches. To compute the radiosities you have to solve the n simultaneous equations. –Techniques exist to solve a system of simultaneous equations so not to worry, but it could be expensive The more patches we have the longer the radiosity calculations take, but the prettier our pictures will look (up to some point where reducing the size of our patches will not have any noticeable effect on the picture). Radiosity is compute intensive but the surfaces can have their radiosities precomputed if the world does not change. The radiosities are view independent. Therefore the radiosity of each patch can be precomputed and stored with the patch.

RayTracing / Radiosity Revisit the comparison Ray tracing results in some realism but with a few drawbacks + Handles both diffuse and specular reflections as well as refractions –Compute intensive –Shadows are too crisp –If the viewer moves --- have to ray trace again –If the world moves --- have to ray trace again Radiosity is a type of global illumination method that works in object space. + If the view moves, we DO NOT have to rerun the radiosity algorithm = view independent –Only diffuse, no specular reflection (therefore no mirrorlike surfaces) + Shadows are softer, more realistic + Color bleeds from surfaces to nearby surfaces (diffuse-diffuse reflections)

RayTracing / Radiosity Radiosity and Ray tracing can be combined to produce a more realistic image than either one separately. Radiosity algorithm would execute on the first pass and store the output with the surfaces. Then do Ray Tracing next based on viewer position. If the viewer position changes, but the world stays constant, radiosity does NOT need to be rerun (therefore we can precompute the radiosity of a scene.) However, radiosity would need to be rerun if the world changes in any way (e.g. lights move, objects move, etc.)

Ray / Sphere Intersection A ray is a “line” starting at some point and continuing out to infinity. P(s) = P 0 + R d s where P 0 is the starting point of the ray, R d is a unit directional vector and s is the parameter which represents the distance from P 0 Let's find the intersection of P(s) with a sphere with radius r and center point P c.

Ray / Sphere Intersection Earlier we saw an algebraic solution to the ray-sphere intersection. Here (with the accompanying drawings on the board) is a geometric solution that allows you to find out ealier in the computations if the ray and sphere do not intersect (thereby reducing unneeded computations.) 1. Determine if the ray's origin (P 0 ) is outside or inside of the sphere by: P 0 P c = P c – P 0. If the length squared of P 0 P c < r 2 then P 0 is inside sphere otherwise the it is outside the sphere and we continue onto step Find the length L, of the ray from P 0 to the point on the ray that is closest to the center of the sphere. L = | P 0 P c | cosA = |P 0 P c | |R d | cosA = P 0 P c R d If L < 0, then ray does not intersect with the sphere, done. Otherwise go to step 3.

Ray / Sphere Intersection 3. Find the square of the distance, E 2 from the point on the ray that is closest to the center of the sphere to the intersection of the the ray with the sphere. From pythagorean theorem, r 2 = E 2 + D 2 so E 2 = r 2 – D 2 Also from pythagorean theorem, D 2 = |P 0 P c | 2 – L 2 So, E 2 = r 2 – (|P 0 P c | 2 – L 2 ) If E 2 < 0, ray does not intersect the sphere, done. Otherwise go to step Find s, the parameter of the intersection to use for the ray equation P(s) = P 0 + R d s If ray originates outside the sphere then s = L – E If ray originates inside the sphere then s = L + E 5. Calculate the intersection using s from step 4, (x i, y i, z i ) = P 0 + R d s

Ray / Sphere Intersection 6. Calculate the normal vector at the intersection If ray's origin was outside the sphere, N = [(x i -x c )/r, (y i -y c )/r, (z i -z c )/r] If inside the sphere, N = [(x c -x i )/r, (y c -y i )/r, (z c -z i )/r] (this procedure is based on Drew Kessler's notes from Lehigh, 1999)

Ray / Polygon Intersection The first step in Ray/Polygon intersection is to compute the intersection of the ray with the plane that the polygon lives on. At this point we have –the plane equation Ax+By+Cz+D = 0 –the point of intersection P I = (x I, y I, z I ) of the ray and plane –the vertices V = (x j, y j, z j ) of the polygon on that plane A technique that makes computation easier at this point is to orthographically project the polygon onto either the x-y, y-z, or z-x plane. To do this we just have to ignore the same coordinate of all of the vertices of the polygon and we end up with 2d points. The best coordinate to ignore is the one whose corresponding coefficient in the plane equation is dominant (largest absolute value.)

Ray / Polygon Intersection The best coordinate to ignore is the one whose corresponding coefficient in the plane equation is dominant (largest absolute value.) It gives us a polygon in 2d with the largest area of the 3 choices.

Ray / Polygon Intersection Note: this technique is a combination of ideas from –Computer Graphics Principles and Practive by Foley, Van Dam, Feiner and Hughes, 1996 Addison-Wesley –Dr. G. Drew Kessler's csc313 course 1999, Lehigh Univ. and –Dr. Xiaoyu Zhang's Advanced Computer Graphics & Visualization page Example: If the plane equation is –0.2 x +0.4 y – z +5 = 0 we would orthographically project the polygon onto the x-y plane (ignore the z coordinate of each vertex) This will yield the largest (area) projection. Once we have done this projection, we can translate the intersection point P I to the origin of this new 2d space (call it u-v coordinates). Then determine whether the origin is inside or outside the polygon by counting the number of polygon edge crossings with the positive u axis.

Ray / Polygon Intersection The next algorithm distinguishes between several different situations to determine when to add 1 to the number of times the polygon's edges cross the positive u axis. For some edge –1) if the signs of the v coordinate in both vertices are the same, then that edge DOES NOT cross the positive u-axis –2) if the signs of the v coordinate in both vertices are different AND both u coordinates are positive then that edge DOES cross the positive u-axis. –3) if the signs of the v coordinate in both vertices are different AND one of the u coordinates is positive then compute the intersection of the line with v=0. If the u coordinate of this intersection is positive then that edge DOES cross the positive u-axis. –4) if the signs of the v coordinate in both vertices are different AND one of the u coordinates is positive then compute the intersection of the line with v=0. If the u coordinate of this intersection is not positive then that edge DOES NOT cross the positive u-axis. –For cases 2 and 3 above, add 1 to a counter. Do this for all edges in the polygon in order and then check the value of the counter --- if it is odd then the point is in the interior of the polygon and hence the ray intersects with the polygon.

Ray / Polygon Intersection The n vertices of the polygon are (u i, v i ) where i goes from 0 to n-1. Pseudocode to determine if the origin is inside the polygon initialize numCross to 0 if v 0 > 0 then signHold1 = +1 else signHold1 = -1 for each edge (u a, v a ) to (u b, v b ) { if v b > 0, signHold2 = +1, else signHold2 = -1 if signHold1 != signHold2 { if u a and u b are both > 0, then numCross++ if one of u a or u b is > 0, then { if (crossPosUAxis(u a, v a, u b, v b ) then numCross++ } } signHold1 = signHold2 } if numCross is odd, then the ray and polygon intersect

Ray / Polygon Intersection pseudocode for crossPosUAxis recall the parametric equations of a line: u = u b + (u a - u b )t v = v b + (v a - v b )t = 0 (because we're looking for intersection with u axis) so, use the second equation to solve for t then solve the first for u and get u = (u b + ( u a - u b ) * ( v b / (v b -v a ) ) ) crossPosUAxis(u a, v a, u b, v b ) if ( (u b + ( u a - u b ) * ( v b / (v b -v a ) ) ) > 0 ) return true else return false