Public Group

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

## Recommended Posts

Hi,

(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:

[attachment=6533:hexagon.jpg]

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

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

##### 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 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)

//EDIT
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

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633694
• Total Posts
3013381
×