mirror of
https://github.com/overte-org/overte.git
synced 2025-08-15 04:44:19 +02:00
Removed fade transition on shape entities. Fixed broken custom shaders on shapes
This commit is contained in:
parent
490aad2a06
commit
0415364c0e
1 changed files with 38 additions and 3 deletions
|
@ -19,7 +19,11 @@
|
|||
|
||||
#include <render-utils/simple_vert.h>
|
||||
#include <render-utils/simple_frag.h>
|
||||
#include <FadeEffect.h>
|
||||
|
||||
//#define USE_FADE_EFFECT
|
||||
#ifdef USE_FADE_EFFECT
|
||||
# include <FadeEffect.h>
|
||||
#endif
|
||||
|
||||
// Sphere entities should fit inside a cube entity of the same size, so a sphere that has dimensions 1x1x1
|
||||
// is a half unit sphere. However, the geometry cache renders a UNIT sphere, so we need to scale down.
|
||||
|
@ -74,7 +78,17 @@ void RenderableShapeEntityItem::setUserData(const QString& value) {
|
|||
}
|
||||
|
||||
bool RenderableShapeEntityItem::isTransparent() {
|
||||
#ifdef USE_FADE_EFFECT
|
||||
return getLocalRenderAlpha() < 1.0f;
|
||||
#else
|
||||
if (_procedural && _procedural->isFading()) {
|
||||
float isFading = Interpolate::calculateFadeRatio(_procedural->getFadeStartTime()) < 1.0f;
|
||||
_procedural->setIsFading(isFading);
|
||||
return isFading;
|
||||
} else {
|
||||
return getLocalRenderAlpha() < 1.0f || EntityItem::isTransparent();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace render {
|
||||
|
@ -92,7 +106,10 @@ namespace render {
|
|||
}
|
||||
|
||||
template <> const ShapeKey shapeGetShapeKey(const ShapePayload::Pointer& payload) {
|
||||
auto shapeKey = ShapeKey::Builder().withCustom(GeometryCache::CUSTOM_PIPELINE_NUMBER);
|
||||
auto shapeKey = ShapeKey::Builder();
|
||||
#ifdef USE_FADE_EFFECT
|
||||
shapeKey.withCustom(GeometryCache::CUSTOM_PIPELINE_NUMBER);
|
||||
#endif
|
||||
auto entity = payload->_entity;
|
||||
if (entity->getLocalRenderAlpha() < 1.f) {
|
||||
shapeKey.withTranslucent();
|
||||
|
@ -112,8 +129,9 @@ bool RenderableShapeEntityItem::addToScene(const EntityItemPointer& self, const
|
|||
renderPayload->addStatusGetters(statusGetters);
|
||||
|
||||
transaction.resetItem(_myItem, renderPayload);
|
||||
#ifdef USE_FADE_EFFECT
|
||||
transaction.addTransitionToItem(_myItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -121,6 +139,9 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
PerformanceTimer perfTimer("RenderableShapeEntityItem::render");
|
||||
//Q_ASSERT(getType() == EntityTypes::Shape);
|
||||
Q_ASSERT(args->_batch);
|
||||
#ifndef USE_FADE_EFFECT
|
||||
checkFading();
|
||||
#endif
|
||||
|
||||
if (!_procedural) {
|
||||
_procedural.reset(new Procedural(getUserData()));
|
||||
|
@ -148,6 +169,9 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
if (_procedural->ready()) {
|
||||
_procedural->prepare(batch, getPosition(), getDimensions(), getOrientation());
|
||||
auto outColor = _procedural->getColor(color);
|
||||
#ifndef USE_FADE_EFFECT
|
||||
outColor.a *= _procedural->isFading() ? Interpolate::calculateFadeRatio(_procedural->getFadeStartTime()) : 1.0f;
|
||||
#endif
|
||||
batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a);
|
||||
if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
|
||||
DependencyManager::get<GeometryCache>()->renderWireShape(batch, MAPPING[_shape]);
|
||||
|
@ -157,6 +181,7 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
} else {
|
||||
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
#ifdef USE_FADE_EFFECT
|
||||
auto shapeKey = render::ShapeKey(args->_itemShapeKey);
|
||||
|
||||
assert(args->_shapePipeline != nullptr);
|
||||
|
@ -185,6 +210,16 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
geometryCache->renderSolidShapeInstance(args, batch, MAPPING[_shape], color, args->_shapePipeline);
|
||||
}
|
||||
}
|
||||
#else
|
||||
color.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||
auto pipeline = color.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
|
||||
if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
|
||||
geometryCache->renderWireShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
|
||||
}
|
||||
else {
|
||||
geometryCache->renderSolidShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const auto triCount = DependencyManager::get<GeometryCache>()->getShapeTriangleCount(MAPPING[_shape]);
|
||||
|
|
Loading…
Reference in a new issue