Fixed blur problems on screen edges

This commit is contained in:
Olivier Prat 2017-08-09 18:15:05 +02:00
parent 01a028cbb6
commit 57dfe10baf
2 changed files with 15 additions and 8 deletions

View file

@ -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<BLUR_KERNEL_SIZE ; x++) {
outlinedDepth = texture(outlinedDepthMap, uv).x;
outlineIntensity += (outlinedDepth < FAR_DISTANCE) ? 1.0 : 0.0;
uv.x += deltaUv;
if (uv.y>=0.0 && uv.y<=1.0) {
for (x=0 ; x<BLUR_KERNEL_SIZE ; x++) {
if (uv.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) {

View file

@ -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 };