Switch to more compact TextGlyph vertex format

This commit is contained in:
Georg Hagen
2025-01-05 00:02:01 +01:00
parent 47a904f572
commit e9a1c629d9
13 changed files with 249 additions and 248 deletions

View File

@@ -0,0 +1,64 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec2 position[4];
layout(location = 4) in vec2 textureCoordinates[4];
layout(location = 8) in vec4 color;
layout(location = 9) in vec4 bgColor;
layout(location = 0) out vec4 outColor;
layout(location = 1) out vec4 outBgColor;
layout(location = 2) out vec2 outTexture;
layout(set = 0, binding = 0) uniform NodeData
{
mat4 world;
} node;
layout(set = 1, binding = 0) uniform CameraData
{
mat4 viewProjection;
mat4 view;
mat4 projection;
vec4 camPos;
} cam;
layout(set = 4, binding = 0) uniform BillboardData
{
vec2 size;
bool isFixedSize;
} billboardInfo;
void main()
{
vec4 pos = vec4(position[gl_VertexIndex], 0, 1);
if (!billboardInfo.isFixedSize)
{
mat4 mv = cam.view * node.world;
mv[0][0] = 1;
mv[0][1] = 0;
mv[0][2] = 0;
mv[1][0] = 0;
mv[1][1] = 1;
mv[1][2] = 0;
mv[2][0] = 0;
mv[2][1] = 0;
mv[2][2] = 1;
gl_Position = cam.projection * mv * pos;
}
else
{
vec4 billboardPos = vec4(0.5, 0.5, 0.5, 1);
vec4 viewPos = cam.view * node.world * billboardPos;
float dist = -viewPos.z;
gl_Position = cam.projection * (viewPos + vec4(pos.xy * dist * 0.2, 0, 0));
}
outTexture = textureCoordinates[gl_VertexIndex];
outColor = color;
outBgColor = bgColor;
}