CS G140 Graduate Computer Graphics

Slides:



Advertisements
Similar presentations
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Advertisements

Computer Graphics I, Fall 2010 Shading II.
Light Issues in Computer Graphics Presented by Saleema Amershi.
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
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
©College of Computer and Information Science, Northeastern UniversityJune 26, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 11.
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
CS 376 Introduction to Computer Graphics 03 / 26 / 2007 Instructor: Michael Eckmann.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.
©College of Computer and Information Science, Northeastern UniversitySeptember 9, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture.
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
College of Computer and Information Science, Northeastern UniversityOctober 18, CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.
Computer Science Term 1, 2006 Tutorial 5 The Final Exam.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Programming 3D Applications CE Displaying Computer Graphics Week 3 Lecture 5 Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
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.
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
College of Computer and Information Science, Northeastern UniversityJanuary 6, CS4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 22 –
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
College of Computer and Information Science, Northeastern UniversityFebruary 3, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
Yingcai Xiao Yingcai Xiao Chapter 3 Computer Graphics Primer.
CSCE 441 Computer Graphics: 2D Transformations
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
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.
Photorealistic Rendering vs. Interactive 3D Graphics
Review: Transformations
CS G140 Graduate Computer Graphics
CS G140 Graduate Computer Graphics
Review: Transformations
2D Transformations y y x x y x.
Prof. Harriet Fell Spring 2007 Lecture 26 – March 19, 2007
Unit-7 Lighting and Shading
Computer Graphics Transformations
Transformations.
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
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
GR2 Advanced Computer Graphics AGR
Computer Graphics Material Colours and Lighting
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Introduction to Ray Tracing
Presentation transcript:

CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006 Lecture 2 - January 23, 2006 April 27, 2019

Today’s Topics Ray Tracing More Math Ray-Sphere Intersection Light: Diffuse Reflection Shadows Phong Shading More Math Matrices Transformations Homogeneous Coordinates April 27, 2019

Ray Tracing a World of Spheres April 27, 2019

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 April 27, 2019

-.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 April 27, 2019

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 April 27, 2019

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; April 27, 2019

Ray Trace 1 Finding Visible Surfaces April 27, 2019

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) April 27, 2019

Sphere Equation y Center C = (cx, cy, cz) Radius R (x, y, z) x April 27, 2019

Ray Equation P0 = (x0, y0, z0) and P1 = (x1, y1, z1) 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  April 27, 2019

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 April 27, 2019

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. April 27, 2019

The Quadratic Coefficients Set dx = x1 - x0 dy = y1 - y0 dz = z1 - z0 Now find the the coefficients: April 27, 2019

Computing Coefficients April 27, 2019

The Coefficients April 27, 2019

Solving the Equation April 27, 2019

The intersection nearest P0 is given by: To find the coordinates of the intersection point: April 27, 2019

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) April 27, 2019

Visible Surfaces Ambient Light April 27, 2019

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 April 27, 2019

Diffuse Light April 27, 2019

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. April 27, 2019

Physics of Lambertian Reflection Incoming light is partially absorbed and partially transmitted equally in all directions April 27, 2019

Geometry of Lambert’s Law N L  L 90 -  dA dA  dAcos() 90 -  Surface 1 Surface 2 April 27, 2019

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) April 27, 2019

Finding N N = (x-cx, y-cy, z-cz) |(x-cx, y-cy, z-cz)| normal (x, y, z) radius (cx, cy, cz) April 27, 2019

Diffuse Light 2 April 27, 2019

Time for a Break April 27, 2019

Shadows on Spheres April 27, 2019

More Shadows April 27, 2019

Finding Shadows Shadow Ray P Pixel gets shadow color April 27, 2019

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. April 27, 2019

Shape of Shadows April 27, 2019

Different Views April 27, 2019

Planets April 27, 2019

Starry Skies April 27, 2019

Shadows on the Plane April 27, 2019

Finding Shadows on the Back Plane Shadow Ray P Pixel in Shadow April 27, 2019

Close up April 27, 2019

On the Table April 27, 2019

Phong Highlight April 27, 2019

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 April 27, 2019

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) April 27, 2019

Powers of cos() cos10() cos20() cos40() cos80() April 27, 2019

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   April 27, 2019

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) April 27, 2019

Varied Phong Highlights April 27, 2019

Varying Reflectivity April 27, 2019

More Math Matrices Transformations Homogeneous Coordinates April 27, 2019

Matrices We use 2x2, 3x3, and 4x4 matrices in computer graphics. We’ll start with a review of 2D matrices and transformations. April 27, 2019

Basic 2D Linear Transforms April 27, 2019

Scale by .5 (1, 0) (0.5, 0) (0, 1) (0, 0.5) April 27, 2019

Scaling by .5 y x y x April 27, 2019

General Scaling y x y x April 27, 2019

General Scaling y x y x sx 1 sy April 27, 2019

Rotation  sin() cos() -sin()  cos() April 27, 2019

Rotation y x y x  April 27, 2019

Reflection in y-axis April 27, 2019

Reflection in y-axis y x y x April 27, 2019

Reflection in x-axis April 27, 2019

Reflection in x-axis y y x x April 27, 2019

Shear-x s April 27, 2019

Shear x y x y x April 27, 2019

Shear-y s April 27, 2019

Shear y y x y x April 27, 2019

Linear Transformations Scale, Reflection, Rotation, and Shear are all linear transformations They satisfy: T(au + bv) = aT(u) + bT(v) u and v are vectors a and b are scalars If T is a linear transformation T((0, 0)) = (0, 0) April 27, 2019

Composing Linear Transformations If T1 and T2 are transformations T2 T1(v) =def T2( T1(v)) If T1 and T2 are linear and are represented by matrices M1 and M2 T2 T1 is represented by M2 M1 T2 T1(v) = T2( T1(v)) = (M2 M1)(v) April 27, 2019

Reflection About an Arbitrary Line (through the origin) x y x April 27, 2019

Reflection as a Composition y x April 27, 2019

Decomposing Linear Transformations Any 2D Linear Transformation can be decomposed into the product of a rotation, a scale, and a rotation if the scale can have negative numbers. M = R1SR2 April 27, 2019

Rotation about an Arbitrary Point x  y x  This is not a linear transformation. The origin moves. April 27, 2019

Translation (x, y)(x+a,y+b) (a, b) This is not a linear transformation. The origin moves. April 27, 2019

Homogeneous Coordinates y y Embed the xy-plane in R3 at z = 1. (x, y)  (x, y, 1) x x z April 27, 2019

2D Linear Transformations as 3D Matrices Any 2D linear transformation can be represented by a 2x2 matrix or a 3x3 matrix April 27, 2019

2D Linear Translations as 3D Matrices Any 2D translation can be represented by a 3x3 matrix. This is a 3D shear that acts as a translation on the plane z = 1. April 27, 2019

Translation as a Shear y y x x z April 27, 2019