No colored lights with normal mapping.

Blitz3D Forums/Blitz3D Programming/No colored lights with normal mapping.

DH(Posted 2005) [#1]
Damn, that sucks..

Did some normal mapping, and using colored lights (yellow).

With the normal mapping the color is white, but without the normal mapping applied to the mesh the color is yellow...

Anyone know a workaround for this?


sswift(Posted 2005) [#2]
The problem is you are not simulating the virtual light completely.

The normal map provides the brightness at each pixel. You need to multiply this by the color of the light. I don't remember exactly how normal mapping works off the top of my head, but either you have to set the object color to yellow, or you have to put a yellow surface beneath or above the normal mapped surface and multiply that by the normal mapped surface to change the color.

Also I don't know what you mean by doing normal mapping with coored lights. Normal mapping uses virtual lights that you create, not the ligths in Blitz.

In other words, you would store the position of the light and dtermine the direction of that relative to your object, and set your object color to be the same as that vector by normalizing the vector then multiplying it's length by 255 or something, and then that is the color you set the object to before dot3 blending the normal mapped surface, and the result is a shaded version of the object in black and white, which you then apply color to in some way, like having that second skin I described that you multiply with it. So you'd have an object with two surfaces with the same polygons in each.

So I don't know what you mean by a colored normal light if you don't know how to apply color to the object. :-)


DH(Posted 2005) [#3]
What I mean is I create an object, normal map it, texture it.

Then I create a light and move the light around. The normal mapping looks pretty good as the light moves, however the object is not colored with the light.

So if I had a sphere normal mapped, how would your technique apply to it?


sswift(Posted 2005) [#4]
How are you creating this light source?

Are you using the object color or vertex colors to define the light source vector that the dot3 map is multiplied with?

What texture layer is the object texture on?
What is it's blending mode?

What texture layer is the normal map on?

The easiest way to make a light a certain color might be to place a texture of the appropriate color on the third texture later and set that layer to multiply blend. I'm not positive that will work, but I think it will.

This assumes that you have the normal map on the first texture layer, are dot 3 blending it with the color of the object or vertex colors below, and you have the texture on layer 2 which you are multiplying or multiplyx2 with the result of the first operation. You then need to multiply the result of THAT by the light color, hence the texture on the third layer.


DH(Posted 2005) [#5]
I am creating the light with:

light = createlight(2)

and simply moving the light entity around. The normal maps seem to work pretty well. I have a screen shot at home, when I get home I will show it to you.

not sure what layer, the code is at home, however i used the code in the code archives to apply a normal map to an existing texture in an object by texture name. The is the only bit of code I borrowed.

hmmm, perhaps I am doing the wrong though, now that I think of it, the normal maps didnt have direction, just intensity when the light moved around..

I will have to rethink my methods.

Thanks a ton for the help sswift.


sswift(Posted 2005) [#6]
Dark:
Well then you're doing things wrong, and if all you see is intensity then the normal maps AREN'T working very well. :-)

You do NOT use Blitz lights with normal maps. Any lights you create would be virtual lights you store the positions of yourself and calculate the data for.

Normal maps in Blitz are only half supported, because Blitz doesn't have pixel shaders. You need pixel shaders to do proper normal maps. Some folks here have indicated they have got them working with levels in the past, but I have my doubts about whether they're realyl working right. It's often hard to tell. As far as I know you can only normal map a character model sort of right, and only if they do not animate.

For that you would create a normal map in I guess global space, and then set the color of the object to the vector representing the direction of a directional light in the object's space. You would have to convert it from world space to obejct space to do that. Then you dot3 blend that map with the object color, and that calculates the right pixel shades, which you then have to apply color to.

But if the object moves, the normal map would be distorted and the vectors would no longer be pointing in the right directions. And you can't fix this by using vertex colors instead because A) vertex colors don't get normalized, or treated as vectors, and your colors have to represent a normalized vector (one with a length of 1), and B) You can't get the locations of the vertices as they change position in the animation. Blitz always returns their static location. And if you don't know where they are, you don't know how the angles of the surfaces attached to them have changed.

In short, I wouldn't even be trying to mess with normal maps in Blitz. They are nothing but pain.


If you want to make your models look better, instead of trying to make them normal mapped, maybe you should try to do specular mapping? Specular mapping is where some parts of the obejct are shinier than others. You can get some very nice looking bump like effects with specular mapping.

I'm not going to go into how to do specular mapping right now though. I'll just say you need a mesh with two surfaces, and top one which has specular turned up, and an alpha map, and the bottom which has specular turned down and no alpha map. Those are the basics.


DH(Posted 2005) [#7]
Thanks a ton for the info, I guess normal mapping is pretty much a lost cause in Blitz3d (damn).

Here was the screenshot I had taken of what I got to work:
http://www.kcstudios.net/gallery/gallery.asp?Gallery=2&Category=18&Image=70