Normal Mapping (again)

Blitz3D Forums/Blitz3D Programming/Normal Mapping (again)


have created the level and applied the normal maps, but now when using the same lighting method as in other demos (EntityColor mesh,r,g,b) it just makes my mesh all black.



Each ploygon of the level should be treated seperately...polygons where the light is hitting it strait on would be colored 127,127,255...this equates to a normal value of 0,0,1...when the normal map is DOT3 applied, the videocard performs a dot product operation between the polygon and normal map...the result is a greyscale value from black to white.

About the easiest way to get the proper normal colors for the level would be to create a pivot...move it to each polygon verticy...point the pivot at each light source visable to the polygon...record the pivot normal...point it to the next lightsource...record the pivot normal...repeat until no more lightsources strike the polygon the verticy is attached to...then average the recorded pivot normals...convert that averaged normal into a RGB color (average normal X axis * 127 + 127 = red...average normal Y Axis * 127 + 127 = Blue, etc..) and give that particular verticy that color...move the pivot to the next verticy and repeat...once all the verticy colors have been calculated, save the level mesh.

Then in your game engine just render it with the fullbrite and verticy color flags...DOT3 the normal maps onto that, followed by the regular textures and lightmap....note: this is only static precalculated lighting...additionaly the calculated verticy colors arn't the actual verticy normals, rather they are the normals (or vector) pointing in the direction of the light as it strikes the surface.