Fix for Bloom filter

This commit is contained in:
Edwin Jakobs
2020-01-14 17:41:12 +01:00
parent 9ebd536223
commit 9d2683e4ec
2 changed files with 6 additions and 6 deletions

View File

@@ -51,17 +51,18 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(Shader.createFrom
lastDownsampleRate = downsampleRate lastDownsampleRate = downsampleRate
for (downsample in 0 until downsamples * 2 step 2) { 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 div = downsample + downsampleRate
val bufferB = colorBuffer(dest.width, dest.height, 1.0 / (downsample + downsampleRate), target[0].format, ColorType.FLOAT16) 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)) samplers.add(Pair(bufferA, bufferB))
} }
} }
for ((bufferA) in samplers) { for ((bufferA, _) in samplers) {
blur.apply(src, bufferA) blur.apply(src, bufferA)
} }
for ((index, buffers) in samplers.asReversed().withIndex()) { for ((index, buffers) in samplers.asReversed().withIndex()) {
val (bufferCurrA) = buffers val (bufferCurrA) = buffers

View File

@@ -13,8 +13,7 @@ uniform float gain;
out vec4 o_color; out vec4 o_color;
void main() { void main() {
vec2 s = textureSize(tex0, 0).xy; vec2 s = 1.0 / textureSize(tex0, 0).xy;
s = vec2(1.0/s.x, 1.0/s.y);
int w = window; int w = window;
vec4 sum = vec4(0.0); vec4 sum = vec4(0.0);