So I've got a triangle:
And I've got a vertex shader:
uniform mat4 uViewProjection;
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoords;
varying vec2 vTextureCoords;
void main(void) {
vTextureCoords = aTextureCoords;
gl_Position = uViewProjection * vec4(aVertexPosition, 1.0);
}
And I've got a fragment shader:
precision mediump float;
uniform sampler2D uMyTexture;
varying vec2 vTextureCoords;
void main(void) {
gl_FragColor = texture2D(uMyTexture, vTextureCoords);
}
And I feed in three sets of vertices and UVs, interleaved:
# x, y, z, s, t
0.0, 1.0, 0.0, 0.5, 1.0
-1.0, -1.0, 0.0, 0.0, 0.0
1.0, -1.0, 0.0, 1.0, 0.0
How does the fragment shader know to draw pixel A differently from pixel B? What changes?