所以我一直在学习一些OpenGL,它需要很多东西,我只是一个初学者,但我不明白GLSL中的“布局限定符”。OpenGL:布局限定符?
因此,像这样:
layout (location = 0) in vec3 position;
在一个简单的顶点着色器
像这样:
#version 330 core
layout (location = 0) in vec3 position; // The position variable has attribute position 0
out vec4 vertexColor; // Specify a color output to the fragment shader
void main()
{
gl_Position = vec4(position, 1.0); // See how we directly give a vec3 to vec4's constructor
vertexColor = vec4(0.5f, 0.0f, 0.0f, 1.0f); // Set the output variable to a dark-red color
}
我理解为实例进行vec4(因为多数民众赞成将片段着色器)。例如,vertexColor是有意义的。
但也许我不理解“位置”,究竟这意味着什么?有人关心解释吗? opengl wiki诚实地没有帮助我。
但也许我误解了一个顶点着色器(当然,我仍然有点不确定的管道)。但从我的理解来看,顶点规范是我们所做的第一件事情呢? (如果需要,顶点/索引)并将它们存储到VAO中。
那么顶点着色器是与每个单独的顶点交互? (我希望),因为这是我的理解?
那么,为什么你会使用什么,但为零? – msmith1114
那么如果你有例如位置和法线,您可以在属性0和法线属性1位置,你不能把两者在属性0 – Jerem
啊是有道理的,或者属性0类似的位置,和颜色1或类似的东西。 – msmith1114