mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Introducing the HUD layer rendering pass into it s own task and file
This commit is contained in:
parent
c30e65350a
commit
e5a772a9b8
7 changed files with 102 additions and 59 deletions
|
@ -106,34 +106,6 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs&
|
|||
}
|
||||
}
|
||||
|
||||
void CompositeHUD::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& inputs) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_context);
|
||||
|
||||
// We do not want to render HUD elements in secondary camera
|
||||
if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the HUD texture
|
||||
#if !defined(DISABLE_QML)
|
||||
gpu::doInBatch("CompositeHUD", renderContext->args->_context, [&](gpu::Batch& batch) {
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
renderContext->args->getViewFrustum().evalProjectionMatrix(projMat);
|
||||
renderContext->args->getViewFrustum().evalViewTransform(viewMat);
|
||||
batch.setProjectionTransform(projMat);
|
||||
batch.setViewTransform(viewMat, true);
|
||||
if (inputs) {
|
||||
batch.setFramebuffer(inputs);
|
||||
}
|
||||
if (renderContext->args->_hudOperator) {
|
||||
renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void Blit::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_context);
|
||||
|
|
|
@ -77,16 +77,6 @@ protected:
|
|||
bool _opaquePass { true };
|
||||
};
|
||||
|
||||
class CompositeHUD {
|
||||
public:
|
||||
// IF specified the input Framebuffer is actively set by the batch of this job before calling the HUDOperator.
|
||||
// If not, the current Framebuffer is left unchanged.
|
||||
//using Inputs = gpu::FramebufferPointer;
|
||||
using JobModel = render::Job::ModelI<CompositeHUD, gpu::FramebufferPointer>;
|
||||
|
||||
void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& inputs);
|
||||
};
|
||||
|
||||
class Blit {
|
||||
public:
|
||||
using JobModel = render::Job::ModelI<Blit, gpu::FramebufferPointer>;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "FadeEffect.h"
|
||||
#include "BloomStage.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
#include "RenderHUDLayerTask.h"
|
||||
|
||||
#include "AmbientOcclusionEffect.h"
|
||||
#include "AntialiasingEffect.h"
|
||||
|
@ -232,8 +233,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
task.addJob<DrawLayered3D>("DrawInFrontOpaque", inFrontOpaquesInputs, true);
|
||||
task.addJob<DrawLayered3D>("DrawInFrontTransparent", inFrontTransparentsInputs, false);
|
||||
|
||||
const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneLayeredAntialiasing");
|
||||
|
||||
// AA job before bloom to limit flickering
|
||||
const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, lightingFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
|
||||
task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
|
||||
|
@ -257,16 +256,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
// Upscale to finale resolution
|
||||
const auto primaryFramebuffer = task.addJob<render::Upsample>("PrimaryBufferUpscale", scaledPrimaryFramebuffer);
|
||||
|
||||
// Composite the HUD and HUD overlays
|
||||
task.addJob<CompositeHUD>("HUD", primaryFramebuffer);
|
||||
|
||||
const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f));
|
||||
const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying();
|
||||
const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying();
|
||||
task.addJob<DrawLayered3D>("DrawHUDOpaque", hudOpaquesInputs, true);
|
||||
task.addJob<DrawLayered3D>("DrawHUDTransparent", hudTransparentsInputs, false);
|
||||
|
||||
task.addJob<EndGPURangeTimer>("ToneAndPostRangeTimer", toneAndPostRangeTimer);
|
||||
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying();
|
||||
task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs);
|
||||
|
||||
// Blit!
|
||||
task.addJob<Blit>("Blit", primaryFramebuffer);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "FramebufferCache.h"
|
||||
#include "TextureCache.h"
|
||||
#include "RenderCommonTask.h"
|
||||
#include "RenderHUDLayerTask.h"
|
||||
|
||||
namespace ru {
|
||||
using render_utils::slot::texture::Texture;
|
||||
|
@ -168,14 +169,9 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
|||
|
||||
#endif
|
||||
|
||||
// Layered Overlays
|
||||
// Composite the HUD and HUD overlays
|
||||
task.addJob<CompositeHUD>("HUD", primaryFramebuffer);
|
||||
|
||||
const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying();
|
||||
const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying();
|
||||
task.addJob<DrawLayered3D>("DrawHUDOpaque", hudOpaquesInputs, true);
|
||||
task.addJob<DrawLayered3D>("DrawHUDTransparent", hudTransparentsInputs, false);
|
||||
// HUD Layer
|
||||
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying();
|
||||
task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs);
|
||||
|
||||
// Disable blit because we do tonemapping and compositing directly to the blit FBO
|
||||
// Blit!
|
||||
|
|
60
libraries/render-utils/src/RenderHUDLayerTask.cpp
Normal file
60
libraries/render-utils/src/RenderHUDLayerTask.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Created by Sam Gateau on 2019/06/14
|
||||
// Copyright 2013-2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "RenderHUDLayerTask.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include "RenderCommonTask.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
void CompositeHUD::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& inputs) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_context);
|
||||
|
||||
// We do not want to render HUD elements in secondary camera
|
||||
if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the HUD texture
|
||||
#if !defined(DISABLE_QML)
|
||||
gpu::doInBatch("CompositeHUD", renderContext->args->_context, [&](gpu::Batch& batch) {
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
renderContext->args->getViewFrustum().evalProjectionMatrix(projMat);
|
||||
renderContext->args->getViewFrustum().evalViewTransform(viewMat);
|
||||
batch.setProjectionTransform(projMat);
|
||||
batch.setViewTransform(viewMat, true);
|
||||
if (inputs) {
|
||||
batch.setFramebuffer(inputs);
|
||||
}
|
||||
if (renderContext->args->_hudOperator) {
|
||||
renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderHUDLayerTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
||||
const auto& inputs = input.get<Input>();
|
||||
|
||||
const auto& primaryFramebuffer = inputs[0];
|
||||
const auto& lightingModel = inputs[1];
|
||||
const auto& hudOpaque = inputs[2];
|
||||
const auto& hudTransparent = inputs[3];
|
||||
|
||||
// Composite the HUD and HUD overlays
|
||||
task.addJob<CompositeHUD>("HUD", primaryFramebuffer);
|
||||
|
||||
// And HUD Layer objects
|
||||
const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f));
|
||||
const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying();
|
||||
const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying();
|
||||
task.addJob<DrawLayered3D>("DrawHUDOpaque", hudOpaquesInputs, true);
|
||||
task.addJob<DrawLayered3D>("DrawHUDTransparent", hudTransparentsInputs, false);
|
||||
}
|
34
libraries/render-utils/src/RenderHUDLayerTask.h
Normal file
34
libraries/render-utils/src/RenderHUDLayerTask.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by Sam Gateau on 2019/06/14
|
||||
// Copyright 2013-2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_RenderHUDLayerTask_h
|
||||
#define hifi_RenderHUDLayerTask_h
|
||||
|
||||
#include "LightingModel.h"
|
||||
|
||||
|
||||
class CompositeHUD {
|
||||
public:
|
||||
// IF specified the input Framebuffer is actively set by the batch of this job before calling the HUDOperator.
|
||||
// If not, the current Framebuffer is left unchanged.
|
||||
//using Inputs = gpu::FramebufferPointer;
|
||||
using JobModel = render::Job::ModelI<CompositeHUD, gpu::FramebufferPointer>;
|
||||
|
||||
void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& inputs);
|
||||
};
|
||||
|
||||
class RenderHUDLayerTask {
|
||||
public:
|
||||
// Framebuffer where to draw, lighting model, opaque items, transparent items
|
||||
using Input = render::VaryingSet4<gpu::FramebufferPointer, LightingModelPointer, render::ItemBounds, render::ItemBounds>;
|
||||
using JobModel = render::Task::ModelI<RenderHUDLayerTask, Input>;
|
||||
|
||||
void build(JobModel& task, const render::Varying& input, render::Varying& output);
|
||||
};
|
||||
|
||||
#endif // hifi_RenderHUDLayerTask_h
|
|
@ -35,7 +35,7 @@ Column {
|
|||
object: Render
|
||||
property: "viewportResolutionScale"
|
||||
min: 0.1
|
||||
max: 2.0
|
||||
max: 1.1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue