Robs Normal Mapping Statue code and demo?

Blitz3D Forums/Blitz3D Programming/Robs Normal Mapping Statue code and demo?

To explain in a little more depth, changing the light direction of a normal map, involves you changing, either:

The entitycolor, or,
The vertex colors, or,
The texture blending with the normal map.

Alot of examples use the textureblending, as they can use a cubemap, with colour normal information stored on it. Basically, as the model moves/animates, the vertex normals of the model change. Since a cubemap adjusts the texturecoords dynamically, it automatically maps a certain part of the texture, for particular vertex normals of the cubemap. Therefore, this always shows the correct normal colour for mixing with the normalmap, providing the correct lighting.

For a rotatable lightsource, you actually have to the rotate the cubemap, which is an expensive process, so alot of codes use a very small cubemap, to reduce the rendering process of the new cubemap.

A simple way though for normalmaps, with a rotatable light source, is to use entity color, and change the red green and blue parts yourself, to determine a position(normal) for the light. 255 being 1, 128 being 0 and 0 being -1 (for normals)

However, you can only use this on static meshes, which do not move, as their normals would be incorrect.

Vertex colours can be used, but that would involve you looping through every vertex and calculating their light value, based on light direction. This gives you some ability to have spot light and omi lights too, depending on the numb er and distribution of vertices in the mesh.