game screen blur level added

This commit is contained in:
Harrison Deng 2017-10-08 19:48:03 -05:00
parent 6d135e3b2b
commit 05a701b643

View File

@ -38,6 +38,8 @@ public class GameScreen extends ScreenAdapter {
private TextureRegion fboRegion;
private int fboSize;
private int blurlvl = 4;
/**
* The game screen where the game play area, and hud are placed.
* @param core The game context object
@ -156,6 +158,7 @@ public class GameScreen extends ScreenAdapter {
}
gameArea.getViewport().apply();
blurlvl = 4;
if (gaussianBlurShader != null) {
//Begin drawing a normal version of screen
normalBuffer.begin();
@ -210,6 +213,34 @@ public class GameScreen extends ScreenAdapter {
gameArea.getViewport().getScreenWidth(),
gameArea.getViewport().getScreenHeight());
for (int i = 0; i < blurlvl; i++) {
//Horizontal gaussian blur
hBlur.begin();
fboRegion.setRegion(vBlur.getColorBufferTexture());
gameArea.getBatch().setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 1);
gameArea.getBatch().draw(fboRegion, 0f, 0f, RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT);
gameArea.getBatch().flush();
hBlur.end(
gameArea.getViewport().getScreenX(),
gameArea.getViewport().getScreenY(),
gameArea.getViewport().getScreenWidth(),
gameArea.getViewport().getScreenHeight());
//Vertical gaussian blur
vBlur.begin();
fboRegion.setRegion(hBlur.getColorBufferTexture());
gameArea.getBatch().setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 0);
gameArea.getBatch().draw(fboRegion, 0f, 0f, RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT);
gameArea.getBatch().flush();
vBlur.end(
gameArea.getViewport().getScreenX(),
gameArea.getViewport().getScreenY(),
gameArea.getViewport().getScreenWidth(),
gameArea.getViewport().getScreenHeight());
}
//Draw everything to screen
gameArea.getBatch().setShader(combineShader);
fboRegion.setRegion(normalBuffer.getColorBufferTexture());