1 / 33

Lighting

Lighting. What is Light?. A very complex process Find a dark area – how is it being lit? Light bounces (mirrors, shiny objects) Light refracts through other media (water, heat) Light comes from everywhere (Global Illumination) Light bounces off of lakes in weird ways (Fresnel effect)

tarmon
Download Presentation

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.

E N D

Presentation Transcript


  1. Lighting Jeff Chastine

  2. What is Light? • A very complex process • Find a dark area – how is it being lit? • Light bounces (mirrors, shiny objects) • Light refracts through other media (water, heat) • Light comes from everywhere (Global Illumination) • Light bounces off of lakes in weird ways (Fresnel effect) • THUS • We’re forced to make approximations • Tradeoff between time and realism • “If it looks good, it is good” – Michael Abrash http://en.wikipedia.org/wiki/File:Global_illumination.JPG http://darrentakenaga.com/3d.html Jeff Chastine

  3. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? Directional light - position doesn’t matter - triangle is almost fully lit P0 P1 P2 Jeff Chastine

  4. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? P0 (Triangle less lit) P1 P2 Jeff Chastine

  5. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? P0 P1 P2 (Little to no light hits the surface) Jeff Chastine

  6. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? P0 (Directional light) P1 P2 Jeff Chastine

  7. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? P0 (Directional light) P1 P2 Jeff Chastine

  8. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? Lesson learned: Lighting depends on angles between vectors! P0 (Directional light) P1 P2 Jeff Chastine

  9. A Basic Lighting Concept • How can we determine how much light should be cast onto a triangle from a directional light? P0 (Directional light) P1 P2 Assuming N and L are normalized, and N∙L isn’t negative Jeff Chastine

  10. Basic Lighting • Four independent components: • Diffuse – the way light “falls off” of an object • Specular – the “shininess” of the object • Ambient – a minimum amount of light used to simulate “global illumination” • Emit – a “glowing” effect Only diffuse Jeff Chastine

  11. Basic Lighting • Four independent components: • Diffuse – the way light “falls off” of an object • Specular – the “shininess” of the object • Ambient – a minimum amount of light used to simulate “global illumination” • Emit – a “glowing” effect Diffuse+Specular Jeff Chastine

  12. Basic Lighting • Four independent components: • Diffuse – the way light “falls off” of an object • Specular – the “shininess” of the object • Ambient – a minimum amount of light used to simulate “global illumination” • Emit – a “glowing” effect Diffuse+Specular+Ambient Ambient Jeff Chastine

  13. Basic Lighting • Four independent components: • Diffuse – the way light “falls off” of an object • Specular – the “shininess” of the object • Ambient – a minimum amount of light used to simulate “global illumination” • Emit – a “glowing” effect D+S+A+Emit Note: emit does not produce light! Jeff Chastine

  14. Interaction between Material and Lights • Final color of an object is comprised of many things: • The base object color (called a “material”) • The light color • Example: a purple light on a white surface • Any textures we apply (later) • Materials and lights have four individual components • Diffuse color (cdand ld) • Specular color (csand ls) • Ambient color (caand la) • Emit color (ceand le) • cd* ld = [cd.r*ld.r, cd.g*ld.g, cd.b*ld.b] // R, G, B Jeff Chastine

  15. General Lighting • Primary vectors • l – the incoming light vector • n – the normal of the plane/vertex • r – the reflection vector • v – the viewpoint (camera) v n l r θ θ Jeff Chastine

  16. LambertianReFlectance(diffuse Component) • Light falling on an object is the same regardless of the observer’s viewpoint • Good for rough surfaces without specular highlights • where and are normalized n l θ Jeff Chastine

  17. LambertianReFlectance(diffuse Component) • Light falling on an object is the same regardless of the observer’s viewpoint • Good for rough surfaces without specular highlights • where and are normalized 3 parts (R, G, B) scalar n l θ Note: final_colordiffusehas R, G, B Jeff Chastine

  18. LambertianReFlectance(diffuse Component) • Technically, it should be: n l θ Jeff Chastine

  19. BLINN-PHONG Reflection(Specular Component) • Describes the specular highlight and is dependent on viewpoint v • Also describes a “half-vector” h that is halfway between v and l h v n r l θ θ Jeff Chastine

  20. BLINN-PHONG Reflection(Specular Component) • - which is really Blinn’s contribution to the original Phong model h v n r l θ θ Note: vectors should be normalized Jeff Chastine

  21. BLINN-PHONG Reflection(Specular Component) • Our final specular equation is: h v n r l θ θ Jeff Chastine

  22. Determining • Realize that will always be < 1.0, so raising it to a power will make it smaller • is the “shininess” factor • It relates to the size of the specular highlight s = ~1 s = ~30 s = ~255 Jeff Chastine

  23. Ambient and Emit Components • Ambient: • Used to simulate light bouncing around the environment (global illumination) • Real world is far too complex for real time, so just add a little light! • Emit: • Used to make the object “glow” • Does not emit light!!! • Both: • Independent of viewpoint • Super easy to calculate Jeff Chastine

  24. Final Color • To determine the final color (excluding textures) we sum up all components: final_colordiffuse final_colorspecular final_colorambient final_coloremit final_color + http://en.wikipedia.org/wiki/Phong_reflection_model Jeff Chastine

  25. What about Multiple lights? • Calculate final colors and sum them all together • Assuming results are in f [ ] and there are count number of lights Jeff Chastine

  26. Common Kinds of Lights • Point light • Directional Light • Spot Light • Area Light • Interesting fact: • Lights cannot be seen! • Only their effects • We can light per vertex (fast) or per fragment (slower) Jeff Chastine

  27. Point Lights • These lights have a position in 3D space • Sometimes called a “Lamp” • Light emanates from the light in all directions • Distance d determines brightness (“attenuation”): Here, per fragment lighting used Jeff Chastine

  28. Point Lights • These lights have a position in 3D space • Sometimes called a “Lamp” • Light emanates from the light in all directions • Distance d determines brightness (“attenuation”): Here, per vertex lighting used Jeff Chastine

  29. Directional Lights • Are infinitely far away • position in NO WAY matters • Have only direction • All objects are lit evenly • Sometimes called a “Sun” Jeff Chastine

  30. Spotlights • Point light source • Conical in shape Jeff Chastine

  31. Spotlights • Point light source • Conical in shape • Have: • An inner and outer cone angle • Umbra – areas that are fully in shadow • Penumbra – areas that are in partial shadow • Note: There’s an ambient light Jeff Chastine

  32. Area Lights • A “surface” lights objects • Has a position and direction • Provides for a smoother drop off than point • Larger surface == smoother shadows • Expensive to calculate Jeff Chastine

  33. What you’ll see if you don’t glEnable(GL_LIGHTING) The End!

More Related