Hello everyone,
I'm trying to implement a lighting technique that uses something similar to spherical environment reflection mapping. The light would be represented by a texture. The center of the texture would be bright, and would become darker around the edges. The closer each vertex normal is to the light direction, the closer to the center of the texture it should be mapped.
[attachment=18368:Sphere.png]
note: "Polygon normal" should instead read "vertex normal". In addition. the math in the image is slightly off. See the code below instead:
The code I'm currently using does what I want to some extent, but has the unwanted side effect of mapping back-facing vertices (nearly) the same as front-facing vertices:
u = ( dot(vertex.normal,Light.Right) * 0.5 ) + 0.5;
v = ( dot(vertex.normal,Light.Up) * -0.5 ) + 0.5;
My goal is to map vertices from the center of the texture, outward, based on how far away the vertex normal points from the light direction. Vertex normals facing away from the light should be mapped to the very edge of the texture. In addition, the direction-axis that changes should control the direction the texture coordinates move away from the center - if the light spins left-right, the uv coordinate should change left/right (as opposed to up/down, or some arbitrary direction).
One simple idea I came up with was to use dot(vertex.normal,light.forward) as some type of scaler for the other two axes, but I couldn't come up with any decent math to make it work.
This code to convert is implemented in a vertex shader, so I'm trying to limit conditional expressions/code. I'm sure others have done this before for the same or different purposes. I'm pretty confuzzled at the moment, and could really use some outside thinking. I really appreciate any input or advice anyone may have. Thank you very much.