
four wrote: >>Basically, my problem is this: Given the cosine between a light unit vector, and a normal unit vector (which is 1 to 1), how do I map that value to a 24 bit color model? >> >>My light is a headlight, which is attached to a moving camera. It's purpose is to pretty much light the polygons as the headlight of a car, or a flashlight would. Polygons perpindicular to the light (or view vector), and facing it are pure white, and polygons perpindicular and facing away from the light are pure black. >> >>I was making the oversight that my cosine was between 0 and 1  I was ignoring the 0 to 1 polygons  and just using that 0  1 as my color intensity for each element RGB. I just realized though that the results are wrong. >> >>Here's my current code for mapping the cosine to a 24 color value: >> >>// SurfaceIntensity is the cosine (0 to 1 in this method): >>Vertex[A].r = SurfaceIntensity * 255; >>Vertex[A].g = SurfaceIntensity * 255; >>Vertex[A].b = SurfaceIntensity * 255; >> >>With this method, if the camera is stationary, in the center of a sphere, the polygons to the left of the camera are pure black, the polygons to the front of the camera are grey, the polygons to the right of the camera are pure white, and all polygons beyond the camera are pure black as well. >> >>I need a way of mapping the cosine to the color so that the polygons to the left are grey, to the front are pure white, to the right are grey, and to the back are pure black. >> >>All of the books that I've checked out use the method that I am currently using, but I really don't see how it can work properly. Am I missing something?
Off hand, I see two possible causes for your problem: 1) You calculate the surfaceintensity in a wrong way. 2) You get intensities from 0..255 here. for a 24bit color mode that's okay, but maybe you're using a 16mode. This causes overflows.
Maybe I'm stating the obvious, but it would be helpfull if you posted the code which calculates the cosine.
Jeroen
