2
\$\begingroup\$

DiffuseShadowIssue DiffuseCubeIssue

As you can see in this image the diffuse shading is working correctly in some places but in other places such as the the bottom of the sphere you can see the squares/triangles of the mesh.

Any idea what would be causing this? Let me know if you need anymore information related to code. I can upload my normals calculations and shader effect if required.

EDIT: Here's a link to the shader I'm using http://pastebin.com/gymVc7CP

Link to normals calculations: http://pastebin.com/KnMGdzHP

Seems to be an issue with edge lighting. Can't seem to see where I'm going wrong with the normals calculations though.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Looks to me like some of your normals are probably pointing backwards. Remember that the cross product is anticommutative, which means that if you swap the two vectors your applying it to you'll get a negated result. \$\endgroup\$ Apr 21, 2014 at 12:48
  • \$\begingroup\$ See what you mean, but if you look at my normal calculations I'm not swapping the vectors around. I know that it has to do with edge lighting, that Reimer touched on in his tutorials. His solution is to combine the normal vectors on the edges that are shared by the triangles. I can't figure out how to do this though. \$\endgroup\$
    – adtither
    Apr 21, 2014 at 12:55

1 Answer 1

1
\$\begingroup\$

I don't see any obvious issue in the code you've provided.

One thing that could go wrong is the order of the indices for some faces, which would lead to normals pointing backward on them (as Joseph Mansfield hinted in comments).

Check your index buffer: are you building up all faces in the same order, either clockwise or anti-clockwise? If not then what you see is perfectly normal. The order of the vertices matter, it defines in which direction the face is oriented.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .