mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 19:00:28 +02:00
stutter fix: only perform fade transactions when depth == 0
This commit is contained in:
parent
43e15c0bc4
commit
aaa92df973
13 changed files with 43 additions and 105 deletions
|
@ -242,8 +242,6 @@
|
|||
#include <raypick/RayPick.h>
|
||||
#include <raypick/MouseTransformNode.h>
|
||||
|
||||
#include <FadeEffect.h>
|
||||
|
||||
#include "ResourceRequestObserver.h"
|
||||
|
||||
#include "webbrowser/WebBrowserSuggestionsEngine.h"
|
||||
|
@ -913,7 +911,6 @@ bool setupEssentials(const QCommandLineParser& parser, bool runningMarkerExisted
|
|||
DependencyManager::set<SelectionScriptingInterface>();
|
||||
DependencyManager::set<TTSScriptingInterface>();
|
||||
|
||||
DependencyManager::set<FadeEffect>();
|
||||
DependencyManager::set<ResourceRequestObserver>();
|
||||
DependencyManager::set<Keyboard>();
|
||||
DependencyManager::set<KeyboardScriptingInterface>();
|
||||
|
|
|
@ -1748,9 +1748,8 @@ ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const Sha
|
|||
if (!std::get<2>(key)) {
|
||||
_pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), std::get<2>(key), wireframe)] = std::make_shared<render::ShapePipeline>(pipeline, nullptr, nullptr, nullptr);
|
||||
} else {
|
||||
const auto& fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
_pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), std::get<2>(key), wireframe)] = std::make_shared<render::ShapePipeline>(pipeline, nullptr,
|
||||
fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
|
||||
FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,28 +17,31 @@
|
|||
#include "render-utils/ShaderConstants.h"
|
||||
#include <PathUtils.h>
|
||||
|
||||
gpu::TexturePointer FadeEffect::_maskMap;
|
||||
|
||||
FadeEffect::FadeEffect() {
|
||||
auto texturePath = PathUtils::resourcesPath() + "images/fadeMask.png";
|
||||
_maskMap = DependencyManager::get<TextureCache>()->getImageTexture(texturePath, image::TextureUsage::STRICT_TEXTURE);
|
||||
std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
auto texturePath = PathUtils::resourcesPath() + "images/fadeMask.png";
|
||||
_maskMap = DependencyManager::get<TextureCache>()->getImageTexture(texturePath, image::TextureUsage::STRICT_TEXTURE);
|
||||
});
|
||||
}
|
||||
|
||||
void FadeEffect::build(render::Task::TaskConcept& task, const task::Varying& editableItems) {
|
||||
void FadeEffect::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) {
|
||||
auto editedFadeCategory = task.addJob<FadeJob>("Fade");
|
||||
auto& fadeJob = task._jobs.back();
|
||||
_configurations = fadeJob.get<FadeJob>().getConfigurationBuffer();
|
||||
|
||||
const auto fadeEditInput = FadeEditJob::Input(editableItems, editedFadeCategory).asVarying();
|
||||
const auto fadeEditInput = FadeEditJob::Input(inputs, editedFadeCategory).asVarying();
|
||||
task.addJob<FadeEditJob>("FadeEdit", fadeEditInput);
|
||||
}
|
||||
|
||||
render::ShapePipeline::BatchSetter FadeEffect::getBatchSetter() const {
|
||||
return [this](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args*) {
|
||||
render::ShapePipeline::BatchSetter FadeEffect::getBatchSetter() {
|
||||
return [](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args*) {
|
||||
batch.setResourceTexture(render_utils::slot::texture::FadeMask, _maskMap);
|
||||
batch.setUniformBuffer(render_utils::slot::buffer::FadeParameters, _configurations);
|
||||
batch.setUniformBuffer(render_utils::slot::buffer::FadeParameters, FadeJob::getConfigurationBuffer());
|
||||
};
|
||||
}
|
||||
|
||||
render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() const {
|
||||
render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() {
|
||||
return [](const render::ShapePipeline& shapePipeline, render::Args* args, const render::Item& item) {
|
||||
if (!render::TransitionStage::isIndexInvalid(item.getTransitionId())) {
|
||||
const auto& scene = args->_scene;
|
||||
|
@ -71,39 +74,3 @@ render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() const {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
render::ShapePipeline::ItemSetter FadeEffect::getItemStoredSetter() {
|
||||
return [this](const render::ShapePipeline& shapePipeline, render::Args* args, const render::Item& item) {
|
||||
if (!render::TransitionStage::isIndexInvalid(item.getTransitionId())) {
|
||||
auto scene = args->_scene;
|
||||
auto transitionStage = scene->getStage<render::TransitionStage>();
|
||||
auto& transitionState = transitionStage->getTransition(item.getTransitionId());
|
||||
const auto fadeCategory = FadeJob::transitionToCategory[transitionState.eventType];
|
||||
|
||||
_lastCategory = fadeCategory;
|
||||
_lastThreshold = transitionState.threshold;
|
||||
_lastNoiseOffset = transitionState.noiseOffset;
|
||||
_lastBaseOffset = transitionState.baseOffset;
|
||||
_lastBaseInvSize = transitionState.baseInvSize;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void FadeEffect::packToAttributes(const int category, const float threshold, const glm::vec3& noiseOffset,
|
||||
const glm::vec3& baseOffset, const glm::vec3& baseInvSize,
|
||||
glm::vec4& packedData1, glm::vec4& packedData2, glm::vec4& packedData3) {
|
||||
packedData1.x = noiseOffset.x;
|
||||
packedData1.y = noiseOffset.y;
|
||||
packedData1.z = noiseOffset.z;
|
||||
packedData1.w = (float)(category+0.1f); // GLSL hack so that casting back from float to int in fragment shader returns the correct value.
|
||||
|
||||
packedData2.x = baseOffset.x;
|
||||
packedData2.y = baseOffset.y;
|
||||
packedData2.z = baseOffset.z;
|
||||
packedData2.w = threshold;
|
||||
|
||||
packedData3.x = baseInvSize.x;
|
||||
packedData3.y = baseInvSize.y;
|
||||
packedData3.z = baseInvSize.z;
|
||||
packedData3.w = 0.f;
|
||||
}
|
||||
|
|
|
@ -11,44 +11,22 @@
|
|||
#ifndef hifi_render_utils_FadeEffect_h
|
||||
#define hifi_render_utils_FadeEffect_h
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <render/Engine.h>
|
||||
|
||||
class FadeEffect : public Dependency {
|
||||
SINGLETON_DEPENDENCY;
|
||||
|
||||
class FadeEffect {
|
||||
public:
|
||||
using Input = render::ItemBounds;
|
||||
using JobModel = render::Task::ModelI<FadeEffect, render::ItemBounds>;
|
||||
|
||||
void build(render::Task::TaskConcept& task, const task::Varying& editableItems);
|
||||
FadeEffect();
|
||||
|
||||
render::ShapePipeline::BatchSetter getBatchSetter() const;
|
||||
render::ShapePipeline::ItemSetter getItemUniformSetter() const;
|
||||
render::ShapePipeline::ItemSetter getItemStoredSetter();
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
||||
|
||||
int getLastCategory() const { return _lastCategory; }
|
||||
float getLastThreshold() const { return _lastThreshold; }
|
||||
const glm::vec3& getLastNoiseOffset() const { return _lastNoiseOffset; }
|
||||
const glm::vec3& getLastBaseOffset() const { return _lastBaseOffset; }
|
||||
const glm::vec3& getLastBaseInvSize() const { return _lastBaseInvSize; }
|
||||
|
||||
static void packToAttributes(const int category, const float threshold, const glm::vec3& noiseOffset,
|
||||
const glm::vec3& baseOffset, const glm::vec3& baseInvSize,
|
||||
glm::vec4& packedData1, glm::vec4& packedData2, glm::vec4& packedData3);
|
||||
static render::ShapePipeline::BatchSetter getBatchSetter();
|
||||
static render::ShapePipeline::ItemSetter getItemUniformSetter();
|
||||
|
||||
private:
|
||||
|
||||
gpu::BufferView _configurations;
|
||||
gpu::TexturePointer _maskMap;
|
||||
|
||||
// The last fade set through the stored item setter
|
||||
int _lastCategory { 0 };
|
||||
float _lastThreshold { 0.f };
|
||||
glm::vec3 _lastNoiseOffset { 0.f, 0.f, 0.f };
|
||||
glm::vec3 _lastBaseOffset { 0.f, 0.f, 0.f };
|
||||
glm::vec3 _lastBaseInvSize { 1.f, 1.f, 1.f };
|
||||
|
||||
explicit FadeEffect();
|
||||
virtual ~FadeEffect() { }
|
||||
|
||||
static gpu::TexturePointer _maskMap;
|
||||
};
|
||||
|
||||
#endif // hifi_render_utils_FadeEffect_h
|
||||
|
|
|
@ -531,6 +531,8 @@ void FadeConfig::load(const QString& configFilePath) {
|
|||
}
|
||||
}
|
||||
|
||||
FadeJob::FadeConfigurationBuffer FadeJob::_configurations;
|
||||
|
||||
FadeJob::FadeJob() {
|
||||
_previousTime = usecTimestampNow();
|
||||
}
|
||||
|
@ -558,6 +560,8 @@ void FadeJob::configure(const Config& config) {
|
|||
|
||||
void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Output& output) {
|
||||
Config* jobConfig = static_cast<Config*>(renderContext->jobConfig.get());
|
||||
output = (FadeCategory)jobConfig->editedCategory;
|
||||
|
||||
auto scene = renderContext->args->_scene;
|
||||
auto transitionStage = scene->getStage<render::TransitionStage>();
|
||||
uint64_t now = usecTimestampNow();
|
||||
|
@ -565,8 +569,6 @@ void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Ou
|
|||
render::Transaction transaction;
|
||||
bool isFirstItem = true;
|
||||
bool hasTransaction = false;
|
||||
|
||||
output = (FadeCategory) jobConfig->editedCategory;
|
||||
|
||||
// And now update fade effect
|
||||
for (auto transitionId : *transitionStage) {
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
void configure(const Config& config);
|
||||
void run(const render::RenderContextPointer& renderContext, FadeJob::Output& output);
|
||||
|
||||
gpu::BufferView getConfigurationBuffer() const { return _configurations; }
|
||||
static gpu::BufferView getConfigurationBuffer() { return _configurations; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -219,7 +219,7 @@ private:
|
|||
};
|
||||
using FadeConfigurationBuffer = gpu::StructBuffer<FadeConfiguration>;
|
||||
|
||||
FadeConfigurationBuffer _configurations;
|
||||
static FadeConfigurationBuffer _configurations;
|
||||
float _thresholdScale[FADE_CATEGORY_COUNT];
|
||||
uint64_t _previousTime{ 0 };
|
||||
|
||||
|
|
|
@ -725,9 +725,8 @@ render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool
|
|||
|
||||
render::ShapePipelinePointer GeometryCache::getFadingShapePipeline(bool textured, bool transparent, bool unlit, bool depthBias, bool forward,
|
||||
graphics::MaterialKey::CullFaceMode cullFaceMode) {
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
auto fadeBatchSetter = fadeEffect->getBatchSetter();
|
||||
auto fadeItemSetter = fadeEffect->getItemUniformSetter();
|
||||
auto fadeBatchSetter = FadeEffect::getBatchSetter();
|
||||
auto fadeItemSetter = FadeEffect::getItemUniformSetter();
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, unlit, depthBias, true, true, forward, cullFaceMode), nullptr,
|
||||
[fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args* args) {
|
||||
batch.setResourceTexture(gr::Texture::MaterialAlbedo, DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
|
|
|
@ -481,8 +481,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
|
|||
std::call_once(once, [] {
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setColorWriteMask(false, false, false, false);
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
initZPassPipelines(*shapePlumber, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
|
||||
initZPassPipelines(*shapePlumber, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter());
|
||||
});
|
||||
auto sharedParameters = std::make_shared<HighlightSharedParameters>();
|
||||
|
||||
|
|
|
@ -357,9 +357,8 @@ public:
|
|||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
PrepareStencil::testMaskDrawShape(*state);
|
||||
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
initMirrorPipelines(*_forwardPipelines, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter(), true);
|
||||
initMirrorPipelines(*_deferredPipelines, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter(), false);
|
||||
initMirrorPipelines(*_forwardPipelines, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter(), true);
|
||||
initMirrorPipelines(*_deferredPipelines, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter(), false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -101,12 +101,11 @@ void RenderDeferredTask::configure(const Config& config) {
|
|||
}
|
||||
|
||||
void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, size_t depth) {
|
||||
static auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
// Prepare the ShapePipelines
|
||||
static ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
initDeferredPipelines(*shapePlumber, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
|
||||
initDeferredPipelines(*shapePlumber, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter());
|
||||
});
|
||||
|
||||
const auto& inputs = input.get<Input>();
|
||||
|
@ -146,7 +145,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
// Shadow Stage Frame
|
||||
const auto shadowFrame = shadowTaskOutputs[1];
|
||||
|
||||
fadeEffect->build(task, opaques);
|
||||
if (depth == 0) {
|
||||
task.addJob<FadeEffect>("FadeEffect", opaques);
|
||||
}
|
||||
|
||||
const auto jitter = task.addJob<JitterSample>("JitterCam");
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "render-utils/ShaderConstants.h"
|
||||
#include "StencilMaskPass.h"
|
||||
#include "ZoneRenderer.h"
|
||||
#include "FadeEffect.h"
|
||||
#include "ToneMapAndResampleTask.h"
|
||||
#include "BackgroundStage.h"
|
||||
#include "FramebufferCache.h"
|
||||
|
@ -72,7 +71,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
|||
task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::FORWARD);
|
||||
|
||||
// Prepare the ShapePipelines
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
static ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
|
@ -112,9 +110,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
|||
|
||||
const auto& zones = lightingStageInputs[1];
|
||||
|
||||
// First job, alter faded
|
||||
fadeEffect->build(task, opaques);
|
||||
|
||||
// GPU jobs: Start preparing the main framebuffer
|
||||
const auto scaledPrimaryFramebuffer = task.addJob<PreparePrimaryFramebufferMSAA>("PreparePrimaryBufferForward");
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
|
|||
static ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
initZPassPipelines(*shapePlumber, std::make_shared<gpu::State>(), fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
|
||||
initZPassPipelines(*shapePlumber, std::make_shared<gpu::State>(), FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter());
|
||||
});
|
||||
|
||||
const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup", input);
|
||||
|
|
|
@ -30,7 +30,10 @@ gpu::PipelinePointer DrawSceneOctree::_drawItemBoundPipeline;
|
|||
gpu::Stream::FormatPointer DrawSceneOctree::_cellBoundsFormat = std::make_shared<gpu::Stream::Format>();
|
||||
|
||||
DrawSceneOctree::DrawSceneOctree() {
|
||||
_cellBoundsFormat->setAttribute(0, 0, gpu::Element(gpu::VEC4, gpu::INT32, gpu::XYZW), 0, gpu::Stream::PER_INSTANCE);
|
||||
std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
_cellBoundsFormat->setAttribute(0, 0, gpu::Element(gpu::VEC4, gpu::INT32, gpu::XYZW), 0, gpu::Stream::PER_INSTANCE);
|
||||
});
|
||||
}
|
||||
|
||||
const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
|
||||
|
|
Loading…
Reference in a new issue