Some **are** negative...
How do I identify what the correct order is? Is there a good URL or site that explains what the order is -- because for what I thought, it was all the same, so long as you take three points in a triangle.
EDIT:
I revisited a few things and saw that a "Front" face is defined (by default) as going COUNTER clockwise (unless you change it). I reversed the order of my points for the triangles that were always rendering funky, so that they were counter-clockwise (one triangle of the quad was counter-clockwise, the other was clockwise).
That seems to have fixed everything! Oy! I *never* read/learned anything about this stuff before even in formal education.
Help with Shadow Mapping and Multi-Texturing
That fixed it! Thank you. Now, to try and solve other problems and get this all working together. :-)
OK, so I've been working on my engine some more and I'm having an issue when calculating the face normals. I've seen a lot of different methods online about calculating the subtraction between vertices in a triangle. The most common appears to be B - A = Vector 1; C - A = Vector 2; Then cross-product the two vectors and you have your face normal.
So, say I have two triangles that compose a tile that is used. The triangles form a triangle mesh in the form of:
AD
BC
Wherein ABC is the first triangle and CDA is the second triangle.
When I run through the calculations to do the face normal of ABC, the vector appears to be in the wrong direction. My directional light is at 0,0,1; the normal is at 0,0,-1 for a flat face (or in the negative Z axis, in general). I was using B - A and C - A; Then I figured it should be B - A and B - C to calculate the correct direction -- and indeed, my face normal goes to +Z.
Is this the correct order to do it? I've googled and haven't found a very good explanation on what the correct order is -- very few sites actually draw it out cleanly to explain which order one should do it in -- they just throw in Spaghetti code (which I'm guilty of copying) to do the basic B - A and C - A -- which was totally wrong.
EDIT: And now I see another topic a little further down that suggest A - B and C - B, wherein B is the common shared point between the two in the triangle... Which again, works to some degree.
At this point, I think I may have my light being setup incorrectly -- which sucks, but it's good to know that my Light is just wrong (so I can fix it). Once I know the correct order, I can proceed, I think, to building this correctly.
Thoughts?
So, say I have two triangles that compose a tile that is used. The triangles form a triangle mesh in the form of:
AD
BC
Wherein ABC is the first triangle and CDA is the second triangle.
When I run through the calculations to do the face normal of ABC, the vector appears to be in the wrong direction. My directional light is at 0,0,1; the normal is at 0,0,-1 for a flat face (or in the negative Z axis, in general). I was using B - A and C - A; Then I figured it should be B - A and B - C to calculate the correct direction -- and indeed, my face normal goes to +Z.
Is this the correct order to do it? I've googled and haven't found a very good explanation on what the correct order is -- very few sites actually draw it out cleanly to explain which order one should do it in -- they just throw in Spaghetti code (which I'm guilty of copying) to do the basic B - A and C - A -- which was totally wrong.
EDIT: And now I see another topic a little further down that suggest A - B and C - B, wherein B is the common shared point between the two in the triangle... Which again, works to some degree.
At this point, I think I may have my light being setup incorrectly -- which sucks, but it's good to know that my Light is just wrong (so I can fix it). Once I know the correct order, I can proceed, I think, to building this correctly.
Thoughts?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement