diff --git a/android/assets/1280x720/splashlogo.png b/android/assets/1280x720/splashlogo.png deleted file mode 100755 index 52e86e3..0000000 Binary files a/android/assets/1280x720/splashlogo.png and /dev/null differ diff --git a/android/assets/1280x800/splashlogo.png b/android/assets/1280x800/splashlogo.png deleted file mode 100755 index 45390b5..0000000 Binary files a/android/assets/1280x800/splashlogo.png and /dev/null differ diff --git a/android/assets/1366x768/splashlogo.png b/android/assets/1366x768/splashlogo.png deleted file mode 100755 index 07c1aa4..0000000 Binary files a/android/assets/1366x768/splashlogo.png and /dev/null differ diff --git a/android/assets/1920x1080/splashlogo.png b/android/assets/1920x1080/splashlogo.png deleted file mode 100755 index 23efe16..0000000 Binary files a/android/assets/1920x1080/splashlogo.png and /dev/null differ diff --git a/android/assets/1920x1200/splashlogo.png b/android/assets/1920x1200/splashlogo.png deleted file mode 100755 index f9f53dc..0000000 Binary files a/android/assets/1920x1200/splashlogo.png and /dev/null differ diff --git a/android/assets/3840x2160/splashlogo.png b/android/assets/3840x2160/splashlogo.png deleted file mode 100755 index c6db1d9..0000000 Binary files a/android/assets/3840x2160/splashlogo.png and /dev/null differ diff --git a/android/assets/800x480/splashlogo.png b/android/assets/800x480/splashlogo.png deleted file mode 100755 index 96fdfd0..0000000 Binary files a/android/assets/800x480/splashlogo.png and /dev/null differ diff --git a/android/assets/music/Alan Walker - Spectre.mp3 b/android/assets/music/Alan Walker - Spectre.mp3 new file mode 100755 index 0000000..53f14af Binary files /dev/null and b/android/assets/music/Alan Walker - Spectre.mp3 differ diff --git a/android/assets/particles/beateffect.p b/android/assets/particles/beateffect.p index 6678577..6e7e056 100755 --- a/android/assets/particles/beateffect.p +++ b/android/assets/particles/beateffect.p @@ -11,7 +11,7 @@ max: 50 lowMin: 0.0 lowMax: 0.0 highMin: 45.0 -highMax: 70.0 +highMax: 60.0 relative: false scalingCount: 3 scaling0: 1.0 @@ -125,9 +125,9 @@ timeline0: 0.0 active: false - Tint - colorsCount: 3 -colors0: 0.7411765 -colors1: 0.20392157 -colors2: 0.0 +colors0: 1.0 +colors1: 0.6627451 +colors2: 0.23921569 timelineCount: 1 timeline0: 0.0 - Transparency - @@ -138,13 +138,13 @@ highMax: 1.0 relative: false scalingCount: 5 scaling0: 0.21052632 -scaling1: 0.5263158 +scaling1: 0.45614034 scaling2: 0.54385966 scaling3: 0.45614034 scaling4: 0.0 timelineCount: 5 timeline0: 0.0 -timeline1: 0.38356164 +timeline1: 0.56164384 timeline2: 0.67808217 timeline3: 0.7671233 timeline4: 1.0 diff --git a/android/assets/shaders/gaussian_blur.fsh b/android/assets/shaders/gaussian_blur.fsh index 88548a8..b3f4611 100755 --- a/android/assets/shaders/gaussian_blur.fsh +++ b/android/assets/shaders/gaussian_blur.fsh @@ -14,20 +14,20 @@ uniform sampler2D u_texture; uniform float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); void main() { - vec2 tex_offset = 1.0 /textureSize(u_texture, 0); - vec3 result = texture(u_texture, vTexCoord).rgb * weight[0]; - - if (horizontal == 1) { - for (int i = 1; i < 5; ++i) { - result += texture(u_texture, vTexCoord + vec2(tex_offset.x *i, 0.0)).rgb * weight[i]; - result += texture(u_texture, vTexCoord - vec2(tex_offset.x *i, 0.0)).rgb * weight[i]; - } - } else { - for (int i = 1; i < 5; ++i) { - result += texture(u_texture, vTexCoord + vec2(0.0, tex_offset.y * i)).rgb * weight[i]; - result += texture(u_texture, vTexCoord - vec2(0.0, tex_offset.y * i)).rgb * weight[i]; - } - } - - gl_FragColor = vec4(result, 1.0); -} + vec2 tex_offset = 1.0 / textureSize(u_texture, 0); + vec3 result = texture(u_texture, vTexCoord).rgb * weight[0]; + + if (horizontal == 1) { + for (int i = 1; i < 5; ++i) { + result += texture(u_texture, vTexCoord + vec2(tex_offset.x * i, 0.0)).rgb * weight[i]; + result += texture(u_texture, vTexCoord - vec2(tex_offset.x * i, 0.0)).rgb * weight[i]; + } + } else { + for (int i = 1; i < 5; ++i) { + result += texture(u_texture, vTexCoord + vec2(0.0, tex_offset.y * i)).rgb * weight[i]; + result += texture(u_texture, vTexCoord - vec2(0.0, tex_offset.y * i)).rgb * weight[i]; + } + } + + gl_FragColor = vec4(result, 1.0); +} \ No newline at end of file diff --git a/android/assets/splashlogo.png b/android/assets/splashlogo.png new file mode 100755 index 0000000..f2fab6d Binary files /dev/null and b/android/assets/splashlogo.png differ diff --git a/core/src/zero1hd/rhythmbullet/RhythmBullet.java b/core/src/zero1hd/rhythmbullet/RhythmBullet.java index 4acd9d3..403db2e 100755 --- a/core/src/zero1hd/rhythmbullet/RhythmBullet.java +++ b/core/src/zero1hd/rhythmbullet/RhythmBullet.java @@ -71,8 +71,9 @@ public class RhythmBullet extends Game { new Resolution(1920, 1080, "1920x1080"), new Resolution(1920, 1200, "1920x1200"), new Resolution(2560, 1440, "2560x1440"), - new Resolution(3840, 2160, "3840x2160"), + new Resolution(3840, 2160, "3840x2160") }; + InternalFileHandleResolver internalFileResolver = new InternalFileHandleResolver(); rRHandler = new RoundingResolutionHandler(internalFileResolver, resolution); GenericFileTypeHandler genericFileFinder = new GenericFileTypeHandler(internalFileResolver); @@ -101,7 +102,9 @@ public class RhythmBullet extends Game { generateFonts(Gdx.graphics.getHeight()); defineSkinStyles(); assetManager.get("standard_thrust.p", ParticleEffect.class).flipY(); - ((TransitionAdapter) getScreen()).postTransition(); + if (initComplete) { + ((TransitionAdapter) getScreen()).postTransition(); + } } } super.render(); @@ -123,7 +126,7 @@ public class RhythmBullet extends Game { @Override public void resize(int width, int height) { if (initComplete) { - Gdx.app.debug("Resize", "Pre-transition is happening."); + Gdx.app.debug("Resize", "Pre-transition is happening. Using resolution " + width + "x" + height); rRHandler.setResolution(width, height); ((TransitionAdapter) getScreen()).preTransition(); assetManager.clear(); @@ -137,7 +140,11 @@ public class RhythmBullet extends Game { } public int fontScale(float fontSize, int height) { - return MathUtils.round(Gdx.graphics.getDensity()*(fontSize*height)); + int size = MathUtils.round(Gdx.graphics.getDensity()*(fontSize*height)); + if (size >= 200) { + size = 200; + } + return size; } public AssetManager getAssetManager() { @@ -184,9 +191,10 @@ public class RhythmBullet extends Game { assetManager.load("tpSelector.png", Texture.class); assetManager.load("magic1.png", Texture.class); } + public void generateFonts(final int height) { defaultSkin = new Skin(); - Gdx.app.debug("Prelaunch Debug Info", "Generating fonts..."); + Gdx.app.debug("Prelaunch Debug Info", "Generating fonts with screen height of " + height); skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class); getDefaultSkin().addRegions(skinAtlas); diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index 29e8491..7fc72d9 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -61,10 +61,9 @@ public class Mp3Manager implements MusicManager { } catch (IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) { e.printStackTrace(); - } finally { - lock.unlock(); } - + lock.unlock(); + }); diff --git a/core/src/zero1hd/rhythmbullet/audio/SongList.java b/core/src/zero1hd/rhythmbullet/audio/SongList.java index 18213e1..7b4e7c4 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongList.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongList.java @@ -36,7 +36,8 @@ public class SongList { } public MusicManager getMusicInfoFromIndex(int index) { - if (index > songList.size) { + if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet..."); + if (songList.size == 0) { return null; } return getAudioData(songList.get(index)); @@ -48,7 +49,7 @@ public class SongList { public FileHandle getSongFileHandleFromIndex(int index) { if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet..."); - if (index > songList.size) { + if (songList.size == 0) { return null; } return songList.get(index); diff --git a/core/src/zero1hd/rhythmbullet/audio/SongListController.java b/core/src/zero1hd/rhythmbullet/audio/SongListController.java index 98eba3c..f4e6937 100755 --- a/core/src/zero1hd/rhythmbullet/audio/SongListController.java +++ b/core/src/zero1hd/rhythmbullet/audio/SongListController.java @@ -36,7 +36,7 @@ public class SongListController implements OnCompletionListener { public void play() { mdp.play(); - mdp.setVolume(prefs.getFloat("music vol")); + mdp.setVolume(prefs.getFloat("music vol", 1f)); } public void setSongByIndex(int index) { @@ -58,7 +58,11 @@ public class SongListController implements OnCompletionListener { public void onCompletion(Music music) { if (autoPlay) { if (shuffle) { - currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + if (songList.getAmountOfSongs() != 0) { + currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + } else { + currentPlaybackID = 0; + } } else { currentPlaybackID++; if (currentPlaybackID > songList.getAmountOfSongs()) { @@ -71,7 +75,11 @@ public class SongListController implements OnCompletionListener { } public void shuffle() { - currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + if (songList.getAmountOfSongs() == 0) { + currentPlaybackID = 0; + } else { + currentPlaybackID = rand.nextInt(songList.getAmountOfSongs()); + } changeSong(); } @@ -99,7 +107,10 @@ public class SongListController implements OnCompletionListener { this.mdp = songList.getMusicInfoFromIndex(currentPlaybackID); if (mdp == null) { - mdp = songList.getAudioData(Gdx.files.internal("music/default.mp3")); + if (!Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3").exists()) { + Gdx.files.internal("music/Alan Walker - Spectre.mp3").copyTo(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3")); + } + mdp = songList.getAudioData(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3")); } mdp.setOnCompletionListener(this); sendEvent(); diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java index de1789a..40712ce 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java @@ -29,6 +29,7 @@ public class TitleBarVisualizer extends Group implements Disposable { ParticleEffectPool beatEffectPool; Array effects = new Array<>(); + private boolean lastEffect; public TitleBarVisualizer(AssetManager assets) { if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL"); visual = new Visualizer(); @@ -67,7 +68,7 @@ public class TitleBarVisualizer extends Group implements Disposable { titleImage.setColor(Color.WHITE); addActor(titleImage); - beatEffectPool = new ParticleEffectPool(assets.get("beateffect.p", ParticleEffect.class), 0, 5) { + beatEffectPool = new ParticleEffectPool(assets.get("beateffect.p", ParticleEffect.class), 0, 8) { @Override protected PooledEffect newObject() { PooledEffect effect = super.newObject(); @@ -75,14 +76,22 @@ public class TitleBarVisualizer extends Group implements Disposable { return effect; } }; + } @Override public void act(float delta) { - if (visual.getVis().getCurrentAvg() > visual.getVis().getMaxAvgHeight()*0.55f) { - PooledEffect effect = beatEffectPool.obtain(); - effect.setPosition(0, 0); - effects.add(effect); + if (!lastEffect) { + if (visual.getVis().getCurrentAvg() > visual.getVis().getMaxAvgHeight()*0.55f) { + PooledEffect effect = beatEffectPool.obtain(); + effect.setPosition(0, 0); + effects.add(effect); + + lastEffect = true; + } + } else { + lastEffect = false; } + super.act(delta); } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java index dae68e5..bbaf98f 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MainPage.java @@ -1,6 +1,5 @@ package zero1hd.rhythmbullet.graphics.ui.pages; -import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.ui.Label; @@ -16,7 +15,7 @@ public class MainPage extends Page implements OnDifferentSongListener { private SongListController sc; private TitleBarVisualizer titleBar; - public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc, OrthographicCamera camera) { + public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc) { this.sc = sc; titleBar = new TitleBarVisualizer(core.getAssetManager()); diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/windows/VolumeWindow.java b/core/src/zero1hd/rhythmbullet/graphics/ui/windows/VolumeWindow.java index 32eba52..a42cbd1 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/windows/VolumeWindow.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/windows/VolumeWindow.java @@ -35,7 +35,7 @@ public class VolumeWindow extends Window { save(); musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%"); if (music != null) { - music.setVolume(musicVolSlider.getValue()/100f); + music.setVolume(musicVolSlider.getValue()); } } }); @@ -70,7 +70,7 @@ public class VolumeWindow extends Window { public void setMusic(MusicManager music) { this.music = music; if (music != null) { - music.setVolume(prefs.getFloat("music vol")/100f); + music.setVolume(prefs.getFloat("music vol")); } } } diff --git a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java index 7a08e15..f21846d 100755 --- a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java @@ -80,10 +80,10 @@ public class GameScreen extends ScreenAdapter { } /** - * needs to be called right after set as screen (should be called in show method). - * This is due to the saving preference being done once the screen is hidden. - * @param prefs - */ + * needs to be called right after set as screen (should be called in show method). + * This is due to the saving preference being done once the screen is hidden. + * @param prefs + */ public void loadShaders() { if (core.getPrefs().getBoolean("glow shader")) { Gdx.app.debug("Shader", "using glow shader"); @@ -141,6 +141,7 @@ public class GameScreen extends ScreenAdapter { ShaderProgram.pedantic = false; } + @Override public void render(float delta) { Gdx.gl.glClearColor(0f, 0f, 0f, 1f); @@ -185,9 +186,9 @@ public class GameScreen extends ScreenAdapter { //Horizontal gaussian blur hBlur.begin(); - fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture()); + fboRegion.setRegion(lightFilterBuffer.getColorBufferTexture()); gameArea.getBatch().setShader(gaussianBlurShader); - gaussianBlurShader.setUniformf("horizontal", 1); + gaussianBlurShader.setUniformi("horizontal", 1); gameArea.getBatch().draw(fboRegion, 0f, 0f, RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT); gameArea.getBatch().flush(); hBlur.end( @@ -198,9 +199,9 @@ public class GameScreen extends ScreenAdapter { //Vertical gaussian blur vBlur.begin(); - fboRegion.setTexture(hBlur.getColorBufferTexture()); + fboRegion.setRegion(hBlur.getColorBufferTexture()); gameArea.getBatch().setShader(gaussianBlurShader); - gaussianBlurShader.setUniformf("horizontal", 0); + gaussianBlurShader.setUniformi("horizontal", 0); gameArea.getBatch().draw(fboRegion, 0f, 0f, RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT); gameArea.getBatch().flush(); vBlur.end( diff --git a/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java b/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java index 53b732d..11e7161 100755 --- a/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/LoadingScreen.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.ScreenAdapter; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.ParticleEffect; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.Image; @@ -16,24 +15,24 @@ import zero1hd.rhythmbullet.RhythmBullet; public class LoadingScreen extends ScreenAdapter implements ApplicationListener { private Stage stage; - RhythmBullet core; - Image zero1HD; + private RhythmBullet core; + private Texture splash; + private Image zero1HD; private boolean done; public LoadingScreen(RhythmBullet core) { this.core = core; - core.getAssetManager().load("splashlogo.png", Texture.class); - core.getAssetManager().finishLoading(); - stage = new Stage(new ScreenViewport()); - - zero1HD = new Image(this.core.getAssetManager().get("splashlogo.png", Texture.class)); + splash = new Texture(Gdx.files.internal("splashlogo.png")); + zero1HD = new Image(splash); + zero1HD.setScale((Gdx.graphics.getHeight()*0.8f)/zero1HD.getHeight()); zero1HD.setColor(0f,1f,1f,0f); stage.addActor(zero1HD); - zero1HD.setPosition(stage.getWidth()/2 - zero1HD.getWidth()/2, stage.getHeight()/2 - zero1HD.getHeight()/2); + zero1HD.setPosition((stage.getWidth() - zero1HD.getWidth()*zero1HD.getScaleX())/2f, (stage.getHeight() - zero1HD.getHeight()*zero1HD.getScaleY())/2f); zero1HD.addAction(Actions.sequence(Actions.color(Color.WHITE, 1f), Actions.fadeOut(0.5f))); - + core.getrRHandler().setResolution(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); core.queueAssets(); + } @Override @@ -51,6 +50,7 @@ public class LoadingScreen extends ScreenAdapter implements ApplicationListener if (!zero1HD.hasActions() & core.getAssetManager().update()) { moveOn(); } + stage.draw(); super.render(delta); } @@ -59,14 +59,11 @@ public class LoadingScreen extends ScreenAdapter implements ApplicationListener if (!done) { Gdx.app.debug("Loading Screen", "queue has all been loaded. Action is done playing."); done = true; - - core.generateFonts(core.getPrefs().getInteger("screen-height")); + core.generateFonts(Gdx.graphics.getHeight()); core.defineSkinStyles(); core.setScreen(new MainMenu(core)); zero1HD.remove(); - core.getAssetManager().unload("splashlogo.png"); - core.getAssetManager().get("standard_thrust.p", ParticleEffect.class).flipY(); } } @@ -79,6 +76,7 @@ public class LoadingScreen extends ScreenAdapter implements ApplicationListener @Override public void hide() { core.setInitComplete(); + splash.dispose(); super.hide(); } diff --git a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java index fa105fe..4da4214 100755 --- a/core/src/zero1hd/rhythmbullet/screens/MainMenu.java +++ b/core/src/zero1hd/rhythmbullet/screens/MainMenu.java @@ -5,6 +5,10 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.ScreenAdapter; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.glutils.FrameBuffer; +import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; @@ -34,6 +38,18 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { private SongListController sc; private float lerpAlpha; + + private ShaderProgram gaussianBlurShader; + private ShaderProgram brightFilterShader; + private ShaderProgram combineShader; + private FrameBuffer lightFilterBuffer; + private FrameBuffer normalBuffer; + private FrameBuffer hBlur, vBlur; + private TextureRegion fboRegion; + private int fboSize; + + private int blurlvl = 2; + public MainMenu(final RhythmBullet core) { this.core = core; stage = new Stage(new ScreenViewport()); @@ -46,9 +62,153 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { sc = new SongListController(songList, core.getPrefs()); sc.setAutoPlay(true); sc.setShuffle(true); + + loadShaders(); + postTransition(); } + public void loadShaders() { + if (core.getPrefs().getBoolean("glow shader")) { + Gdx.app.debug("Shader", "using glow shader"); + brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh")); + if (!brightFilterShader.isCompiled()) { + System.err.println(brightFilterShader.getLog()); + System.exit(0); + } + if (brightFilterShader.getLog().length() != 0) { + System.out.println(brightFilterShader.getLog()); + } + + gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh")); + if (!gaussianBlurShader.isCompiled()) { + System.err.println(gaussianBlurShader.getLog()); + System.exit(0); + } + if (gaussianBlurShader.getLog().length() != 0) { + System.out.println(gaussianBlurShader.getLog()); + } + + combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh")); + if (!combineShader.isCompiled()) { + System.err.println(combineShader.getLog()); + System.exit(0); + } + if (combineShader.getLog().length() != 0) { + System.out.println(combineShader.getLog()); + } + + + if (Gdx.graphics.getWidth() < 1024) { + fboSize = 2048; + } else if (Gdx.graphics.getWidth() < 2048) { + fboSize = 4096; + } else { + fboSize = 4096; + } + + lightFilterBuffer = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false); + normalBuffer = new FrameBuffer(Format.RGBA8888, fboSize, fboSize, false); + hBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false); + vBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false); + + fboRegion = new TextureRegion(); + + combineShader.begin(); + combineShader.setUniformi("u_texture1", 1); + combineShader.end(); + + vBlur.getColorBufferTexture().bind(1); + + Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); + } + + ShaderProgram.pedantic = false; + } + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0.212f, 0.094f, 0f, 1f); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + stage.act(delta); + blurlvl = 5; + + if (gaussianBlurShader != null) { + + //Begin drawing a normal version of screen + normalBuffer.begin(); + Gdx.gl.glClearColor(0.212f, 0.094f, 0f, 1f); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + stage.draw(); + normalBuffer.end(); + //END + + //Begin light filtering + lightFilterBuffer.begin(); + Gdx.gl.glClearColor(0f, 0f, 0f, 1f); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + stage.getBatch().setShader(brightFilterShader); + stage.getBatch().begin(); //BATCH STARTS HERE + stage.getRoot().draw(stage.getBatch(), 1f); + stage.getBatch().flush(); + lightFilterBuffer.end(); + + //Horizontal gaussian blur + hBlur.begin(); + fboRegion.setRegion(lightFilterBuffer.getColorBufferTexture()); + stage.getBatch().setShader(gaussianBlurShader); + gaussianBlurShader.setUniformi("horizontal", 1); + stage.getBatch().draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight()); + stage.getBatch().flush(); + hBlur.end(); + + //Vertical gaussian blur + vBlur.begin(); + fboRegion.setRegion(hBlur.getColorBufferTexture()); + stage.getBatch().setShader(gaussianBlurShader); + gaussianBlurShader.setUniformi("horizontal", 0); + stage.getBatch().draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight()); + stage.getBatch().flush(); + vBlur.end(); + + for (int i = 0; i < blurlvl; i++) { + //Horizontal gaussian blur + hBlur.begin(); + fboRegion.setRegion(vBlur.getColorBufferTexture()); + stage.getBatch().setShader(gaussianBlurShader); + gaussianBlurShader.setUniformi("horizontal", 1); + stage.getBatch().draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight()); + stage.getBatch().flush(); + hBlur.end(); + + //Vertical gaussian blur + vBlur.begin(); + fboRegion.setRegion(hBlur.getColorBufferTexture()); + stage.getBatch().setShader(gaussianBlurShader); + gaussianBlurShader.setUniformi("horizontal", 0); + stage.getBatch().draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight()); + stage.getBatch().flush(); + vBlur.end(); + } + + //Draw everything to screen + stage.getBatch().setShader(combineShader); + fboRegion.setRegion(normalBuffer.getColorBufferTexture()); + fboRegion.flip(false, true); + stage.getBatch().draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight()); + stage.getBatch().setShader(null); + stage.getBatch().end(); //BATCH ENDS HERE + } else { + stage.draw(); + } + + if (stage.getCamera().position.x != targetPosition.x || stage.getCamera().position.y != targetPosition.y) { + stage.getCamera().position.lerp(targetPosition, lerpAlpha); + } + + super.render(delta); + } + @Override public void preTransition() { stage.clear(); @@ -60,7 +220,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { @Override public void postTransition() { - mainPage = new MainPage(core, targetPosition, sc, (OrthographicCamera) stage.getCamera()); + mainPage = new MainPage(core, targetPosition, sc); mainPage.setPosition(0, 0); stage.addActor(mainPage); @@ -129,19 +289,6 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { } } - @Override - public void render(float delta) { - Gdx.gl.glClearColor(0.212f, 0.094f, 0f, 1f); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - stage.act(); - stage.draw(); - if (stage.getCamera().position.x != targetPosition.x || stage.getCamera().position.y != targetPosition.y) { - stage.getCamera().position.lerp(targetPosition, lerpAlpha); - } - - super.render(delta); - } - @Override public void resize(int width, int height) { stage.getViewport().update(width, height, false);