PDA

View Full Version : NVidia Bump Mapping



GW
08-22-2001, 10:22 AM
I'm trying to follow the bump mapping from the NVidia SDK, and have yet to get it working in a demo I'm doing. Basically I took one texture and used Photoshop to create a grayscale alpha channel version of the original texture adding some height to the texture to give it the "bump" effect. Now as I understand it the textures have to be combined using multitexturing and blending, so I'm trying to do the following:

glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ONE);

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textures[1]);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textures[3]);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);

And then I use:

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,...)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,...)

What am I doing wrong?

Korval
08-22-2001, 06:39 PM
"What am I doing wrong?"

Well, where should I start?

First, let's separate the notions of blending (that is, blending as in glEnable(GL_BLEND)) and multitexture per-fragment operations (those activated with glTexEnv* and it's kin). What you need are multitextured per-fragment operations.

Secondly, you should understand that bump mapping isn't like turning on a switch (it should be, but it isn't). If you're talking about tangent-space bump mapping (sometimes referred to as DotProduct3 bump mapping), which is what most nVidia code uses, you have to do a lot of work:

1: convert your height map (the alpha map you generated in Photoshop) into a normal offset map.
2: Per vertex, you must compute and transform the light-space normals into tangent space via a transformation matrix.
3: You must pass this tangent-space light normal through your vertex processing as a color (so you have to disable lighting).
4: Per-pixel, you must set your multitexturing per-fragment operation to perform a dot product combination between the normal offset map and the interpolated tangent-space light normal.
5: Lastly, you must modulate the result of the last stage with your regular texture color.

If you don't understand these steps, feel free to look at nVidia's website. There are numerous demos, and some of them have pretty good documentation. Also, try downloading the nVidia OpenGL SDK; it's pretty helpful for learning about Tangent-Space bump mapping.

In short, bump mapping isn't simple. It is a complex exercise that requires significant time to get working right.

GW
08-23-2001, 09:43 AM
Thanks a bunch. I was mistaken in that I thought bump mapping was simply multitexturing with the texture map and height map. Now I realize why all the NVidia demos I've seen were much more complicated. I really appreciate the help and will download some more of the NVidia demos.

MButchers
08-24-2001, 12:13 AM
hi there,

just before i start down the bump mapping route is
it possible to do it with multiple light
sources?

mark.