• 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!

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

  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

  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

  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

  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

  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

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