# Can't understand Bump mapping

This topic is 4028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am trying out some bump mapping and have went through some onlines tutorials and articles like Peter Germishuys tutorial. However I don't understand why are the normals from the normal map unpack using this formula? float3 Normal = 2.0f * tex2D(texSampler1, IN.tex1).rgb - 1.0f; And how do i get the Tangent, binormal, and normal to form the TBN matrix. Does it mean that each pixel will have its own TBN matrix since they will have different tangent, binormal and normal?

##### Share on other sites
well this formula
float3 Normal = 2.0f * tex2D(texSampler1, IN.tex1).rgb - 1.0f;
because colors ranges in 0..1 but you need a normal vector who range in -1..1 think of the range of the normal vector as a sphere ,if the range is 0..1 you will only use half of the sphere so the normal vector will never be negative (pointing backward ) , and for the second thing you can get the TBN matrix like this

float3x3 TBN
TBN[0]= mul(tangent,world);
TBN[1]=mul(binormal,world);//if you don't have binormal use cross(tangent,normal)
TBN[2]=mul(normal,world);
create the matrix in the vertex shader those normals tangents and binormal belongs to vertices not pixels , all you need from the pixel is the normal from the normal map , and the color from the color map , and maybe gloss from gloss map(for specular)

##### Share on other sites
Ahh I understand now, thanks.

But I still have some queries about the TBN matrix. A triangle has 3 vertex, thus when a pixel in the triangle goes through the pixel shader, which TBN matrix will it take from the 3 vertices?

##### Share on other sites
Quote:
 Original post by littlekidAhh I understand now, thanks.But I still have some queries about the TBN matrix. A triangle has 3 vertex, thus when a pixel in the triangle goes through the pixel shader, which TBN matrix will it take from the 3 vertices?

The same thing happens as with any vertex attribute. For example If each vertex was set to a different color, each pixel would be a color computed by interpolating the color at each vertex.

Similarly in the case of bump mapping, you supply a TBN Matrix at each vertex in the triangle as vertex attributes. Then for every pixel a specific TBN matrix is calculated by interpolating the TBN matrix at each vertex.

1. 1
2. 2
3. 3
4. 4
frob
20
5. 5
JoeJ
20

• 11
• 11
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632214
• Total Posts
3004853

×