Unconstrained Vertices

Now we can have almost arbitrary vertices. As long as the modelViewMatrix places them withing the view frustum, the perspective matrix will project them onto the normalized device coordinate cube. And we control the frustum by setting xscale, yscale, znear and zfar.

206                 var vertices       = [
207                                       -150.0, -150.0, -1.0,
208                                          1.0,    0.0,  0.0, 1.0,
209                                        150.0, -150.0, -1.0,
210                                          0.0,    1.0,  0.0, 1.0,
211                                          0.0,  150.0, -1.0,
212                                          0.0,    0.0,  1.0, 1.0
213                                     ];
214 
215                 // Like any three dimensional polygon, we specify the vertices.
216                 var moreVertices   =  [
217                                       -150.0, -150.0,  -2.0,
218                                          0.0,    0.0,   1.0, 1.0,
219                                        150.0, -150.0,  -2.0,
220                                         0.0,     1.0,   0.0, 1.0,
221                                         0.0,   150.0,  -2.0,
222                                         1.0,     0.0,   0.0, 1.0
223                                     ];

Notes

The first triangle is right at the base of the frustum, with x and y dimensions the same as xscale and yscale. As expected, this triangle fills the field of view.

          (-150,-150,-1.0)  (150,-150,-1)  (0,150,-1.0)
      

The second triangle is set back a bit, and its apparent size is diminished significantly. This is expected, as a object moves away from you its apparent size decreases rapidly, but the decrease is less rapid as the object gets further away.

          (-150,-150,-1.0)  (150,-150,-1)  (0,150,-1.0)
      

Keep in mind that the output from the vertex shader, is these points after being operated on by the perspective projection matrix. The resulting poionts are within the range x, y, z ∈ [-1, 1].