Turn on/off debug AO from menu item

This commit is contained in:
Niraj Venkat 2015-07-21 12:14:09 -07:00
parent 075c9f05de
commit e0634de403
7 changed files with 28 additions and 10 deletions

View file

@ -3336,6 +3336,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
renderContext._drawItemStatus = sceneInterface->doEngineDisplayItemStatus();
renderContext._occlusionStatus = Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion);
renderArgs->_shouldRender = LODManager::shouldRender;
renderContext.args = renderArgs;

View file

@ -134,7 +134,7 @@ namespace MenuOption {
const QString AddressBar = "Show Address Bar";
const QString AlignForearmsWithWrists = "Align Forearms with Wrists";
const QString AlternateIK = "Alternate IK";
const QString AmbientOcclusion = "Ambient Occlusion";
const QString AmbientOcclusion = "Debug Ambient Occlusion";
const QString Animations = "Animations...";
const QString Atmosphere = "Atmosphere";
const QString Attachments = "Attachments...";

View file

@ -193,8 +193,10 @@ const gpu::PipelinePointer& AmbientOcclusion::getOcclusionPipeline() {
gpu::Shader::makeProgram(*program, slotBindings);
//_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos");
//_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim");
_gScaleLoc = program->getUniforms().findLocation("g_scale");
_gBiasLoc = program->getUniforms().findLocation("g_bias");
_gSampleRadiusLoc = program->getUniforms().findLocation("g_sample_rad");
_gIntensityLoc = program->getUniforms().findLocation("g_intensity");
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
@ -345,7 +347,7 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
// Occlusion step
getOcclusionPipeline();
batch.setResourceTexture(0, DependencyManager::get<TextureCache>()->getPrimaryDepthTexture());
batch.setResourceTexture(1, DependencyManager::get<TextureCache>()->getPrimaryFramebuffer()->getRenderBuffer(0));
batch.setResourceTexture(1, DependencyManager::get<TextureCache>()->getPrimaryNormalTexture());
_occlusionBuffer->setRenderBuffer(0, _occlusionTexture);
batch.setFramebuffer(_occlusionBuffer);
@ -380,12 +382,12 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
batch.setPipeline(getHBlurPipeline());
DependencyManager::get<GeometryCache>()->renderQuad(batch, bottomLeft, topRight, texCoordTopLeft, texCoordBottomRight, color);
// "Blend" step
batch.setResourceTexture(0, _hBlurTexture);
batch.setResourceTexture(0, _occlusionTexture);
batch.setFramebuffer(DependencyManager::get<TextureCache>()->getPrimaryFramebuffer());
// bind the fourth gpu::Pipeline we need - for
// bind the fourth gpu::Pipeline we need - for blending the primary framefuffer with blurred occlusion texture
batch.setPipeline(getBlendPipeline());
glm::vec2 bottomLeftSmall(0.5f, -1.0f);

View file

@ -61,6 +61,10 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
_jobs.push_back(Job(new RenderDeferred::JobModel("RenderDeferred")));
_jobs.push_back(Job(new ResolveDeferred::JobModel("ResolveDeferred")));
_jobs.push_back(Job(new AmbientOcclusion::JobModel("AmbientOcclusion")));
_jobs.back().setEnabled(false);
_occlusionJobIndex = _jobs.size() - 1;
_jobs.push_back(Job(new FetchItems::JobModel("FetchTransparent",
FetchItems(
ItemFilter::Builder::transparentShape().withoutLayered(),
@ -79,7 +83,6 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
_jobs.back().setEnabled(false);
_drawStatusJobIndex = _jobs.size() - 1;
//_jobs.push_back(Job(new AmbientOcclusion::JobModel("AmbientOcclusion")));
_jobs.push_back(Job(new DrawOverlay3D::JobModel("DrawOverlay3D")));
_jobs.push_back(Job(new ResetGLState::JobModel()));
@ -110,6 +113,9 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
// Make sure we turn the displayItemStatus on/off
setDrawItemStatus(renderContext->_drawItemStatus);
// TODO: turn on/off AO through menu item
setOcclusionStatus(renderContext->_occlusionStatus);
renderContext->args->_context->syncCache();
for (auto job : _jobs) {

View file

@ -75,6 +75,11 @@ public:
void setDrawItemStatus(bool draw) { if (_drawStatusJobIndex >= 0) { _jobs[_drawStatusJobIndex].setEnabled(draw); } }
bool doDrawItemStatus() const { if (_drawStatusJobIndex >= 0) { return _jobs[_drawStatusJobIndex].isEnabled(); } else { return false; } }
int _occlusionJobIndex = -1;
void setOcclusionStatus(bool draw) { if (_occlusionJobIndex >= 0) { _jobs[_occlusionJobIndex].setEnabled(draw); } }
bool doOcclusionStatus() const { if (_occlusionJobIndex >= 0) { return _jobs[_occlusionJobIndex].isEnabled(); } else { return false; } }
virtual void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);

View file

@ -39,8 +39,9 @@ void main(void) {
float f = 30.0; // the far plane
float c = (2.0 * n) / (f + n - z * (f - n)); // convert to linear values
//gl_FragColor = vec4(c, c, c, 1.0);
gl_FragColor = mix(depthColor, normalColor, normalColor.a);
vec4 linearizedDepthColor = vec4(c, c, c, 1.0);
gl_FragColor = mix(linearizedDepthColor, normalColor, 0.5);
//gl_FragColor = linearizedDepthColor;
//vec3 p = getPosition(i.uv);
//vec3 n = getNormal(i.uv);

View file

@ -51,6 +51,8 @@ public:
bool _drawItemStatus = false;
bool _occlusionStatus = false;
RenderContext() {}
};
typedef std::shared_ptr<RenderContext> RenderContextPointer;