# Single-Pass DOT3 Bump Mapping Tutorial

## Recommended Posts

Hey everyone, after spending over a week busting my head trying to get DOT3 Bump Mapping to work, I ended up with a success, and a tutorial to help those of you who are trying to figure this out as well. By no means is it an "uber" or "professional" tutorial, but I hope it helps. http://www.unraveledmind.com/bumpmap.html I use this technique in a 3D engine I'm playing around with that I started writing less than two weeks ago. The Engine's source is also included. :) From 3DS file loading to easy stuff such as frustum culling, it covers quite a few things. Hopefully some of you will find this helpful in your own projects. Share the lewt, so to speak. :)

##### Share on other sites
nice one (esp with the recent spate of bumpmapping posts here)
though do u really need to mipmap the cubemap

##### Share on other sites

One problem I noticed is that your texture is mirrored which causes your bumps to be 'outies' on the right half of the model, and 'innies' on the other.

You can fix this either by not mirroring textures, or by using a more robust method of generating tangent space. One method is the NVMeshMender class on the nvidia dev webiste, although that's overkill for the purposes of your tutorial.

##### Share on other sites
zedzeek: Mipmapping turned on makes the framerate higher actually, surprising as it is. Try it without, see what happens. ;)

SimmerD: I never actually noticed that until you mentioned it. Interesting side-effect, I suppose. I can see why it's happening though. I created half of the model using 3D Studio Max and simply mirrored the other half, didn't really consider the fact that it would make the bump map inverted, I suppose.

##### Share on other sites
It's not very surprising that mipmapping raises your framerate as this will make more texture accesses hit the caches on the graphics card, because accesses to a lower mip will be more "together" than accesses to a minified bigger mip.

##### Share on other sites
Just a quick update. I fixed the flipped bumpmap problem by adding this code right after it normalizes the tangents:

// Check to make sure the texture isn't mirrored from right to left, and flip the S Tangent if it isif(Dot(Cross(vSTangent[iV], vTTangent[iV]), vNormal[iV]) < 0.0f) vSTangent[iV] = -vSTangent[iV];

##### Share on other sites
Awesome tutorial! Glad that you shared your knowledge regarding this topic as few people do.

##### Share on other sites
i was sorta thinking of building the mipmaps not giving the correct result (ie a normalized vector) but on further thought its gonna be very close