[英]How to use flat shading in OpenTK.Graphics.OpenGL4?
I need to use flat shading in OpenTK.我需要在 OpenTK 中使用平面着色。
I know there is a function in OpenGL (c++) called glShadeModel
, and it was in OpenTK named ( GL.
) ShadeModel
, but it's only in OpenTK.Graphics.ES11, and it's pretty old.我知道 OpenGL (c++) 中有一个名为
glShadeModel
,它在名为 ( GL.
) ShadeModel
,但它仅在 OpenTK.Graphics.ES11 中,而且它已经很老了。
How can I do it using OpenTK.Graphics.OpenGL4?我如何使用 OpenTK.Graphics.OpenGL4 做到这一点?
glShadeModel
has been replaced by Interpolation qualifiers . glShadeModel
已被Interpolation qualifiers取代。
However glShadeModel
is still supportend in "desktop" OpenGL if you are using compatibility profile OpenGL Context and are not using a shader program.但是,如果您使用的是兼容性配置文件OpenGL 上下文并且未使用着色器程序,则“桌面”OpenGL 中仍然支持
glShadeModel
。 This means you need to use the immediate mode and you have to draw by glBegin
/ glEnd
sequences or fixed function attributes, without a shader program.这意味着您需要使用立即模式,并且必须通过
glBegin
/ glEnd
序列或固定函数属性进行glEnd
,而无需着色器程序。
If you are using a core profile OpenGL context and/or a shader program and you want to achieve "flat" shading, you have to use the flat
Interpolation qualifier for the vertex shader output variables.如果您正在使用核心配置文件 OpenGL 上下文和/或着色器程序,并且想要实现“平面”着色,则必须对顶点着色器输出变量使用
flat
插值限定符。 For instance:例如:
Vertex shader顶点着色器
#version 460
// [...]
in vec3 aColor;
flat out vec3 vColor;
void main()
{
vColor = aColor;
// [...]
}
Fragment shader片段着色器
#version 460
flat in vec3 vColor;
out vec4 fragColor;
void main()
{
fragColor = vec4(vColor, 1.0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.