Illumination & Shading I

Similar documents
CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

Illumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.

Illumination and Shading

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

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

Illumination and Shading

Shading and Illumination

Computer Graphics. Illumination and Shading

Illumination & Shading

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

CS 4731: Computer Graphics Lecture 16: Phong Illumination and Shading. Emmanuel Agu

Ambient reflection. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 407

Reflection and Shading

Comp 410/510 Computer Graphics. Spring Shading

CS 4600 Fall Utah School of Computing

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

CS Illumination and Shading. Slide 1

CS452/552; EE465/505. Lighting & Shading

Graphics and Visualization

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

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

CEng 477 Introduction to Computer Graphics Fall

Introduction to Computer Graphics 7. Shading

CS5620 Intro to Computer Graphics

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

Illumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.

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

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

Lighting. CSC 7443: Scientific Information Visualization

Illumination and Shading ECE 567

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

Illumination in Computer Graphics

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

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

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

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

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

INF3320 Computer Graphics and Discrete Geometry

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Illumination & Shading: Part 1

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

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

CS452/552; EE465/505. Intro to Lighting

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

Why we need shading?

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Shading I Computer Graphics I, Fall 2008

Illumination and Shading

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

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

Simple Lighting/Illumination Models

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

Graphics for VEs. Ruth Aylett

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

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

Shading , Fall 2004 Nancy Pollard Mark Tomczak

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

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

Computer Graphics. Illumination and Shading

Illumination Models & Shading

w Foley, Section16.1 Reading

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Sung-Eui Yoon ( 윤성의 )

Graphics for VEs. Ruth Aylett

Virtual Reality for Human Computer Interaction

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

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

CS 5625 Lec 2: Shading Models

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

CS Computer Graphics: Ray Tracing Detail, Part 3

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

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

LIGHTING AND SHADING

Shading II. CITS3003 Graphics & Animation

CS Computer Graphics: Ray Tracing Detail, Part 3

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

CPSC 314 LIGHTING AND SHADING

Illumination Models and Shading

Illumination and Shading

CSE 681 Illumination and Phong Shading

Visualisatie BMT. Rendering. Arjan Kok

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

Shading. Brian Curless CSE 557 Autumn 2017

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ.

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

Illumination and Shading

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

CS 325 Computer Graphics

Raytracing. COSC 4328/5327 Scott A. King

Illumination and Reflection in OpenGL CS 460/560. Computer Graphics. Shadows. Photo-Realism: Ray Tracing. Binghamton University.

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

OpenGL Lighting Computer Graphics Spring Frank Palermo

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

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Transcription:

CS 543: Computer Graphics Illumination & Shading I Robert W. Lindeman Associate Professor Interactive Media & Game Development Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu (with lots of help from Prof. Emmanuel Agu :-)

Illumination and Shading o Problem: Model light/surface point interactions to determine final color and brightness o Apply the lighting model at a set of points across the entire surface lighting Shading R.W. Lindeman - WPI Dept. of Computer Science 2

Illumination Model o The governing principles for computing the illumination o An illumination model usually considers n Light attributes (intensity, color, position, direction, shape) n Object surface attributes (color, reflectivity, transparency, etc.) n Interaction among lights and objects R.W. Lindeman - WPI Dept. of Computer Science 3

Basic Light Sources o Light intensity can be independent or dependent of the distance between object and the light source Point light Spot light Directional light Area light R.W. Lindeman - WPI Dept. of Computer Science 4

Local Illumination o Only consider the light, the observer position, and the object material properties o Almost all renderers do at least this θ R.W. Lindeman - WPI Dept. of Computer Science 5

Global Illumination o Take into account the interaction of light from all the surfaces in the scene o Example: n Ray Tracing n Model light rays bouncing around object 4 object 3 object 2 object 1 R.W. Lindeman - WPI Dept. of Computer Science 6

Global Illumination (cont.) o Example: n Radiosity o Model energy moving from emitters (e.g., lights) into the scene o View independent R.W. Lindeman - WPI Dept. of Computer Science 7

Simple Local Illumination o The model used by OpenGL o Reduce the complex workings of light to three components n Ambient n Diffuse n Specular o Final illumination at a point (vertex) = ambient + diffuse + specular o Materials reflect each component differently n Use different material reflection coefficients o K a, K d, K s R.W. Lindeman - WPI Dept. of Computer Science 8

Ambient Light Contribution o Ambient light = background light o Light that is scattered by the environment n It's just there o Frequently assumed to be constant o Very simple approximation of global illumination o No direction: independent of light position, object orientation, observer s position/orientation object 3 object 4 object 2 constant object 1 Ambient = I x K a R.W. Lindeman - WPI Dept. of Computer Science 9

Diffuse Light Contribution o Diffuse light: The illumination that a surface receives from a light source that reflects equally in all directions n Eye point does not matter R.W. Lindeman - WPI Dept. of Computer Science 10

Diffuse Light Calculation o Need to decide how much light the object point receives from the light source n Based on Lambert s Law Receive more light Receive less light R.W. Lindeman - WPI Dept. of Computer Science 11

Diffuse Light Calculation (cont.) o Lambert s law: the radiant energy D that a small surface patch receives from a light source is: Diffuse = K d x I x cos(θ) K d : diffuse reflection coefficient I: light intensity θ: angle between the light vector and the surface normal light vector (vector from object to light) θ N : surface normal R.W. Lindeman - WPI Dept. of Computer Science 12

Diffuse Light Examples I = 1.0 K d = 0.0 0.2 0.4 0.6 0.8 1.0 R.W. Lindeman - WPI Dept. of Computer Science 13

Specular Light Contribution o The bright spot on the object o The result of total reflection of the incident light in a concentrate region Sees no specular Sees lots of specular R.W. Lindeman - WPI Dept. of Computer Science 14

Specular Light Calculation o How much reflection you can see depends on where you are n But for non-perfect surface you will still see specular highlight when you move a little bit away from the ideal reflection direction Φ is deviation of view angle from mirror direction n When φ is small, you see more specular highlight R.W. Lindeman - WPI Dept. of Computer Science 15

Specular Light Calculation (cont.) o Phong lighting model n Not Phong shading model o The effect of 'f' in the Phong model Specular = K s x I x cos f (φ) f = 10 f = 90 f = 30 f = 270 R.W. Lindeman - WPI Dept. of Computer Science 16

Specular Light Examples K s = 0.25 K s = 0.5 K s = 0.75 f = 3 f = 6 f = 9 f = 25 f = 200 R.W. Lindeman - WPI Dept. of Computer Science 17

Putting It All Together o Illumination from a light Illum = ambient + diffuse + specular = K a x I + K d x I x cos(θ) + K s x I x cos f (φ) o If there are N lights Total illumination for a point P = Σ (Illum) o Some more terms to be added n Self emission n Global ambient n Light distance attenuation and spot light effect R.W. Lindeman - WPI Dept. of Computer Science 18

Putting It All Together (cont.) o Illum = ambient + diffuse + specular R.W. Lindeman - WPI Dept. of Computer Science 19

Ambient Lighting Example R.W. Lindeman - WPI Dept. of Computer Science 20

Diffuse Lighting Example R.W. Lindeman - WPI Dept. of Computer Science 21

Specular Lighting Example R.W. Lindeman - WPI Dept. of Computer Science 22

Adding Color o Sometimes light or surfaces are colored o Treat R, G and B components separately n i.e., can specify different RGB values for either light or material o Illumination equation goes from Illum = ambient + diffuse + specular To: = K a x I + K d x I x cos(θ) + K s x I x cos f (φ) Illum r = K ar x I r + K dr x I r x cos(θ) + K sr x I r x cos f (φ) Illum g = K ag x I g + K dg x I g x cos(θ) + K sg x I g x cos f (φ) Illum b = K ab x I b + K db x I b x cos(θ) + K sb x I b x cos f (φ) R.W. Lindeman - WPI Dept. of Computer Science 23

Adding Color (cont.) Material Ambient Diffuse Specular Exponent f K ar, K ag, K ab K dr, K dg, K db K sr, K sg, K sb 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 R.W. Lindeman - WPI Dept. of Computer Science 24

Lighting Steps o Adopt Phong lighting model n Ambient + Specular + Diffuse lights n Lighting is computed at vertices o Interpolate across surface (Gouraud/smooth shading) o Setting up lighting n Light properties n Surface material properties n Provide correct surface normals n Set light model properties R.W. Lindeman - WPI Dept. of Computer Science 25

Light Properties o Properties n Colors / Position and type / attenuation gllightfv( light, property, value ) 1 2 3 (1) Constant: specify which light you want to set the property for e.g., GL_LIGHT0, GL_LIGHT1, GL_LIGHT2... you can create multiple lights (OpenGL allows at least 8 lights) (2) Constant: specify which light property you want to set e.g., GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_POSITION (check the red book, or the Web, for more) (3) The value you want to set to the property R.W. Lindeman - WPI Dept. of Computer Science 26

Property Example o Define colors and position a light Var light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; Var light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; Var light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; Var light_position[] = { 0.0, 0.0, 1.0, 1.0 }; Pass along data to shaders see book code Colors Position What if I set Position to (0, 0, 1, 0)? R.W. Lindeman - WPI Dept. of Computer Science 27

Types of Lights o WebGL doesn t support lights, you provide your own (see book code): n Local light (point light) n Infinite light (directional light) o WebGL determines the light type by: n w = 0: Infinite light source n w!= 0:Point light o Position = (x/w, y/w, z/w) vec3 light = lightposition.xyz; //shader: already in world space R.W. Lindeman - WPI Dept. of Computer Science 28

Controlling Light Position o Modelview matrix affects a light s position o Two options n Option a: o Treat light like vertex o Perform a translate, rotate on light position o Call LookAt o Light moves independently of camera n Option b: o Load identity matrix in modelview matrix o Call LookAt o Light appears at the eye (like a miner s lamp) R.W. Lindeman - WPI Dept. of Computer Science 29

Material Example o Define ambient/diffuse/specular reflection and shininess var mat_amb_diff[] = { 1.0, 0.5, 0.8, 1.0 }; Refl. var mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; coeff. var shininess[] = { 5.0 }; Range: dull 0 very shiny 128 Pass to the shader (see book code for details) R.W. Lindeman - WPI Dept. of Computer Science 30

Surface Normals o Correct normals are essential for correct lighting o Associate a normal with each vertex normalsarray.push( u, v, n ); pointsarray.push( x, y, z );... o All normals must be specified in unit length n More on why in the next slide set! R.W. Lindeman - WPI Dept. of Computer Science 31

Colored Wireframe R.W. Lindeman - WPI Dept. of Computer Science 32

Colored Hidden-Line Removal R.W. Lindeman - WPI Dept. of Computer Science 33

Ambient Term Only R.W. Lindeman - WPI Dept. of Computer Science 34

Flat Shading R.W. Lindeman - WPI Dept. of Computer Science 35

Diffuse Shading + Interp. Normals R.W. Lindeman - WPI Dept. of Computer Science 36

Gouraud Shading R.W. Lindeman - WPI Dept. of Computer Science 37

Ambient + Diffuse + Specular R.W. Lindeman - WPI Dept. of Computer Science 38

Ambient + Diffuse + Specular + Interpolated Normals R.W. Lindeman - WPI Dept. of Computer Science 39

Radiosity R.W. Lindeman - WPI Dept. of Computer Science 40

Texture Mapping R.W. Lindeman - WPI Dept. of Computer Science 41

Texture Mapping + Ray Tracing R.W. Lindeman - WPI Dept. of Computer Science 42