Oh duh, just re-read it:
float diffuse = max(dot(a_Normal, nSunVector), 0.0);
You have to keep both vectors in the same space. Right now your sun vector is in the world, A_Normal is static/in object space. As the model rotates, you need to take a_normal and multiply it by the model matrix. This keeps it in world space. If you put the view matrix in there as well then the normal is in view space relative to the viewer.
So multiply a_Normal by the model matrix and you are fine, or
multiply a_Normal by the modelviewmatrix and the sun by the view matrix to get them both into view space.
Show differencesHistory of post edits
#1dpadam450
Posted 01 July 2012 - 06:39 PM
Oh duh, just re-read it:
float diffuse = max(dot(a_Normal, nSunVector), 0.0);
that should be ModelViewNormal. You have to keep both vectors in the same space. Right now your sun vector is in the world, A_Normal is static/in object space. As the model rotates, you need to take a_normal and multiply it by the model matrix. This keeps it in world space. If you put the view matrix in there as well then the normal is in view space relative to the viewer.
float diffuse = max(dot(a_Normal, nSunVector), 0.0);
that should be ModelViewNormal. You have to keep both vectors in the same space. Right now your sun vector is in the world, A_Normal is static/in object space. As the model rotates, you need to take a_normal and multiply it by the model matrix. This keeps it in world space. If you put the view matrix in there as well then the normal is in view space relative to the viewer.