further adjustments on bloom
This commit is contained in:
parent
8fd8308d47
commit
80d4132510
@ -11,12 +11,12 @@ varying vec2 vTexCoord;
|
|||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
void main() {
|
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);
|
float brightness = (color.r*0.2126) + (color.g*0.7152) + (color.b * 0.0722);
|
||||||
|
|
||||||
if (brightness > 0.7) {
|
if (brightness > 0.7) {
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
} else {
|
} else {
|
||||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
gl_FragColor = vec4(0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,14 @@ varying vec2 vTexCoord;
|
|||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
uniform sampler2D u_texture1;
|
uniform sampler2D u_texture1;
|
||||||
|
uniform sampler2D u_texture2;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 origColor = texture(u_texture, vTexCoord);
|
vec4 origColor = texture2D(u_texture, vTexCoord);
|
||||||
vec4 blurredColor = texture(u_texture1, vTexCoord);
|
vec4 blurredColor = texture2D(u_texture1, vTexCoord);
|
||||||
gl_FragColor = origColor + blurredColor;
|
vec4 lightFilterColor = texture2D(u_texture2, vTexCoord);
|
||||||
|
|
||||||
|
vec4 result;
|
||||||
|
result = origColor + blurredColor;
|
||||||
|
gl_FragColor = result*vColor;
|
||||||
}
|
}
|
||||||
|
@ -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 + 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;
|
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);
|
||||||
}
|
}
|
@ -63,12 +63,13 @@ public class BloomShader implements Disposable {
|
|||||||
normalBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
normalBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||||
hBlur = 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);
|
vBlur = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||||
|
|
||||||
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
|
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
|
||||||
fboRegion.flip(false, true);
|
fboRegion.flip(false, true);
|
||||||
|
|
||||||
combineShader.begin();
|
combineShader.begin();
|
||||||
combineShader.setUniformi("u_texture1", 1);
|
combineShader.setUniformi("u_texture1", 1);
|
||||||
|
combineShader.setUniformi("u_texture2", 2);
|
||||||
combineShader.end();
|
combineShader.end();
|
||||||
|
|
||||||
gaussianBlurShader.begin();
|
gaussianBlurShader.begin();
|
||||||
@ -76,7 +77,7 @@ public class BloomShader implements Disposable {
|
|||||||
gaussianBlurShader.end();
|
gaussianBlurShader.end();
|
||||||
|
|
||||||
vBlur.getColorBufferTexture().bind(1);
|
vBlur.getColorBufferTexture().bind(1);
|
||||||
|
lightFilterBuffer.getColorBufferTexture().bind(2);
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ public class BloomShader implements Disposable {
|
|||||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||||
hBlur.begin();
|
hBlur.begin();
|
||||||
screenBatch.setShader(gaussianBlurShader);
|
screenBatch.setShader(gaussianBlurShader);
|
||||||
gaussianBlurShader.setUniformf("radius", 1f + 0.2f*bloomLevel);
|
gaussianBlurShader.setUniformf("radius", 1f + 0.2f*(bloomLevel*1.75f));
|
||||||
gaussianBlurShader.setUniformi("pass", 0);
|
gaussianBlurShader.setUniformi("pass", 0);
|
||||||
screenBatch.draw(fboRegion, 0f, 0f, width, height);
|
screenBatch.draw(fboRegion, 0f, 0f, width, height);
|
||||||
screenBatch.flush();
|
screenBatch.flush();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user