Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualPixelSmasher

Posted 31 March 2013 - 10:19 AM

In your vertex shader, you are computing the vertex normal with

  frag_normal = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the last "w" scalar value set to 1.0 means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.

 

 

Moreover, normalizing the interpolation variable frag_normal (set as "smooth out" and "smooth in" by default) will lead to incorrect normal vectors as they won't stay normed during their interpolation across vertices. You should normalize it in the fragment shader.


#6PixelSmasher

Posted 29 March 2013 - 05:56 PM

In your vertex shader, you are computing the vertex normal with

  frag_normal = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the last "w" scalar value set to 1.0 means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.

 

 

Moreover, normalizing the interpolation variable frag_normal (set as "smooth out" and "smooth in" by default) will lead to incorrect normal vectors as they won't stay normed during their interpolation across vertices. You should normalizing it in the fragment shader.


#5PixelSmasher

Posted 29 March 2013 - 05:55 PM

In your vertex shader, you are computing the vertex normal with

  frag_normal = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the last "w" scalar value set to 1.0 means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.

 

 

Moreover, normalizing the interpolation variable frag_normal (set as "smooth out" and "smooth in" by default) will lead to incorrect normal vectors as they won't stay normed during their interpolation. You should normalizing it in the fragment shader.


#4PixelSmasher

Posted 29 March 2013 - 05:51 PM

In your vertex shader, you are computing the vertex normal with

  frag_normal = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the last "w" scalar value set to 1.0 means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.


#3PixelSmasher

Posted 29 March 2013 - 05:51 PM

In your vertex shader, you are computing the vertex normal with

  frag_normal = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the last "w" scalar value means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.


#2PixelSmasher

Posted 29 March 2013 - 05:50 PM

In your vertex shader, you are computing the vertex normal with

  frag_normal   = normalize(WorldMatrix * vec4(vert_normal, 1.0)); 

In homogenous coordinates, the "w" scalar value means that vert_normal is a point. As it is a mere unpositioned vector, i think using 0.0 should fix your bug.


PARTNERS