Unify text shader handling

This commit is contained in:
Georg Hagen
2025-01-04 02:46:24 +01:00
parent bc78af70e8
commit 94025c79c6
7 changed files with 60 additions and 51 deletions

View File

@@ -21,19 +21,13 @@ namespace OpenVulkano::Scene
struct TextConfig
{
Math::Vector4f textColor = { 1, 1, 1, 1 };
Math::Vector4f borderColor = { 1, 0, 0, 1 };
Math::Vector4f backgroundColor = { 0, 1, 0, 0 };
float threshold = 0.4f;
float borderSize = 0.05f;
float smoothing = 1.f/32.f;
uint32_t applyBorder = false;
//bool sdfMultiChannel = false;
};
class TextDrawable : public SimpleDrawable
{
static Shader DEFAULT_SHADER_BITMAP, DEFAULT_SHADER_SDF, DEFAULT_SHADER_MSDF;
Geometry m_geometry;
Material m_material;
UniformBuffer m_uniBuffer;
@@ -45,9 +39,6 @@ namespace OpenVulkano::Scene
uint32_t GetFallbackGlyph() const;
public:
[[nodiscard]] static Shader& GetSdfDefaultShader() { return DEFAULT_SHADER_SDF; }
[[nodiscard]] static Shader& GetMsdfDefaultShader() { return DEFAULT_SHADER_MSDF; }
[[nodiscard]] static Shader& GetBitmapDefaultShader() { return DEFAULT_SHADER_BITMAP; }
TextDrawable(const TextConfig& config = TextConfig());
TextDrawable(const Array<char>& atlasMetadata, const TextConfig& config = TextConfig());
TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config = TextConfig());