From 9d2683e4ece516c0c9040f10d996e2b7d27e5021 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Tue, 14 Jan 2020 17:41:12 +0100 Subject: [PATCH] Fix for Bloom filter --- orx-fx/src/main/kotlin/blur/Bloom.kt | 9 +++++---- .../extra/fx/gl3/blur/approximate-gaussian-blur.frag | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/orx-fx/src/main/kotlin/blur/Bloom.kt b/orx-fx/src/main/kotlin/blur/Bloom.kt index dc0c6052..940819c0 100644 --- a/orx-fx/src/main/kotlin/blur/Bloom.kt +++ b/orx-fx/src/main/kotlin/blur/Bloom.kt @@ -51,17 +51,18 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(Shader.createFrom lastDownsampleRate = downsampleRate for (downsample in 0 until downsamples * 2 step 2) { - val bufferA = colorBuffer(dest.width, dest.height, 1.0 / (downsample + downsampleRate), target[0].format, ColorType.FLOAT16) - val bufferB = colorBuffer(dest.width, dest.height, 1.0 / (downsample + downsampleRate), target[0].format, ColorType.FLOAT16) - + val div = downsample + downsampleRate + val bufferA = colorBuffer(dest.width/div, dest.height/div, 1.0, target[0].format, ColorType.FLOAT16) + val bufferB = colorBuffer(dest.width/div, dest.height/div, 1.0, target[0].format, ColorType.FLOAT16) samplers.add(Pair(bufferA, bufferB)) } } - for ((bufferA) in samplers) { + for ((bufferA, _) in samplers) { blur.apply(src, bufferA) } + for ((index, buffers) in samplers.asReversed().withIndex()) { val (bufferCurrA) = buffers diff --git a/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/blur/approximate-gaussian-blur.frag b/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/blur/approximate-gaussian-blur.frag index 549f2132..56377ffb 100644 --- a/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/blur/approximate-gaussian-blur.frag +++ b/orx-fx/src/main/resources/org/openrndr/extra/fx/gl3/blur/approximate-gaussian-blur.frag @@ -13,8 +13,7 @@ uniform float gain; out vec4 o_color; void main() { - vec2 s = textureSize(tex0, 0).xy; - s = vec2(1.0/s.x, 1.0/s.y); + vec2 s = 1.0 / textureSize(tex0, 0).xy; int w = window; vec4 sum = vec4(0.0);