#version 410 uniform float yRatio; // height/width uniform float eyePos; uniform mat4 cameraMatrix; in vec3 pos; in vec2 uv; out vec2 uvV; void main(void) { float yRatioScaler = yRatio > 1.0 ? 1.0 : yRatio; float xMore = yRatio / yRatioScaler; float yMore = 1.0 / yRatioScaler; float zFixer = -150.0; // we flip & compress Z for the final depth write. Our world is all in RHS, negative Z from screen. Device is +Z. // matrix is actually transpose of how it "looks" here... mat4 projectionMatrix = mat4(xMore, 0, 0, 0, 0, yMore, 0, 0, 0, 0, 1.0 / zFixer, -1.0 / eyePos, 0, 0, eyePos / zFixer, 0); mat4 transformMatrix = projectionMatrix * cameraMatrix; vec4 a = vec4(pos,1); a = transformMatrix * a; gl_Position = a; uvV = uv; }