Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Similar documents
Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Comp 410/510 Computer Graphics. Spring Shading

Illumination & Shading

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

Illumination & Shading I

Shading. Why we need shading. Scattering. Shading. Objectives

Introduction to Computer Graphics 7. Shading

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Shading I Computer Graphics I, Fall 2008

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Shading 1: basics Christian Miller CS Fall 2011

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CS 4600 Fall Utah School of Computing

Illumination in Computer Graphics

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

Objectives. Shading II. Distance Terms. The Phong Reflection Model

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.

Why we need shading?

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Objectives. Continue discussion of shading Introduce modified Phong model Consider computation of required vectors

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Illumination and Shading

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Shading II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

w Foley, Section16.1 Reading

Introduction. Lighting model Light reflection model Local illumination model Reflectance model BRDF

CS452/552; EE465/505. Intro to Lighting

CPSC 314 LIGHTING AND SHADING

Shading II. CITS3003 Graphics & Animation

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

CS Illumination and Shading. Slide 1

CS5620 Intro to Computer Graphics

Reflection and Shading

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

Computer Graphics (CS 543) Lecture 8 (Part 1): Physically-Based Lighting Models

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics V. Guoying Zhao 1 / 65

Shading. Brian Curless CSE 557 Autumn 2017

Shading. Brian Curless CSE 457 Spring 2017

CS 5625 Lec 2: Shading Models

Visualisatie BMT. Rendering. Arjan Kok

Simple Lighting/Illumination Models

Illumination Models & Shading

Today we will start to look at illumination models in computer graphics

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Computer Graphics. Illumination and Shading

Illumination & Shading: Part 1

CS230 : Computer Graphics Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

CSE 167: Introduction to Computer Graphics Lecture #6: Colors. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

CPSC / Illumination and Shading

Raytracing. COSC 4328/5327 Scott A. King

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics. Illumination and Shading

Virtual Reality for Human Computer Interaction

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Lighting and Materials

Reading. Shading. Introduction. An abundance of photons. Required: Angel , Optional: OpenGL red book, chapter 5.

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Shading and Illumination

Graphics and Visualization

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

CEng 477 Introduction to Computer Graphics Fall

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

CS452/552; EE465/505. Lighting & Shading

Raytracing CS148 AS3. Due :59pm PDT

Interactive Real-Time Raycasting

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Illumination. The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

CS Computer Graphics: Ray Tracing Detail, Part 3

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Shading. CSE 457 Winter 2015

Sung-Eui Yoon ( 윤성의 )

CSE 681 Illumination and Phong Shading

CS Computer Graphics: Ray Tracing Detail, Part 3

CS6670: Computer Vision

Illumination and Shading

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

Shading. Brian Curless CSE 457 Spring 2015

Lighting. Figure 10.1

Graphics for VEs. Ruth Aylett

Illumination and Shading

Transcription:

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI)

Why do we need Lighting & shading? Has visual cues for humans (shape, light position, viewer position, surface orientation, material properties, etc) Sphere without lighting & shading Sphere with lighting & shading

What Causes Shading? Shading caused by different angles with light, camera at different points

Lighting? Problem: Calculate surface color based on angle of surface with light, viewer Programmer writes vertex shader code to calculate lighting at vertices! Equation for lighting calculation = lighting model 3. Interaction between lights and objects 1. Light attributes: intensity, color, position, direction, shape 2. Surface attributes color, reflectivity, transparency, etc

Shading? After triangle is rasterized (converted to pixels) Per-vertex lighting calculation means color at vertices is accurate, known (red dots) Shading: Graphics hardware figures out color of interior pixels (blue dots) How? Assume linear change => interpolate Lighting (calc at vertices in vertex shader) Rasterization Find pixels belonging to each object Shading (done in hardware during rasterization)

Global Illumination (Lighting) Model Global illumination: model interaction of light from all surfaces in scene (track multiple bounces) shadow translucent surface multiple reflection

Rendering Equation The infinite reflection, scattering and absorption of light is described by the rendering equation Includes many effects (Reflection, Shadows, etc) Mathematical basis for all global illumination algorithms L o Le Lo is outgoing radiance Li incident radiance Le emitted radiance, ( x, fr( x,, ) Li( x, )( n) d fr is bidirectional reflectance distribution function (BRDF) Fraction of incident light reflected by a surface Li fr Le Lo

Local Illumination (Lighting) Model One bounce! Doesn t track inter-reflections, transmissions q Global Illumination (GI) is accurate, looks real But raster graphics pipeline (e.g. OpenGL) renders each polygon independently (local rendering), no GI

Light Sources General light sources are difficult to model (e.g. light bulb) Why? We must compute effect of light coming from all points on light source

Light Sources Abstractions We generally use simpler light sources Abstractions that are easier to model Point light Directional light Light intensity can be independent or dependent of the distance between object and the light source Spot light Area light

Light-Material Interaction Light strikes object, some absorbed, some reflected Fraction reflected determines object color and brightness Example: A surface looks red under white light because red component of light is reflected, other wavelengths absorbed

Phong Model Simple lighting model that can be computed quickly 3 components Diffuse Specular Ambient Compute each component separately Vertex Illumination = ambient + diffuse + specular Materials reflect each component differently

Phong Model Compute lighting (components) at each vertex (P) Uses 4 vectors, from vertex To light source (l) To viewer (v) Normal (n) Mirror direction (r)

Mirror Direction? Angle of reflection = angle of incidence Normal is determined by surface orientation r = 2 (l n ) n - l

Surface Roughness Smooth surfaces: more reflected light concentrated in mirror direction Rough surfaces: reflects light in all directions smooth surface rough surface

Diffuse Lighting Example

Diffuse Light Calculation How much light received from light source? Based on Lambert s Law Receive more light Receive less light

Diffuse Light Reflected Illumination surface received from light source, reflected equally in all directions Eye position does not matter

Diffuse Light Calculation light vector (from object to light) q N : surface normal Lambert s law: radiant energy D a small surface patch receives from a light source is: I: light intensity D = I x k D cos (q) q: angle between light vector and surface normal k D : Diffuse reflection coefficient. Controls how much diffuse light surface reflects

Specular light example Specular? Bright spot on object

Specular light contribution Incoming light reflected out in small surface area Specular depends on viewer position relative to mirror direction Specular bright in mirror direction Drops off away from mirror direction specular highlight Mirror direction: lots of specular Away from mirror direction A little specular

Specular light calculation is deviation of view angle from mirror direction Small = more specular incoming intensity q Mirror direction I s = k s I cos a p reflected intensity shininess coef Absorption coef

The Shininess Coefficient, a a controls falloff sharpness High a sharper falloff = small, bright highlight Low a slow falloff = large, dull highlight a between 100 and 200 = metals a between 5 and 10 = plastic look cos a -90 90

Specular light: Effect of α I s = k s I cos a α = 10 α = 90 α = 30 α = 270

Ambient Light Contribution Very simple approximation of global illumination (Lump 2 nd, 3 rd, 4 th,. etc bounce into single term) Assume to be a constant No direction! Independent of light position, object orientation, observer s position or orientation object 4 object 3 object 2 object 1 Ambient = Ia x Ka constant

Ambient Light Example Ambient: background light, scattered by environment

Light Attentuation with Distance Light reaching a surface inversely proportional to square of distance d We can multiply by factor of form 1/(ad + bd +cd 2 ) to diffuse and specular terms

Adding up the Components Adding all components (no attentuation term), phong model for each light source can be written as diffuse + specular + ambient I = k d I d cosq + k s I s cos a + k a I a = k d I d (l n) + k s I s (v r ) a + k a I a Note: cosq = l n cos = v r q

Separate RGB Components Can separate red, green and blue components. Instead of: I = k d I d (l n) + k s I s (v r ) a + k a I a We computing lighting for RGB colors separately I r = k dr I dr l n + k sr I sr (v r ) a + k ar I ar I g = k dg I dg l n + k sg I sg (v r ) a + k ag I ag I b = k db I db l n + k sb I sb (v r ) a + k ab I ab Red Green Blue Above equation is just for one light source!! For N lights, repeat calculation for each light Total illumination for a point P = S (Lighting for all lights)

Coefficients for Real Materials Material Ambient Kar, Kag,kab Diffuse Kdr, Kdg,kdb Specular Ksr, Ksg,ksb Exponent, a Black plastic 0.0 0.0 0.01 0.01 0.5 0.5 32 0.0 0.01 0.5 Brass 0.329412 0.780392 0.992157 27.8974 0.223529 0.568627 0.941176 0.027451 0.113725 0.807843 Polished 0.23125 0.2775 0.773911 89.6 Silver 0.23125 0.2775 0.773911 0.23125 0.2775 0.773911 Figure 8.17, Hill, courtesy of McReynolds and Blythe

Modified Phong Model I = k d I d l n + k s I s (v r ) a + k a I a I = k d I d l n + k s I s (n h ) b + k a I a Blinn proposed using halfway vector, more efficient h is normalized vector halfway between l and v Similar results as original Phong Used in OpenGL h = ( l + v )/ l + v

References Interactive Computer Graphics (6 th edition), Angel and Shreiner Computer Graphics using OpenGL (3 rd edition), Hill and Kelley