Wednesday, February 5, 2020

opengl - smooth shading vs flat shading, what's the difference in the models?


I'm loading the exact same model with Assimp, except one is exported from Blender, shaded smoothly, and the other was exported from Blender, shaded flatly. Here is my results from loading both into my game: enter image description here


The Flat drawn model has 1968 vertices and the Smooth drawn model only has 671, why is this happening, I don't understand why there would be less vertices when it's shaded smoothly...?



Answer



For smooth shading, two adjacent triangles must share common vertex normals. The reason is interpolation. The normal from one vertex is smoothly interpolated to the normal on the second vertex. You need to ensure that the normal of triangle at a particular vertex matches the normal of all adjacent triangles at that same vertex. If you think of a smooth sphere, each vertex on the surface (which is used by multiple triangles) has a single normal.


With flat shading, the normal for each vertex on every triangle must be the same so that when interpolated the value is the same across the whole surface. This means that if a single vertex is shared by multiple triangles then the vertex must be duplicated for each triangle in order to have an independent normal for each triangle.


Overall this means that a smoothly-shaded model can share vertices in ways that a flat-shaded model cannot.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...