From 43f9db5b70ea2aa025948ee1e9e693984f09d2e4 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 23 Oct 2017 11:08:13 +0200 Subject: [PATCH] Fixed small bug due to half texel offset in outline shader --- libraries/render-utils/src/Outline.slh | 10 +++++----- libraries/render-utils/src/OutlineEffect.cpp | 2 +- .../utilities/render/outlinePage/OutlinePage.qml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/render-utils/src/Outline.slh b/libraries/render-utils/src/Outline.slh index fe9594cc12..aeaf20a24a 100644 --- a/libraries/render-utils/src/Outline.slh +++ b/libraries/render-utils/src/Outline.slh @@ -35,16 +35,14 @@ void main(void) { // We offset by half a texel to be centered on the depth sample. If we don't do this // the blur will have a different width between the left / right sides and top / bottom // sides of the silhouette - vec2 halfTexel = getInvWidthHeight() / 2; - vec2 texCoord0 = varTexCoord0+halfTexel; - float outlinedDepth = texture(outlinedDepthMap, texCoord0).x; + float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x; float intensity = 0.0; if (outlinedDepth < FAR_Z) { // We're not on the far plane so we are on the outlined object, thus no outline to do! <@if IS_FILLED@> // But we need to fill the interior - float sceneDepth = texture(sceneDepthMap, texCoord0).x; + float sceneDepth = texture(sceneDepthMap, varTexCoord0).x; // Transform to linear depth for better precision outlinedDepth = -evalZeyeFromZdb(outlinedDepth); sceneDepth = -evalZeyeFromZdb(sceneDepth); @@ -55,6 +53,8 @@ void main(void) { discard; <@endif@> } else { + vec2 halfTexel = getInvWidthHeight() / 2; + vec2 texCoord0 = varTexCoord0+halfTexel; float weight = 0.0; vec2 deltaUv = params._size / params._blurKernelSize; vec2 lineStartUv = texCoord0 - params._size / 2.0; @@ -72,7 +72,7 @@ void main(void) { { outlinedDepth = texture(outlinedDepthMap, uv).x; intensity += (outlinedDepth < FAR_Z) ? 1.0 : 0.0; - weight += 1.f; + weight += 1.0; } uv.x += deltaUv.x; } diff --git a/libraries/render-utils/src/OutlineEffect.cpp b/libraries/render-utils/src/OutlineEffect.cpp index 8822bcc649..ca67347ecf 100644 --- a/libraries/render-utils/src/OutlineEffect.cpp +++ b/libraries/render-utils/src/OutlineEffect.cpp @@ -446,7 +446,7 @@ void DrawOutlineTask::build(JobModel& task, const render::Varying& inputs, rende auto shapePlumber = std::make_shared(); { auto state = std::make_shared(); - state->setDepthTest(true, true, gpu::LESS); + state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setColorWriteMask(false, false, false, false); state->setScissorEnable(true); initMaskPipelines(*shapePlumber, state); diff --git a/scripts/developer/utilities/render/outlinePage/OutlinePage.qml b/scripts/developer/utilities/render/outlinePage/OutlinePage.qml index f8976162ab..a78bf02d3e 100644 --- a/scripts/developer/utilities/render/outlinePage/OutlinePage.qml +++ b/scripts/developer/utilities/render/outlinePage/OutlinePage.qml @@ -33,7 +33,7 @@ Item { integral: false config: root.drawConfig property: "width" - max: 15.0 + max: 5.0 min: 0.0 width: 280 }