250 likes | 415 Views
Week 9 - Wednesday. CS361. Last time. What did we talk about last time? Fresnel reflection Snell's Law Microgeometry effects Implementing BRDFs Image based rendering. Questions?. Project 3. Area Lighting. Area lighting.
E N D
Week 9 - Wednesday CS361
Last time • What did we talk about last time? • Fresnel reflection • Snell's Law • Microgeometry effects • Implementing BRDFs • Image based rendering
Area lighting • So far, we have only been talking about lighting as coming from a particular source • Lighting like that happens mostly in space • On earth, area lighting has a huge impact • Sky light from the sun's light scattering through the atmosphere • Indoor lighting is usually indirect (because a bare bulb hurts the eyes)
Area light sources • Area lights are complex • The book describes the 3D integration over a hemisphere of angles needed to properly quantify radiance • No lights in reality are point lights • All lights have an area that has some effect
Ambient light • The simplest model of indirect light is ambient light • This is light that has a constant value • It doesn't change with direction • It doesn't change with distance • Without modeling occlusion (which usually ends up looking like shadows) ambient lighting can look very bad • We can add ambient lighting to our existing BRDF formulation with a constant term:
Environment mapping • A more complicated tool for area lighting is environment mapping (EM) • The key assumption of EM is that only direction matters • Light sources must be far away • The object does not reflect itself • In EM, we make a 2D table of the incoming radiance based on direction • Because the table is 2D, we can store it in an image
Mirror reflection • The radiance reflected by a mirror is based on the reflected view vector r = 2(n•v)n – v • The reflectance equation is: where RF is the Fresnel reflectance and Li is the incoming radiance from vector r
EM algorithm • Steps: • Generate or load a 2D image representing the environment • For each pixel that contains a reflective object, compute the normal at the corresponding location on the surface • Compute the reflected view vector from the view vector and the normal • Use the reflected view vector to compute an index into the environment map • Use the texel for incoming radiance
Problems with EM • It doesn't work well with flat surfaces • The direction doesn't vary much, mapping a lot of the surface to a narrow part of the environment map • Normal mapping combined with EM helps a lot • The range of values in an environment map may be large (to cover many light intensities) • As a consequence, the space requirements may be higher than normal textures
Blinn and Newell's method • Blinn and Newell used a longitude/latitude system with a projection like Mercator • is longitude and goes from 0 to 2π • is latitude and goes from 0 to π • We can compute these from the normalized reflected view vector: • = arccos(-rz) • = atan2(ry, rx) • Problems • There are too many texels near the poles • The seam of the left and the right halves cannot easily be interpolated across
Sphere mapping • Imagine the environment is viewed through a perfectly reflective sphere • The resulting sphere map (also called a light probe) is what you'd see if you photographed such a sphere (like a Christmas ornament) • The sphere map has a basis giving its own coordinate system (h,u,f) • The image was generated by looking along the f axis, with h to the right and u up (all normalized)
Sphere mapping continued • To use the sphere map, convert the surface normal n and the view vector v to the sphere space by multiplying by the following matrix: • Sphere mapping only shows the environment on the front of the sphere • It is view dependent
Cubic environmental mapping • Cubic environmental mapping is the most popular current method • Fast • Flexible • Take a camera, render a scene facing in all six directions • Generate six textures • For each point on the surface of the object you're rendering, map to the appropriate texel in the cube
Pros and cons of cubic mapping • Pros • Fast, supported by hardware • View independent • Shader Model 4.0 can generate a cube map in a single pass with the geometry shader • Cons • It has better sampling uniformity than sphere maps, but not perfect (isocubes improve this) • Still requires high dynamic range textures (lots of memory) • Still only works for distant objects
Glossy reflections • We have talked about using environment mapping for mirror-like surfaces • The same idea can be applied to glossy (but not perfect) reflections • By blurring the environment map texture, the surface will appear rougher • For surfaces with varying roughness, we can simply access different mipmap levels on the cube map texture
Irradiance environment mapping • Environment mapping can be used for diffuse colors as well • Such maps are called irradiance environment maps • Because the viewing angle is not important for diffuse colors, only the surface normal is used to decide what part of the irradiance map is used
Next time… • Global illumination basics
Reminders • Keep reading Chapter 8 • Start reading Chapter 9