Environment Mapping
Examples Fall 20132
Motivation Silver candlestick No appropriate texture for it “ environment ” map Simulates the results of ray-tracing without going through expensive ray-tracing computation Fall 20133
Reflection Mapping (wikipedia) Standard Environment Mapping in which a single texture contains the image of the surrounding as reflected on a mirror ball Cubic Environment Mapping in which the environment is unfolded onto the six faces of a cube and stored therefore as six square textures. A typical drawback of these techniques is the absence of self reflections: you cannot see any part of the reflected object inside the reflection itself. Fall 20134
What’s available in OpenGL SphereMapCubemap Fall 20135
Cube Map Encode the environment with a cube map Fall 20136
Overview 1/2 The texture is a set of six 2D images representing the faces of a cube. These targets must be consistent, complete, and have equal width and height. The texture coordinate (s,t,r) can be generated with (1) reflection map, or (2) normal map The (s,t,r) texture coordinates are treated as a direction vector emanating from the center of a cube. Fall 20137
8
Overview 2/2 The interpolated per-fragment (s,t,r) selects one cube face 2D image based on the largest magnitude coordinate (the major axis). A new 2D (s,t) is calculated by dividing the two other coordinates (the minor axes values) by the major axis value. Then the new (s,t) is used to lookup into the selected 2D texture image face of the cube map. Fall 20139
Example: (s,t,r) (s,t) (2,0,1) Majorsctcma +ry02 s = (-1/2 + 1)/2 = ¼ t = (0/2 + 1)/2 = ½ s t x y z [1/4,1/2] (s,t,r) need not be normalized! Fall
Two TexGen Modes REFLECTION_MAP (s,t,r): vertex ’ s eye- space reflection vector NORMAL_MAP (s,t,r): vertex ’ s transformed eye- space normal Fall
Reflection Map [Eye Space] nene r Every vertex (fragment) needs to compute the corresponding reflection vector as tex coord. (more accurate but time consuming) Fall
Normal Map nene Use the normal vector (world or eye) to index into the cube map. Quickly get an environment map feel, but not a real reflection. Fall
Cubemap Textures (ref)ref Debug Snow Red sky Fall
Other Applications of Cube Maps Stable specular highlights A better alternative over massive over tessellation Limited to distant specular lights Fall
Other Applications (cont) Sky illumination Dynamic cube map reflections Per-pixel shading (w/o shader) Fall
Front face color Debug Cubemap Settings Fall
Other Environment Maps Sphere map (OpenGL) View dependent (different sphere map required for different eye position) Authoring texture images is non-obvious (require special image warping) Fall
Spheremap involves the use of a textured sphere infinitely far away from the object that reflects it. By creating a spherical texture using a fisheye lens or via prerendering or with a light probe, this texture is mapped to a hollow sphere, and the texel colors are determined by calculating the light vectors from the points on the object to the texels in the environment map. This technique may produce results which are superficially similar to those produced by raytracing, but incurs less of a performance hit because all of the colors of the points to be referenced are known beforehand, so all it has to do is to calculate the angles of incidence and reflection. There are a few glaring limitations to spherical mapping. For one thing, due to the nature of the texture used for the map, there is an abrupt point of singularity on the backside of objects using spherical mapping. Fall
Sphere Map (from Spec) Fall
Sphere Map Fall
Sphere Map (cont) (x,y,z): the reflection vector r (in eye coord) Fall
GLSL Implementation Fall
Generating Sphere Map Fisheye lens Fall
FishEye PS: Filter/distort/spherize Fisheye lens/camera Cheap fisheye Fall
Add Specular with Sphere Map Fall
Adding Silhouettes with Sphere Map Fall
[bug?!] Somehow, the results from ShaderMaker is wrong!? The result from OpenGL & glsl is correct Fall