pixels/shaders/shader.vert

44 lines
851 B
GLSL
Raw Normal View History

// IMPORTANT: This shader needs to be compiled out-of-band to SPIR-V
// See: https://github.com/parasyte/pixels/issues/9
#version 450
out gl_PerVertex {
vec4 gl_Position;
};
layout(location = 0) out vec2 v_TexCoord;
layout(set = 0, binding = 2) uniform Locals {
mat4 u_Transform;
};
const vec2 positions[6] = vec2[6](
// Upper left triangle
vec2(-1.0, -1.0),
vec2(1.0, -1.0),
vec2(-1.0, 1.0),
// Lower right triangle
vec2(-1.0, 1.0),
vec2(1.0, -1.0),
vec2(1.0, 1.0)
);
const vec2 uv[6] = vec2[6](
// Upper left triangle
vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
// Lower right triangle
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0)
);
void main() {
v_TexCoord = uv[gl_VertexIndex];
gl_Position = u_Transform * vec4(positions[gl_VertexIndex], 0.0, 1.0);
}