further adjustments on bloom

This commit is contained in:
Harrison Deng 2018-09-03 20:39:26 -05:00
parent 8fd8308d47
commit 80d4132510
4 changed files with 16 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -69,6 +69,7 @@ public class BloomShader implements Disposable {
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();