[Opengl4.0] glsl-flat shading plane coloring

Source: Internet
Author: User

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.