This Dot3 business that's coming in the next update

Blitz3D Forums/Blitz3D Programming/This Dot3 business that's coming in the next update

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I've read up on Dot3 blending some more and I found some information which appears to indicate that this MIGHT be the same Dot3 blending that Doom 3 uses, but that in order to use it for normal maps, you need to do some OTHER special operations.

For example, I see some sites mentioning pixel shaders, and "normalized environment maps" and other sites mentioning storing the light direction in the vertex colors, but that keeping these values normalized is difficult if not impossible.

I presume that this means that to actually use Dot3 blending for normal maps you need to take extra steps beyond simply sticking the map into a texture channel and telling it to multiply ot add blend the shading calculated by the card with the texture.

Damn.

I think this means that it will be difficult to use this normal mapping without the support for pixel shaders in Blitz, which is a moot point because that would mean the effect wouldn't work on most people's cards since only newer cards have pixel shaders.

There's still hope though. I did see mention of using environment maps. So maybe it is possible to take the normal maps and blend them with a cubic map applied to your model which has the colors in it set to a normal map with normalized colors which indicates the direction of the light source?



I think I'm starting to understand how this Dot3 blending works actually.

Let's say that these Dot3 maps are just maps of how the normal changes across a surface.

Now when you rotate your object, these colors don't change. So they're always relative to the surface beneath. So, you need a way to first convert them to global space.

You would do this I suppose, by blending them with another color, and possibly renormalizing them?

Now once you've done that...

A dot product is a value between -1 and 1 which indicates how much two vectors point towards eachother.

So if you have blended your surface normal map, with another map to rotate those normals into global space instead of surface space, then if you perform a dot3 blend with a LIGHT vector, then the result will be that any pixels that point towards the light will have a value of 1, ie, 255, and any which point away will have a value of 0..-1, which all get clamped to a color of 0.

Maybe I'm overcomplicating things though. Maybe there is a way to convert a light's normal to surface space and then blend with that. Hm... You'd have to do that for each surface in the model.

Actually, I think I'm mistaken. Those normal maps aren't in surface space. They're all in the same space. In object space. The space of the object the map is applied to. That means they all need to be rotated the same way to get them into global space.

It's like a TformNormal Vx, Vy, Vz, Object, 0 operation on each pixel.

Hm...

So what you REALLY need to do is convert the light's normal into object space. Then you have to generate a normal map which represents this, and then you dot3 blend the object with this map.

But why do you need a map? You only have one light normal. You only need a single color for the light that represents it's normal... don't you? Hm...

So you take this one color, and you dot3 blend the object's normal map with it, and each pixel should get set to 255 or 0 depending on which way the light's normal points relative to the normal at each pixel.

I wonder if that's right? I'm not sure. It seems a lot simpler than the methods I saw people discussing. But it seems to make sense if dot3 does what I think it does.