2020-06-01 16:21:18 -07:00
|
|
|
// Assumes the following uniforms exist in the surrounding context:
|
2020-06-08 17:55:41 -07:00
|
|
|
// uniform vec2 frame_shape;
|
2020-06-02 16:18:44 -07:00
|
|
|
// uniform float focal_distance;
|
2020-06-01 16:21:18 -07:00
|
|
|
|
|
|
|
vec4 get_gl_Position(vec3 point){
|
2020-06-08 17:55:41 -07:00
|
|
|
point.x *= 2 / frame_shape.x;
|
|
|
|
point.y *= 2 / frame_shape.y;
|
2020-06-02 16:18:44 -07:00
|
|
|
point.z /= focal_distance;
|
|
|
|
point.xy /= max(1 - point.z, 0);
|
2020-06-01 16:21:18 -07:00
|
|
|
// Todo, does this discontinuity add weirdness? Theoretically, by this point,
|
|
|
|
// the z-coordiante of gl_Position only matter for z-indexing. The reason
|
|
|
|
// for thie line is to avoid agressive clipping of distant points.
|
|
|
|
if(point.z < 0) point.z *= 0.1;
|
2020-06-03 17:10:33 -07:00
|
|
|
return vec4(point.xy, -point.z, 1);
|
2020-06-01 16:21:18 -07:00
|
|
|
}
|