mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Removed transparency on fading shapes
This commit is contained in:
parent
db7871fca7
commit
f8b2ffe359
3 changed files with 28 additions and 16 deletions
|
@ -73,13 +73,7 @@ void RenderableShapeEntityItem::setUserData(const QString& value) {
|
|||
}
|
||||
|
||||
bool RenderableShapeEntityItem::isTransparent() {
|
||||
if (_procedural && _procedural->isFading()) {
|
||||
float isFading = Interpolate::calculateFadeRatio(_procedural->getFadeStartTime()) < 1.0f;
|
||||
_procedural->setIsFading(isFading);
|
||||
return isFading;
|
||||
} else {
|
||||
return getLocalRenderAlpha() < 1.0f || EntityItem::isTransparent();
|
||||
}
|
||||
return getLocalRenderAlpha() < 1.0f || EntityItem::isTransparent();
|
||||
}
|
||||
|
||||
namespace render {
|
||||
|
@ -148,7 +142,6 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
if (_procedural->ready()) {
|
||||
_procedural->prepare(batch, getPosition(), getDimensions(), getOrientation());
|
||||
auto outColor = _procedural->getColor(color);
|
||||
outColor.a *= _procedural->isFading() ? Interpolate::calculateFadeRatio(_procedural->getFadeStartTime()) : 1.0f;
|
||||
batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a);
|
||||
if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
|
||||
DependencyManager::get<GeometryCache>()->renderWireShape(batch, MAPPING[_shape]);
|
||||
|
@ -156,7 +149,6 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
DependencyManager::get<GeometryCache>()->renderShape(batch, MAPPING[_shape]);
|
||||
}
|
||||
} else {
|
||||
color.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
auto pipeline = color.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "TextureCache.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
#include "StencilMaskPass.h"
|
||||
#include "FadeEffect.h"
|
||||
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
|
||||
|
@ -543,15 +544,16 @@ void GeometryCache::initializeShapePipelines() {
|
|||
if (!_simpleOpaquePipeline) {
|
||||
_simpleOpaquePipeline = getShapePipeline(false, false, true, false);
|
||||
_simpleTransparentPipeline = getShapePipeline(false, true, true, false);
|
||||
_simpleOpaqueFadePipeline = getShapePipeline(false, false, true, false, false, true);
|
||||
_simpleTransparentFadePipeline = getShapePipeline(false, true, true, false, false, true);
|
||||
_simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, true, false, false);
|
||||
_simpleTransparentFadePipeline = getFadingShapePipeline(false, true, true, false, false);
|
||||
_simpleWirePipeline = getShapePipeline(false, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool transparent, bool culled,
|
||||
bool unlit, bool depthBias, bool fading) {
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, fading), nullptr,
|
||||
bool unlit, bool depthBias) {
|
||||
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, false), nullptr,
|
||||
[](const render::ShapePipeline&, gpu::Batch& batch, render::Args*) {
|
||||
// Set the defaults needed for a simple program
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||
|
@ -560,6 +562,22 @@ render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool
|
|||
);
|
||||
}
|
||||
|
||||
render::ShapePipelinePointer GeometryCache::getFadingShapePipeline(bool textured, bool transparent, bool culled,
|
||||
bool unlit, bool depthBias) {
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
auto fadeBatchSetter = fadeEffect->getBatchSetter();
|
||||
auto fadeItemSetter = fadeEffect->getItemSetter();
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, true), nullptr,
|
||||
[fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& pipeline, gpu::Batch& batch, render::Args* args) {
|
||||
// Set the defaults needed for a simple program
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
fadeBatchSetter(pipeline, batch, args);
|
||||
},
|
||||
fadeItemSetter
|
||||
);
|
||||
}
|
||||
|
||||
render::ShapePipelinePointer GeometryCache::getOpaqueShapePipeline(bool isFading) {
|
||||
return isFading ? _simpleOpaqueFadePipeline : _simpleOpaquePipeline;
|
||||
}
|
||||
|
|
|
@ -174,9 +174,6 @@ public:
|
|||
|
||||
static void initializeShapePipelines();
|
||||
|
||||
static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true,
|
||||
bool unlit = false, bool depthBias = false, bool fading = false);
|
||||
|
||||
render::ShapePipelinePointer getOpaqueShapePipeline() { assert(_simpleOpaquePipeline != nullptr); return _simpleOpaquePipeline; }
|
||||
render::ShapePipelinePointer getTransparentShapePipeline() { assert(_simpleTransparentPipeline != nullptr); return _simpleTransparentPipeline; }
|
||||
render::ShapePipelinePointer getOpaqueFadeShapePipeline() { assert(_simpleOpaqueFadePipeline != nullptr); return _simpleOpaqueFadePipeline; }
|
||||
|
@ -458,6 +455,11 @@ private:
|
|||
gpu::PipelinePointer _simpleOpaqueWebBrowserOverlayPipeline;
|
||||
gpu::ShaderPointer _simpleTransparentWebBrowserOverlayShader;
|
||||
gpu::PipelinePointer _simpleTransparentWebBrowserOverlayPipeline;
|
||||
|
||||
static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true,
|
||||
bool unlit = false, bool depthBias = false);
|
||||
static render::ShapePipelinePointer getFadingShapePipeline(bool textured = false, bool transparent = false, bool culled = true,
|
||||
bool unlit = false, bool depthBias = false);
|
||||
};
|
||||
|
||||
#endif // hifi_GeometryCache_h
|
||||
|
|
Loading…
Reference in a new issue