OpenRCT2/data/shaders/drawline.vert

32 lines
655 B
GLSL
Raw Normal View History

2016-06-15 18:53:26 +02:00
#version 150
2016-06-11 18:43:53 +02:00
// Allows for about 8 million draws per frame
const float DEPTH_INCREMENT = 1.0 / float(1u << 22u);
2016-06-11 18:43:53 +02:00
uniform ivec2 uScreenSize;
2023-12-08 13:02:43 +01:00
// clang-format off
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 18:43:53 +02:00
2017-10-19 22:46:49 +02:00
in mat4x2 vVertMat;
2016-06-11 18:43:53 +02:00
flat out uint fColour;
2016-06-11 18:43:53 +02:00
void main()
{
vec2 pos = clamp(vVertMat * vec4(vBounds), vec2(vClip.xy), vec2(vClip.zw));
2016-06-11 18:43:53 +02:00
2017-10-22 04:04:24 +02: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;
fColour = vColour;
2016-06-11 18:43:53 +02:00
gl_Position = vec4(pos, depth, 1.0);
2016-06-11 18:43:53 +02:00
}