From 57dfe10baf6d4be910de76806c9e4a4559bf849f Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Wed, 9 Aug 2017 18:15:05 +0200 Subject: [PATCH] Fixed blur problems on screen edges --- libraries/render-utils/src/Outline.slf | 17 ++++++++++++----- libraries/render-utils/src/OutlineEffect.h | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libraries/render-utils/src/Outline.slf b/libraries/render-utils/src/Outline.slf index f3f01ff72b..d55938e9d7 100644 --- a/libraries/render-utils/src/Outline.slf +++ b/libraries/render-utils/src/Outline.slf @@ -35,6 +35,7 @@ void main(void) { //float sceneDepth = texture(sceneDepthMap, varTexCoord0).x; float outlineIntensity = 0.0; + float weight = 0.0; { const float deltaUv = params._size / BLUR_KERNEL_SIZE; vec2 uv; @@ -46,14 +47,20 @@ void main(void) { uv = startUv; startUv.y += deltaUv; - for (x=0 ; x=0.0 && uv.y<=1.0) { + for (x=0 ; x=0.0 && uv.x<=1.0) + { + outlinedDepth = texture(outlinedDepthMap, uv).x; + outlineIntensity += (outlinedDepth < FAR_DISTANCE) ? 1.0 : 0.0; + weight += 1.f; + } + uv.x += deltaUv; + } } } - outlineIntensity /= BLUR_KERNEL_SIZE*BLUR_KERNEL_SIZE; + outlineIntensity /= weight; } if (outlineIntensity < 1e-3) { diff --git a/libraries/render-utils/src/OutlineEffect.h b/libraries/render-utils/src/OutlineEffect.h index 0561510d2b..3e58d78acc 100644 --- a/libraries/render-utils/src/OutlineEffect.h +++ b/libraries/render-utils/src/OutlineEffect.h @@ -81,13 +81,13 @@ class DrawOutlineConfig : public render::Job::Config { Q_PROPERTY(float colorB READ getColorB WRITE setColorB NOTIFY dirty) public: - void setColorR(float value) { color.r = value; } + void setColorR(float value) { color.r = value; emit dirty(); } float getColorR() const { return color.r; } - void setColorG(float value) { color.g = value; } + void setColorG(float value) { color.g = value; emit dirty(); } float getColorG() const { return color.g; } - void setColorB(float value) { color.b = value; } + void setColorB(float value) { color.b = value; emit dirty(); } float getColorB() const { return color.b; } float width{ 5.f };