v/shaders/triangle.vert

41 lines
1.1 KiB
GLSL

#version 460
#extension GL_EXT_nonuniform_qualifier : require
struct Vertex {
vec2 pos;
vec2 uv;
vec4 color;
float alpha;
uint textureID;
};
layout(set = 0, binding = 0) uniform sampler2D globalTextures[];
layout(std430, set = 0, binding = 1) readonly buffer VertexBuffer {
Vertex vertices[];
} vBuf;
layout(location = 0) out vec2 uv;
layout(location = 1) out vec4 color;
layout(location = 2) out flat uint tex_id;
void main() {
Vertex testVertices[6] = Vertex[](
Vertex(vec2(-0.5, -0.5), vec2(0.0, 0.0), vec4(1.0, 0.0, 0.0, 1.0), 1.0, 0),
Vertex(vec2( 0.5, -0.5), vec2(1.0, 0.0), vec4(0.0, 1.0, 0.0, 1.0), 1.0, 0),
Vertex(vec2(-0.5, 0.5), vec2(0.0, 1.0), vec4(0.0, 0.0, 1.0, 1.0), 1.0, 0),
Vertex(vec2( 0.5, 0.5), vec2(1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0), 1.0, 0),
Vertex(vec2(-0.5, 0.5), vec2(0.0, 1.0), vec4(0.0, 0.0, 1.0, 1.0), 1.0, 0),
Vertex(vec2( 0.5, -0.5), vec2(1.0, 1.0), vec4(0.0, 1.0, 0.0, 1.0), 1.0, 0)
);
Vertex v = vBuf.vertices[gl_VertexIndex];
uv = v.uv;
color = v.color;
tex_id = v.textureID;
gl_Position = vec4(v.pos, 0.0, 1.0);
}