From 80d413251061238905f64661f32b2aa065dbb3f6 Mon Sep 17 00:00:00 2001 From: Recrown Date: Mon, 3 Sep 2018 20:39:26 -0500 Subject: [PATCH] further adjustments on bloom --- android/assets/shaders/bright_filter.fsh | 4 ++-- android/assets/shaders/combine.fsh | 12 +++++++++--- android/assets/shaders/gaussian_blur.fsh | 2 +- .../rhythmbullet/graphics/shaders/BloomShader.java | 7 ++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/android/assets/shaders/bright_filter.fsh b/android/assets/shaders/bright_filter.fsh index 8338ba4..15f40c2 100755 --- a/android/assets/shaders/bright_filter.fsh +++ b/android/assets/shaders/bright_filter.fsh @@ -11,12 +11,12 @@ varying vec2 vTexCoord; uniform sampler2D u_texture; void main() { - vec4 color = texture(u_texture, vTexCoord)*vColor; + vec4 color = texture(u_texture, vTexCoord); float brightness = (color.r*0.2126) + (color.g*0.7152) + (color.b * 0.0722); if (brightness > 0.7) { gl_FragColor = color; } else { - gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + gl_FragColor = vec4(0.0); } } diff --git a/android/assets/shaders/combine.fsh b/android/assets/shaders/combine.fsh index a07f084..5bb6044 100755 --- a/android/assets/shaders/combine.fsh +++ b/android/assets/shaders/combine.fsh @@ -11,8 +11,14 @@ varying vec2 vTexCoord; uniform sampler2D u_texture; uniform sampler2D u_texture1; +uniform sampler2D u_texture2; + void main() { - vec4 origColor = texture(u_texture, vTexCoord); - vec4 blurredColor = texture(u_texture1, vTexCoord); - gl_FragColor = origColor + blurredColor; + vec4 origColor = texture2D(u_texture, vTexCoord); + vec4 blurredColor = texture2D(u_texture1, vTexCoord); + vec4 lightFilterColor = texture2D(u_texture2, vTexCoord); + + vec4 result; + result = origColor + blurredColor; + gl_FragColor = result*vColor; } diff --git a/android/assets/shaders/gaussian_blur.fsh b/android/assets/shaders/gaussian_blur.fsh index 8f927e9..a484d96 100755 --- a/android/assets/shaders/gaussian_blur.fsh +++ b/android/assets/shaders/gaussian_blur.fsh @@ -43,5 +43,5 @@ void main() { sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.035855; sum += texture2D(u_texture, vec2(tc.x + 5.0*blur*hstep, tc.y + 5.0*blur*vstep)) * 0.014374; - gl_FragColor = vColor * vec4(sum.rgb, 1.0); + gl_FragColor = vec4(sum.rgb, 1.0); } \ No newline at end of file diff --git a/core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java b/core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java index a849a37..ad7867d 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java +++ b/core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java @@ -63,12 +63,13 @@ public class BloomShader implements Disposable { normalBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); hBlur = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); vBlur = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); - + fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture()); fboRegion.flip(false, true); combineShader.begin(); combineShader.setUniformi("u_texture1", 1); + combineShader.setUniformi("u_texture2", 2); combineShader.end(); gaussianBlurShader.begin(); @@ -76,7 +77,7 @@ public class BloomShader implements Disposable { gaussianBlurShader.end(); vBlur.getColorBufferTexture().bind(1); - + lightFilterBuffer.getColorBufferTexture().bind(2); Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); } @@ -109,7 +110,7 @@ public class BloomShader implements Disposable { fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture()); hBlur.begin(); screenBatch.setShader(gaussianBlurShader); - gaussianBlurShader.setUniformf("radius", 1f + 0.2f*bloomLevel); + gaussianBlurShader.setUniformf("radius", 1f + 0.2f*(bloomLevel*1.75f)); gaussianBlurShader.setUniformi("pass", 0); screenBatch.draw(fboRegion, 0f, 0f, width, height); screenBatch.flush();