PDA

View Full Version : [OpenGL] Bump-mapping - can someone explain?



Brainer
04-07-2008, 05:19 AM
Hello. :)

Well, I've been reading up a bit on it, yet I still don't understand it. As you can read on Wikipedia, bump mapping is:


a computer graphics technique where at each pixel, a perturbation to the surface normal of the object being rendered is looked up in a heightmap and applied before the illumination calculation is done (see, for instance, Phong shading). The result is a richer, more detailed surface representation that more closely resembles the details inherent in the natural world. Normal mapping is the most commonly used bump mapping technique, but there are other alternatives, such as parallax mapping.

Okay, then what do I need for a SIMPLE bump mapping effect? I already have my texture and a normal map. How do I apply bump mapping? Simply by putting these two textures on an object? Or do I have to do some extra calculations, like mentioned in the quotation?

Please explain it to me.

Thank you in advance.

waran
04-07-2008, 05:31 AM
Simple bumpmapping using a normalmap works by manipulating the lighting
done in your fragment- or vertexshader. Usually you use the normal coming
with your vertex (pointing straight upwards) to determine the angle from
where the light falls on your face.

Using bumpmapping you read this normal from a texture (your normalmap)
instead. The 3 coordinates of the normal vector are stored each pixel in RGB.

There's another method to use normalmaps which doesn't require shaders.
It uses nVidias register combiner... just google for it. I have no clue how it
works :)

Mirage
04-07-2008, 06:04 AM
You can't simply apply normal map because each normal on that texture should be transformed into so called tangent space and only after that applied to object's normal. Tangent space is a 3D basis built for each object triangle on three vectors - normal, tangent and binormal. So you need to calculate these vectors and send them to videocard with other model data.
When in fragment shader you pick normals from normal map, transform them into tangent space and combine to triangle's normal. After that you can use the resulting normal for lighting calculations.