mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
Drafting ways to rescale in forward
This commit is contained in:
parent
6485809c82
commit
5288314d02
9 changed files with 166 additions and 56 deletions
|
@ -37,7 +37,7 @@ void RenderScriptingInterface::loadSettings() {
|
||||||
forceAntialiasingEnabled(_antialiasingEnabled);
|
forceAntialiasingEnabled(_antialiasingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() {
|
RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() const {
|
||||||
return (RenderMethod) _renderMethod;
|
return (RenderMethod) _renderMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const {
|
||||||
return refrenderMethodNames;
|
return refrenderMethodNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getShadowsEnabled() {
|
bool RenderScriptingInterface::getShadowsEnabled() const {
|
||||||
return _shadowsEnabled;
|
return _shadowsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getAmbientOcclusionEnabled() {
|
bool RenderScriptingInterface::getAmbientOcclusionEnabled() const {
|
||||||
return _ambientOcclusionEnabled;
|
return _ambientOcclusionEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderScriptingInterface::getAntialiasingEnabled() {
|
bool RenderScriptingInterface::getAntialiasingEnabled() const {
|
||||||
return _antialiasingEnabled;
|
return _antialiasingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,3 +145,47 @@ void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float RenderScriptingInterface::getViewportResolutionScale() const {
|
||||||
|
return _viewportResolutionScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderScriptingInterface::setViewportResolutionScale(float scale) {
|
||||||
|
if (_viewportResolutionScale != scale) {
|
||||||
|
forceViewportResolutionScale(scale);
|
||||||
|
emit settingsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderScriptingInterface::forceViewportResolutionScale(float scale) {
|
||||||
|
_renderSettingLock.withWriteLock([&] {
|
||||||
|
_viewportResolutionScale = (scale);
|
||||||
|
// _antialiasingEnabledSetting.set(enabled);
|
||||||
|
|
||||||
|
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
|
||||||
|
assert(renderConfig);
|
||||||
|
auto deferredView = renderConfig->getConfig("RenderMainView.RenderDeferredTask");
|
||||||
|
// mainView can be null if we're rendering in forward mode
|
||||||
|
if (deferredView) {
|
||||||
|
deferredView->setProperty("resolutionScale", _viewportResolutionScale);
|
||||||
|
}
|
||||||
|
auto forwardView = renderConfig->getConfig("RenderMainView.RenderForwardTask");
|
||||||
|
// mainView can be null if we're rendering in forward mode
|
||||||
|
if (forwardView) {
|
||||||
|
forwardView->setProperty("resolutionScale", _viewportResolutionScale);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
|
||||||
|
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
|
||||||
|
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
|
||||||
|
if (enabled) {
|
||||||
|
mainViewJitterCamConfig->play();
|
||||||
|
mainViewAntialiasingConfig->setDebugFXAA(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainViewJitterCamConfig->none();
|
||||||
|
mainViewAntialiasingConfig->setDebugFXAA(true);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class RenderScriptingInterface : public QObject {
|
||||||
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged)
|
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged)
|
||||||
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged)
|
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged)
|
||||||
Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged)
|
Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled NOTIFY settingsChanged)
|
||||||
|
Q_PROPERTY(float viewportResolutionScale READ getViewportResolutionScale WRITE setViewportResolutionScale NOTIFY settingsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderScriptingInterface();
|
RenderScriptingInterface();
|
||||||
|
@ -66,7 +67,7 @@ public slots:
|
||||||
* @function Render.getRenderMethod
|
* @function Render.getRenderMethod
|
||||||
* @returns {number} <code>"DEFERRED"</code> or <code>"FORWARD"</code>
|
* @returns {number} <code>"DEFERRED"</code> or <code>"FORWARD"</code>
|
||||||
*/
|
*/
|
||||||
RenderMethod getRenderMethod();
|
RenderMethod getRenderMethod() const;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Sets the current render method
|
* Sets the current render method
|
||||||
|
@ -88,7 +89,7 @@ public slots:
|
||||||
* @function Render.getShadowsEnabled
|
* @function Render.getShadowsEnabled
|
||||||
* @returns {bool} <code>true</code> if shadows are enabled, otherwise <code>false</code>
|
* @returns {bool} <code>true</code> if shadows are enabled, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
bool getShadowsEnabled();
|
bool getShadowsEnabled() const;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Enables or disables shadows
|
* Enables or disables shadows
|
||||||
|
@ -102,7 +103,7 @@ public slots:
|
||||||
* @function Render.getAmbientOcclusionEnabled
|
* @function Render.getAmbientOcclusionEnabled
|
||||||
* @returns {bool} <code>true</code> if ambient occlusion is enabled, otherwise <code>false</code>
|
* @returns {bool} <code>true</code> if ambient occlusion is enabled, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
bool getAmbientOcclusionEnabled();
|
bool getAmbientOcclusionEnabled() const;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Enables or disables ambient occlusion
|
* Enables or disables ambient occlusion
|
||||||
|
@ -116,7 +117,7 @@ public slots:
|
||||||
* @function Render.getAntialiasingEnabled
|
* @function Render.getAntialiasingEnabled
|
||||||
* @returns {bool} <code>true</code> if anti-aliasing is enabled, otherwise <code>false</code>
|
* @returns {bool} <code>true</code> if anti-aliasing is enabled, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
bool getAntialiasingEnabled();
|
bool getAntialiasingEnabled() const;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Enables or disables anti-aliasing
|
* Enables or disables anti-aliasing
|
||||||
|
@ -130,14 +131,14 @@ public slots:
|
||||||
* @function Render.getViewportResolutionScale
|
* @function Render.getViewportResolutionScale
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
// float getViewportResolutionScale();
|
float getViewportResolutionScale() const;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Sets the current viewport resolution scale
|
* Sets the current viewport resolution scale
|
||||||
* @function Render.setViewportResolutionScale
|
* @function Render.setViewportResolutionScale
|
||||||
* @param {number} resolutionScale - between epsilon and 1.0
|
* @param {number} resolutionScale - between epsilon and 1.0
|
||||||
*/
|
*/
|
||||||
// void setViewportResolutionScale(float resolutionScale);
|
void setViewportResolutionScale(float resolutionScale);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
@ -151,6 +152,7 @@ private:
|
||||||
bool _shadowsEnabled{ true };
|
bool _shadowsEnabled{ true };
|
||||||
bool _ambientOcclusionEnabled{ false };
|
bool _ambientOcclusionEnabled{ false };
|
||||||
bool _antialiasingEnabled{ true };
|
bool _antialiasingEnabled{ true };
|
||||||
|
float _viewportResolutionScale{ 1.0f };
|
||||||
|
|
||||||
// Actual settings saved on disk
|
// Actual settings saved on disk
|
||||||
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
|
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
|
||||||
|
@ -163,6 +165,7 @@ private:
|
||||||
void forceShadowsEnabled(bool enabled);
|
void forceShadowsEnabled(bool enabled);
|
||||||
void forceAmbientOcclusionEnabled(bool enabled);
|
void forceAmbientOcclusionEnabled(bool enabled);
|
||||||
void forceAntialiasingEnabled(bool enabled);
|
void forceAntialiasingEnabled(bool enabled);
|
||||||
|
void forceViewportResolutionScale(float scale);
|
||||||
|
|
||||||
static std::once_flag registry_flag;
|
static std::once_flag registry_flag;
|
||||||
};
|
};
|
||||||
|
|
|
@ -313,7 +313,7 @@ gpu::FramebufferPointer PreparePrimaryFramebuffer::createFramebuffer(const char*
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreparePrimaryFramebuffer::configure(const Config& config) {
|
void PreparePrimaryFramebuffer::configure(const Config& config) {
|
||||||
_resolutionScale = config.resolutionScale;
|
_resolutionScale = config.getResolutionScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreparePrimaryFramebuffer::run(const RenderContextPointer& renderContext, Output& primaryFramebuffer) {
|
void PreparePrimaryFramebuffer::run(const RenderContextPointer& renderContext, Output& primaryFramebuffer) {
|
||||||
|
|
|
@ -89,13 +89,18 @@ private:
|
||||||
|
|
||||||
class PreparePrimaryFramebufferConfig : public render::Job::Config {
|
class PreparePrimaryFramebufferConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float resolutionScale MEMBER resolutionScale NOTIFY dirty)
|
Q_PROPERTY(float resolutionScale WRITE setResolutionScale READ getResolutionScale)
|
||||||
public:
|
public:
|
||||||
|
float getResolutionScale() const { return resolutionScale; }
|
||||||
float resolutionScale{ 1.0f };
|
void setResolutionScale(float scale) {
|
||||||
|
resolutionScale = std::max(0.1f, std::min(1.0f, resolutionScale));
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float resolutionScale{ 1.0f };
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreparePrimaryFramebuffer {
|
class PreparePrimaryFramebuffer {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "LightStage.h"
|
#include "LightStage.h"
|
||||||
#include "LightingModel.h"
|
#include "LightingModel.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BeginGPURangeTimer {
|
class BeginGPURangeTimer {
|
||||||
public:
|
public:
|
||||||
using JobModel = render::Job::ModelO<BeginGPURangeTimer, gpu::RangeTimerPointer>;
|
using JobModel = render::Job::ModelO<BeginGPURangeTimer, gpu::RangeTimerPointer>;
|
||||||
|
|
|
@ -99,7 +99,7 @@ void RenderDeferredTask::configure(const Config& config) {
|
||||||
auto upsamplePrimaryBufferConfig = config.getConfig<Upsample>("PrimaryBufferUpscale");
|
auto upsamplePrimaryBufferConfig = config.getConfig<Upsample>("PrimaryBufferUpscale");
|
||||||
assert(preparePrimaryBufferConfig);
|
assert(preparePrimaryBufferConfig);
|
||||||
assert(upsamplePrimaryBufferConfig);
|
assert(upsamplePrimaryBufferConfig);
|
||||||
preparePrimaryBufferConfig->setProperty("resolutionScale", config.resolutionScale);
|
preparePrimaryBufferConfig->setResolutionScale(config.resolutionScale);
|
||||||
upsamplePrimaryBufferConfig->setProperty("factor", 1.0f / config.resolutionScale);
|
upsamplePrimaryBufferConfig->setProperty("factor", 1.0f / config.resolutionScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,16 @@ using namespace render;
|
||||||
|
|
||||||
extern void initForwardPipelines(ShapePlumber& plumber);
|
extern void initForwardPipelines(ShapePlumber& plumber);
|
||||||
|
|
||||||
|
void RenderForwardTask::configure(const Config& config) {
|
||||||
|
// Propagate resolution scale to sub jobs who need it
|
||||||
|
auto preparePrimaryBufferConfig = config.getConfig<PreparePrimaryFramebufferMSAA>("PreparePrimaryBuffer");
|
||||||
|
// auto upsamplePrimaryBufferConfig = config.getConfig<Upsample>("PrimaryBufferUpscale");
|
||||||
|
assert(preparePrimaryBufferConfig);
|
||||||
|
// assert(upsamplePrimaryBufferConfig);
|
||||||
|
preparePrimaryBufferConfig->setResolutionScale(config.resolutionScale);
|
||||||
|
// upsamplePrimaryBufferConfig->setProperty("factor", 1.0f / config.resolutionScale);
|
||||||
|
}
|
||||||
|
|
||||||
void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
||||||
task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::FORWARD);
|
task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::FORWARD);
|
||||||
|
|
||||||
|
@ -87,16 +97,19 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
// First job, alter faded
|
// First job, alter faded
|
||||||
fadeEffect->build(task, opaques);
|
fadeEffect->build(task, opaques);
|
||||||
|
|
||||||
// Prepare objects shared by several jobs
|
|
||||||
const auto deferredFrameTransform = task.addJob<GenerateDeferredFrameTransform>("DeferredFrameTransform");
|
|
||||||
|
|
||||||
// GPU jobs: Start preparing the main framebuffer
|
// GPU jobs: Start preparing the main framebuffer
|
||||||
const auto framebuffer = task.addJob<PrepareFramebuffer>("PrepareFramebuffer");
|
const auto scaledPrimaryFramebuffer = task.addJob<PreparePrimaryFramebufferMSAA>("PreparePrimaryBuffer");
|
||||||
|
|
||||||
task.addJob<PrepareForward>("PrepareForward", lightFrame);
|
// Prepare deferred, generate the shared Deferred Frame Transform. Only valid with the scaled frame buffer
|
||||||
|
const auto deferredFrameTransform = task.addJob<GenerateDeferredFrameTransform>("DeferredFrameTransform");
|
||||||
|
|
||||||
|
// Prepare Forward Framebuffer pass
|
||||||
|
const auto prepareForwardInputs = PrepareForward::Inputs(scaledPrimaryFramebuffer, lightFrame).asVarying();
|
||||||
|
task.addJob<PrepareForward>("PrepareForward", prepareForwardInputs);
|
||||||
|
|
||||||
// draw a stencil mask in hidden regions of the framebuffer.
|
// draw a stencil mask in hidden regions of the framebuffer.
|
||||||
task.addJob<PrepareStencil>("PrepareStencil", framebuffer);
|
task.addJob<PrepareStencil>("PrepareStencil", scaledPrimaryFramebuffer);
|
||||||
|
|
||||||
// Draw opaques forward
|
// Draw opaques forward
|
||||||
const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying();
|
const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying();
|
||||||
|
@ -130,7 +143,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
|
|
||||||
// Just resolve the msaa
|
// Just resolve the msaa
|
||||||
const auto resolveInputs =
|
const auto resolveInputs =
|
||||||
ResolveFramebuffer::Inputs(framebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
|
ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
|
||||||
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
|
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
|
||||||
//auto resolvedFramebuffer = task.addJob<ResolveNewFramebuffer>("Resolve", framebuffer);
|
//auto resolvedFramebuffer = task.addJob<ResolveNewFramebuffer>("Resolve", framebuffer);
|
||||||
|
|
||||||
|
@ -157,35 +170,38 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
|
||||||
// task.addJob<Blit>("Blit", framebuffer);
|
// task.addJob<Blit>("Blit", framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareFramebuffer::configure(const Config& config) {
|
gpu::FramebufferPointer PreparePrimaryFramebufferMSAA::createFramebuffer(const char* name, const glm::uvec2& frameSize, int numSamples) {
|
||||||
_numSamples = config.getNumSamples();
|
gpu::FramebufferPointer framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create(name));
|
||||||
}
|
|
||||||
|
|
||||||
void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
|
||||||
glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w);
|
|
||||||
|
|
||||||
// Resizing framebuffers instead of re-building them seems to cause issues with threaded rendering
|
|
||||||
if (_framebuffer && (_framebuffer->getSize() != frameSize || _framebuffer->getNumSamples() != _numSamples)) {
|
|
||||||
_framebuffer.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_framebuffer) {
|
|
||||||
_framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("forward"));
|
|
||||||
|
|
||||||
int numSamples = _numSamples;
|
|
||||||
|
|
||||||
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
|
auto colorFormat = gpu::Element::COLOR_SRGBA_32;
|
||||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
|
|
||||||
auto colorTexture =
|
auto colorTexture =
|
||||||
gpu::Texture::createRenderBufferMultisample(colorFormat, frameSize.x, frameSize.y, numSamples, defaultSampler);
|
gpu::Texture::createRenderBufferMultisample(colorFormat, frameSize.x, frameSize.y, numSamples, defaultSampler);
|
||||||
_framebuffer->setRenderBuffer(0, colorTexture);
|
framebuffer->setRenderBuffer(0, colorTexture);
|
||||||
|
|
||||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
||||||
auto depthTexture =
|
auto depthTexture =
|
||||||
gpu::Texture::createRenderBufferMultisample(depthFormat, frameSize.x, frameSize.y, numSamples, defaultSampler);
|
gpu::Texture::createRenderBufferMultisample(depthFormat, frameSize.x, frameSize.y, numSamples, defaultSampler);
|
||||||
_framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
||||||
|
|
||||||
|
return framebuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreparePrimaryFramebufferMSAA::configure(const Config& config) {
|
||||||
|
_resolutionScale = config.getResolutionScale();
|
||||||
|
_numSamples = config.getNumSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparePrimaryFramebufferMSAA::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
||||||
|
glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w);
|
||||||
|
glm::uvec2 scaledFrameSize(glm::vec2(frameSize) * _resolutionScale);
|
||||||
|
|
||||||
|
// Resizing framebuffers instead of re-building them seems to cause issues with threaded rendering
|
||||||
|
if (!_framebuffer || (_framebuffer->getSize() != scaledFrameSize) || (_framebuffer->getNumSamples() != _numSamples)) {
|
||||||
|
_framebuffer = createFramebuffer("forward", scaledFrameSize, _numSamples);
|
||||||
|
}
|
||||||
|
/*
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
gpu::doInBatch("PrepareFramebuffer::run", args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch("PrepareFramebuffer::run", args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
@ -196,7 +212,7 @@ void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::Fra
|
||||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH |
|
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH |
|
||||||
gpu::Framebuffer::BUFFER_STENCIL,
|
gpu::Framebuffer::BUFFER_STENCIL,
|
||||||
vec4(vec3(0), 0), 1.0, 0, true);
|
vec4(vec3(0), 0), 1.0, 0, true);
|
||||||
});
|
});*/
|
||||||
|
|
||||||
framebuffer = _framebuffer;
|
framebuffer = _framebuffer;
|
||||||
}
|
}
|
||||||
|
@ -204,18 +220,30 @@ void PrepareFramebuffer::run(const RenderContextPointer& renderContext, gpu::Fra
|
||||||
void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
|
void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
|
|
||||||
|
auto primaryFramebuffer = inputs.get0();
|
||||||
|
auto lightStageFrame = inputs.get1();
|
||||||
|
|
||||||
gpu::doInBatch("RenderForward::Draw::run", args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch("RenderForward::Draw::run", args->_context, [&](gpu::Batch& batch) {
|
||||||
args->_batch = &batch;
|
args->_batch = &batch;
|
||||||
|
|
||||||
|
batch.enableStereo(false);
|
||||||
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
batch.setStateScissorRect(args->_viewport);
|
||||||
|
|
||||||
|
batch.setFramebuffer(primaryFramebuffer);
|
||||||
|
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH |
|
||||||
|
gpu::Framebuffer::BUFFER_STENCIL,
|
||||||
|
vec4(vec3(0), 0), 1.0, 0, true);
|
||||||
|
|
||||||
graphics::LightPointer keySunLight;
|
graphics::LightPointer keySunLight;
|
||||||
auto lightStage = args->_scene->getStage<LightStage>();
|
auto lightStage = args->_scene->getStage<LightStage>();
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
keySunLight = lightStage->getCurrentKeyLight(*inputs);
|
keySunLight = lightStage->getCurrentKeyLight(*lightStageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics::LightPointer keyAmbiLight;
|
graphics::LightPointer keyAmbiLight;
|
||||||
if (lightStage) {
|
if (lightStage) {
|
||||||
keyAmbiLight = lightStage->getCurrentAmbientLight(*inputs);
|
keyAmbiLight = lightStage->getCurrentAmbientLight(*lightStageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keySunLight) {
|
if (keySunLight) {
|
||||||
|
|
|
@ -17,39 +17,57 @@
|
||||||
#include "AssembleLightingStageTask.h"
|
#include "AssembleLightingStageTask.h"
|
||||||
#include "LightingModel.h"
|
#include "LightingModel.h"
|
||||||
|
|
||||||
|
class RenderForwardTaskConfig : public render::Task::Config {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(float resolutionScale MEMBER resolutionScale NOTIFY dirty)
|
||||||
|
public:
|
||||||
|
float resolutionScale{ 1.f };
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dirty();
|
||||||
|
};
|
||||||
|
|
||||||
class RenderForwardTask {
|
class RenderForwardTask {
|
||||||
public:
|
public:
|
||||||
using Input = render::VaryingSet3<RenderFetchCullSortTask::Output, LightingModelPointer, AssembleLightingStageTask::Output>;
|
using Input = render::VaryingSet3<RenderFetchCullSortTask::Output, LightingModelPointer, AssembleLightingStageTask::Output>;
|
||||||
using JobModel = render::Task::ModelI<RenderForwardTask, Input>;
|
using Config = RenderForwardTaskConfig;
|
||||||
|
using JobModel = render::Task::ModelI<RenderForwardTask, Input, Config>;
|
||||||
|
|
||||||
RenderForwardTask() {}
|
RenderForwardTask() {}
|
||||||
|
|
||||||
|
void configure(const Config& config);
|
||||||
void build(JobModel& task, const render::Varying& input, render::Varying& output);
|
void build(JobModel& task, const render::Varying& input, render::Varying& output);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PrepareFramebufferConfig : public render::Job::Config {
|
class PreparePrimaryFramebufferMSAAConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int numSamples WRITE setNumSamples READ getNumSamples NOTIFY dirty)
|
Q_PROPERTY(float resolutionScale WRITE setResolutionScale READ getResolutionScale)
|
||||||
|
Q_PROPERTY(int numSamples WRITE setNumSamples READ getNumSamples)
|
||||||
public:
|
public:
|
||||||
|
float getResolutionScale() const { return resolutionScale; }
|
||||||
|
void setResolutionScale(float scale) {
|
||||||
|
resolutionScale = std::max(0.1f, std::min(1.0f, resolutionScale));
|
||||||
|
}
|
||||||
|
|
||||||
int getNumSamples() const { return numSamples; }
|
int getNumSamples() const { return numSamples; }
|
||||||
void setNumSamples(int num) {
|
void setNumSamples(int num) {
|
||||||
numSamples = std::max(1, std::min(32, num));
|
numSamples = std::max(1, std::min(32, num));
|
||||||
emit dirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
float resolutionScale{ 1.0f };
|
||||||
int numSamples{ 4 };
|
int numSamples{ 4 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrepareFramebuffer {
|
class PreparePrimaryFramebufferMSAA {
|
||||||
public:
|
public:
|
||||||
using Inputs = gpu::FramebufferPointer;
|
using Output = gpu::FramebufferPointer;
|
||||||
using Config = PrepareFramebufferConfig;
|
using Config = PreparePrimaryFramebufferMSAAConfig;
|
||||||
using JobModel = render::Job::ModelO<PrepareFramebuffer, Inputs, Config>;
|
using JobModel = render::Job::ModelO<PreparePrimaryFramebufferMSAA, Output, Config>;
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext,
|
void run(const render::RenderContextPointer& renderContext,
|
||||||
|
@ -57,12 +75,15 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gpu::FramebufferPointer _framebuffer;
|
gpu::FramebufferPointer _framebuffer;
|
||||||
|
float _resolutionScale{ 1.0f };
|
||||||
int _numSamples;
|
int _numSamples;
|
||||||
|
|
||||||
|
static gpu::FramebufferPointer createFramebuffer(const char* name, const glm::uvec2& frameSize, int numSamples);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrepareForward {
|
class PrepareForward {
|
||||||
public:
|
public:
|
||||||
using Inputs = LightStage::FramePointer;
|
using Inputs = render::VaryingSet2 <gpu::FramebufferPointer, LightStage::FramePointer>;
|
||||||
using JobModel = render::Job::ModelI<PrepareForward, Inputs>;
|
using JobModel = render::Job::ModelI<PrepareForward, Inputs>;
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext,
|
void run(const render::RenderContextPointer& renderContext,
|
||||||
|
|
|
@ -30,5 +30,12 @@ Column {
|
||||||
object: Render
|
object: Render
|
||||||
property: "shadowsEnabled"
|
property: "shadowsEnabled"
|
||||||
}
|
}
|
||||||
|
Prop.PropScalar {
|
||||||
|
label: "Viewport Resolution Scale"
|
||||||
|
object: Render
|
||||||
|
property: "viewportResolutionScale"
|
||||||
|
min: 0.1
|
||||||
|
max: 1.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue