mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:13:09 +02:00
Better debugging options for bloom
This commit is contained in:
parent
0261265330
commit
76305c5285
3 changed files with 112 additions and 22 deletions
|
@ -157,7 +157,9 @@ void BloomApply::run(const render::RenderContextPointer& renderContext, const In
|
||||||
DebugBloom::DebugBloom() {
|
DebugBloom::DebugBloom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugBloom::~DebugBloom() {
|
void DebugBloom::configure(const Config& config) {
|
||||||
|
_mode = static_cast<DebugBloomConfig::Mode>(config.mode);
|
||||||
|
assert(_mode < DebugBloomConfig::MODE_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugBloom::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
void DebugBloom::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
||||||
|
@ -176,12 +178,15 @@ void DebugBloom::run(const render::RenderContextPointer& renderContext, const In
|
||||||
level2FB->getRenderBuffer(0)
|
level2FB->getRenderBuffer(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static auto TEXCOORD_RECT_SLOT = 1;
|
||||||
|
|
||||||
if (!_pipeline) {
|
if (!_pipeline) {
|
||||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
auto vs = gpu::StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS();
|
||||||
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
|
slotBindings.insert(gpu::Shader::Binding(std::string("texcoordRect"), TEXCOORD_RECT_SLOT));
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
@ -199,21 +204,39 @@ void DebugBloom::run(const render::RenderContextPointer& renderContext, const In
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
batch.setPipeline(_pipeline);
|
batch.setPipeline(_pipeline);
|
||||||
|
|
||||||
Transform modelTransform = gpu::Framebuffer::evalSubregionTexcoordTransform(framebufferSize, args->_viewport / 2);
|
Transform modelTransform;
|
||||||
modelTransform.postTranslate(glm::vec3(-1.0f, 1.0f, 0.0f));
|
if (_mode == DebugBloomConfig::MODE_ALL_LEVELS) {
|
||||||
batch.setModelTransform(modelTransform);
|
batch._glUniform4f(TEXCOORD_RECT_SLOT, 0.0f, 0.0f, 1.f, 1.f);
|
||||||
batch.setResourceTexture(0, levelTextures[0]);
|
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
|
||||||
|
|
||||||
modelTransform.postTranslate(glm::vec3(2.0f, 0.0f, 0.0f));
|
modelTransform = gpu::Framebuffer::evalSubregionTexcoordTransform(framebufferSize, args->_viewport / 2);
|
||||||
batch.setModelTransform(modelTransform);
|
modelTransform.postTranslate(glm::vec3(-1.0f, 1.0f, 0.0f));
|
||||||
batch.setResourceTexture(0, levelTextures[1]);
|
batch.setModelTransform(modelTransform);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.setResourceTexture(0, levelTextures[0]);
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
||||||
modelTransform.postTranslate(glm::vec3(-2.0f, -2.0f, 0.0f));
|
modelTransform.postTranslate(glm::vec3(2.0f, 0.0f, 0.0f));
|
||||||
batch.setModelTransform(modelTransform);
|
batch.setModelTransform(modelTransform);
|
||||||
batch.setResourceTexture(0, levelTextures[2]);
|
batch.setResourceTexture(0, levelTextures[1]);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
||||||
|
modelTransform.postTranslate(glm::vec3(-2.0f, -2.0f, 0.0f));
|
||||||
|
batch.setModelTransform(modelTransform);
|
||||||
|
batch.setResourceTexture(0, levelTextures[2]);
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
} else {
|
||||||
|
auto viewport = args->_viewport;
|
||||||
|
auto blurLevel = _mode - DebugBloomConfig::MODE_LEVEL0;
|
||||||
|
|
||||||
|
viewport.z /= 2;
|
||||||
|
|
||||||
|
batch._glUniform4f(TEXCOORD_RECT_SLOT, 0.5f, 0.0f, 0.5f, 1.f);
|
||||||
|
|
||||||
|
modelTransform = gpu::Framebuffer::evalSubregionTexcoordTransform(framebufferSize, viewport);
|
||||||
|
modelTransform.postTranslate(glm::vec3(-1.0f, 0.0f, 0.0f));
|
||||||
|
batch.setModelTransform(modelTransform);
|
||||||
|
batch.setResourceTexture(0, levelTextures[blurLevel]);
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,11 +98,25 @@ private:
|
||||||
|
|
||||||
class DebugBloomConfig : public render::Job::Config {
|
class DebugBloomConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int mode MEMBER mode NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum Mode {
|
||||||
|
MODE_LEVEL0 = 0,
|
||||||
|
MODE_LEVEL1,
|
||||||
|
MODE_LEVEL2,
|
||||||
|
MODE_ALL_LEVELS,
|
||||||
|
|
||||||
|
MODE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
DebugBloomConfig() : render::Job::Config(false) {}
|
DebugBloomConfig() : render::Job::Config(false) {}
|
||||||
|
|
||||||
|
int mode{ MODE_ALL_LEVELS };
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebugBloom {
|
class DebugBloom {
|
||||||
|
@ -112,13 +126,13 @@ public:
|
||||||
using JobModel = render::Job::ModelI<DebugBloom, Inputs, Config>;
|
using JobModel = render::Job::ModelI<DebugBloom, Inputs, Config>;
|
||||||
|
|
||||||
DebugBloom();
|
DebugBloom();
|
||||||
~DebugBloom();
|
|
||||||
|
|
||||||
void configure(const Config& config) {}
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gpu::PipelinePointer _pipeline;
|
gpu::PipelinePointer _pipeline;
|
||||||
|
DebugBloomConfig::Mode _mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Bloom {
|
class Bloom {
|
||||||
|
|
|
@ -28,11 +28,64 @@ Item {
|
||||||
root.config["enabled"] = checked;
|
root.config["enabled"] = checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckBox {
|
GroupBox {
|
||||||
text: "Debug"
|
title: "Debug"
|
||||||
checked: root.configDebug["enabled"]
|
Row {
|
||||||
onCheckedChanged: {
|
ExclusiveGroup { id: debugGroup }
|
||||||
root.configDebug["enabled"] = checked;
|
RadioButton {
|
||||||
|
text : "Off"
|
||||||
|
checked : !root.configDebug["enabled"]
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
root.configDebug["enabled"] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclusiveGroup : debugGroup
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
text : "Lvl 0"
|
||||||
|
checked :root.configDebug["enabled"] && root.configDebug["mode"]==0
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
root.configDebug["enabled"] = true
|
||||||
|
root.configDebug["mode"] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclusiveGroup : debugGroup
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
text : "Lvl 1"
|
||||||
|
checked : root.configDebug["enabled"] && root.configDebug["mode"]==1
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
root.configDebug["enabled"] = true
|
||||||
|
root.configDebug["mode"] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclusiveGroup : debugGroup
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
text : "Lvl 2"
|
||||||
|
checked : root.configDebug["enabled"] && root.configDebug["mode"]==2
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
root.configDebug["enabled"] = true
|
||||||
|
root.configDebug["mode"] = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclusiveGroup : debugGroup
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
text : "All"
|
||||||
|
checked : root.configDebug["enabled"] && root.configDebug["mode"]==3
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
root.configDebug["enabled"] = true
|
||||||
|
root.configDebug["mode"] = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclusiveGroup : debugGroup
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConfigSlider {
|
ConfigSlider {
|
||||||
|
|
Loading…
Reference in a new issue