I'm trying to perform the same transform in javascript as in a vertex shader. My vertex shader is transforming vertices like a typical WebGL example:
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0)
My canvas is 600x600px (but the canvas size turns out to be irrelevant in this case.)
The resulting gl_Position.xy is not what I expected. Rather than being in the range 0,600 or -300,300 or -1,1, it seems to be roughly -6,6. (I ended up writing tests in the shader eg: if the transformed gl_Position.x > 5.0 color it red.)
That -6,6 (or 12x12) drawing area remains constant regardless of canvas size.
After adding a scale factor and tweaking it by eye, I've managed to sync my javascript transform with the shader transform. But how do I get the size of the drawing area of the transformed vertices from WebGL? How is that -6,6 range determined?