Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualdpadam450

Posted 01 July 2012 - 06:41 PM

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.

#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.

PARTNERS