try to fade in web entities

This commit is contained in:
SamGondelman 2016-08-03 15:56:41 -07:00
parent 27bacc9165
commit 7713c1f4bf
7 changed files with 20 additions and 6 deletions

View file

@ -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();
}
}

View file

@ -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;

View file

@ -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) {

View file

@ -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;
};

View file

@ -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(

View file

@ -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,

View file

@ -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,