mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 20:11:13 +02:00
Render depth buffer to quad
Useful for graphics debugging
This commit is contained in:
parent
0ee916fb6f
commit
022529f03f
4 changed files with 32 additions and 12 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
#include "DependencyManager.h"
|
#include "DependencyManager.h"
|
||||||
#include "ViewFrustum.h"
|
#include "ViewFrustum.h"
|
||||||
|
#include "GeometryCache.h"
|
||||||
|
|
||||||
#include "ambient_occlusion_vert.h"
|
#include "ambient_occlusion_vert.h"
|
||||||
#include "ambient_occlusion_frag.h"
|
#include "ambient_occlusion_frag.h"
|
||||||
|
@ -190,10 +191,10 @@ const gpu::PipelinePointer& AmbientOcclusion::getAOPipeline() {
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
||||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||||
|
|
||||||
// Blend on transparent
|
// Blend on transparent
|
||||||
state->setBlendFunction(true,
|
state->setBlendFunction(false,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||||
|
|
||||||
|
@ -225,11 +226,17 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
|
||||||
batch.setProjectionTransform(projMat);
|
batch.setProjectionTransform(projMat);
|
||||||
batch.setViewTransform(viewMat);
|
batch.setViewTransform(viewMat);
|
||||||
batch.setModelTransform(Transform());
|
batch.setModelTransform(Transform());
|
||||||
|
batch.setResourceTexture(0, DependencyManager::get<TextureCache>()->getPrimaryDepthTexture());
|
||||||
|
|
||||||
// bind the one gpu::Pipeline we need
|
// bind the one gpu::Pipeline we need
|
||||||
batch.setPipeline(getAOPipeline());
|
batch.setPipeline(getAOPipeline());
|
||||||
|
|
||||||
//renderFullscreenQuad();
|
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec2 bottomLeft(0.5f, -1.0f);
|
||||||
|
glm::vec2 topRight(1.0f, -0.5f);
|
||||||
|
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
||||||
|
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
||||||
|
DependencyManager::get<GeometryCache>()->renderQuad(batch, bottomLeft, topRight, texCoordTopLeft, texCoordBottomRight, color);
|
||||||
|
|
||||||
args->_context->syncCache();
|
args->_context->syncCache();
|
||||||
renderContext->args->_context->syncCache();
|
renderContext->args->_context->syncCache();
|
||||||
|
|
|
@ -59,6 +59,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
||||||
_jobs.push_back(Job(new RenderDeferred::JobModel("RenderDeferred")));
|
_jobs.push_back(Job(new RenderDeferred::JobModel("RenderDeferred")));
|
||||||
_jobs.push_back(Job(new ResolveDeferred::JobModel("ResolveDeferred")));
|
_jobs.push_back(Job(new ResolveDeferred::JobModel("ResolveDeferred")));
|
||||||
|
_jobs.push_back(Job(new AmbientOcclusion::JobModel("AmbientOcclusion")));
|
||||||
_jobs.push_back(Job(new FetchItems::JobModel("FetchTransparent",
|
_jobs.push_back(Job(new FetchItems::JobModel("FetchTransparent",
|
||||||
FetchItems(
|
FetchItems(
|
||||||
ItemFilter::Builder::transparentShape().withoutLayered(),
|
ItemFilter::Builder::transparentShape().withoutLayered(),
|
||||||
|
@ -77,8 +78,9 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_jobs.back().setEnabled(false);
|
_jobs.back().setEnabled(false);
|
||||||
_drawStatusJobIndex = _jobs.size() - 1;
|
_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 DrawOverlay3D::JobModel("DrawOverlay3D")));
|
||||||
_jobs.push_back(Job(new AmbientOcclusion::JobModel("AmbientOcclusion")));
|
|
||||||
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
||||||
|
|
||||||
// Give ourselves 3 frmaes of timer queries
|
// Give ourselves 3 frmaes of timer queries
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
//
|
//
|
||||||
// simple.frag
|
// ambient_occlusion.frag
|
||||||
// fragment shader
|
// fragment shader
|
||||||
//
|
//
|
||||||
// Created by Andrzej Kapolka on 9/15/14.
|
// Created by Niraj Venkat on 7/15/15.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -17,6 +17,16 @@
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
//varying vec4 interpolatedNormal;
|
//varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
|
varying vec2 varTexcoord;
|
||||||
|
|
||||||
|
uniform sampler2D depthTexture;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = vec4(0.0, 1.0, 1.0, 1.0);
|
vec4 depthColor = texture2D(depthTexture, varTexcoord.xy);
|
||||||
|
float z = depthColor.r; // fetch the z-value from our depth texture
|
||||||
|
float n = 1.0; // the near plane
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
//
|
//
|
||||||
// simple.vert
|
// ambient_occlusion.vert
|
||||||
// vertex shader
|
// vertex shader
|
||||||
//
|
//
|
||||||
// Created by Andrzej Kapolka on 9/15/14.
|
// Created by Niraj Venkat on 7/15/15.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
//varying vec4 interpolatedNormal;
|
//varying vec4 interpolatedNormal;
|
||||||
|
varying vec2 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//gl_TexCoord[0] = gl_MultiTexCoord0;
|
varTexcoord = gl_MultiTexCoord0.xy;
|
||||||
gl_Position = gl_Vertex;
|
gl_Position = gl_Vertex;
|
||||||
}
|
}
|
Loading…
Reference in a new issue