mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:48:56 +02:00
On single bilateral blur shader
This commit is contained in:
parent
349a8b39ad
commit
1998096630
8 changed files with 14 additions and 59 deletions
|
@ -32,8 +32,7 @@
|
||||||
#include "ViewFrustum.h"
|
#include "ViewFrustum.h"
|
||||||
|
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_occlusionPipeline;
|
gpu::PipelinePointer AmbientOcclusionEffect::_occlusionPipeline;
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_hBlurPipeline;
|
gpu::PipelinePointer AmbientOcclusionEffect::_bilateralBlurPipeline;
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_vBlurPipeline;
|
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_mipCreationPipeline;
|
gpu::PipelinePointer AmbientOcclusionEffect::_mipCreationPipeline;
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_gatherPipeline;
|
gpu::PipelinePointer AmbientOcclusionEffect::_gatherPipeline;
|
||||||
gpu::PipelinePointer AmbientOcclusionEffect::_buildNormalsPipeline;
|
gpu::PipelinePointer AmbientOcclusionEffect::_buildNormalsPipeline;
|
||||||
|
@ -415,31 +414,17 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
|
||||||
return _occlusionPipeline;
|
return _occlusionPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
|
const gpu::PipelinePointer& AmbientOcclusionEffect::getBilateralBlurPipeline() {
|
||||||
if (!_hBlurPipeline) {
|
if (!_bilateralBlurPipeline) {
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_makeHorizontalBlur);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_bilateralBlur);
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
||||||
state->setColorWriteMask(true, true, true, false);
|
state->setColorWriteMask(true, true, true, false);
|
||||||
|
|
||||||
// Good to go add the brand new pipeline
|
// Good to go add the brand new pipeline
|
||||||
_hBlurPipeline = gpu::Pipeline::create(program, state);
|
_bilateralBlurPipeline = gpu::Pipeline::create(program, state);
|
||||||
}
|
}
|
||||||
return _hBlurPipeline;
|
return _bilateralBlurPipeline;
|
||||||
}
|
|
||||||
|
|
||||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getVBlurPipeline() {
|
|
||||||
if (!_vBlurPipeline) {
|
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_makeVerticalBlur);
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
|
||||||
|
|
||||||
// Vertical blur write just the final result Occlusion value in the alpha channel
|
|
||||||
state->setColorWriteMask(true, true, true, false);
|
|
||||||
|
|
||||||
// Good to go add the brand new pipeline
|
|
||||||
_vBlurPipeline = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
|
||||||
return _vBlurPipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getMipCreationPipeline() {
|
const gpu::PipelinePointer& AmbientOcclusionEffect::getMipCreationPipeline() {
|
||||||
|
@ -530,8 +515,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
|
|
||||||
auto framebufferSize = _framebuffer->getSourceFrameSize();
|
auto framebufferSize = _framebuffer->getSourceFrameSize();
|
||||||
auto occlusionPipeline = getOcclusionPipeline();
|
auto occlusionPipeline = getOcclusionPipeline();
|
||||||
auto firstHBlurPipeline = getHBlurPipeline();
|
auto bilateralBlurPipeline = getBilateralBlurPipeline();
|
||||||
auto lastVBlurPipeline = getVBlurPipeline();
|
|
||||||
auto mipCreationPipeline = getMipCreationPipeline();
|
auto mipCreationPipeline = getMipCreationPipeline();
|
||||||
#if SSAO_USE_QUAD_SPLIT
|
#if SSAO_USE_QUAD_SPLIT
|
||||||
auto gatherPipeline = getGatherPipeline();
|
auto gatherPipeline = getGatherPipeline();
|
||||||
|
@ -680,12 +664,12 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
model.setScale(uvScale);
|
model.setScale(uvScale);
|
||||||
batch.setModelTransform(model);
|
batch.setModelTransform(model);
|
||||||
}
|
}
|
||||||
|
batch.setPipeline(bilateralBlurPipeline);
|
||||||
batch.setViewportTransform(firstBlurViewport);
|
batch.setViewportTransform(firstBlurViewport);
|
||||||
batch.setFramebuffer(occlusionBlurredFBO);
|
batch.setFramebuffer(occlusionBlurredFBO);
|
||||||
// Use full resolution depth and normal for bilateral upscaling and blur
|
// Use full resolution depth and normal for bilateral upscaling and blur
|
||||||
batch.setResourceTexture(render_utils::slot::texture::SsaoDepth, linearDepthTexture);
|
batch.setResourceTexture(render_utils::slot::texture::SsaoDepth, linearDepthTexture);
|
||||||
batch.setUniformBuffer(render_utils::slot::buffer::SsaoBlurParams, _hblurParametersBuffer);
|
batch.setUniformBuffer(render_utils::slot::buffer::SsaoBlurParams, _hblurParametersBuffer);
|
||||||
batch.setPipeline(firstHBlurPipeline);
|
|
||||||
batch.setResourceTexture(render_utils::slot::texture::SsaoOcclusion, occlusionFBO->getRenderBuffer(0));
|
batch.setResourceTexture(render_utils::slot::texture::SsaoOcclusion, occlusionFBO->getRenderBuffer(0));
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
batch.popProfileRange();
|
batch.popProfileRange();
|
||||||
|
@ -705,7 +689,6 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
batch.setViewportTransform(sourceViewport);
|
batch.setViewportTransform(sourceViewport);
|
||||||
batch.setFramebuffer(occlusionFBO);
|
batch.setFramebuffer(occlusionFBO);
|
||||||
batch.setUniformBuffer(render_utils::slot::buffer::SsaoBlurParams, _vblurParametersBuffer);
|
batch.setUniformBuffer(render_utils::slot::buffer::SsaoBlurParams, _vblurParametersBuffer);
|
||||||
batch.setPipeline(lastVBlurPipeline);
|
|
||||||
batch.setResourceTexture(render_utils::slot::texture::SsaoOcclusion, occlusionBlurredFBO->getRenderBuffer(0));
|
batch.setResourceTexture(render_utils::slot::texture::SsaoOcclusion, occlusionBlurredFBO->getRenderBuffer(0));
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
batch.popProfileRange();
|
batch.popProfileRange();
|
||||||
|
|
|
@ -190,15 +190,13 @@ private:
|
||||||
BlurParametersBuffer _hblurParametersBuffer;
|
BlurParametersBuffer _hblurParametersBuffer;
|
||||||
|
|
||||||
static const gpu::PipelinePointer& getOcclusionPipeline();
|
static const gpu::PipelinePointer& getOcclusionPipeline();
|
||||||
static const gpu::PipelinePointer& getHBlurPipeline(); // first
|
static const gpu::PipelinePointer& getBilateralBlurPipeline();
|
||||||
static const gpu::PipelinePointer& getVBlurPipeline(); // second
|
|
||||||
static const gpu::PipelinePointer& getMipCreationPipeline();
|
static const gpu::PipelinePointer& getMipCreationPipeline();
|
||||||
static const gpu::PipelinePointer& getGatherPipeline();
|
static const gpu::PipelinePointer& getGatherPipeline();
|
||||||
static const gpu::PipelinePointer& getBuildNormalsPipeline();
|
static const gpu::PipelinePointer& getBuildNormalsPipeline();
|
||||||
|
|
||||||
static gpu::PipelinePointer _occlusionPipeline;
|
static gpu::PipelinePointer _occlusionPipeline;
|
||||||
static gpu::PipelinePointer _hBlurPipeline;
|
static gpu::PipelinePointer _bilateralBlurPipeline;
|
||||||
static gpu::PipelinePointer _vBlurPipeline;
|
|
||||||
static gpu::PipelinePointer _mipCreationPipeline;
|
static gpu::PipelinePointer _mipCreationPipeline;
|
||||||
static gpu::PipelinePointer _gatherPipeline;
|
static gpu::PipelinePointer _gatherPipeline;
|
||||||
static gpu::PipelinePointer _buildNormalsPipeline;
|
static gpu::PipelinePointer _buildNormalsPipeline;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
VERTEX ssao_blur
|
|
|
@ -1 +0,0 @@
|
||||||
VERTEX ssao_blur
|
|
|
@ -2,7 +2,7 @@
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
//
|
//
|
||||||
// ssao_makeVerticalBlur.frag
|
// ssao_bilateralBlur.frag
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 1/1/16.
|
// Created by Sam Gateau on 1/1/16.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
<@include ssao.slh@>
|
<@include ssao.slh@>
|
||||||
|
|
||||||
// Hack comment
|
// Hack comment
|
|
@ -2,7 +2,7 @@
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
//
|
//
|
||||||
// ssao_blur.vert
|
// ssao_bilateralBlur.vert
|
||||||
//
|
//
|
||||||
// Draw the unit quad [-1,-1 -> 1,1] filling in
|
// Draw the unit quad [-1,-1 -> 1,1] filling in
|
||||||
// Simply draw a Triangle_strip of 2 triangles, no input buffers or index buffer needed
|
// Simply draw a Triangle_strip of 2 triangles, no input buffers or index buffer needed
|
|
@ -1,26 +0,0 @@
|
||||||
<@include gpu/Config.slh@>
|
|
||||||
<$VERSION_HEADER$>
|
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
|
||||||
//
|
|
||||||
// ssao_makeHorizontalBlur.frag
|
|
||||||
//
|
|
||||||
// Created by Sam Gateau on 1/1/16.
|
|
||||||
// Copyright 2016 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 ssao.slh@>
|
|
||||||
|
|
||||||
// Hack comment
|
|
||||||
|
|
||||||
<$declareBlurPass()$>
|
|
||||||
|
|
||||||
layout(location=0) in vec4 varTexCoord0;
|
|
||||||
|
|
||||||
layout(location=0) out vec4 outFragColor;
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
outFragColor = vec4(getBlurredOcclusion(ivec2(gl_FragCoord.xy), varTexCoord0.xy, varTexCoord0.zw), 1.0);
|
|
||||||
}
|
|
Loading…
Reference in a new issue