Per-vertexRendering technology is used to perform rendering calculations for each vertex, and then associate the calculated color value with this vertex. Then the smooth rendering effect after color interpolation is performed on the polygon surface. This is also calledGouraud shading. In the early OpenGL version, it is the default rendering technology.
Sometimes we need to hide one effect: there is only one color on a polygon, rather than the smoothing effect obtained through this interpolation method. Rendering at this time is calledFlat Shading.
The following figure shows the comparison of the two rendering effects:
Gouraud shading
Flat Shading
In the early OpenGL version, the flat shading effect was implemented through the following function calls:
Glshademodel (gl_flat ).
In addition, the color used by the current polygon is the color of the last rendered vertex in the polygon vertex.
In opengl4.0, the flat shading effect can be improved by using a modifier for the input and output variables of the colorant.FlatIt is easy to implement.
Use this modifier before the output variable and fragment color of the vertex coloring tool must be used as the color input variable.
This modifier indicates that this value does not exist when it is passed to the part shader.InterpolationOccurred.
The color of the last polygon may be the color of the first or last rendered vertex in its vertex. You can use the following function calls to control the operation:
Glprovokingvertex (gl_first_vertex_convention );
Or
Glprovokingvertex (gl_last_vertex_convention );
References:
Http://www.futuretech.blinkenlights.nl/gouraud.html
Http://graphics.wikia.com/wiki/Flat_shading
Http://en.wikipedia.org/wiki/Gouraud_shading
Http://www.cs.cmu.edu /~ FP/courses/02-graphics/PDF-color/08-shading.pdf