Files

30 lines
605 B
GLSL
Raw Permalink Normal View History

#version 330 core
2016-06-11 17:43:53 +01:00
2017-10-19 18:49:26 -05:00
// Allows for about 8 million draws per frame
const float DEPTH_INCREMENT = 1.0 / float(1u << 22u);
2016-06-11 17:43:53 +01:00
uniform ivec2 uScreenSize;
2017-10-19 18:49:26 -05:00
2023-12-08 13:02:43 +01:00
// clang-format off
2017-10-19 18:49:26 -05:00
in ivec4 vBounds;
in uint vColour;
in int vDepth;
2023-12-08 13:02:43 +01:00
// clang-format on
2016-06-11 17:43:53 +01:00
2017-10-19 15:46:49 -05:00
in mat4x2 vVertMat;
2016-06-11 17:43:53 +01:00
2017-10-19 18:49:26 -05:00
flat out uint fColour;
2016-06-11 17:43:53 +01:00
void main()
{
vec2 pos = vVertMat * vec4(vBounds);
2016-06-11 17:43:53 +01:00
2017-10-21 21:04:24 -05:00
// Transform screen coordinates to viewport coordinates
pos = (pos * (2.0 / vec2(uScreenSize))) - 1.0;
pos.y *= -1.0;
float depth = 1.0 - (float(vDepth) + 1.0) * DEPTH_INCREMENT;
2016-06-11 17:43:53 +01:00
2017-10-19 18:49:26 -05:00
fColour = vColour;
gl_Position = vec4(pos, depth, 1.0);
2016-06-11 17:43:53 +01:00
}