mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 06:34:11 +00:00
82d0b7ecd5
It turns out the slice pipeline is compatible with the glyph pipeline in that its vertex attribute data is a superset (just the addition of the offset attributes). While the queues have yet to be merged, this will eventually get glyphs, sliced sprites, and general (static) quads into the one pipeline. Although this is slightly slower for glyph rendering (due to the need to pass an extra 8 bytes per glyph), this should be faster for quad rendering (when done) as it will be 24 bytes per quad instead of 32 bytes per vertex (ie, 128 bytes per quad), but this does serve as a proof of concept for doing quads, glyphs and sprites in the one pipeline.
32 lines
951 B
GLSL
32 lines
951 B
GLSL
#version 450
|
|
#extension GL_GOOGLE_include_directive : enable
|
|
|
|
layout (set = 0, binding = 0) uniform
|
|
#include "matrices.h"
|
|
;
|
|
|
|
// rg -> offset x,y
|
|
// ba -> texture u,v
|
|
layout (set = 1, binding = 1) uniform textureBuffer glyph_data;
|
|
|
|
// per instance data
|
|
layout (location = 0) in uint glyph_index;
|
|
layout (location = 1) in vec4 glyph_color;
|
|
layout (location = 2) in vec2 glyph_position;
|
|
layout (location = 3) in vec2 glyph_offset; // for 9-slice
|
|
|
|
layout (location = 0) out vec2 uv;
|
|
layout (location = 1) out vec4 color;
|
|
|
|
void
|
|
main (void)
|
|
{
|
|
vec2 offset = vec2 ((gl_VertexIndex & 4) >> 2, (gl_VertexIndex & 8) >> 3);
|
|
vec4 glyph = texelFetch (glyph_data, int(glyph_index + gl_VertexIndex));
|
|
// offset stored in glyph components 0 and 1
|
|
vec2 position = glyph_position + glyph.xy + offset * glyph_offset;
|
|
gl_Position = Projection2d * vec4 (position.xy, 0.0, 1.0);
|
|
// texture uv stored in glyph components 2 and 3
|
|
uv = glyph.pq;
|
|
color = glyph_color;
|
|
}
|