Prof. Harriet Fell Spring 2007 Lecture 26 – March 19, 2007

Slides:



Advertisements
Similar presentations
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Advertisements

Illumination and Shading
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.
University of New Mexico
Computer Graphics - Class 10
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
(conventional Cartesian reference system)
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
CS 325 Introduction to Computer Graphics 03 / 26 / 2010 Instructor: Michael Eckmann.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
CSE 381 – Advanced Game Programming GLSL Lighting.
CS 325 Introduction to Computer Graphics 03 / 24 / 2010 Instructor: Michael Eckmann.
Introduction to 3D Graphics Lecture 2: Mathematics of the Simple Camera Anthony Steed University College London.
Illumination.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
College of Computer and Information Science, Northeastern UniversityJanuary 6, CS4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 22 –
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Local Illumination and Shading
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Illumination and Shading Sang Il Park Sejong University.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
7. Illumination Phong Illumination Diffuse, Specular and Ambient
Shading CS 465 Lecture 4 © 2004 Steve Marschner • 1.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
CS G140 Graduate Computer Graphics
Unit-7 Lighting and Shading
Chapter 14 Shading Models.
Prof. Harriet Fell Fall 2011 Lecture 24 – November 2, 2011
Ray Tracing.
Illumination Model How to compute color to represent a scene
CSE 470 Introduction to Computer Graphics Arizona State University
Illumination and Shading
Fundamentals of Computer Graphics Part 6 Shading
Prof. Harriet Fell Spring 2006 Lecture 21 – February 28,2007
Isaac Gang University of Mary Hardin-Baylor
Illumination and Shading
Advanced Computer Graphics
14th Lecture – Final Lecture
GR2 Advanced Computer Graphics AGR
CS G140 Graduate Computer Graphics
Computer Graphics Material Colours and Lighting
Computer Graphics (Fall 2003)
Chapter 14 Shading Models.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Introduction to Ray Tracing
Presentation transcript:

Prof. Harriet Fell Spring 2007 Lecture 26 – March 19, 2007 CS U540 Computer Graphics Prof. Harriet Fell Spring 2007 Lecture 26 – March 19, 2007 September 12, 2018

Today’s Topics Gouraud Shading Phong Shading --------------------------------- Ray Tracing September 12, 2018

Flat Shading A single normal vector is used for each polygon. The object appears to have facets. http://en.wikipedia.org/wiki/Phong_shading September 12, 2018

Gouraud Shading Average the normals for all the polygons that meet a vertex to calculate its surface normal. Compute the color intensities at vertices base on the Lambertian diffuse lighting model. Average the color intensities across the faces. This image is licensed under the Creative Commons Attribution License v. 2.5. September 12, 2018

Phong Shading Gouraud shading lacks specular highlights except near the vertices. Phong shading eliminates these problems. Compute vertex normals as in Gouraud shading. Interpolate vertex normals to compute normals at each point to be rendered. Use these normals to compute the Lambertian diffuse lighting. http://en.wikipedia.org/wiki/Phong_shading September 12, 2018

Ray Tracing a World of Spheres September 12, 2018

What is a Sphere Vector3D center; // 3 doubles double radius; double R, G, B; // for RGB colors between 0 and 1 double kd; // diffuse coeficient double ks; // specular coefficient int specExp; // specular exponent 0 if ks = 0 (double ka; // ambient light coefficient) double kgr; // global reflection coefficient double kt; // transmitting coefficient int pic; // > 0 if picture texture is used September 12, 2018

-.01 .01 500 800 // transform theta phi mu distance 1 // antialias 1 // numlights 100 500 800 // Lx, Ly, Lz 9 // numspheres //cx cy cz radius R G B ka kd ks specExp kgr kt pic -100 -100 0 40 .9 0 0 .2 .9 .0 4 0 0 0 -100 0 0 40 .9 0 0 .2 .8 .1 8 .1 0 0 -100 100 0 40 .9 0 0 .2 .7 .2 12 .2 0 0 0 -100 0 40 .9 0 0 .2 .6 .3 16 .3 0 0 0 0 0 40 .9 0 0 .2 .5 .4 20 .4 0 0 0 100 0 40 .9 0 0 .2 .4 .5 24 .5 0 0 100 -100 0 40 .9 0 0 .2 .3 .6 28 .6 0 0 100 0 0 40 .9 0 0 .2 .2 .7 32 .7 0 0 100 100 0 40 .9 0 0 .2 .1 .8 36 .8 0 0 September 12, 2018

World of Spheres Vector3D VP; // the viewpoint int numLights; Vector3D theLights[5]; // up to 5 white lights double ka; // ambient light coefficient int numSpheres; Sphere theSpheres[20]; // 20 sphere max int ppmT[3]; // ppm texture files View sceneView; // transform data double distance; // view plane to VP bool antialias; // if true antialias September 12, 2018

Simple Ray Tracing for Detecting Visible Surfaces select window on viewplane and center of projection for (each scanline in image) { for (each pixel in the scanline) { determine ray from center of projection through pixel; for (each object in scene) { if (object is intersected and is closest considered thus far) record intersection and object name; } set pixel’s color to that of closest object intersected; September 12, 2018

Ray Trace 1 Finding Visible Surfaces September 12, 2018

Ray-Sphere Intersection Given Sphere Center (cx, cy, cz) Radius, R Ray from P0 to P1 P0 = (x0, y0, z0) and P1 = (x1, y1, z1) View Point (Vx, Vy, Vz) Project to window from (0,0,0) to (w,h,0) September 12, 2018

Sphere Equation y Center C = (cx, cy, cz) Radius R (x, y, z) x September 12, 2018

Ray Equation P0 = (x0, y0, z0) and P1 = (x1, y1, z1) P1 The ray from P0 to P1 is given by: P(t) = (1 - t)P0 + tP1 0 <= t <= 1 = P0 + t(P1 - P0) P0 P1 t  September 12, 2018

Intersection Equation P(t) = P0 + t(P1 - P0) 0 <= t <= 1 is really three equations x(t) = x0 + t(x1 - x0) y(t) = y0 + t(y1 - y0) z(t) = z0 + t(z1 - z0) 0 <= t <= 1 Substitute x(t), y(t), and z(t) for x, y, z, respectively in September 12, 2018

Solving the Intersection Equation is a quadratic equation in variable t. For a fixed pixel, VP, and sphere, x0, y0, z0, x1, y1, z1, cx, cy, cz, and R eye pixel sphere are all constants. We solve for t using the quadratic formula. September 12, 2018

The Quadratic Coefficients Set dx = x1 - x0 dy = y1 - y0 dz = z1 - z0 Now find the the coefficients: September 12, 2018

September 12, 2018

Computing Coefficients September 12, 2018

The Coefficients September 12, 2018

Solving the Equation September 12, 2018

The intersection nearest P0 is given by: To find the coordinates of the intersection point: September 12, 2018

First Lighting Model Ambient light is a global constant. Ambient Light = ka (AR, AG, AB) ka is in the “World of Spheres” 0  ka  1 (AR, AG, AB) = average of the light sources (AR, AG, AB) = (1, 1, 1) for white light Color of object S = (SR, SG, SB) Visible Color of an object S with only ambient light CS= ka (AR SR, AG SG, AB SB) For white light CS= ka (SR, SG, SB) September 12, 2018

Visible Surfaces Ambient Light September 12, 2018

Second Lighting Model Point source light L = (LR, LG, LB) at (Lx, Ly, Lz) Ambient light is also present. Color at point p on an object S with ambient & diffuse reflection Cp= ka (AR SR, AG SG, AB SB)+ kd kp(LR SR, LG SG, LB SB) For white light, L = (1, 1, 1) Cp= ka (SR, SG, SB) + kd kp(SR, SG, SB) kp depends on the point p on the object and (Lx, Ly, Lz) kd depends on the object (sphere) ka is global ka + kd  1 September 12, 2018

Diffuse Light September 12, 2018

Lambertian Reflection Model Diffuse Shading For matte (non-shiny) objects Examples Matte paper, newsprint Unpolished wood Unpolished stones Color at a point on a matte object does not change with viewpoint. September 12, 2018

Physics of Lambertian Reflection Incoming light is partially absorbed and partially transmitted equally in all directions September 12, 2018

Geometry of Lambert’s Law N L  L 90 -  dA dA  dAcos() 90 -  Surface 1 Surface 2 September 12, 2018

cos()=NL Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) Surface 2 N dA 90 -   dAcos() L N Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) September 12, 2018

Finding N N = (x-cx, y-cy, z-cz) |(x-cx, y-cy, z-cz)| normal (x, y, z) radius (cx, cy, cz) September 12, 2018

Diffuse Light 2 September 12, 2018

Time for a Break September 12, 2018

Shadows on Spheres September 12, 2018

More Shadows September 12, 2018

Finding Shadows Shadow Ray P Pixel gets shadow color September 12, 2018

Shadow Color Given Ray from P (point on sphere S) to L (light) P= P0 = (x0, y0, z0) and L = P1 = (x1, y1, z1) Find out whether the ray intersects any other object (sphere). If it does, P is in shadow. Use only ambient light for pixel. September 12, 2018

Shape of Shadows September 12, 2018

Different Views September 12, 2018

Planets September 12, 2018

Starry Skies September 12, 2018

Shadows on the Plane September 12, 2018

Finding Shadows on the Back Plane Shadow Ray P Pixel in Shadow September 12, 2018

Close up September 12, 2018

On the Table September 12, 2018

Phong Highlight September 12, 2018

Phong Lighting Model Light The viewer only sees the light when  is 0. Normal Reflected View The viewer only sees the light when  is 0. N L R V    We make the highlight maximal when  is 0, but have it fade off gradually. Surface September 12, 2018

Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) + ks (RV)n(1, 1, 1) Phong Lighting Model cos() = RV We use cosn(). The higher n is, the faster the drop off. N L R V For white light    Surface Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) + ks (RV)n(1, 1, 1) September 12, 2018

Powers of cos() cos10() cos20() cos40() cos80() September 12, 2018

Computing R L + R = (2 LN) N R = (2 LN) N - L LN LN R L N L+R R L   September 12, 2018

Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) + ks (HN)n (1, 1, 1) The Halfway Vector From the picture +  =  -  +  So  = /2. H = L+ V |L+ V| Use HN instead of RV. H is less expensive to compute than R. N H This is not generally true. Why? L R  V    Surface Cp= ka (SR, SG, SB) + kd NL (SR, SG, SB) + ks (HN)n (1, 1, 1) September 12, 2018

Varied Phong Highlights September 12, 2018

Varying Reflectivity September 12, 2018