Environment Mapping Examples Fall 2013 2 Motivation Silver

  • Slides: 28
Download presentation
Environment Mapping

Environment Mapping

Examples Fall 2013 2

Examples Fall 2013 2

Motivation Silver candlestick n n No appropriate texture for it “environment” map Simulates the

Motivation Silver candlestick n n No appropriate texture for it “environment” map Simulates the results of ray-tracing without going through expensive ray-tracing computation Fall 2013 3

Reflection Mapping (wikipedia) Standard Environment Mapping in which a single texture contains the image

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 4

What’s available in Open. GL Sphere. Map Cubemap Fall 2013 5

What’s available in Open. GL Sphere. Map Cubemap Fall 2013 5

Cube Map Encode the environment with a cube map Fall 2013 6

Cube Map Encode the environment with a cube map Fall 2013 6

Overview 1/2 The texture is a set of six 2 D images representing the

Overview 1/2 The texture is a set of six 2 D 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 7

Fall 2013 8

Fall 2013 8

Overview 2/2 The interpolated per-fragment (s, t, r) selects one cube face 2 D

Overview 2/2 The interpolated per-fragment (s, t, r) selects one cube face 2 D image based on the largest magnitude coordinate (the major axis). A new 2 D (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 2 D texture image face of the cube map. Fall 2013 9

(s, t, r) need not be normalized! Example: (s, t, r) (s, t) y

(s, t, r) need not be normalized! Example: (s, t, r) (s, t) y x z (2, 0, 1) t [1/4, 1/2] s Major sc tc ma +ry -1 0 2 Fall 2013 s = (-1/2 + 1)/2 = ¼ t = (0/2 + 1)/2 = ½ 10

Two Tex. Gen Modes REFLECTION_MAP (s, t, r): vertex’s eyespace reflection vector Fall 2013

Two Tex. Gen Modes REFLECTION_MAP (s, t, r): vertex’s eyespace reflection vector Fall 2013 NORMAL_MAP (s, t, r): vertex’s transformed eyespace normal 11

Reflection Map [Eye Space] ne r Every vertex (fragment) needs to compute the corresponding

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 12

Normal Map ne Use the normal vector (world or eye) to index into the

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 13

Cubemap Textures (ref) Debug Snow Red sky Fall 2013 14

Cubemap Textures (ref) Debug Snow Red sky Fall 2013 14

Other Applications of Cube Maps Stable specular highlights n n A better alternative over

Other Applications of Cube Maps Stable specular highlights n n A better alternative over massive over tessellation Limited to distant specular lights Fall 2013 15

Other Applications (cont) Sky illumination Dynamic cube map reflections Per-pixel shading (w/o shader) Fall

Other Applications (cont) Sky illumination Dynamic cube map reflections Per-pixel shading (w/o shader) Fall 2013 16

Debug Cubemap Settings Front face color Fall 2013 17

Debug Cubemap Settings Front face color Fall 2013 17

Other Environment Maps Sphere map (Open. GL) n n View dependent (different sphere map

Other Environment Maps Sphere map (Open. GL) n n View dependent (different sphere map required for different eye position) Authoring texture images is non-obvious (require special image warping) Fall 2013 18

Spheremap involves the use of a textured sphere infinitely far away from the object

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 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 19

Sphere Map (from Spec) Fall 2013 20

Sphere Map (from Spec) Fall 2013 20

Sphere Map Fall 2013 21

Sphere Map Fall 2013 21

Sphere Map (cont) (x, y, z): the reflection vector r (in eye coord) Fall

Sphere Map (cont) (x, y, z): the reflection vector r (in eye coord) Fall 2013 22

GLSL Implementation Fall 2013 23

GLSL Implementation Fall 2013 23

Generating Sphere Map Fisheye lens Fall 2013 24

Generating Sphere Map Fisheye lens Fall 2013 24

Fish. Eye Fisheye lens/camera PS: Filter/distort/spherize Fall 2013 Cheap fisheye 25

Fish. Eye Fisheye lens/camera PS: Filter/distort/spherize Fall 2013 Cheap fisheye 25

Add Specular with Sphere Map Fall 2013 26

Add Specular with Sphere Map Fall 2013 26

Adding Silhouettes with Sphere Map Fall 2013 27

Adding Silhouettes with Sphere Map Fall 2013 27

[bug? !] Somehow, the results from Shader. Maker is wrong!? Fall 2013 The result

[bug? !] Somehow, the results from Shader. Maker is wrong!? Fall 2013 The result from Open. GL & gls is correct 28