1 / 14

Bump Mapping

Bump Mapping. Topics in Computer Graphics Spring 2010. Application. Shading. Maps. Height map (Grey scale). Base texture (RGB). Normal map (normal encoded RGB). Normal Map & Height Field. Normal Map. Normal vector encoded as rgb [-1,1] 3 [0,1] 3 : rgb = n*0.5 + 0.5

waneta
Download Presentation

Bump Mapping

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. Bump Mapping Topics in Computer Graphics Spring 2010

  2. Application

  3. Shading

  4. Maps Height map (Grey scale) Base texture (RGB) Normal map (normal encoded RGB)

  5. Normal Map & Height Field

  6. Normal Map • Normal vector encoded as rgb • [-1,1]3[0,1]3: rgb = n*0.5 + 0.5 • RGB decoding in fragment shaders • vec3 n = texture2D(NormalMap, texcoord.st).xyz * 2.0 – 1.0 • In tangent space, the default (unit) normal points in the +z direction. • Hence the RGB color for the straight up normal is (0.5, 0.5, 1.0). This is why normal maps are a blueish color • Normals are then used for shading computation • Diffuse: n•l • Specular: (n•h)shininess • Computations done in tangent space

  7. Tangent Space • In order to build this Tangent Space, we need to define an orthonormal (per vertex) basis, which will define our tangent space. • Tangent space is composed of 3 orthogonal vectors (T, B, N) • Tangent (S Tangent) • Bitangent (T Tangent) • Normal • One has to calculate a tangent space matrix for every single vertex

  8. Tangent Space • Suppose a point pi in world coordinate system for whose texture coordinates are (ui, vi) • Writing this equation for the points p1, p2 and p3, defining the triangle : p1 = u1.T + v1.B p2 = u2.T + v2.Bp3 = u3.T + v3.B

  9. Tangent Space 6 eqns, 6 unknowns • p2 - p1 = (u2 - u1).T + (v2 - v1).Bp3 - p1 = (u3 - u1).T + (v3 - v1).B • (v3 - v1).(p2 - p1)  =   (v3 - v1).(u2 - u1).T + (v3 - v1).(v2 - v1).B- (v2 - v1).(p3 - p1)    - (v2 - v1).(u3 - u1).T - (v2 - v1).(v3 - v1).B • (u3 - u1).(p2 - p1)  =  (u3 - u1).(u2 - u1).T + (u3 - u1).(v2 - v1).B- (u2 - u1).(p3 - p1)    - (u2 - u1).(u3 - u1).T - (u2 - u1).(v3 - v1).B • (v3 - v1).(p2 - p1) - (v2 - v1).(p3 - p1)T = --------------------------------------- (u2 - u1).(v3 - v1) - (v2 - v1).(u3 - u1) • (u3 - u1).(p2 - p1) - (u2 - u1).(p3 - p1)B = ---------------------------------------(v2 - v1).(u3 - u1) - (u2 - u1).(v3 - v1) T,B: (unit) vectors in object space

  10. TBN Matrix Per Vertex • Use the averaged face normal as the vertex normal • Do the same for tangent and bitangent vectors • Note that the T, B vectors might not be orthogonal to the normal vector • Use Gram-Schmidt to make sure they are orthonormal

  11. Coordinate Transformation Tangent space to object space Object space to tangent space This reference (http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson8.php) is correct TyphoonLabs is not right.

  12. What is mat3 (v1,v2,v3)?! It turns out to be “blue” This is the matrix that converts object space to tangent space

  13. Reference • http://www.opengl.org/sdk/docs/tutorials/TyphoonLabs/Chapter_4.pdf • http://www.ozone3d.net/tutorials/bump_mapping.php • http://www.paulsprojects.net/tutorials/simplebump/simplebump.html • http://www.terathon.com/code/tangent.html • http://www.blacksmith-studios.dk/projects/downloads/tangent_matrix_derivation.php • http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson8.php

More Related