Closed vkj98 closed 1 year ago
There is no such thing as a "proper" rendering; all depends on conventions that you use. Given a single triangle, how can you know which side is the "front" and which one is the "back" side? No way to define in general without some sort of a convention. One possibility is to say that if you look at a triangle from the "front" side, the vertices are numbered counter-clockwise. Or the other way round ;)
Footnote: auto orientation of normals can be possible for closed (i.e. without boundary edges) manifold surfaces.
One possibility is to say that if you look at a triangle from the "front" side, the vertices are numbered counter-clockwise
Does the model used here follow such a convention so that the normals calculated using the provided code come out to be "outwards" or "inwards" ?
african_head.obj uses clockwise ordering if I am not mistaken
Lesson2 states the following
But the dot product can be negative. What does it mean? It means that the light comes from behind the polygon.
Is this always true ?We calculate the normal to the surface as follows,
Vec3f n = (world_coords[2]-world_coords[0])^(world_coords[1]-world_coords[0]);
If we change the order of terms (sides of the triangle) on the RHS, the direction of normal will flip. Then the triangles that had positive dot product with the light direction will have negative values now. With the provided model and code, we get proper rendering of the face. Is there some pre defined ordering of vertices of faces in the model file that ensures that we get proper direction of all the normals ?