mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 12:33:37 +02:00
try to fade in web entities
This commit is contained in:
parent
27bacc9165
commit
7713c1f4bf
7 changed files with 20 additions and 6 deletions
libraries
|
@ -19,7 +19,7 @@ namespace render {
|
|||
if (payload->entity->getType() == EntityTypes::Light) {
|
||||
return ItemKey::Builder::light();
|
||||
}
|
||||
if (payload && (payload->entity->getType() == EntityTypes::PolyLine || payload->entity->isTransparent())) {
|
||||
if (payload && payload->entity->isTransparent()) {
|
||||
return ItemKey::Builder::transparentShape();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
virtual void update(const quint64& now) override;
|
||||
virtual bool needsToCallUpdate() const override { return true; };
|
||||
|
||||
bool isTransparent() override { return true; }
|
||||
|
||||
SIMPLE_RENDERABLE();
|
||||
|
||||
NetworkTexturePointer _texture;
|
||||
|
|
|
@ -181,6 +181,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
if (!buildWebSurface(static_cast<EntityTreeRenderer*>(args->_renderer))) {
|
||||
return;
|
||||
}
|
||||
_fadeStartTime = usecTimestampNow();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -208,10 +209,13 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
batch._glActiveBindTexture(GL_TEXTURE0, GL_TEXTURE_2D, _texture);
|
||||
textured = emissive = true;
|
||||
}
|
||||
bool transparent = false;
|
||||
|
||||
float fadeRatio = Interpolate::calculateFadeRatio(_fadeStartTime);
|
||||
bool transparent = fadeRatio < 1.0f;
|
||||
batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, textured, transparent, culled, emissive);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QSharedPointer>
|
||||
|
||||
#include <WebEntityItem.h>
|
||||
#include <Interpolate.h>
|
||||
|
||||
#include "RenderableEntityItem.h"
|
||||
|
||||
|
@ -35,6 +36,8 @@ public:
|
|||
void update(const quint64& now) override;
|
||||
bool needsToCallUpdate() const override { return _webSurface != nullptr; }
|
||||
|
||||
bool isTransparent() override { return Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f; }
|
||||
|
||||
SIMPLE_RENDERABLE();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +56,8 @@ private:
|
|||
QMetaObject::Connection _mouseReleaseConnection;
|
||||
QMetaObject::Connection _mouseMoveConnection;
|
||||
QMetaObject::Connection _hoverLeaveConnection;
|
||||
|
||||
quint64 _fadeStartTime;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ void main(void) {
|
|||
|
||||
#endif
|
||||
|
||||
if (_color.a < 1.0) {
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (_color.a < ALPHA_THRESHOLD) {
|
||||
if (emissiveAmount > 0.0) {
|
||||
// TODO: transparent emissive?
|
||||
packDeferredFragmentTranslucent(
|
||||
|
|
|
@ -30,7 +30,8 @@ void main(void) {
|
|||
texel = colorToLinearRGBA(texel);
|
||||
}
|
||||
|
||||
if (_color.a * texel.a < 1.0) {
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (_color.a * texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normal),
|
||||
_color.a * texel.a,
|
||||
|
|
|
@ -29,7 +29,8 @@ void main(void) {
|
|||
texel = colorToLinearRGBA(texel);
|
||||
}
|
||||
|
||||
if (_color.a * texel.a < 1.0) {
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (_color.a * texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normal),
|
||||
_color.a * texel.a,
|
||||
|
|
Loading…
Reference in a new issue