mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Bilateral blur shader cleanup and quad split normal at occlusion resolution
This commit is contained in:
parent
135e10eaa2
commit
8e914fa565
2 changed files with 14 additions and 24 deletions
|
@ -108,7 +108,7 @@ void AmbientOcclusionFramebuffer::allocate() {
|
||||||
if (_isStereo) {
|
if (_isStereo) {
|
||||||
sideSize.x >>= 1;
|
sideSize.x >>= 1;
|
||||||
}
|
}
|
||||||
sideSize = divideRoundUp(sideSize, 1 << _depthResolutionLevel);
|
sideSize = divideRoundUp(sideSize, 1 << _resolutionLevel);
|
||||||
if (_isStereo) {
|
if (_isStereo) {
|
||||||
sideSize.x <<= 1;
|
sideSize.x <<= 1;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ AmbientOcclusionEffectConfig::AmbientOcclusionEffectConfig() :
|
||||||
radius{ 0.3f },
|
radius{ 0.3f },
|
||||||
perspectiveScale{ 1.0f },
|
perspectiveScale{ 1.0f },
|
||||||
obscuranceLevel{ 0.5f },
|
obscuranceLevel{ 0.5f },
|
||||||
falloffAngle{ 0.3f },
|
falloffAngle{ 0.45f },
|
||||||
edgeSharpness{ 1.0f },
|
edgeSharpness{ 1.0f },
|
||||||
blurDeviation{ 2.5f },
|
blurDeviation{ 2.5f },
|
||||||
numSpiralTurns{ 7.0f },
|
numSpiralTurns{ 7.0f },
|
||||||
|
@ -363,19 +363,12 @@ void AmbientOcclusionEffect::updateBlurParameters() {
|
||||||
vblur._blurInfo.z = 1.0f;
|
vblur._blurInfo.z = 1.0f;
|
||||||
vblur._blurInfo.w = occlusionSize.y / float(frameSize.y);
|
vblur._blurInfo.w = occlusionSize.y / float(frameSize.y);
|
||||||
|
|
||||||
// Depth axis
|
// Occlusion axis
|
||||||
hblur._blurAxis.x = 1.0f / occlusionSize.x;
|
hblur._blurAxis.x = hblur._blurInfo.z / occlusionSize.x;
|
||||||
hblur._blurAxis.y = 0.0f;
|
hblur._blurAxis.y = 0.0f;
|
||||||
|
|
||||||
vblur._blurAxis.x = 0.0f;
|
vblur._blurAxis.x = 0.0f;
|
||||||
vblur._blurAxis.y = 1.0f / occlusionSize.y;
|
vblur._blurAxis.y = vblur._blurInfo.w / occlusionSize.y;
|
||||||
|
|
||||||
// Occlusion axis
|
|
||||||
hblur._blurAxis.z = hblur._blurAxis.x * hblur._blurInfo.z;
|
|
||||||
hblur._blurAxis.w = 0.0f;
|
|
||||||
|
|
||||||
vblur._blurAxis.z = 0.0f;
|
|
||||||
vblur._blurAxis.w = vblur._blurAxis.y * vblur._blurInfo.w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmbientOcclusionEffect::updateFramebufferSizes() {
|
void AmbientOcclusionEffect::updateFramebufferSizes() {
|
||||||
|
@ -489,7 +482,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
auto occlusionDepthTexture = linearDepthTexture;
|
auto occlusionDepthTexture = linearDepthTexture;
|
||||||
auto sourceViewport = args->_viewport;
|
auto sourceViewport = args->_viewport;
|
||||||
// divideRoundUp is used two compute the quarter or half resolution render sizes.
|
// divideRoundUp is used two compute the quarter or half resolution render sizes.
|
||||||
// We need to take the rounded up resolution.
|
// We choose to take the rounded up resolution.
|
||||||
auto occlusionViewport = divideRoundUp(sourceViewport, 1 << resolutionLevel);
|
auto occlusionViewport = divideRoundUp(sourceViewport, 1 << resolutionLevel);
|
||||||
auto firstBlurViewport = sourceViewport;
|
auto firstBlurViewport = sourceViewport;
|
||||||
firstBlurViewport.w = occlusionViewport.w;
|
firstBlurViewport.w = occlusionViewport.w;
|
||||||
|
@ -541,7 +534,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
// _frameId = (_frameId + 1) % SSAO_RANDOM_SAMPLE_COUNT;
|
// _frameId = (_frameId + 1) % SSAO_RANDOM_SAMPLE_COUNT;
|
||||||
|
|
||||||
gpu::doInBatch("AmbientOcclusionEffect::run", args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch("AmbientOcclusionEffect::run", args->_context, [=](gpu::Batch& batch) {
|
||||||
PROFILE_RANGE_BATCH(batch, "AmbientOcclusion");
|
PROFILE_RANGE_BATCH(batch, "SSAO");
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
|
||||||
_gpuTimer->begin(batch);
|
_gpuTimer->begin(batch);
|
||||||
|
@ -552,7 +545,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
batch.setModelTransform(Transform());
|
batch.setModelTransform(Transform());
|
||||||
|
|
||||||
// We need this with the mips levels
|
// We need this with the mips levels
|
||||||
batch.pushProfileRange("Depth Mip Generation");
|
batch.pushProfileRange("Depth Mips");
|
||||||
if (isHorizonBased) {
|
if (isHorizonBased) {
|
||||||
batch.setPipeline(mipCreationPipeline);
|
batch.setPipeline(mipCreationPipeline);
|
||||||
batch.generateTextureMipsWithPipeline(occlusionDepthTexture);
|
batch.generateTextureMipsWithPipeline(occlusionDepthTexture);
|
||||||
|
@ -562,7 +555,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
batch.popProfileRange();
|
batch.popProfileRange();
|
||||||
|
|
||||||
#if SSAO_USE_QUAD_SPLIT
|
#if SSAO_USE_QUAD_SPLIT
|
||||||
batch.pushProfileRange("Normal Generation");
|
batch.pushProfileRange("Normal Gen.");
|
||||||
{
|
{
|
||||||
const auto uvScale = glm::vec3(
|
const auto uvScale = glm::vec3(
|
||||||
normalViewport.z / (sourceViewport.z * depthResolutionScale),
|
normalViewport.z / (sourceViewport.z * depthResolutionScale),
|
||||||
|
@ -579,7 +572,8 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
|
|
||||||
model.setScale(uvScale);
|
model.setScale(uvScale);
|
||||||
model.setTranslation(uvTranslate);
|
model.setTranslation(uvTranslate);
|
||||||
batch.setModelTransform(model);
|
// TEMPO OP batch.setModelTransform(model);
|
||||||
|
batch.setModelTransform(Transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build face normals pass
|
// Build face normals pass
|
||||||
|
@ -658,7 +652,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
{
|
{
|
||||||
PROFILE_RANGE_BATCH(batch, "Bilateral Blur");
|
PROFILE_RANGE_BATCH(batch, "Bilateral Blur");
|
||||||
// Blur 1st pass
|
// Blur 1st pass
|
||||||
batch.pushProfileRange("Horizontal");
|
batch.pushProfileRange("Horiz.");
|
||||||
{
|
{
|
||||||
const auto uvScale = glm::vec3(
|
const auto uvScale = glm::vec3(
|
||||||
occlusionViewport.z / float(sourceViewport.z),
|
occlusionViewport.z / float(sourceViewport.z),
|
||||||
|
@ -684,7 +678,7 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte
|
||||||
batch.popProfileRange();
|
batch.popProfileRange();
|
||||||
|
|
||||||
// Blur 2nd pass
|
// Blur 2nd pass
|
||||||
batch.pushProfileRange("Vertical");
|
batch.pushProfileRange("Vert.");
|
||||||
{
|
{
|
||||||
const auto uvScale = glm::vec3(
|
const auto uvScale = glm::vec3(
|
||||||
1.0f,
|
1.0f,
|
||||||
|
|
|
@ -27,10 +27,6 @@ layout(binding=RENDER_UTILS_BUFFER_SSAO_BLUR_PARAMS) uniform blurParamsBuffer {
|
||||||
};
|
};
|
||||||
|
|
||||||
vec2 getBlurOcclusionAxis() {
|
vec2 getBlurOcclusionAxis() {
|
||||||
return blurParams._blurAxis.zw;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec2 getBlurDepthAxis() {
|
|
||||||
return blurParams._blurAxis.xy;
|
return blurParams._blurAxis.xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ float evalBlurCoefficient(vec3 blurScales, float radialDistance, float zDistance
|
||||||
return exp2(dot(blurScales, distances*distances));
|
return exp2(dot(blurScales, distances*distances));
|
||||||
}
|
}
|
||||||
|
|
||||||
const float BLUR_EDGE_DISTANCE_SCALE = 1000 * SSAO_DEPTH_KEY_SCALE;
|
const float BLUR_EDGE_DISTANCE_SCALE = 10000 * SSAO_DEPTH_KEY_SCALE;
|
||||||
const float BLUR_EDGE_NORMAL_SCALE = 2.0;
|
const float BLUR_EDGE_NORMAL_SCALE = 2.0;
|
||||||
const float BLUR_EDGE_NORMAL_LIMIT = 0.25;
|
const float BLUR_EDGE_NORMAL_LIMIT = 0.25;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue