rework label shader

This commit is contained in:
ohyzha
2024-08-28 11:12:59 +03:00
parent e2ae1687ac
commit 6305cbfe1e
7 changed files with 231 additions and 129 deletions

View File

@@ -25,22 +25,23 @@ namespace OpenVulkano::Scene
Math::Vector4f backgroundColor = { 1, 0, 0, 1 };
float horizontalOffset = 0.05f;
float verticalOffset = 0.05f;
float cornerRadius = 0.5f;
float cornerRadius = 0.05f;
float arrowLength = 0.5f;
float arrowWidth = 0.2f;
int32_t hasRoundedCorners = false;
int32_t hasArrow = false;
};
namespace
struct LabelUniformData
{
struct LabelUniformData
{
Math::Vector2f textSize = { 0, 0 };
float cornerRadius = 0.f;
float arrowLength = 0.f;
int32_t hasRoundedCorners = false;
int32_t hasArrow = false;
};
Math::Vector4f textSize = { 0, 0, 0, 0 };
Math::Vector4f color = { 0, 0, 0, 0 };
Math::Vector4f bboxCenter = { 0, 0, 0, 0 };
float cornerRadius = 0.f;
float arrowLength = 0.f;
float arrowWidth = 0.f;
int32_t hasRoundedCorners = false;
int32_t hasArrow = false;
};
class LabelDrawable final : public Drawable
@@ -56,7 +57,6 @@ namespace OpenVulkano::Scene
LabelDrawableSettings& GetSettings() { return m_settings; }
UniformBuffer* GetBillboardBuffer() { return &m_billboardBuffer; }
UniformBuffer* GetLabelBuffer() { return &m_labelBuffer; }
Geometry& GetBackgroundGeometry() { return m_backgroundGeometry; }
BillboardControlBlock& GetBillboardSettings() { return m_billboardSettings; }
Math::Vector3f& GetPosition() { return m_position; }
bool IsBillboard() const { return m_isBillboard; }
@@ -67,10 +67,8 @@ namespace OpenVulkano::Scene
void SetupBuffers();
private:
Shader m_backgroundShader;
Geometry m_backgroundGeometry;
UniformBuffer m_billboardBuffer;
UniformBuffer m_labelBuffer;
std::vector<Shader> m_billboardTextShaders;
// list over vector to prevent memory reallocation and crash
std::list<TextDrawable> m_texts;
Shader m_textShader;