Advanced Lighting Techniques in OpenGL: Understanding Material Properties and Color Perception
This document covers advanced lighting techniques in OpenGL, including per-vertex and per-pixel lighting. Key concepts discussed include light and material properties, color representation using RGBA values, and the calculation of spectral energy. The text explores different types of reflections such as diffuse, specular, and ambient lighting. It introduces the Blinn-Phong model, BRDF, and the implications of color perception through the CIE color standard. Finally, it examines the technical aspects of hardware color mapping and the geometrical properties of light in 3D graphics.
Advanced Lighting Techniques in OpenGL: Understanding Material Properties and Color Perception
E N D
Presentation Transcript
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi
Lighting in OpenGL • Per-vertex • per-pixel with Cg • Light and Material Properties • glLightfv: RGBA • Color of light – RGBA in [0:255] • glMaterialfv: RGBA • Color of material – RGBA in [0:255] • glColor3f: RGBA • Uses glColorMaterial
Intensity λ Color Perception • Energy? • Q = h/λ • Some colors are perceived brighter
Definitions • Energy per unit wavelength? • Spectral Energy: (Q in an interval ∆λ)/∆λ→ dQ/dλ • Irradiance, H • Spectral Power reaching surface per unit area • Radiance • ∆H/∆σ, per unit solid angle
Surface Radiance l θ n Surface Radiance L =
Radiance Non-Attenuation Both detectors see the same Radiance
Surface Radiance l dA θ θ n dA cosθ Surface Radiance L =
BRDF • Bi-directional Reflectance Function • ρio = Lo / Hlight -i o
Types of BRDFs • Isotropic • Reflectance independent of rotation about a given surface normal • Smooth plastics • Anisotropic • Reflectance changes with rotation around a given surface normal • Brushed metal, satin, hair
Luminous Efficiency • Lumens per watt (lm/W) • Photopic efficiency < 683 lm/W • @ Monochromatic light with λ = 555 nm (green). • Scotopic efficiency < 1700 lm/W • @ λ = 507 nm
Tri-Stimulus Theory • Metamers appear the same • Eyes have sensors: • Rods (low resolution, Peripheral, Many) • Cones (High res, in fovea, few, 3 types) • Maximum response at 420 nm (blue), • Maximum response at 534 nm (Bluish-Green), • Maximum response at 564 nm (Yellowish-Green). • Integrating (Filtering) Sensors
CIE Color Standard • Three components • X Y Z • Y has luminance (perceived brightness) • X and Z have brightness • C = X + Y + Z • Represented as • x = X/(X+Y+Z), y = Y/(X+Y+Z), Y • x and y have chromaticity, Y has luminance
Color Spaces • HSV • RGB • CMYK • HDR • Tone Mapping
Color in Hardware • RED is not the same on every monitor • Not even the same everytime on the same HW • User knobs, Ambient lighting • 0:1, in a normalized space • No limit in reality • 1 => Maximum screen brightness • 0 => Minimum screen brightness • Why R, G, B? • Engineering convenience • Gamma correction • Gamma can be commonly set by the user
Hardware Color Mapping • Normalize each component to [0:1] • Fixed number of steps • Monitor dependent • Typically 255 • Values 0..255 -> v -> intensity • Displayed I α (Maximum I) vy
Geometry of Local Lighting • Vertex normals make it “smooth” • Lights in Camera space • Already specified so in OpenGL L n l v
Diffuse Reflection • Reflection uniformly in all directions • Matte (Non-shiny) appearance • Eg, chalk • Most materials are not ideally diffuse
Specular Reflection • Light reflects in a single direction • Shiny • Eg, silvered mirror • Most materials are not ideally specular
Diffuse/Specular Reflection • Most materials are a combination of diffuse and specular • Reflection distribution function • Need not be in a plane • Need not be isotropic
Diffuse Reflection • 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 l3 l2 n l1 surface
Diffuse Reflection • Unit vector l points to the light source cl n l fdiff
Directional Light • Distant light source • A unit length direction vector d and a color c • l = -d • Color shining on the surface cl = c
Point Lights • 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 p cpnt l n cl v fdiff
Attenuation • Sometimes, inverse square falloff behavior is hacked approximated • A common damping of “distance attenuation” is:
Multiple Lights • Additive • Interference does happen • E.g., soap bubbles
Ambient Light • Poor man’s “global illumination” • Same amount everywhere • Often, famb is set to equal fdif
Blinn’s Model • Smooth => well defined small highlights, • Rough => Blurred, larger • Surface roughness modeled by microfacets • Distribution of microfacet normals Polished: Smooth: Rough: Rougher:
Specular Highlights • 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) n h cl e l fspec
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 n h cl e l fspec
Specular Highlights • 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 Blinn lighting model: • s is shininess or specular exponent
Specular Highlights • 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 • Blinn lighting model.
Classic Lighting Models • Lambert • Blinn • Phong • Considers angle between normal and viewer • Cook-Torrance n n h cl cl e e l l fspec fspec Phong Blinn
Cook & Torrance • Contributors: • Torrance & Sparrow (1967) • Blinn (1977) • Models of Light Reflection for Computer Synthesized Pictures, SIGGRAPH’77 • Cook & Torrance (1982) • A Reflectance Model for Computer Graphics, ACM TOG 1(1) • Thermodynamics and geometric optics • Explains off-cpecular peaks • No electromagnetics • Fails for very smooth surfaces
Cook & Torrance • Ei = Ii (N.L) di • R = Ir/Ei • Ir = R Ii (N.L) di • R = sRs + dRd, s + d = 1. • IrA= RA IiAf • f = 1/ ∫ (N.L) di • Shortcut, f = 1
Intensity of Reflected Light IR = IiARA + l (Iil (N•Ll) ∆il(sRs + dRD)) l: Individual lights Iil: Average intensity of the incident light N: Surface unit normal Ll: Unit vector in the direction of light l ∆il: solid angle of a beam of incident light
Cook-Torrance Model Rs = F D G___ (N•L) (N•V) 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: 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: D = 1/(m2cos4) e-(tan2/m2)
Beckmann vs Blinn m = 0.2 m = 0.6
Geometric Attenuation • 0 <= G <= 1 • No occlusion to full occlusion
Fresnel Factor • Wavelength dependent. • Refractive Index • Mirror-like at grazing angles
Some Examples Metal :: refractive index :: absorption coeff. Silver :: 0.177 :: 3.638 Copper :: 0.617 :: 2.63 Steel :: 2.485 :: 3.433
Results of Cook-Torrance Copper colored plastic Copper vase
Compared to Phong 30o Incidence 70o Incidence Torrance et al. Phong
Shading • Gouraud • Light vertices • Interpolate colors • glShadeModel(GL_SMOOTH) • Phong • Per-pixel (Phong) lighting • Interpolate normals • Need pixel-programs