mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 08:12:53 +01:00
implement DrawLine with shader
This commit is contained in:
20
data/shaders/drawline.frag
Normal file
20
data/shaders/drawline.frag
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
|
||||
uniform ivec2 uScreenSize;
|
||||
uniform ivec4 uClip;
|
||||
uniform vec4 uColour;
|
||||
|
||||
in vec2 fPosition;
|
||||
|
||||
layout (location = 0) out vec4 oColour;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (fPosition.x < uClip.x || fPosition.x > uClip.z ||
|
||||
fPosition.y < uClip.y || fPosition.y > uClip.w)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
oColour = uColour;
|
||||
}
|
||||
30
data/shaders/drawline.vert
Normal file
30
data/shaders/drawline.vert
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 330
|
||||
|
||||
uniform ivec2 uScreenSize;
|
||||
uniform ivec4 uBounds;
|
||||
|
||||
in int vIndex;
|
||||
|
||||
out vec2 fPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos;
|
||||
if (vIndex == 0)
|
||||
{
|
||||
pos = uBounds.xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = uBounds.zw;
|
||||
}
|
||||
|
||||
fPosition = pos;
|
||||
|
||||
// Transform screen coordinates to viewport
|
||||
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
|
||||
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
|
||||
pos.y *= -1;
|
||||
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user