diff options
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/image.frag.glsl | 10 | ||||
| -rw-r--r-- | shaders/image.vert.glsl | 33 |
2 files changed, 43 insertions, 0 deletions
diff --git a/shaders/image.frag.glsl b/shaders/image.frag.glsl new file mode 100644 index 00000000..927d5f65 --- /dev/null +++ b/shaders/image.frag.glsl @@ -0,0 +1,10 @@ +#version 450 + +layout(set = 2, binding = 0) uniform sampler2D u_image; + +layout(location = 0) in vec2 v_uv; +layout(location = 0) out vec4 o_col; + +void main() { + o_col = texture(u_image, v_uv); +} diff --git a/shaders/image.vert.glsl b/shaders/image.vert.glsl new file mode 100644 index 00000000..ace55a53 --- /dev/null +++ b/shaders/image.vert.glsl @@ -0,0 +1,33 @@ +#version 450 + +// One instance per Surface image attachment. The CPU has already converted +// the pane's cell rectangle and the aspect-preserving contain fit to NDC. +layout(location = 0) in vec4 a_rect; // x0, y0, x1, y1 +layout(location = 1) in vec4 a_uv_rect; // u0, v0, u1, v1 + +layout(location = 0) out vec2 v_uv; + +void main() { + vec2 pos; + int corner = gl_VertexIndex % 6; + if (corner == 0) { + pos = vec2(a_rect.x, a_rect.y); + v_uv = vec2(a_uv_rect.x, a_uv_rect.y); + } else if (corner == 1) { + pos = vec2(a_rect.z, a_rect.y); + v_uv = vec2(a_uv_rect.z, a_uv_rect.y); + } else if (corner == 2) { + pos = vec2(a_rect.z, a_rect.w); + v_uv = vec2(a_uv_rect.z, a_uv_rect.w); + } else if (corner == 3) { + pos = vec2(a_rect.x, a_rect.y); + v_uv = vec2(a_uv_rect.x, a_uv_rect.y); + } else if (corner == 4) { + pos = vec2(a_rect.z, a_rect.w); + v_uv = vec2(a_uv_rect.z, a_uv_rect.w); + } else { + pos = vec2(a_rect.x, a_rect.w); + v_uv = vec2(a_uv_rect.x, a_uv_rect.w); + } + gl_Position = vec4(pos, 0.0, 1.0); +} |
