1 / 53

CSL 859: Advanced Computer Graphics

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

lcarmine
Download Presentation

CSL 859: Advanced Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Spectrum

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

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

  6. Surface Radiance l θ n Surface Radiance L =

  7. Radiance Non-Attenuation Both detectors see the same Radiance

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

  9. BRDF • Bi-directional Reflectance Function • ρio = Lo / Hlight -i o

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

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

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

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

  14. CIE Chromaticity Diagram

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

  16. Hue, Saturation, Value

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

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

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

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

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

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

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

  24. Diffuse Reflection • Unit vector l points to the light source cl n l fdiff

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

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

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

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

  29. Ambient Light • Poor man’s “global illumination” • Same amount everywhere • Often, famb is set to equal fdif

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

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

  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 n h cl e l fspec

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

  34. Specular Highlights • 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 • Blinn lighting model.

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

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

  39. Cook & Torrance • Ei = Ii (N.L) di • R = Ir/Ei • Ir = R Ii (N.L) di • R = sRs + dRd, s + d = 1. • IrA= RA IiAf • f = 1/ ∫ (N.L) di • Shortcut, f = 1

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

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

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

  43. Beckmann vs Blinn m = 0.2 m = 0.6

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

  45. Geometric Attenuation

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

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

  48. Results of Cook-Torrance Copper colored plastic Copper vase

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

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

More Related