My normal maps look like hell

I want to set the last texture unit to the normal map and blend it with the result of the previous texture units, in a way such that the normal map both lightens and darkens the texture.

I am trying to do it like this, but my normal maps come out almost full black. Every vertex in the color array is set to (196,196,255), just for testing, so I know the vertex colors aren’t a problem:

					glBindTexture GL_TEXTURE_2D,bumpmap
					glTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE
					glTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_DOT3_RGB
					glTexEnvi GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_PREVIOUS
					glTexEnvi GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_TEXTURE

If you set the normal map to the last texture unit in the way you do, you are doing dot3 operation between normal map and color result from the previous texture units interpreted as vector. The resulting nonsense greyscale value is used as final color.

You need to set the normal map dot3 operation to the first unit and modulate its output with whatever the other texture units are doing.

Thank you.

I set the bumpmap up on texture unit 0, like this:
glTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE
glTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_DOT3_RGB
glTexEnvi GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_SRC_COLOR
glTexEnvi GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_TEXTURE

Like this, I can’t see the bumpmap, even when I turn off all other texture units. I had tried several other variations, keeping the normal map on texture unit 0.

You are setting incorrect value for GL_SOURCE0_RGB parameter. It should be GL_PRIMARY_COLOR or GL_PREVIOUS.

The GL_SRC_COLOR is one from possible values set to the GL_OPERAND0_RGB parameter it has no sense to set is as value to GL_SOURCE0_RGB parameter.

Well, I tried that and a lot of things, but I just get pure white.

Something’s wrong…let me look at this some more…

How your current setup for the enabled texture units looks like?

If you enable only the texture unit with the normal map and you set its texture environment mode to the GL_REPLACE, does the texture look correct?

If you disable all texture units, does the vertex color look correct?

Okay, I got it to work using this:
glTexEnvi GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_PREVIOUS
glTexEnvi GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_TEXTURE

I found that I got the most correct lighting by setting the blue value to 192 (halfway between 128 and 255) and using a mod2x blend on the next texture unit using “glTexEnvf GL_TEXTURE_ENV,GL_RGB_SCALE,2.0”. This made the normal map brighten and darken the texture.

Here’s the final result:

Another shot. :slight_smile:

That looks cool for just using texture stages.

I imagine they’re highly tesselated.

Looks like you got it, there was some dodgy advice given earlier, you need to do your DOT3 first then modulate. If you use crossbar it’s slightly less of an issue but the point is you need to get your DOT3 result THEN do something with it like modulate another texture, taking anything other than meaningful vectors into a DOT3 will produce garbage.

Knackered, I just built the wall in a way so that a couple of vertices would lie under the spotlight:

So are you using a cube-map with a “dot” on one side to do that spotlight?

Not sure what you mean. The lighting is a lightmap. The bumpmapping is done by calculating which lights affect each vertex.

Ok, I though the spotlight was dynamic - AKA like those old Ron Frazier demos. (can’t provide link as he has taken down his tutorials - was at http://www.ronfrazier.net/apparition/research/per_pixel_lighting.html and http://www.ronfrazier.net/apparition/research/advanced_per_pixel_lighting.html )

http://web.archive.org/web/20041025015343/http://www.ronfrazier.net/apparition/index.asp

Click on Research Projects on the left…

owned! :slight_smile:

It’s a shame we have to access his page like this. Sure it’s old, but still good IMHO.

It looks to me like he is just drawing on the cubemap to move lights around. This is like a dynamic lightmap, but even more limited, since it will only work on a box-shape room with the camera in the center.

His room isn’t a box.

The tutorials are still up on his website, but the old links don’t work.
http://www.ronfrazier.net/apparition/
then go to research projects