So far, when I’ve interpolated colors or textures, I’ve always used the UV coordinates or the position. But now I would like to do this more precisely from the vertex-dependent positions in order to bind the interpolation firmly between the vertexpoints of the geometry. To do this I would need to access the vertex coordinates exactly.
how would you access the three points in the vertex shader that make up a fragment in order to then transfer the exact coordinates of the three vertices to the fragment shader in order to play the interpolation games there
const VS =`
precision highp float;
precision highp int;
//attributes
in vec3 position;
in vec3 normal;
// Outputs
out vec3 vCoords;
out vec3 vNormal;
void main() {
vCoords = (modelMatrix * vec4(position, 1.0)).xyz;
vNormal = normal;
//i want the three vertices from the attributes to pass their values to the fragmentshader
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`;
const FS =`
precision highp float;
precision highp int;
in vec3 vCoords;
in vec3 vNormal;
void main() {
//just red
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}`;