CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.

Slides:



Advertisements
Similar presentations
Computer Graphics - Shading -
Advertisements

1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 6 Physically Based Reflection Model.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Local Reflection Model Jian Huang, CS 594, Fall 2002.
Computer Graphics (Fall 2008) COMS 4160, Lecture 18: Illumination and Shading 1
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 21: Radiometry Many slides courtesy Pat Hanrahan.
Basic Principles of Surface Reflectance
Physically Based Illumination Models
Advanced Computer Graphics (Spring 2013) CS 283, Lecture 8: Illumination and Reflection Many slides courtesy.
Torrance Sparrow Model of Reflectance + Oren Nayar Model of Reflectance.
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 2008 Tamara Munzner Lighting/Shading II Week.
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Computer Graphics (Spring 2008) COMS 4160, Lecture 20: Illumination and Shading 2
CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005
Part I: Basics of Computer Graphics
3-D Computer Vision CSc83029 / Ioannis Stamos 3-D Computer Vision CSc Radiometry and Reflectance.
6.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 6 Physically Based Reflection Model.
Computer Graphics (Fall 2008) COMS 4160, Lecture 19: Illumination and Shading 2
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Introduction to Computer Vision CS / ECE 181B Tues, May 18, 2004 Ack: Matthew Turk (slides)
7M836 Animation & Rendering
Basic Principles of Surface Reflectance
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.
Computer Graphics (Fall 2004) COMS 4160, Lecture 16: Illumination and Shading 2 Lecture includes number of slides from.
CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CHAPTER 9 Lighting © 2008 Cengage Learning EMEA. LEARNING OBJECTIVES In this chapter you will learn about: – –Light sources – –Point lights – –Spotlights.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
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 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
MIT EECS 6.837, Durand and Cutler Local Illumination.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
Advanced Illumination Models Chapter 7 of “Real-Time Rendering, 3 rd Edition”
Illumination.
Announcements Office hours today 2:30-3:30 Graded midterms will be returned at the end of the class.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Material Representation K. H. Ko School of Mechatronics Gwangju Institute.
CSCE 641 Computer Graphics: Reflection Models Jinxiang Chai.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Computer Graphics (Spring 2003) COMS 4160, Lecture 18: Shading 2 Ravi Ramamoorthi Guest Lecturer: Aner Benartzi.
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.
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.
Physically-based Illumination Models (2) CPSC 591/691.
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.
Light. Intensity calculation = wavelength I( ) = wavelength intensity of light reaching eye I( ) = I diff ( ) + I spec ( ) + I refl ( ) + I trans ( )
Reflectance Models CS 319 Advanced Topics in Computer Graphics John C. Hart.
Computer Graphics: Illumination
7. Illumination Phong Illumination Diffuse, Specular and Ambient
Advanced Computer Graphics
Unit-7 Lighting and Shading
Fundamentals of Computer Graphics Part 6 Shading
Isaac Gang University of Mary Hardin-Baylor
Lighting Calculations
Presentation transcript:

CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi

Lighting in OpenGL Per-vertex Per-vertex per-pixel with Cg per-pixel with Cg Light and Material Properties Light and Material Properties glLightfv: RGBA glLightfv: RGBA Color of light – RGBA in [0:255] Color of light – RGBA in [0:255] glMaterialfv: RGBA glMaterialfv: RGBA Color of material – RGBA in [0:255] Color of material – RGBA in [0:255] glColor3f: RGBA glColor3f: RGBA Uses glColorMaterial Uses glColorMaterial

Spectrum

Color Perception Energy? Energy? Q = h/ λ Q = h/ λ Some colors are perceived brighter Some colors are perceived brighter λ Intensity

Definitions Energy per unit wavelength? Energy per unit wavelength? Spectral Energy: (Q in an interval ∆ λ )/∆ λ → dQ/dλ Spectral Energy: (Q in an interval ∆ λ )/∆ λ → dQ/dλ Irradiance, H Irradiance, H Spectral Power reaching surface per unit area Spectral Power reaching surface per unit area Radiance Radiance ∆H/∆ σ, per unit solid angle ∆H/∆ σ, per unit solid angle

Surface Radiance θ Surface Radiance L = n l

Radiance Non-Attenuation Both detectors see the same Radiance

Surface Radiance dA dA cosθ θ θ Surface Radiance L = n l

BRDF Bi-directional Reflectance Function Bi-directional Reflectance Function ρ io = L o / H light ρ io = L o / H light -i o

Types of BRDFs Isotropic Isotropic Reflectance independent of rotation about a given surface normal Reflectance independent of rotation about a given surface normal Smooth plastics Smooth plastics Anisotropic Anisotropic Reflectance changes with rotation around a given surface normal Reflectance changes with rotation around a given surface normal Brushed metal, satin, hair Brushed metal, satin, hair

Luminous Efficiency Lumens per watt (lm/W) Lumens per watt (lm/W) Photopic efficiency < 683 lm/W Photopic efficiency < 683 Monochromatic light with λ = 555 nm Monochromatic light with λ = 555 nm (green). Scotopic efficiency < 1700 lm/W Scotopic efficiency < 1700 λ = 507 λ = 507 nm

Tri-Stimulus Theory Metamers appear the same Metamers appear the same Eyes have sensors: Eyes have sensors: Rods (low resolution, Peripheral, Many) Rods (low resolution, Peripheral, Many) Cones (High res, in fovea, few, 3 types) Cones (High res, in fovea, few, 3 types) Maximum response at 420 nm (blue), Maximum response at 420 nm (blue), Maximum response at 534 nm (Bluish-Green), Maximum response at 534 nm (Bluish-Green), Maximum response at 564 nm (Yellowish- Green). Maximum response at 564 nm (Yellowish- Green). Integrating (Filtering) Sensors Integrating (Filtering) Sensors

CIE Color Standard Three components Three components X Y Z X Y Z Y has luminance (perceived brightness) Y has luminance (perceived brightness) X and Z have brightness X and Z have brightness C = X + Y + Z C = X + Y + Z Represented as Represented as x = X/(X+Y+Z), y = Y/(X+Y+Z), Y x = X/(X+Y+Z), y = Y/(X+Y+Z), Y x and y have chromaticity, Y has luminance x and y have chromaticity, Y has luminance

CIE Chromaticity Diagram

Color Spaces HSV HSV RGB RGB CMYK CMYK HDR HDR Tone Mapping Tone Mapping

Hue, Saturation, Value

Color in Hardware RED is not the same on every monitor RED is not the same on every monitor Not even the same everytime on the same HW Not even the same everytime on the same HW User knobs, Ambient lighting User knobs, Ambient lighting 0:1, in a normalized space 0:1, in a normalized space No limit in reality No limit in reality 1 => Maximum screen brightness 1 => Maximum screen brightness 0 => Minimum screen brightness 0 => Minimum screen brightness Why R, G, B? Why R, G, B? Engineering convenience Engineering convenience Gamma correction Gamma correction Gamma can be commonly set by the user Gamma can be commonly set by the user

Hardware Color Mapping Normalize each component to [0:1] Normalize each component to [0:1] Fixed number of steps Fixed number of steps Monitor dependent Monitor dependent Typically 255 Typically 255 Values > v -> intensity Values > v -> intensity Displayed I α (Maximum I) v y Displayed I α (Maximum I) v y

Geometry of Local Lighting Vertex normals make it “smooth” Vertex normals make it “smooth” Lights in Camera space Lights in Camera space Already specified so in OpenGL Already specified so in OpenGL L n v l

Diffuse Reflection Reflection uniformly in all directions Reflection uniformly in all directions Matte (Non-shiny) appearance Matte (Non-shiny) appearance Eg, chalk Eg, chalk Most materials are not ideally diffuse Most materials are not ideally diffuse

Specular Reflection Light reflects in a single direction Light reflects in a single direction Shiny Shiny Eg, silvered mirror Eg, silvered mirror Most materials are not ideally specular Most materials are not ideally specular

Diffuse/Specular Reflection Most materials are a combination of diffuse and specular Most materials are a combination of diffuse and specular Reflection distribution function Reflection distribution function Need not be in a plane Need not be in a plane Need not be isotropic Need not be isotropic

Diffuse Reflection n Lambert’s law Lambert’s law “Amount” of incident light per unit area is proportional to the cosine of the angle between the normal and the light rays “Amount” of incident light per unit area is proportional to the cosine of the angle between the normal and the light rays surface l1l1 l2l2 l3l3

Diffuse Reflection Unit vector l points to the light source Unit vector l points to the light source n l clcl f diff

Directional Light Distant light source Distant light source A unit length direction vector d and a color c A unit length direction vector d and a color c l = -d l = -d Color shining on the surface c l = c Color shining on the surface c l = c

Point Lights Radiates light equally in all directions Radiates light equally in all directions Intensity from a point light source drops off proportionally to the inverse square of the distance from the light Intensity from a point light source drops off proportionally to the inverse square of the distance from the light n l clcl f diff v p c pnt

Attenuation Sometimes, inverse square falloff behavior is hacked approximated Sometimes, inverse square falloff behavior is hacked approximated A common damping of “distance attenuation” is: A common damping of “distance attenuation” is:

Multiple Lights Additive Additive Interference does happen Interference does happen E.g., soap bubbles E.g., soap bubbles

Ambient Light Poor man’s “global illumination” Poor man’s “global illumination” Same amount everywhere Same amount everywhere Often, f amb is set to equal f dif Often, f amb is set to equal f dif

Blinn’s Model Smooth => well defined small highlights, Smooth => well defined small highlights, Rough => Blurred, larger Rough => Blurred, larger Surface roughness modeled by microfacets Surface roughness modeled by microfacets Distribution of microfacet normals Distribution of microfacet normalsPolished:Smooth:Rough:Rougher:

Specular Highlights n l clcl f spec e h To compute the highlight intensity, we start by finding the unit length ‘halfway’ vector h, which is halfway between the vector l pointing to the light and the vector e pointing to the eye (camera) To compute the highlight intensity, we start by finding the unit length ‘halfway’ vector h, which is halfway between the vector l pointing to the light and the vector e pointing to the eye (camera)

Specular Highlights The halfway vector h represents the direction that a mirror-like microfacet would have to be aligned in order to cause the maximum highlight intensity The halfway vector h represents the direction that a mirror-like microfacet would have to be aligned in order to cause the maximum highlight intensity n l clcl f spec e h

Specular Highlights The microfacet normals generally point in the direction of the macro surface normal The microfacet normals generally point in the direction of the macro surface normal The further h is from n, fewer facets are likely to align with h The further h is from n, fewer facets are likely to align with h The Blinn lighting model: The Blinn lighting model: s is shininess or specular exponent s is shininess or specular exponent

Specular Highlights Higher exponent more narrow the highlight Higher exponent more narrow the highlight

Shininess n = 1 n = 5 n = 10 n = 50

Specular Highlights To account for highlights, we simply add an additional contribution to our total lighting equation To account for highlights, we simply add an additional contribution to our total lighting equation Blinn lighting model. Blinn lighting model.

Classic Lighting Models Lambert Lambert Blinn Blinn Phong Phong Considers angle between normal and viewer Considers angle between normal and viewer Cook-Torrance Cook-Torrance n l clcl f spec e h n l clcl e Blinn Phong

Cook & Torrance Contributors: Contributors: Torrance & Sparrow (1967) Torrance & Sparrow (1967) Blinn (1977) Blinn (1977) Models of Light Reflection for Computer Synthesized Pictures, SIGGRAPH’77 Models of Light Reflection for Computer Synthesized Pictures, SIGGRAPH’77 Cook & Torrance (1982) Cook & Torrance (1982) A Reflectance Model for Computer Graphics, ACM TOG 1(1) A Reflectance Model for Computer Graphics, ACM TOG 1(1) Thermodynamics and geometric optics Thermodynamics and geometric optics Explains off-cpecular peaks Explains off-cpecular peaks No electromagnetics No electromagnetics Fails for very smooth surfaces Fails for very smooth surfaces

Cook & Torrance E i = I i (N.L) d  i E i = I i (N.L) d  i R = I r /E i R = I r /E i I r = R I i (N.L) d  i I r = R I i (N.L) d  i R = sR s + dR d, s + d = 1. R = sR s + dR d, s + d = 1. I rA = R A I iA f I rA = R A I iA f f = 1/  ∫ (N.L) d  i f = 1/  ∫ (N.L) d  i Shortcut, f = 1 Shortcut, f = 1

Intensity of Reflected Light I R = I iA R A +  l (I il (NL l ) ∆  il (sR s + dR D )) l: Individual lights I il : Average intensity of the incident light N: Surface unit normal L l : Unit vector in the direction of light l ∆  il : solid angle of a beam of incident light

Cook-Torrance Model R s = F D G___  (NL) (NV)  (NL) (NV) F: Fresnel term D: Facet slope distribution: Fraction of facets oriented along H (Roughness) G: Geometrical attenuation factor (occlusion) V: Unit vector in the direction of the viewer

Roughness Blinn: Blinn: D = ce -(  /m) 2  : angle between H and N (H: angular bisector of V and L) m: root mean square (rms) slope of the facets Beckmann: Beckmann: D = 1/(m 2 cos 4  ) e -(tan 2  /m 2 )

Beckmann vs Blinn m = 0.2 m = 0.6

Geometric Attenuation 0 <= G <= 1 0 <= G <= 1 No occlusion to full occlusion No occlusion to full occlusion

Geometric Attenuation

Fresnel Factor Wavelength dependent. Refractive Index Mirror-like at grazing angles

Some Examples Materialsdm Carbon Rubber Obsidian Lunar Dust 01X Olive drab Rust

Some Examples Metal :: refractive index :: absorption coeff. Silver :: :: Copper :: :: 2.63 Steel :: :: 3.433

Results of Cook-Torrance Copper colored plastic Copper vase

Compared to Phong Phong Torrance et al. 30 o Incidence 70 o Incidence

Shading Gouraud Gouraud Light vertices Light vertices Interpolate colors Interpolate colors glShadeModel(GL_SMOOTH) glShadeModel(GL_SMOOTH) Phong Phong Per-pixel (Phong) lighting Per-pixel (Phong) lighting Interpolate normals Interpolate normals Need pixel-programs Need pixel-programs

Advanced Lighting Shadows Shadows Accurate reflection models Accurate reflection models Procedural shaders Procedural shaders Global Illumination Global Illumination Volumetric effects (fog, translucency…) Volumetric effects (fog, translucency…) Lens imperfections Lens imperfections Exposure (& dynamic range) Exposure (& dynamic range)

Shadow Map Scene

Shadow Map Find x,y in the light space Find x,y in the light space Unproject camera, then Project light Unproject camera, then Project light But x and y may not be integers But x and y may not be integers Find nearest integers? Find nearest integers? Read Depth buffer Read Depth buffer Compare projected z with stored z. Compare projected z with stored z.