Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi."— Presentation transcript:

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

2 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

3 Spectrum

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

5 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

6 Surface Radiance θ Surface Radiance L = n l

7 Radiance Non-Attenuation Both detectors see the same Radiance

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

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

10 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

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

12 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

13 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

14 CIE Chromaticity Diagram

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

16 Hue, Saturation, Value

17 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

18 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 0..255 -> v -> intensity Values 0..255 -> v -> intensity Displayed I α (Maximum I) v y Displayed I α (Maximum I) v y

19 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

20 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

21 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

22 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

23 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

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

25 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

26 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

27 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:

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

29 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

30 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:

31 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)

32 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

33 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

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

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

36 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.

37 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

38 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

39 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

40 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

41 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

42 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 )

43 Beckmann vs Blinn m = 0.2 m = 0.6

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

45 Geometric Attenuation

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

47 Some Examples Materialsdm Carbon.3.7.4 Rubber.4.6.3 Obsidian.8.2.15 Lunar Dust 01X Olive drab.3.7.5 Rust.2.8.35

48 Some Examples Metal :: refractive index :: absorption coeff. Silver :: 0.177 :: 3.638 Copper :: 0.617 :: 2.63 Steel :: 2.485 :: 3.433

49 Results of Cook-Torrance Copper colored plastic Copper vase

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

51 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

52 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)

53 Shadow Map Scene

54 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.


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

Similar presentations


Ads by Google