Bump mapping

Bump mapping

Post by Gernot Frisc » Mon, 30 Jun 2003 08:04:12


Can I simply load a 2nd Texture and tell OpenGL to use it for bump-mapping
heights? Or what's the easiest way to implement it?


In order to reply, revert my forename.

DiNGS Game Basic + ClipChap


Bump mapping

Post by Wolfgang Draxinge » Mon, 30 Jun 2003 22:43:54

> Hi,

> Can I simply load a 2nd Texture and tell OpenGL to use it for bump-mapping
> heights? Or what's the easiest way to implement it?

No, there is no OpenGL function for bump mapping. Actually you'll have
to do it on your own, but in the same step you'll also gain per fragment
lighting which normally has better quality then the per vertex lighting
OpenGL normally does.

What you want is DOT3 based bump mapping. Well there are a lot of
tutorials out there on this topic. I'll give you the idea behind it:

Assuming you bump map is a grayscale image of the surface displacement
you must convert this: For bump mapping the surface displacement is
irrelevant (since the actual surface isn't altered at all), but what's
needed are the local variations of the surface normal. So the first
thing is to convert you heightmap into a normal map. nVidia provides a
Photoshop plugin that does this job for you (you can write a programm
for this purpose, yourself too of course). This results in a "normal
map" where for each pixel the local normal vector is encoded into a RGB

The normal map is then used to render the illumination of the object.
For this purpose you must calculate the vector of each vertex to the
light source in _texture_ space (which is actually the most hardest step
in the whole process). The resulting vector is then encoded into a RGB
triplet as in the normal map and then used as the vertex color. The
vertex colors are interpolated and thus also the light vectors.

Then you use one of the combiner extensions to apply a DOT3 operation on
color and texture et voila you've bump mapping.

Then you only have to apply the actual texture of the object, do
specular lighting (again with DOT3 but then the light vector replaced
with the half vector between light vector and view vector)

Also a good tip is, that normally a good effect also result's when only
using the light and half-light vector to the center of the object's
bounding sphere and then just transforming theso to the texture space.
It's not 100% accurate but it saves a lot of calculations, which is
considerable, especially on older machines.

| +----------------+ WOLFGANG DRAXINGER          |
| | ,-.   DARKSTAR | lead programmer             |

| | `-' / GAMES /                                |
| +----+''''''''     http://www.darkstargames.de |


1. Bump size in Bump Mapping

I still have problem with controlling the the size
of the virtual bumps in using the Bump Mapping
algorithm.  How do we control the size of the
bump?  I am using Bump Mapping in a forward
ray tracer to obtain perturbed surface normals.
Any advice is greatly appreciated.


Min Lu

2. Lots of Crashes

3. Patch modeling & box modeling - can you mix the two?

4. Image mapping, filtering and bump mapping.

5. .bgi not supported?

6. Layering bump maps with mat maps...


8. Earth bump map/image map

9. Bump maps, UVW map, Unwrap Questions

10. Bugs: When Using Bump maps with Bones/Weight Maps

11. Image map + bump map weird problem.

12. Bump Mapping/Texture Mapping