# object space normal map

can anyone help me with getting my bump map into an object space normal map??

Does this help? http://www.geocrawler.com/archives/3/4856/2002/3/0/8218231/

-SirKnight

thanks,

I read it but it doesn’t seem to describe how I create my object space normal map…

anyone actually implemented object space bump mapping???

Ah yes you’re right, I didn’t read the whole thing. I think I remember some discussion about this on this board before. Try searching the board and see if there is something there.

-SirKnight

It kind of depends on what your looking for. A common reason you might use this is if your bumpmaps are already in object space because they came from some kind of bumpmaker like polybump or ati’s rendition. The other reason is that you dont need the extra matrix transform thus saving the calculation time. For a regular bumpmap (must be nonrepeating, nonmirrored) you can just multiply by the inverse of your tangent matrix taking it from tangent space to object space. To do this on a per texel basis I would do a slerp of the quaternions representing the tangent matrices of the vertices of each triangle. Then you can use this tangent transform instead of the matrix of the triangle for instance. I’m not doing object space myself, at least not yet, so this is untested but it should be in line with the theory. Even if you want a repeated bumpmap you can always create the final nonrepeated map from a repeating one. You might need different uv’s though depending on the repeating.

Also on a side note to use both and add these 2 bumpmaps together.
pseudo code:
vector n1,n2,final;
n1=n1/n1.z;
n2=n2/n2.z;
final=vector(n1.x+n2.x,n1.y+n2.y,1);
final.normalize();

This will give you in my opinion a better resualt then just (n1+n2).normalize()

[This message has been edited by zeroprey (edited 10-25-2002).]

Sorry, I have no code to share.

The general algorithm is:

For each model triangle
Find the vertex normals n1, n2 and n3
For each texel in the output normal map mapped to that triangle
Find the barycentric u, v (NOT the same as texture coordinates s, t for the texel)
output_texel = normalize( un2 + vn3 + (1-u-v)*n1 );

The barycentric weights u, v are such that they’re 0, 0 at the vertex generating n1, 1,0 at the vertex generating n2 and 0,1 at the vertex generating n3; it is always true for a triangle that 0 <= (1-u-v) <= 1.

EDIT: Then, of course, you have to add the actual bump map distortion from the height map. Else it wouldn’t be a very useful model space bump map, now, would it? Rotate the input grayscale height map into the model space so that “up” is the direction of the normal (you might want to do this per pixel) and so that the s,t of the bump map point in the direction of s,t in the output normal map (which is NOT the same as the barycentric u,v). Then use your favourite heightmap slope function to find a deviation for the interpolated normal as above. You want to do this per texel in the output normal map.

[This message has been edited by jwatte (edited 10-25-2002).]

thanks for the help