Optimize label size calculation

This commit is contained in:
Georg Hagen
2025-01-05 16:31:04 +01:00
parent e9a1c629d9
commit aca64c57b7
6 changed files with 102 additions and 103 deletions

View File

@@ -8,18 +8,18 @@ layout(set = 0, binding = 0) uniform NodeData
layout(set = 1, binding = 0) uniform CameraData
{
mat4 viewProjection;
mat4 viewProjection;
} cam;
layout(set = 5, binding = 0) uniform LabelData
{
vec4 textSize;
vec4 color;
vec4 bboxCenter;
float radius;
float arrowLength;
bool hasRoundedCorners;
bool hasArrow;
vec4 color;
vec2 textSize;
vec2 bboxCenter;
float radius;
float arrowLength;
bool hasRoundedCorners;
bool hasArrow;
} labelInfo;
layout(location = 0) out vec4 color;
@@ -28,18 +28,18 @@ layout(location = 1) out vec2 textureCoordinates;
// Background plane positions are in clipped space
const vec4 PLANE[4] = vec4[](
vec4(-0.5, -0.5, 0, 1), vec4(0.5, -0.5, 0, 1), vec4(-0.5, 0.5, 0, 1), vec4(0.5, 0.5, 0, 1)
);
const vec2 TEX_COORDS[4] = vec2[](
vec2(0, 0), vec2(1, 0), vec2(0, 1), vec2(1, 1)
);
void main() {
vec4 position = PLANE[gl_VertexIndex];
vec2 bbox = labelInfo.textSize.xy;
position.xy *= bbox;
position.xy += vec2(labelInfo.bboxCenter);
position.z = -0.001;
gl_Position = cam.viewProjection * node.world * position;
textureCoordinates = TEX_COORDS[gl_VertexIndex] * bbox;
void main()
{
vec4 position = PLANE[gl_VertexIndex];
position.xy *= labelInfo.textSize;
position.xy += labelInfo.bboxCenter;
//position.z = -0.001;
gl_Position = cam.viewProjection * node.world * position;
textureCoordinates = TEX_COORDS[gl_VertexIndex] * labelInfo.textSize;
}