University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.

Slides:



Advertisements
Similar presentations
Computer Graphics Inf4/MSc Computer Graphics Lecture 13 Illumination I – Local Models.
Advertisements

CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Illumination and Shading
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading III Week.
Computer Graphics - Class 10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Shading, Advanced Rendering.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading II Week.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Lighting/Shading I, II,
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading II Week.
(conventional Cartesian reference system)
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
©Larry F. Hodges (modified by Amos Johnson) 1 Shading Models.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
CS 445 / 645: Introductory Computer Graphics
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading II Week.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Shading in OpenGL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
Computer Graphics I, Fall 2010 Shading in OpenGL.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading III Week.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
Illumination and Shading
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Lighting/Shading IV Advanced Rendering I Week 8, Mon Mar 3
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Local Illumination and Shading
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Lighting/Shading University of British Columbia
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,
CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Shading To determine the correct shades of color on the surface of graphical objects.
Chapter 14 Shading Models.
CSC461: Lecture 23 Shading Computation
Shading in OpenGL Ed Angel
Lighting/Shading III Week 7, Wed Mar 3
Lighting Phong's Lighting Model normals
Lighting/Shading II Week 7, Mon Mar 1
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Computer Graphics Material Colours and Lighting
Computer Graphics (Fall 2003)
Chapter 14 Shading Models.
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week 5, Wed Feb 2

2 News: Homework homework correction: questions should use: unit square has points A=(0,0,0,1), B=(0,1,0,1), C=(0,1,1,1), D=(0,0,1,1) in world coordinates homework clarification: question 1 C_i is down one-half unit and sideways one unit.

3 News: Project Handin when handing after the deadline, handin has this unfriendly warning message Checking that handin was successful... /cs/csbox/user FAILED to find user a1b2. Your files DO NOT appear to be handed in successfully Do you want to cancel? don’t panic go ahead and complete the handin, do not cancel! your submission will be put in the LATE directory

4 Review: Reflectance specular: perfect mirror with no scattering gloss: mixed, partial specularity diffuse: all directions with equal energy + + = specular + glossy + diffuse = reflectance distribution

5 Review: Reflection Equations I diffuse = k d I light (n l) nl  2 ( N (N · L)) – L = R

6 Clarification: Calculating The R Vector P = N cos  = projection of L onto N why is P = N cos  not L cos  ? N and R and L are unit length difference between length of projection of u onto v scalar: |u| cos  in this case length of u is 1 cos  projection of u onto v vector in direction of v, with scale factor scale depends on angle between u and v, length of u v |u| cos  in this case length of u is 1 v cos  L P N  R scalar length!

7 Review: Reflection Equations 2 Blinn improvement full Phong lighting model combine ambient, diffuse, specular components lnv h

8 Review: Lighting lighting models ambient normals don’t matter Lambert/diffuse angle between surface normal and light Phong/specular surface normal, light, and viewpoint

9 Lighting in OpenGL light source: amount of RGB light emitted value represents percentage of full intensity e.g., (1.0,0.5,0.5) every light source emits ambient, diffuse, and specular light materials: amount of RGB light reflected value represents percentage reflected e.g., (0.0,1.0,0.5) interaction: multiply components red light (1,0,0) x green surface (0,1,0) = black (0,0,0)

10 Lighting in OpenGL glLightfv(GL_LIGHT0, GL_AMBIENT, amb_light_rgba ); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif_light_rgba ); glLightfv(GL_LIGHT0, GL_SPECULAR, spec_light_rgba ); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHT0); glMaterialfv( GL_FRONT, GL_AMBIENT, ambient_rgba ); glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuse_rgba ); glMaterialfv( GL_FRONT, GL_SPECULAR, specular_rgba ); glMaterialfv( GL_FRONT, GL_SHININESS, n ); warning: glMaterial is expensive and tricky use cheap and simple glColor when possible see OpenGL Pitfall #14 from Kilgard’s list

11 Lighting vs. Shading lighting process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D point, usually on a surface shading the process of assigning colors to pixels (why the distinction?)

12 Applying Illumination we now have an illumination model for a point on a surface if surface defined as mesh of polygonal facets, which points should we use? fairly expensive calculation several possible answers, each with different implications for visual quality of result

13 Applying Illumination polygonal/triangular models each facet has a constant surface normal if light is directional, diffuse reflectance is constant across the facet. why?

14 Flat Shading simplest approach calculates illumination at a single point for each polygon obviously inaccurate for smooth surfaces

15 Flat Shading Approximations if an object really is faceted, is this accurate? no! for point sources, the direction to light varies across the facet for specular reflectance, direction to eye varies across the facet

16 Improving Flat Shading what if evaluate Phong lighting model at each pixel of the polygon? better, but result still clearly faceted for smoother-looking surfaces we introduce vertex normals at each vertex usually different from facet normal used only for shading think of as a better approximation of the real surface that the polygons approximate

17 Vertex Normals vertex normals may be provided with the model computed from first principles approximated by averaging the normals of the facets that share the vertex

18 Gouraud Shading most common approach, and what OpenGL does perform Phong lighting at the vertices linearly interpolate the resulting colors over faces along edges along scanlines C1C1 C2C2 C3C3 edge: mix of c 1, c 2 edge: mix of c1, c3 interior: mix of c1, c2, c3 does this eliminate the facets?

19 Gouraud Shading Artifacts often appears dull, chalky lacks accurate specular component if included, will be averaged over entire polygon C1C1 C2C2 C3C3 this interior shading missed! C1C1 C2C2 C3C3 this vertex shading spread over too much area

20 Gouraud Shading Artifacts Mach bands eye enhances discontinuity in first derivative very disturbing, especially for highlights

21 Gouraud Shading Artifacts C1C1 C2C2 C3C3 C4C4 Discontinuity in rate of color change occurs here Mach bands

22 Gouraud Shading Artifacts perspective transformations affine combinations only invariant under affine, not under perspective transformations thus, perspective projection alters the linear interpolation! Z – into the scene Image plane

23 Gouraud Shading Artifacts perspective transformation problem colors slightly “swim” on the surface as objects move relative to the camera usually ignored since often only small difference usually smaller than changes from lighting variations to do it right either shading in object space or correction for perspective foreshortening expensive – thus hardly ever done for colors

24 Phong Shading linearly interpolating surface normal across the facet, applying Phong lighting model at every pixel same input as Gouraud shading pro: much smoother results con: considerably more expensive not the same as Phong lighting common confusion Phong lighting: empirical model to calculate illumination at a point on a surface

25 Phong Shading linearly interpolate the vertex normals compute lighting equations at each pixel can use specular component N1N1 N2N2 N3N3 N4N4 remember: normals used in diffuse and specular terms discontinuity in normal’s rate of change harder to detect

26 Phong Shading Difficulties computationally expensive per-pixel vector normalization and lighting computation! floating point operations required lighting after perspective projection messes up the angles between vectors have to keep eye-space vectors around no direct support in hardware but can be simulated with texture mapping

27 Gouraud Phong Shading Artifacts: Silhouettes polygonal silhouettes remain

28 A D C B Interpolate between AB and AD  B A D C Interpolate between CD and AD Rotate -90 o and color same point Shading Artifacts: Orientation interpolation dependent on polygon orientation view dependence!

29 B A C vertex B shared by two rectangles on the right, but not by the one on the left E D F H G first portion of the scanline is interpolated between DE and AC second portion of the scanline is interpolated between BC and GH a large discontinuity could arise Shading Artifacts: Shared Vertices

30 Shading Models Summary flat shading compute Phong lighting once for entire polygon Gouraud shading compute Phong lighting at the vertices and interpolate lighting values across polygon Phong shading compute averaged vertex normals interpolate normals across polygon and perform Phong lighting across polygon

31 Shutterbug: Flat Shading

32 Shutterbug: Gouraud Shading

33 Shutterbug: Phong Shading

34 Non-Photorealistic Shading draw silhouettes: if, e=edge-eye vector cool-to-warm shading: