09/11/03cs679 - fall 2003 - copyright univ. of wisconsin last time graphics pipeline texturing...
Post on 31-Dec-2015
215 Views
Preview:
TRANSCRIPT
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Last Time
• Graphics Pipeline
• Texturing Overview
• Cubic Environment Mapping
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Today
• More environment mapping
• Light Maps
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Environment Mapping
• Environment mapping produces reflections on shiny objects
• Texture is transferred in the direction of the reflected ray from the environment map onto the object– Uses ray with same direction but
starting at the object center
• Map contains a view of the world as seen from the center of the object
Object
Viewer
Reflected ray
EnvironmentMap
Lookup ray
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Lat/Long Mapping
• The original algorithm (1976) placed the map on a sphere centered on the object
• Mapping functions assume that s,t texture coordinates equate to latitude and longitude on the sphere:
• What is bad about this method?– Sampling
– Map generation
– Complex texture coordinate computations
2
1 ,tan
11
2
1 1
z
x
y tsR
R
R
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Sphere Mapping
• Again the map lives on a sphere, but now the coordinate mapping is simplified
• To generate the map:– Take a map point (s,t), cast a ray onto a sphere in the -Z direction,
and record what is reflected
– Equivalent to photographing a reflective sphere with an orthographic camera (long lens, big distance)
• Again, makes the method suitable for film special effects
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Indexing Sphere Maps
• Given the reflection vector:
• Implemented in hardware
• Problems:– Highly non-uniform sampling
– Highly non-linear mapping
21
222 12
2
1 ,
2
1
zyx
yx
RRRm
m
Rt
m
Rs
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Non-linear Mapping
• Linear interpolation of per-vertex texture coordinates picks up the wrong texture pixels– Use small polygons!
Correct Linear
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Parabolic Mapping
• Assume the map resides on a parabolic surface– Two surfaces, facing each other
• Improves on sphere maps:– Texture coordinate generation is a near linear process
– Sampling is more uniform
– Result is more view-independent
• However, requires multi-passes to implement, so not generally used
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Other Env. Map Tricks
• Partially reflective objects– First stage applied color texture
– Second stage does environment mapping using alpha blend with existing color
• Just put the lights in the environment map– What does this simulate?
• Recursive reflections
• Bad cases for environment maps?
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Light Maps
• Speed up lighting calculations by pre-computing lighting and storing it in maps– Allows complex illumination models to be used in generating the
map (eg shadows, radiosity)– Used in complex rendering algorithms (Radiance), not just games
• Issues:– How is the mapping determined?– How are the maps generated?– How are they applied at run-time?
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Choosing a Mapping
• Problem: In a preprocessing phase, points on polygons must be associated with points in maps
• One solution:– Find groups of polygons that are “near” co-planar and do not
overlap when projected onto a plane• Result is a mapping from polygons to planes
– Combine sections of the chosen planes into larger maps– Store texture coordinates at polygon vertices
• Lighting tends to change quite slowly (except when?), so the map resolution can be poor
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Generating the Map
• Problem: What value should go in each pixel of the light map?
• Solution:– Map texture pixels back into world space (using the inverse of the
texture mapping)
– Take the illumination of the polygon and put it in the pixel
• Advantages of this approach:– Choosing “good” planes means that texture pixels map to roughly
square pieces of polygon - good sampling
– Not too many maps are required, and not much memory is wasted
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Example
Nearest interpolation Linear interpolation
What type of lighting (diffuse, specular, reflections) can the map store?
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Applying Light Maps
• Use multi-texturing hardware– First stage: Apply color texture map
– Second stage: Modulate with light map• Actually, make points darker with light map
• DirectX allows you to make points brighter with texture
• Pre-lighting textures:– Apply the light map to the texture maps as a pre-process
– Why is this less appealing?
• Multi-stage rendering:– Same effect as multi-texturing, but modulating in the frame buffer
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Dynamic Light Maps
• Light maps are a preprocessing step, so they can only capture static lighting
• Texture transformations allow some effects
• What is required to recompute a light map at run-time?
• How might we make this tractable?– Spatial subdivision algorithms allow us to identify nearby objects,
which helps with this process
• Compute a separate, dynamic light map at runtime using same mapping as static light map
• Add additional texture pass to apply the dynamic map
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fog Maps
• Dynamic modification of light-maps
• Put fog objects into the scene
• Compute where they intersect with geometry and paint the fog density into a dynamic light map– Use same mapping as static light map uses
• Apply the fog map as with a light map– Extra texture stage
top related