I’m reading the PShader reference and I have a question about code listing 4.2:
Vertex shader:
uniform mat4 transform;
attribute vec4 position;
attribute vec4 color;
varying vec4 vertColor;
void main() {
gl_Position = transform * position;
vertColor = color;
}
Fragment shader:
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
varying vec4 vertColor;
void main() {
gl_FragColor = vertColor;
}
In the vertex shader color
is the color of the input vertex. In this code listing you set the output color vertColor
equal to the input color color
. However, once you go over to the fragment shader you’re just passed a single vertColor
, which I understand to be the color of a single vertex.
Why are you only passed a single vertColor
? Is vertColor
automatically interpolated from the vertices of the fragment?