1 / 71

#11: Lighting

#11: Lighting. CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006. Outline for today. Overview of lighting Notes on color Local Illumination Light Sources Shading Advanced Lighting. Where we are so far…. We know how to rasterize:

Télécharger la présentation

#11: Lighting

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.


Presentation Transcript

  1. #11: Lighting CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006

  2. Outline for today • Overview of lighting • Notes on color • Local Illumination • Light Sources • Shading • Advanced Lighting

  3. Where we are so far… • We know how to rasterize: • Given a 3D triangle (or a bunch of triangles) • Given a 3D camera… • …we know which pixels represent the triangles • But what color should those pixels be?

  4. Lighting (non-teapot images by Henrik Wann Jensen)

  5. Lighting • To create a photorealistic image: • Simulate the interaction of light with the objects in the scene • Simulate the interaction of light with the eye or camera • I.e., simulation of physics and optics • Advanced rendering course (CSE168) • Many aspects “solved” in principle but still an area of active research • Very slow to compute fully • Use global illumination techniques: examine the whole scene at once • Known as physically-based rendering • For interactive computer graphics: • Use a simplified model for speed • Empirical/perceptual -- approximate interesting observed phenomena • Use local illumination techniques: • only direct effect of lights on surfaces

  6. Basic Components of Lighting • Light sources • AKA emitters • Color and intensity • Geometric attributes: Position, Direction, Shape • Spatial attenuation • Advanced properties: Spectrum, Polarization, … • Surfaces • Geometric attributes: Position, Orientation • Material properties: reflectance • color • shininess, glossiness, … • texture • Advanced: translucency, microstructure, sub-surface scattering, …

  7. Lighting vs. Shading • Lighting: compute the result of light illuminating surfaces • Shading: assign colors to pixels • For photorealistic rendering: • in principle, shading==lighting: perform lighting at every pixel • In practice: • may take shortcuts • may include non-lighting effects • fog • illustration • cartoon shading

  8. Vertex Lighting • Each vertex goes through lighting process • Lighting computation determines final color at the vertex • Based on initial “unlit” vertex color • Based on lights in the scene • Based on material properties of the surface • Based on surface normal • Interpolate colors using Gouraud shading • (Same lighting computation for per-pixel lighting)

  9. Outline for today • Overview of lighting • Notes on color • Local Illumination • Light Sources • Shading • Advanced Lighting

  10. What is light? What is color? • Light is electromagnetic energy • a continuous range of wavelengths • varying intensity at each wavelength • Color is a property of the visual system • Not an inherent property of light • Human eyes have Red, Green, Blue receptors (cones) • Each receptor responds to a range of wavelengths • Gives rise to “primary colors”: • all colors expressed as combination of red, green, blue cone stimulation • Lots of perceptual, psychophysical effects: • adaptation, inhibition, illusion • Physically correct computation • requires computing interactions at all wavelengths • Perceptually correct computation • Requires taking into account psychophysics • Pretty good approximation: • Separate light into red, green, blue components • Process each component independently

  11. Color illusion • The squares marked A and B are the same shade of gray

  12. Color Illusion -- proof

  13. Color Spaces

  14. Material Colors • Inherent “material color” which is the color that the object reflects • Material reflects different wavelengths of light different amounts • In RGB, have a reflectivity amount for each of red, green, blue • An object can’t reflect more light than it receives • Maximum: reflect 100% of light in all wavelengths--bright white • Reasonable: reflect 95% of light, material color =(0.95, 0.95, 0.95) • Material colors range from 0.0 to 1.0 in RGB

  15. Light Color • No limit to total light intensity reflecting from surface • Can make individual light source brighter • Can add more lights • Represent a light source using intensity in RGB • Range from 0.0 up • There is no upper limit to the intensity of light • In other words, a bright white light might have color (10,10,10) • Units? • physically-based rendering: photon power flux density • in practice: arbitrary units (“my light goes up to 11”)

  16. Color & Intensity • Distinction between material color and light color: • Material colors represent the proportion of light reflected • Light colors represent the actual intensity of a beam of light • We never perceive the inherent material color • All we see is the light reflected off of a material • Shine a red light… • on a white or red surface: the object appears red • on a grey surface: the object appears dark red • on a blue surface: the object appears black

  17. Exposure and Display • What do we mean by “white”? • Human eyes (and digital cameras) adjust exposure settings automatically • In a moderatly lit room, intensity 0.5 might appear as white • In bright sunlight, intensity 100 might appear as (same) white • The monitor has an upper limit to the brightness it can display • RGB units: 0=no light at the pixel, 1=full intensity at the pixel • exact color light that emerges depends on monitor properties • brightness, contrast, white point, color balance, … • Final result of lighting calculation shouldn’t be more than 1.0 • Advanced techniques: exposure control, AKA “tone mapping” • In practice: • Assume intensity (1,1,1) is white • clamp all final color values to 0.0-1.0 range before storing in pixel

  18. Outline for today • Overview of lighting • Notes on color • Local Illumination • Light Sources • Shading • Advanced Lighting

  19. Local Illumination • AKA Local Lighting Models • Light on a point on the surface (vertex) • Assume we have an incident ray of light • Light coming from a known direction • With a given RGB color (intensity) • We will build up empirical material properties • Fancy name: Bidirectional Reflectance Distribution Function “BRDF”

  20. Reflectivity • White sheet of paper might reflect 95% of incident light • A mirror might reflect 95% of incedent light • Yet, these two things look completely different: • They reflect light in different directions • The paper is a diffuse reflector • The mirror is a specular reflector

  21. “Standard” Lighting Model • Consists of three terms linearly combined: • Diffuse component for the amount of incoming light reflected equally in all directions • Specular component for the amount of light reflected in a mirror-like fashion • Ambient term to approximate light arriving via other surfaces • This is very simple approximation • particularly good for plastic • particularly good for metal • That’s why CG images tend to look like plastic and metal

  22. Diffuse Reflection • An ideal diffuse reflector receives light from some direction and bounces it uniformly in all directions • very rough at microscopic level • Diffuse materials have a dull or matte appearance • example: chalk

  23. Diffuse Reflection • Assume a beam of parallel rays shining on the surface • Consider area of the surface covered by the beam • varies based on the angle between the beam and the normal • The larger this area, the less incident light per area • The incident light per unit area is proportional to the cosine of the angle between the normal and the light rays • Object darkens as normal turns away from light • This is known as Lambert’s cosine law • Diffuse surfaces AKA Lambertian surfaces n

  24. Lambert’s Cosine Law

  25. Diffuse Reflection • Notes: • Depends on light and normal directions • Doesn’t depend on eye position • diffuse reflection is same in every direction • Don’t want to illuminate from rear • use cl kd

  26. Diffuse Lighting Examples • A Lambertian sphere at several different lighting angles: • Diffuse lighting provides visual cues • indicates 3D depth • indicates surface curvature

  27. Multiple Lights • Can have many light sources in a scene • Light (generally) behaves additively • Add up the contribution of each light

  28. Ambient Light • In the real world, light gets bounced all around the environment • Resulting light illuminates surface from every direction. • Global illumination techniques attempt to compute this. Complex. • Simple approximation (hack): Ambient light • Assume net effect is a constant color shining from every direction • Add to the net color, attenuated by reflectance coefficient • Effect of ambient light: • Keeps unlit areas from going completely black • Makes things look flatter • with ambient and no diffuse: object has solid color, is completely 2D • kaor ca usually small (.1 or less)

  29. Specular Reflection • Shiny surfaces exhibit specular reflection • Polished metal • Glossy car finish • Plastics • A light shining on a specular surface causes a bright spot: • known as a specular highlight • essentially, a rough reflection of the light source • Highlight location depends viewer position relative to surface & lights

  30. Specular Reflection • An ideal specular reflector = mirror • perfectly smooth surface • bounces an incoming light ray in a single direction • angle of incidence equals the angle of reflection

  31. Law of Reflection • Angle of reflectance = angle of incidence p

  32. Specular (Glossy) Reflection • Many materials not quite perfect mirrors • Glossy materials look shiny and will show specular highlights • In CG, this is sometimes referred to as glossy reflection • Many formulations for this • First: most basic and famous: Phong lighting model (1973) • Then: most popular: Blinn lighting model (1977)

  33. Shiny materials • The surface roughness will vary from material to material • Smooth surfaces have sharp highlights • Rougher surfaces have larger, more blurry highlights • Assume surface composed of microfacets with random orientation • Smooth surfaces: microfacet normals very close to surface normal • Rough surfaces: microfacet normals are spread around more • on average, microfacet normals close to surface normal • Polished: • Smooth: • Rough: • Very rough:

  34. Empirical observation • In general, we expect most reflected light to travel in direction of exact reflection • But because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal reflected ray • So: • Most reflected light in direction of ideal reflection • Brightest when eye vector (view vector) is aligned with reflection • Intensity decreases as eye vector angle from reflection increases • Use dot product of eye vector with reflection vector

  35. Phong Lighting Model • parameters: • specular reflectance coefficient, ks • Phong Exponent p controls the apparent size of the specularity • Higher p, smaller highlight cl ks

  36. Phong Lighting Model Examples p=2 p=1 p=4 p=8 p=32 p=16 p=64 p=128 p=256

  37. Blinn Lighting Model cl ks

  38. cl ks Blinn Lighting Model

  39. Complete Blinn Lighting Model • Add to ambient and diffuse • Add specular contribution for each light • It appears in a few slightly different forms and in a wide variety of notations…

  40. Note on color • Do this in parallel for R,G,B • Coefficients ka, kd, ks can be different for each of R,G,B • This defines the material ambient color, diffuse color, and specular color. • Other (expensive) terms in expression are shared for each of R,G,B • Generally, use ambient color = diffuse color • For metals, specular color = diffuse color • highlight is color of the material • For plastics, specular color = white • highlight is the color of the light

  41. Note on normals and spaces • Lighting depends on angles between normals, vectors • Must be in space that preserves angles • World Space or Camera Space • Not normalized view space: perspective doesn’t preserve angles • Conveniently, we can put world-space normals as per-vertex data • Doesn’t get transformed by projection. • But remember, when taking normals from object to world space: • if world transform has nonuniform scale, normals must use inverse-transpose • if world transform has uniform scale, normals must be renormalized • if world transform has no scales, normals transform like vectors

  42. General Lighting Models • General form: • Bidirectional Reflectance Distribution Function BRDF, B() • There are many lighting models • Phong • Blinn • Cook-Torrance • includes “roughness”, other parameters • Gooch • non-photorealistic, for illustrations • Ward • includes anisotropy • etc…

  43. Cook-Torrance

  44. Gooch

  45. Anisotropy • Material reflects differently in different directions • E.g., brushed metal; Ward’s model isotropic anisotropic

  46. Outline for today • Overview of lighting • Notes on color • Local Illumination • Light Sources • Shading • Advanced Lighting

  47. Light Sources • In general, light sources can have complex properties • Geometric area over which light is produced • Anisotropy in direction • Variation in color • Some very simple light sources models are standard

  48. Light Sources • Two aspects of light sources are important for a local shading model: • Where is the light coming from (the L vector)? • How much light is coming (the I values)? • Various light source types give different answers to the above questions: • Directional: Light from a specific direction • Point light source: Light from a specific point • Spotlight: Light from a specific point with intensity that depends on the direction

  49. Directional Light • When light is coming from a distant source • light rays are parallel • light ray direction is the same everywhere in the scene • as if the source were infinitely far away • good approximation to sunlight • Specified by a unit length direction vector, and a color csrc cl

  50. Point Lights • For closer light sources, such as light bulbs • Model as a point that radiates light in all directions equally • Light vector varies across the surface • Intensity from a point light source drops off proportionally to the inverse square of the distance from the light p csrc cl cl v v

More Related