Files
2025-11-20 12:34:36 +00:00

30 lines
917 B
GLSL

#version 450 core
struct PosCol { vec4 pospos; vec4 col; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 1) readonly buffer Pos { PosCol data[]; };
out vec4 vCol;
out vec4 vPos;
out vec2 vScreenPos;
int indices[6] =
{0,3,1
,0,2,3};
// note reversed compared to walls
void main()
{
vCol = data[gl_VertexID / 12].col;
vec4 pp = data[gl_VertexID / 12].pospos;
int j = indices[gl_VertexID % 6];
bool t = gl_VertexID % 12 > 5.5;
float z = (j > 1.5
? (t ? 100 : 5000)
: (t ? 0 : 100)
);
// we draw two quads: one which can be below clouds,
// and one which is always above
vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw);
vPos = vec4( xy, z, 1);
gl_Position = theMat * vPos;
vScreenPos = 0.5 * (vec2(1) + vec2(gl_Position.x / gl_Position.w
,gl_Position.y / gl_Position.w));
}