当前位置:网站首页>API learning of OpenGL (2002) smooth flat of glsl

API learning of OpenGL (2002) smooth flat of glsl

2022-07-06 10:36:00 hankern

use flat When coloring ,OpenGL The color of a vertex in the entity will be used to render the entire entity , Usually, the color of the first or last vertex of the entity will be selected as the color of the entity .
In the use of smooth When coloring ,OpenGL The color of each vertex in the entity will be processed independently . For segment entities , The color of each point on the line segment will be obtained by interpolation according to the color of the two vertices . For polygon primitives , The color of the inner region of the polygon will be interpolated according to the color of all vertices .

1、smooth Of glsl

The vertices

smooth out vec3 FrontColor;
smooth out vec3 BackColor;

fragment

smooth in vec3 FrontColor;
smooth in vec3 BackColor;

effect

 

2、flat Of glsl

The vertices

flat out vec3 FrontColor;
flat out vec3 BackColor;

fragment

flat in vec3 FrontColor;
flat in vec3 BackColor;

effect

 

原网站

版权声明
本文为[hankern]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131709023836.html