1 / 11

Module 05

Module 05. Advanced mapping techniques: Bump mapping. Overview. Multitexturing Texture units Bump mapping. Multitexturing. When you map a texture to polygon, you apply only one texture to it.

cnutter
Télécharger la présentation

Module 05

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module 05 Advanced mapping techniques: Bump mapping

  2. Overview • Multitexturing • Texture units • Bump mapping

  3. Multitexturing • When you map a texture to polygon, you apply only 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.

  4. 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_1D, GL_TEXTURE_2D, GL_TEXTURE_3D and GL_TEXTURE_CUBE_MAP) are enabled or disabled on a per-texture-unit basis.

  5. Texture units (2) • Default texture unit is texture unit 0. • Texture unit pipeline:

  6. Texture units (4) Code Example: Texture1 and texture2 are handles to valid texture objects for 2D textures. The following code binds them to texture unit 0 and texture unit 1: glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D): glBindTexture(GL_TEXTURE_2D, texture1); glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture2);

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

  8. 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

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

  10. Final result

  11. Practice Open: Lab05 / BumpMapping / BumpMapping.sln

More Related