2016-06-15 17:53:26 +01:00
|
|
|
#version 150
|
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 ivec4 vClip;
|
|
|
|
|
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()
|
|
|
|
|
{
|
2021-04-20 08:10:23 +02:00
|
|
|
vec2 pos = clamp(vVertMat * vec4(vBounds), vec2(vClip.xy), vec2(vClip.zw));
|
2016-06-11 17:43:53 +01:00
|
|
|
|
2017-10-21 21:04:24 -05:00
|
|
|
// Transform screen coordinates to viewport coordinates
|
2021-04-20 08:10:23 +02:00
|
|
|
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
|
|
|
}
|