Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
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. –  Joseph Mansfield Apr 21 '14 at 12:48
    
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. –  adtither Apr 21 '14 at 12:55

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.