100 likes | 118 Views
Module 06. Advanced mapping techniques: Environment mapping. Overview. Environment mapping Sphere mapping Cube 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.
E N D
Module 06 Advanced mapping techniques: Environment mapping
Overview • Environment mapping • Sphere mapping • Cube 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.
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
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 inmotion. • Cube maps are also view independent and can be easily mapped onto any objects. • For these reasons, sphere mapping is generally not used often.
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.
Cube mapping(3) • Orientation of the cube map axes relative to each of the six faces:
Cube mapping(4) • Cubemap covering the six faces of a cube
Practice Open: Lab06 /SphereMapping / SphereMapping.sln Lab06 /CubeMapping / CubeMapping.sln