PDA

View Full Version : My normal maps look like hell



halo
08-15-2006, 02:37 PM
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

Komat
08-15-2006, 03:14 PM
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.

halo
08-15-2006, 03:24 PM
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.

Komat
08-15-2006, 03:55 PM
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.

halo
08-15-2006, 04:04 PM
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...

Komat
08-15-2006, 04:13 PM
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?

halo
08-15-2006, 05:42 PM
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:
http://www.leadwerks.com/post/bumpmapping.jpg

halo
08-16-2006, 01:25 PM
Another shot. :)

http://www.leadwerks.com/post/bumpmapping2.jpg

sqrt[-1]
08-16-2006, 08:34 PM
That looks cool for just using texture stages.

knackered
08-17-2006, 04:14 AM
I imagine they're highly tesselated.

dorbie
08-17-2006, 02:22 PM
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.

halo
08-17-2006, 02:25 PM
Knackered, I just built the wall in a way so that a couple of vertices would lie under the spotlight:
http://www.leadwerks.com/post/screenshot001.jpg

sqrt[-1]
08-17-2006, 08:40 PM
So are you using a cube-map with a "dot" on one side to do that spotlight?

halo
08-20-2006, 10:21 PM
Not sure what you mean. The lighting is a lightmap. The bumpmapping is done by calculating which lights affect each vertex.

sqrt[-1]
08-21-2006, 01:45 AM
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 )

SirKnight
08-21-2006, 01:40 PM
http://web.archive.org/web/20041025015343/http://www.ronfrazier.net/apparition/index.asp

Click on Research Projects on the left...


owned! :)

SirKnight
08-21-2006, 01:44 PM
It's a shame we have to access his page like this. Sure it's old, but still good IMHO.

halo
08-21-2006, 01:57 PM
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.

SirKnight
08-21-2006, 02:13 PM
His room isn't a box.

AlexN
08-21-2006, 04:30 PM
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

SirKnight
08-21-2006, 05:36 PM
Hmmmm...it's interesting in that I could have sworn I tried that and got an error. Maybe I had a typo and didn't realize it.

Anyway, that's great news! :)

sqrt[-1]
08-21-2006, 08:40 PM
Humm, it seems that either something is funky my end or the website is broken but when I use firefox "Open in new tab" on the links off the research page, the page is not found(404). If I just click on the links, they work.