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

Slides:



Advertisements
Similar presentations
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Advertisements

CSPC 352: Computer Graphics
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
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.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
7M836 Animation & Rendering
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.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
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.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
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
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
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.
Shading in OpenGL.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Computer Graphics I, Fall 2010 Shading in OpenGL.
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
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.
Illumination.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
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.
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
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
CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics: Illumination
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
1 Dr. Scott Schaefer Lighting. 2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts.
Shading To determine the correct shades of color on the surface of graphical objects.
CSC461: Lecture 23 Shading Computation
Lighting – Light Sources
Isaac Gang University of Mary Hardin-Baylor
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics (Fall 2003)
Lighting Calculations
Presentation transcript:

Virtual Realism LIGHTING AND SHADING

Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive (off-line) Radiosity: Calculate surface inter-reflection approximately Accurate, especially interiors, but expensive (off-line) Phong Illumination model (this lecture): Approximate only interaction light, surface, viewer Relatively fast (on-line), supported in OpenGL

Geometric Ingredients Three ingredients Normal vector m at point P of the surface Vector v from P to the viewers eye Vector s from P to the light source m s v P

Types of Light Sources Ambient light: no identifiable source or direction Diffuse light - Point: given only by point Diffuse light - Direction: given only by direction Spot light: from source in direction Cut-off angle defines a cone of light Attenuation function (brighter in center) Light source described by a luminance Each color is described separately I = [I r I g I b ] T (I for intensity) Sometimes calculate generically (applies to r, g, b)

Ambient Light Global ambient light Independent of light source Lights entire scene Local ambient light Contributed by additional light sources Can be different for each light and primary color Computationally inexpensive

Diffuse Light Point Source Given by a point Light emitted equally in all directions Intensity decreases with square of distance Point source [x y z 1] T Directional Source Given by a direction Simplifies some calculations Intensity dependents on angle between surface normal and direction of light Distant source [x y z 0] T

Spot Lights Spotlights are point sources whose intensity falls off directionally. Requires color, point direction, falloff parameters d P α β Intensity at P = I cos ε ( β )

This model is based on modeling surface reflection as a combination of the following components: Used to model objects that glow A simple way to model indirect reflection The illumination produced by dull smooth surfaces The bright spots appearing on smooth shiny surfaces Phong illumination model

Diffuse Reflection Ideal diffuse reflection An ideal diffuse reflector, at the microscopic level, is a very rough surface (real-world example: chalk) Because of these microscopic variations, an incoming ray of light is equally likely to be reflected in any direction over the hemisphere What does the reflected intensity depend on?

Computing Diffuse Reflection Independent of the angle between m and v Does depend on the direction s (Lambertian surface) Diffuse Reflection Coefficient Adjustment for ‘inside’ face Therefore, the diffuse component is:

Specular Reflection Shiny surfaces exhibit specular reflection Polished metal Glossy car finish A light shining on a specular surface causes a bright spot known as a specular highlight Where these highlights appear is a function of the viewer’s position, so specular reflectance is view dependent

Specular Reflection Perfect specular reflection (perfect mirror) The smoother the surface, the closer it becomes to a perfect mirror Non-perfect specular reflection: Phong Model most light reflects according to Snell’s Law as we move from the ideal reflected ray, some light is still reflected

Non-Ideal Specular Reflectance: Phong Model An illustration of this angular falloff θ m s r

Phong Lighting θ m s r v φ The Specular Intensity, according to Phong model: Specular Reflection Coefficient Shininess factor

Phong Lighting Examples These spheres illustrate the Phong model as s and f are varied:

Blinn and Torrence Variation In Phong Model, r need to be found computationally expensive Instead, halfway vector h = s + v is used angle between m and h measures the falloff of intensity β m s h v

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

The Final Combined Equation Single light source: m s r v Viewer φ 

Adding Color Consider R, G, B components individually Add the components to get the final color of reflected light

Applying Illumination We have an illumination model for a point on a surface Assuming that our surface is defined as a mesh of polygonal facets, which points should we use?

Polygon Shading Types of Shading Model Flat Shading Gouraud ShadingPhong Shading Smooth Shading

Flat Shading For each polygon Determines a single intensity value Uses that value to shade the entire polygon Assumptions Light source at infinity Viewer at infinity The polygon represents the actual surface being modeled

Wire-frame Model Flat Shading

Smooth Shading 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 Two types Gouraud Shading Phong Shading (do not confuse with Phong Lighting Model)

Gouraud Shading This is the most common approach Perform Phong lighting at the vertices Linearly interpolate the resulting colors over faces Along edges Along scanlines

Gouraud Shading x right ysys y top y bott x left color 1 color 2 color 3 color 4 y4y4

Gouraud Shading Vertex 1 I = 0.2 Vertex 2 I =0.8 I = 1.0 Vertex 3 I = 0.6 Vertex

Wire-frame Model Gouraud Shading Flat Shading Gouraud Shading

Artifacts Often appears dull Lacks accurate specular component If included, will be averaged over entire polygon C1C1 C2C2 C3C3 Can’t shade the spot light

Phong Shading ysys x m1m1 m2m2 m3m3 m4m4 m left m right m Interpolate normal vectors at each pixel

Wire-frame Model Phong Shading Flat Shading Gouraud Shading Phong Shading

If a highlight does not fall on a vertex Gouraud shading may miss it completely, but Phong shading does not. Phong vs Gouraud Shading

Shading Models (Direct lighting) 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 Interpolate normals across polygon and perform Phong lighting across polygon

Lighting in OpenGL [1/2] Enabling shading glShadeModel(GL_FLAT) glShadeModel(GL_SMOOTH); // Gouraud Shading only Using light sources Up to 8 light sources To create a light GLfloat light0_position[] = { 600, 40, 600, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING);

Lighting in OpenGL [2/2] Changing light properties GLfloat light0_ambient[] = { 0.4, 0.1, 0.0, 1.0 }; GLfloat light0_diffuse[] = { 0.9, 0.3, 0.3, 1.0 }; GLfloat light0_specular[] = { 0.0, 1.0, 1.0, 1.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); For more detail See Red Book (Ch 5)

References Hill § 8.1 ~ 8.3