Download presentation
Presentation is loading. Please wait.
1
Environment Mapping
2
Examples Fall 2013
3
Motivation Silver candlestick
No appropriate texture for it “environment” map Simulates the results of ray-tracing without going through expensive ray-tracing computation Fall 2013
4
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 2013
5
What’s available in OpenGL
SphereMap Cubemap Fall 2013
6
Cube Map Encode the environment with a cube map Fall 2013
7
Overview1/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 2013
8
Fall 2013
9
Overview2/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 2013
10
Example: (s,t,r)(s,t) (s,t,r) need not be normalized! y x z (2,0,1) t
[1/4,1/2] z t s Major sc tc ma +ry -1 2 s = (-1/2 + 1)/2 = ¼ t = (0/2 + 1)/2 = ½ Fall 2013
11
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 2013
12
Reflection Map [Eye Space]
ne r Every vertex (fragment) needs to compute the corresponding reflection vector as tex coord. (more accurate but time consuming) Fall 2013
13
Normal Map ne 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 2013
14
Cubemap Textures (ref)
Debug Snow Red sky Fall 2013
15
Other Applications of Cube Maps
Stable specular highlights A better alternative over massive over tessellation Limited to distant specular lights Fall 2013
16
Other Applications (cont)
Sky illumination Dynamic cube map reflections Per-pixel shading (w/o shader) Fall 2013
17
Debug Cubemap Settings
Front face color Fall 2013
18
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 2013
19
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 2013
20
Sphere Map (from Spec) Fall 2013
21
Sphere Map Fall 2013
22
Sphere Map (cont) (x,y,z): the reflection vector r (in eye coord)
Fall 2013
23
GLSL Implementation Fall 2013
24
Generating Sphere Map Fisheye lens Fall 2013
25
FishEye Fisheye lens/camera Cheap fisheye PS: Filter/distort/spherize
Fall 2013 Cheap fisheye PS: Filter/distort/spherize
26
Add Specular with Sphere Map
Fall 2013
27
Adding Silhouettes with Sphere Map
Fall 2013
28
[bug?!] Somehow, the results from ShaderMaker is wrong!?
The result from OpenGL & glsl is correct Fall 2013
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.