Closed TaylorMutch closed 7 years ago
Why did this work previously?
This previously worked because in the vertex shader, we specified a single output color per vertex:
// vertex.glsl
uniform vec4 color;
out vec4 finalColor;
void main() {
finalColor = color;
}
Technically this is correct, but we're telling the shader program that each vertex needs to be assigned a color during vertex assembly. This way, with specifying the color as a uniform color in the fragment shader, there is no need to add an additional input variable to the fragment shader. We just assign gl_FragColor
(or technically, the single out vec4
from the fragment shader) to be the uniform we want for the whole shape.
Since we are actually drawing colors per object we want to test against (rather than just perform depth tests), we need to add a fragment shader.