Illumination Lighting and Shading CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford.

Slides:



Advertisements
Similar presentations
OpenGL Course Notes Chapter 5: Lighting Jim Mims, Spring 2009.
Advertisements

SI23 Introduction to Computer Graphics
5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 6.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Lighting and Illumination Lighting is the major problem in computer graphics, for either realism or real-time compositions- harder than modeling Consider.
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
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
3/23/2005 © Dr. Zachary Wartell 1 Illumination Models and Surface- Rendering Methods.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Course Website: Computer Graphics 16: Illumination.
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
Lighting & Shading.
Shading Surface can either (both) 1.Emit light. E.g. light bult 2.Reflect light. E.g. Mirror.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CSC418 Computer Graphics n Raytracing n Shadows n Global Illumination.
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 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.
Human Eye and Color Rays of light enter the pupil and strike the back of the eye (retina) – signals go to the optic nerve and eventually to the brain Retina.
Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
CSE 381 – Advanced Game Programming GLSL Lighting.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
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
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
School of Computer Science
Lighting.
CSE 470 Introduction to Computer Graphics Arizona State University
Isaac Gang University of Mary Hardin-Baylor
Simple Illumination CSE 681.
Computer Graphics Material Colours and Lighting
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
CSC418 Computer Graphics Raytracing Shadows Global Illumination.
Lighting Calculations
Presentation transcript:

Illumination Lighting and Shading CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford

Terminology Illumination: 1. luminous flux at any point on a surface exposed to incident light (direct or indirect) 2. A light source 3. Spiritual or intellectual enlightenment

Terminology Illumination: 1. luminous flux at any point on a surface exposed to incident light (direct or indirect) 2. A light source 3. Spiritual or intellectual enlightenment Lighting: 1. Method to provide artificial illumination 2. Illumination 3. The act of igniting

Terminology Illumination: 1. luminous flux at any point on a surface exposed to incident light (direct or indirect) 2. A light source 3. Spiritual or intellectual enlightenment Lighting: 1. Method to provide artificial illumination 2. Illumination 3. The act of igniting Shading: 1. produce gradations of light or color 2. process of assigning colors to pixels

Terminology Illumination: 1. luminous flux at any point on a surface exposed to incident light (direct or indirect) 2. A light source Lighting: 1. The method used to provide artificial illumination 2. Illumination Shading: 1. produce gradations of light or color 2. process of assigning colors to pixels But you’ll hear them interchanged frequently!

Lighting Overview CG lighting models Elements of a lighting model The Phong illumination model Application of the Phong model Shading methods: flat, Gouraud, Phong OpenGL aspects

CG Lighting Models: Global Multiple interaction of light & objects Not real-time (yet) Examples: Raytracing, radiosity, photon mapping … From: llery/stills.html llery/stills.html

CG Lighting Models: Local Single interaction of light & objects Real-time Supported by OGL Example: Phong illumination model

Elements of a Lighting Model: light sources: number, type (desk lamp vs sun), color

Elements of a Lighting Model: light sources: number, type, color reflections

Elements of a Lighting Model: light sources: number, type, color reflections material properties: reflection & absorption of light

Elements of a Lighting Model: light sources: number, type, color reflections material properties: reflection & absorption of light 3D feel, depth perception lighting model == approximation of real-world lighting!

Elements of the Phong Model Light Source Properties All calculations based on idea that RGB calculated independently

Elements of the Phong Model Light Source Properties 1.ambient light > scattered > no detectable direction > backlighting in a room > can use to give a feel for the main color in a room > not dependent on viewpoint

Elements of the Phong Model Light Source Properties 1.ambient light 2.diffuse light > directional > scatters equally in all directions once hits object > closest to the color of light > not dependent on eye position

Elements of the Phong Model Light Source Properties 1.ambient light 2.diffuse light 3.specular light > comes from a detectable direction > bounces off object in preferred direction > plays a role in shininess > dependent on viewpoint diffuse and specular normally set the same

Elements of the Phong Model Light Source Properties 1.ambient light 2.diffuse light 3.specular light 4.point source vs spotlight > point source: light emitted in all directions > spotlight: cone-shaped

Elements of the Phong Model Light Source Properties 1.ambient light 2.diffuse light 3.specular light 4.point source vs spotlight 5.positional vs directional > positional: like a desk lamp > directional: like the sun all rays parallel when reach object > homogeneous coordinate to distinguish > location transformed by modelview matrix xyzwxyzw

Elements of the Phong Model Material properties

Elements of the Phong Model Material properties 1. reflectance of light a. ambient > amount of ambient light > most visible where no direct light hits

Elements of the Phong Model Material properties 1. reflectance of light a. ambient b. diffuse > degree of scattering of light on surface > matte vs flat paint finish Color of object == ambient and diffuse (typically set the same)

Elements of the Phong Model Material properties 1. reflectance of light a. ambient b. diffuse c. specular > degree of mirror-like quality > typically set to white so highlights produced are color of light

Elements of the Phong Model Material properties 1. reflectance of light a. ambient b. diffuse c. specular d. translucent (opaque)

Elements of the Phong Model Material properties 1. reflectance of light a. ambient b. diffuse c. specular d. translucent (opaque) 2. surface normals (unit length!)

Elements of the Phong Model Material properties 1. reflectance of light a. ambient b. diffuse c. specular d. translucent (opaque) 2. surface normals 3. emissive color

Light & Material Properties Examples increasing diffuseincreasing ambient increasing specular

Light & Material Properties absorption/reflectance influence on color Example: red box will reflect red light absorb green and blue light

Notation: Light Properties Model is computed independently for red, green, blue components Light’s luminance represented by boldface vectors: Ld := diffuse Ls := specular rgbrgb 0 <= r,g,b <= 1  % of full intensity La = := ambient

Notation: Material Properties Material’s properties represented by boldface vectors: ka := ambient kd := diffuse ks := specular Each vector takes form rgbrgb Represents % of reflection of light source’s corresponding property 0 <= r,g,b <= 1

Notation: Material Properties Example material properties:

Geometry of the Phong Model ppoint on surface l (light – p) vector n normal to surface r reflection vector v (viewpoint – p) vector theta angle of incidence phi angle between v and r v p All vectors normalized Recall: angle of incidence equals angle of reflection

Phong Model in OGL vertex color = material emission‡ + (global ambient light scaled by material ambient property) + (ambient, diffuse, specular of lights, attenuated by material properties, viewer location and light position) ‡ at vertex

Diffuse Intensity Calculation Lambert’s Law: light reflected is proportional to the cosine of the angle (theta) between surface normal n and light vector l theta is called the angle of incidence

Diffuse Intensity Calculation Lambert’s Law: light reflected is proportional to the cosine of the angle (theta) between surface normal n and light vector l theta is called the angle of incidence theta=0theta=60

Diffuse Intensity Calculation Id := intensity of reflected diffuse light Id = kd x Ld x cos(theta) cos(theta) = l n theta in [-90,90°] are of interest Id = kd x Ld x (max{l n, 0}) “x” is not cross product 3 separate scalar products Note: independent of viewer

Specular Intensity Calculation cos(phi) = v rr = [2(ln)]n - l Is := intensity of reflected specular light Basic idea: Is = ks x Ls x cos^s(phi) Focus of specular influenced by s Note: depends on viewpoint phi = 0°  full specular |phi| > 90°  no specular (never compute angle directly)

Specular Intensity Calculation s: Phong constant or “shininess” coefficient 90°- 90° s=10 focus s=1 s=0.1 spread cos^s(phi)

Specular Intensity Calculation Blinn-Torrence modification – simplification for faster computation h = (l + v) / || l + v || “halfway” vector cos(alpha) = h n alpha ~ ½ phi so good approximation

Specular Intensity Calculation Blinn-Torrence specular is implemented in OGL Is = ks x Ls x [max{h n, 0}]^s if l n < 0 then Is = 0 (no diffuse, no specular)

Attenuation Function For a positional light... d := distance of light source to vertex for directional light, f(d) = 1 inverse distance functions  diminish intensity d increases ogl choices for functions f(d) = 1/a f(d) = 1/(a + b*d) f(d) = 1/(a + b*d + c*d^2) constant linear quadratic

Spotlight Effect Cone-shaped spotlight defined by: c position gamma “cut-off” angle d direction cos(delta) = -l d if delta > gamma sp = 0 else sp = (max{-l d, 0})^p sp := spotlight effect for a light source defined by angle between -l and d : p influence similar to Phong constant; focus of intensity d gamma c

Putting It All Together Phong Model in OGL I = e + (ka x Ma) + for each light { [f(d) * sp * (ka*La + Id + Is)] } I := intensity at a vertex e := emission intensity at a vertex Ma := ambient intensity for the entire model Remember: boldface indicates r,g,b values

Shading Methods Phong model  color of vertex Shading methods  color of triangle Methods: 1.Flat shading 2.Gouraud (smooth) shading 3.Phong‡ Shading ‡ confusing, but different from Phong illumination model in ogl Recall: triangle normal.vs. averaged vertex normal

Flat Shading One normal per triangle glShadeModel(GL_FLAT) Simulates viewer and light source distant then v, n, l same over triangle  one shading calculation

Gouraud (smooth) Shading One normal per vertex Lighting calculation made at each vertex  I1, I2, I3 Lighting at any point p within triangle v1, v2, v3 I = b1*I1 + b2*I2 + b3* I3 where b1, b2, b3 are the barycentric coordinates of p wrt v1, v2, v3 p = b1*v1 + b2*v2 + b3*v3 (b1 + b2 + b3 = 1)

Phong Shading One normal per vertex... however a normal is calculated for each rendered point p in triangle vertex normals n1, n2, n3 p = b1*v1 + b2*v2 + b3*v3 n = b1*n1 + b2*n2 + b3*n3 Calculate intensity at p wrt n Not considered a real-time algorithm therefore, not in ogl

Setting up the Lighting Model OGL’s glLightModel has four settings … 1.local vs infinite viewer 2.one-sided vs two-sided 3.global ambient intensity 4.specular and texture interaction default: infinite default: one-sided default: none let’s revisit when we discuss texture front-facing triangle: on screen counterclockwise orientation one-sided = just shade front-facing two-sided = shade front and back-facing triangles nice for inside and outside color effect affects highlights of specular infinite: v vector for all vertices the same

OGL Calls Basic steps... 1.create, position & enable lights 2.viewer local or infinite? 3.front and back polygon shading? 4.set material properties Keep in mind that local viewer and lights require more computation Default camera: eye at origin and looking down –z axis (This is eye coordinates.) Reading: Chapter 5 !!

Controlling the Light’s Position Light stationary: glModelMatrixMode(GL_MODELVIEW) glLoadIdentity(); modeling and viewing here glLightfv(GL_LIGHT0, GL_POSITION, position)

Controlling the Light’s Position Rotate light about stationary object: glPushMatrix(); gluLookAt(…); glPushMatrix(); glRotate*(…); glLightfv (GL_LIGHT0, GL_POSITION, position ) glPopMatrix(); draw_object(); glPopMatrix();

Controlling the Light’s Position Move light with viewpoint: key: specify light position in eye coordinates before viewing transf. GLfloat position[] = {0, 0, 0, 1} … glModelMatrixMode(GL_MODELVIEW) glLoadIdentity(); glLightfv(GL_LIGHT0, GL_POSITION, position) glPushMatrix() gluLookAt( …) draw object() glPopMatrix() aka: minor’s hat

Resources Many figures for these slides were taken from Pascal Vuytsteker’s website: ex.en.html Of course, OGL Red book Chapter 5

Material Properties r,g,b,alpha 

Material Properties