Module 05 Bump mapping Module 05 Advanced mapping

  • Slides: 11
Download presentation
Module 05 – Bump mapping Module 05 Advanced mapping techniques: Bump mapping

Module 05 – Bump mapping Module 05 Advanced mapping techniques: Bump mapping

Module 05 – Bump mapping Overview § Multitexturing § Texture units § Bump mapping

Module 05 – Bump mapping Overview § Multitexturing § Texture units § Bump mapping

Module 05 – Bump mapping Multitexturing § When you map a texture to polygon,

Module 05 – Bump mapping Multitexturing § When you map a texture to polygon, you apply one texture to it. § It's actually possible to apply several textures to the same polygon through a series of texture operations. This is called multitexturing. § § Multiple textured objects rendered in a single pass: § Lightmaps § Fog § Bump mapping Multitexturing makes use of a series of texture units. Each texture unit represents a single texture application, and when you perform multitexturing, each texture unit passes its results to the next texture unit.

Module 05 – Bump mapping Texture units (1) § Each texture unit has a

Module 05 – Bump mapping Texture units (1) § Each texture unit has a set of states associated with it that allows it to keep settings separate from the other texture units. Each texture unit has its own texture environment, texture matrix stack, texture coordinate generation states, and texture image and filtering parameters. § The latter texture units are usually derived from the texture object that is bound to the texture unit § In addition, each of the texture targets (GL_TEXTURE_1 D, GL_TEXTURE_2 D, GL_TEXTURE_3 D and GL_TEXTURE_CUBE_MAP) are enabled or disabled on a per-texture-unit basis.

Module 05 – Bump mapping Texture units (2) § Default texture unit is texture

Module 05 – Bump mapping Texture units (2) § Default texture unit is texture unit 0. § Texture unit pipeline:

Module 05 – Bump mapping Texture units (4) Code Example: Texture 1 and texture

Module 05 – Bump mapping Texture units (4) Code Example: Texture 1 and texture 2 are handles to valid texture objects for 2 D textures. The following code binds them to texture unit 0 and texture unit 1: gl. Active. Texture(GL_TEXTURE 0); gl. Enable(GL_TEXTURE_2 D): gl. Bind. Texture(GL_TEXTURE_2 D, texture 1); gl. Active. Texture(GL_TEXTURE 1); gl. Enable(GL_TEXTURE_2 D); gl. Bind. Texture(GL_TEXTURE_2 D, texture 2);

Module 05 – Bump mapping (1) § Bump mapping is a technique that presents

Module 05 – Bump mapping (1) § Bump mapping is a technique that presents the illusion of greater detail to the viewer by using a texture map to perturb the normal vector at each pixel. § High-resolution information about how the normal vector is perturbed is stored in a two-dimensional array of three-dimensional vectors called a bump map or normal map. § Each vector in the bump map represents the direction in which the normal vector should point relative to the interpolated normal vector at a point inside the face of a triangle. § A bump map is typically constructed by extracting normal vectors from a height map whose contents represent the height of a flat surface at each pixel.

Module 05 – Bump mapping (2) § To derive the normal vector corresponding to

Module 05 – Bump mapping (2) § To derive the normal vector corresponding to a particular pixel in the height map, we first calculate tangents in the s and t directions, which are based on the difference in height between adjacent pixels. § Corresponding normal vector N(i, j) is: § This process is computationally very expensive in real time

Module 05 – Bump mapping (3) § To achieve quite the same result as

Module 05 – Bump mapping (3) § To achieve quite the same result as lighting calculation at each pixel based on perturbed normal vectors, we can use Open. GL multitexturing, diffuse lighting and picture emboss effect, provided by image editor like Adobe Photoshop. § Example: + Default texture = Embossed texture Bump-mapped texture

Module 05 – Bump mapping Final result

Module 05 – Bump mapping Final result

Module 05 – Bump mapping Practice Open: Lab 05 / Bump. Mapping. sln

Module 05 – Bump mapping Practice Open: Lab 05 / Bump. Mapping. sln