From 2003495166c81366c8a60c9e196d42f8e160eba0 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Thu, 7 Sep 2017 12:30:20 +0200 Subject: [PATCH] Adjustments to half texel fix --- libraries/render-utils/src/Outline.slh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/render-utils/src/Outline.slh b/libraries/render-utils/src/Outline.slh index 6e510581b4..ac56e4c95c 100644 --- a/libraries/render-utils/src/Outline.slh +++ b/libraries/render-utils/src/Outline.slh @@ -32,14 +32,19 @@ const float OPACITY_EPSILON = 5e-3; <@func main(IS_FILLED)@> void main(void) { - float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x; + // 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 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, varTexCoord0).x; + float sceneDepth = texture(sceneDepthMap, texCoord0).x; // Transform to linear depth for better precision outlinedDepth = -evalZeyeFromZdb(outlinedDepth); sceneDepth = -evalZeyeFromZdb(sceneDepth); @@ -56,10 +61,7 @@ void main(void) { } else { float weight = 0.0; vec2 deltaUv = params._size / params._blurKernelSize; - // 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 lineStartUv = varTexCoord0 + (getInvWidthHeight() - params._size) / 2.0; + vec2 lineStartUv = texCoord0 - params._size / 2.0; vec2 uv; int x; int y;