220 likes | 354 Views
Lighting. CS 4363/6353. What is Light?. A very complex process How is your face being lit right now? Light bounces (mirrors, shiny objects ) Light refracts through other media (water, heat) Light comes from everywhere (Global Illumination)
E N D
Lighting CS 4363/6353
What is Light? • A very complex process • How is your face being lit right now? • Light bounces (mirrors, shiny objects) • Light refracts through other media (water, heat) • Light comes from everywhere (Global Illumination) • Light mixes with other light and the materials it hits • 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
Basic Lighting • We can break light down into four 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
Interaction between Material and Lights • The final color of an object is comprised of many things: • The base color (called a “material”) • The light color • Any textures we apply (later) • The material has four individual components, and so do the lights! • Diffuse color (cdand ld) • Specular color (csand ls) • Ambient color (caand la) • Emit color (ceand le) • Example: what if you shine a red light on a white ball? What color will it be?
General Lighting • Comprised of several 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 θ θ
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 θ http://en.wikipedia.org/wiki/Lambertian
LambertianReFlectance(diffuse Component) • Technically, it should be: n l θ http://en.wikipedia.org/wiki/Lambertian
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 θ θ
BLINN-PHONG Reflection(Specular Component) • - which is really Blinn’s contribution to the original Phong model h v n r l θ θ
BLINN-PHONG Reflection(Specular Component) • Our final specular equation is: h v n r l θ θ
Determining • is the “shininess” factor • It relates to the size of the specular hightlight • Realize that will always be < 1.0, so raising it to a power will make it smaller
Ambient and Emit Components • Ambient: • Used to simulate light bouncing around the environment (global illumination) • Real world is far too complex for real time • Emit: • Used to make the object “glow” • Does not emit light!!! • Both: • Independent of viewpoint • Super easy to calculate
Final Color • To determine the final color (excluding textures) we sum up all components: http://en.wikipedia.org/wiki/Phong_reflection_model
What about Multiple lights? • Sum them all together • Assuming there are count number of lights
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)
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”):
Directional Lights • Are infinitely far away- • position in NO WAY matters • Have only direction • Sometimes called “Suns” • All objects are lit evenly
Spotlights • Point light source • Conical in shape
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
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
Common Methods of Shading • Flat shading: • light is calculated once per polygon • Very fast • Phong (“fung”) shading: • Light is calculated once per fragment • More expensive, but looks better! http://en.wikipedia.org/wiki/File:Phong-shading-sample.jpg
Gouraud Shading(pronounced “ger-oh”) • In between flat and phong shading • Process • Lights each vertex (similar to Project 1) • Interpolates between those vertices (along the edges) • Fast, but bad for specular highlight for low-poly objects http://en.wikipedia.org/wiki/Gouraud_shading