diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-02 13:13:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-10 09:17:07 -0300 |
| commit | 487434a0b55fa7cf479f39481b51da0a7eda79e1 (patch) | |
| tree | ce410e0c52eb030e1de76079834e6697975c9c17 /shaders | |
| parent | d59397d4146ffa23adbbe6dc99c64ebb22a93b2d (diff) | |
| download | pardes-487434a0b55fa7cf479f39481b51da0a7eda79e1.tar.gz pardes-487434a0b55fa7cf479f39481b51da0a7eda79e1.zip | |
gui: draw image surfaces as GPU quads via glsl shaders
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); +} |
