Module 06 environment mapping Module 06 Advanced mapping

  • Slides: 10
Download presentation
Module 06 – environment mapping Module 06 Advanced mapping techniques: Environment mapping

Module 06 – environment mapping Module 06 Advanced mapping techniques: Environment mapping

Module 06 – environment mapping Overview § Environment mapping § Sphere mapping § Cube

Module 06 – environment mapping Overview § Environment mapping § Sphere mapping § Cube mapping

Module 06 – environment mapping Environment mapping § Environment mapping technique is used to

Module 06 – environment mapping Environment mapping § Environment mapping technique is used to model unique type of objects (like chrome, polished metal, glass) which reflect the environment they are in. § In practice, environment mapping applies a special texture map that contains an image of the scene surrounding an object to the object itself. § The result approximates the appearance of a reflective surface, close enough to fool the eye, without incurring any of the expensive computations involved in ray-tracing. § The GL_SPHERE_MAP and GL_REFLECTION_MAP texture generation modes can be used in conjunction with an appropriate texture map to create realistic reflections.

Module 06 – environment mapping Sphere mapping § For the GL_SPHERE_MAP mode, or sphere

Module 06 – environment mapping Sphere mapping § For the GL_SPHERE_MAP mode, or sphere mapping the texture coordinates are generated using a vector from the eye to the point on the surface and the surface normal to create a reflection vector. The reflection vector is used to calculate the texture coordinates. § Drawbacks: - sphere mapping is view dependent, so viewing a reflective object from -- anywhere other than the center of projection can produce incorrect results - the reflection won't pick up any objects moving in the world § Advantage: - faster than cube mapping in static environments

Module 06 – environment mapping Cube mapping (1) § In the GL_REFLECTION_MAP mode, or

Module 06 – environment mapping Cube mapping (1) § In the GL_REFLECTION_MAP mode, or cube mapping the world is rendered six times (once for each direction) from the reflective object's perspective. § The results are then stored in the six faces of a cube map, which is then applied to the object. § This approach is much better than sphere mapping, since a reflection image can be generated anywhere in the world, and it can be updated dynamically to reflect objects in motion. § Cube maps are also view independent and can be easily mapped onto any objects. § For these reasons, sphere mapping is generally not used often.

Module 06 – environment mapping Cube mapping (2) § Texture coordinates used in conjunction

Module 06 – environment mapping Cube mapping (2) § Texture coordinates used in conjunction with cube texture maps are typically generated at runtime. For instance, environment mapping can be performed by calculating the reflection of the direction to the camera and storing it in the {s, t, r) coordinates at each vertex of a triangle mesh. The reflection direction calculation is normally implemented in hardware, so this can be done very efficiently. § The s-, t-, and r-coordinates represent a direction vector emanating from the center of the cube that points toward the texel to be sampled.

Module 06 – environment mapping Cube mapping (3) § Orientation of the cube map

Module 06 – environment mapping Cube mapping (3) § Orientation of the cube map axes relative to each of the six faces:

Module 06 – environment mapping Cube mapping (4) § Cubemap covering the six faces

Module 06 – environment mapping Cube mapping (4) § Cubemap covering the six faces of a cube

Module 06 – environment mapping Final result

Module 06 – environment mapping Final result

Module 06 – environment mapping Practice Open: Lab 06 /Sphere. Mapping / Sphere. Mapping.

Module 06 – environment mapping Practice Open: Lab 06 /Sphere. Mapping / Sphere. Mapping. sln Lab 06 /Cube. Mapping / Cube. Mapping. sln