Joel Graff
10-01-2011, 10:36 PM
Hello,
I'm implementing a simple pint light shader in GLSL using OpenSceneGraph. I appear to have run into a problem and I can't quite visualize what's wrong.
Right now, I have a model loaded with a sphere rotating about it (to represent a revolving light). After implementing the point light shader (following the Orange book text in chapter 9), I had success. The model appeared to be lit correctly as the sphere rotated about it.
However, if I applied a transformation to the model (e.g. rotation on the x-axis 90 degrees), the point light should then be lighting the sides of the model. The model appears correctly transformed, but the light also appears to have been rotated with it. That is, the rotating light is still lighting the top and the bottom, not the sides, after the 90 degree rotation. (Note that I speak of the lighting *effect*, here. The sphere continues to rotate as it did, correctly rotating about the sides of the model).
Following the orange book, I transformed my normals and normalized them, and transformed my light position by the ModelView matrix. The rest of the code is functionally identical to the Orange book's prescription in Chapter 9.
I've also shaded my converted normals (applying x, y, and z values as rgb colors) and they don't appear to make sense of the world coordinate system that OSG uses by default...
Any thoughts?
Joel
I'm implementing a simple pint light shader in GLSL using OpenSceneGraph. I appear to have run into a problem and I can't quite visualize what's wrong.
Right now, I have a model loaded with a sphere rotating about it (to represent a revolving light). After implementing the point light shader (following the Orange book text in chapter 9), I had success. The model appeared to be lit correctly as the sphere rotated about it.
However, if I applied a transformation to the model (e.g. rotation on the x-axis 90 degrees), the point light should then be lighting the sides of the model. The model appears correctly transformed, but the light also appears to have been rotated with it. That is, the rotating light is still lighting the top and the bottom, not the sides, after the 90 degree rotation. (Note that I speak of the lighting *effect*, here. The sphere continues to rotate as it did, correctly rotating about the sides of the model).
Following the orange book, I transformed my normals and normalized them, and transformed my light position by the ModelView matrix. The rest of the code is functionally identical to the Orange book's prescription in Chapter 9.
I've also shaded my converted normals (applying x, y, and z values as rgb colors) and they don't appear to make sense of the world coordinate system that OSG uses by default...
Any thoughts?
Joel