Jump to content
  • Advertisement
Sign in to follow this  

What am I doing wrong with these bumpmaps?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts


(Insight: I think my fault is the random choice of 'a' and 'b', but I don't know what else to use for them)

I'm creating my own raytracer (in java) and I have a little problem with getting bump mapping to work.

So here's the situation:
- I've got some triangles making up a sphere with given normals
- I've got basic texturing working ('calculate (u,v)' )

What I tried:
- Given those same u, v, I looked up the x and y gradient on the bumpmap. Those give me values in [-1, 1]. I constructed two (random) vectors that are perpendicular to the normal and to each other. I then constructed the new normal: new = n + xgradient * a + ygradient * b (where a and b are those perpendicular vectors)

The end result is this:

[attachment=6532:failed bump.JPG]

I used this bumpmap:


So once again
- Get a normal 'n'
- Calculate (random) a and b, perpendicular to n and each other
- Calculate xgradient, ygradient
- newN = n + a * xgradient + b*ygradient (and normalize it)

Once of my sources is this one: http://freespace.vir...cs/x_polybm.htm

Share this post

Link to post
Share on other sites
I don't recall there being any random process in bump mapping? A and B are in fact the tangent and bitangent vectors to your surface, which can be calculated with a few cross-products or just stored along with the normal. They must be perpendicular to each other with respect to the surface normal and be rotated properly for the pixel to be bump-mapped properly. Basically those three vectors (tangent, bitangent and normal) define a 3D "tangent" space which is used to map the bump normal to the base normal you already have.

Share this post

Link to post
Share on other sites
I throught that's what I did wrong. a, b and n are perpendicular to each other, but the rotation is random.

So how exactly should I rotate a and b?

(I'll continue searching while waiting for an answer)

I get it now, a and b have to be aligend to the bumpmap itself. Now its just a question of finding out the correct transformation. Hints are still welcome

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!