mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 21:13:31 +02:00
try to make text entities fade
This commit is contained in:
parent
7713c1f4bf
commit
d7052f6250
3 changed files with 10 additions and 6 deletions
libraries
entities-renderer/src
render-utils/src
|
@ -15,8 +15,6 @@
|
|||
#include <PerfStat.h>
|
||||
#include <Transform.h>
|
||||
|
||||
|
||||
|
||||
#include "RenderableTextEntityItem.h"
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
|
@ -31,8 +29,10 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
Q_ASSERT(getType() == EntityTypes::Text);
|
||||
|
||||
static const float SLIGHTLY_BEHIND = -0.005f;
|
||||
glm::vec4 textColor = glm::vec4(toGlm(getTextColorX()), 1.0f);
|
||||
glm::vec4 backgroundColor = glm::vec4(toGlm(getBackgroundColorX()), 1.0f);
|
||||
float fadeRatio = Interpolate::calculateFadeRatio(_fadeStartTime);
|
||||
bool transparent = fadeRatio < 1.0f;
|
||||
glm::vec4 textColor = glm::vec4(toGlm(getTextColorX()), fadeRatio);
|
||||
glm::vec4 backgroundColor = glm::vec4(toGlm(getBackgroundColorX()), fadeRatio);
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
|
||||
// Render background
|
||||
|
@ -62,7 +62,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
|
||||
batch.setModelTransform(transformToTopLeft);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, false, false, false, true);
|
||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, transparent, false, false, true);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, minCorner, maxCorner, backgroundColor);
|
||||
|
||||
float scale = _lineHeight / _textRenderer->getFontSize();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <TextEntityItem.h>
|
||||
#include <TextRenderer3D.h>
|
||||
#include <Interpolate.h>
|
||||
|
||||
#include "RenderableEntityItem.h"
|
||||
|
||||
|
@ -27,10 +28,13 @@ public:
|
|||
|
||||
virtual void render(RenderArgs* args) override;
|
||||
|
||||
bool isTransparent() override { return Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f; }
|
||||
|
||||
SIMPLE_RENDERABLE();
|
||||
|
||||
private:
|
||||
TextRenderer3D* _textRenderer = TextRenderer3D::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
|
||||
quint64 _fadeStartTime { usecTimestampNow() };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void main() {
|
|||
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normal),
|
||||
a,
|
||||
a * Color.a,
|
||||
Color.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
|
|
Loading…
Reference in a new issue