// Upload Projection, ModelView matrices
gl.uniformMatrix4fv(shaderProgram.uMVMatrix, false, pMVMatrix);
gl.uniformMatrix4fv(shaderProgram.uPMatrix, false, perspM);
In the above lines, I understand that the projection matrix and modelview matrix are being uploaded. I would like to know the math behind this.
I have some 3d vertices (overlayvertices) which are later passed in this manner:
// Upload overlay vertices
gl.bindBuffer(gl.ARRAY_BUFFER, overlayVertices[elementIndex]);
gl.vertexAttribPointer(shaderProgram.aVertexPosition, 3, gl.FLOAT,false, 0, 0);
where overlayvertices[i] is a 4*1 array with x,y,z,1
The final drawing happens on the frame of a particular camera based on which the modelview and projection matrix is determined. I would like to manually get the transformed vertices in the camera frame. i.e, (x,y,1). I later download the data within each frame and hence the x,y should be pixel coordinates. Since this happens internally in webgl, I am not able to retrieve this information.