|
|
|
@@ -6,7 +6,7 @@ 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.Texture;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
|
|
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
|
|
|
@@ -34,7 +34,6 @@ import zero1hd.rhythmbullet.util.AdvancedResizeScreen;
|
|
|
|
|
|
|
|
|
|
public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScreen {
|
|
|
|
|
public Stage stage;
|
|
|
|
|
private Texture background;
|
|
|
|
|
private Vector3 cameraPosition;
|
|
|
|
|
|
|
|
|
|
private MainPage mainPage;
|
|
|
|
@@ -60,9 +59,8 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
private TextureRegion fboRegion;
|
|
|
|
|
private int fboSize;
|
|
|
|
|
private int blurlvl;
|
|
|
|
|
private SpriteBatch screenBatch;
|
|
|
|
|
private Batch batch;
|
|
|
|
|
private ScreenViewport screenViewport;
|
|
|
|
|
private boolean shaderLoaded;
|
|
|
|
|
|
|
|
|
|
public MainMenuScreen(RhythmBullet core) {
|
|
|
|
|
this.core = core;
|
|
|
|
@@ -77,21 +75,110 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
mlc.setShuffle(true);
|
|
|
|
|
|
|
|
|
|
mic = new MusicInfoController(musicList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void render(float delta) {
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
stage.act(delta);
|
|
|
|
|
if (blurlvl > 0) {
|
|
|
|
|
// Begin drawing a normal version of screen
|
|
|
|
|
normalBuffer.begin();
|
|
|
|
|
stage.getViewport().apply();
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
stage.draw();
|
|
|
|
|
normalBuffer.end();
|
|
|
|
|
|
|
|
|
|
// BEGINNING NORMAL SCREEN RENDER
|
|
|
|
|
screenViewport.apply();
|
|
|
|
|
|
|
|
|
|
// Begin light filtering
|
|
|
|
|
lightFilterBuffer.begin();
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
|
|
|
|
batch.setShader(brightFilterShader);
|
|
|
|
|
batch.setProjectionMatrix(screenViewport.getCamera().combined);
|
|
|
|
|
batch.begin(); //BATCH STARTS HERE
|
|
|
|
|
batch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
|
|
|
|
batch.flush();
|
|
|
|
|
lightFilterBuffer.end();
|
|
|
|
|
//
|
|
|
|
|
for (int i = 0; i < blurlvl; i++) {
|
|
|
|
|
// Horizontal gaussian blur
|
|
|
|
|
hBlur.begin();
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
|
|
|
|
} else {
|
|
|
|
|
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
|
|
|
|
}
|
|
|
|
|
batch.setShader(gaussianBlurShader);
|
|
|
|
|
gaussianBlurShader.setUniformi("horizontal", 1);
|
|
|
|
|
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
|
|
|
|
batch.flush();
|
|
|
|
|
hBlur.end();
|
|
|
|
|
|
|
|
|
|
// //Vertical gaussian blur
|
|
|
|
|
vBlur.begin();
|
|
|
|
|
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
|
|
|
|
batch.setShader(gaussianBlurShader);
|
|
|
|
|
gaussianBlurShader.setUniformi("horizontal", 0);
|
|
|
|
|
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
|
|
|
|
batch.flush();
|
|
|
|
|
vBlur.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
batch.setShader(combineShader);
|
|
|
|
|
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
|
|
|
|
batch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
|
|
|
|
|
batch.setShader(null);
|
|
|
|
|
batch.end(); //STAGE BATCH ENDS HERE
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
stage.draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
|
|
|
|
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
|
|
|
|
|
stage.getViewport().apply();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screenBatch = new SpriteBatch();
|
|
|
|
|
super.render(delta);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void preAssetLoad() {
|
|
|
|
|
stage.clear();
|
|
|
|
|
mainPage.dispose();
|
|
|
|
|
optionsPage.dispose();
|
|
|
|
|
creditsPage.dispose();
|
|
|
|
|
keybindPage.dispose();
|
|
|
|
|
musicSelectionPage.dispose();
|
|
|
|
|
|
|
|
|
|
dismantleShaders();
|
|
|
|
|
setBlurlvl(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void postAssetLoad() {
|
|
|
|
|
attemptLoadShaders();
|
|
|
|
|
if (core.getPrefs().getBoolean("glow shader", true)) {
|
|
|
|
|
setupShaders();
|
|
|
|
|
|
|
|
|
|
if (core.getPrefs().getBoolean("enhanced glow", false)) {
|
|
|
|
|
setBlurlvl(1);
|
|
|
|
|
} else {
|
|
|
|
|
setBlurlvl(4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainPage = new MainPage(core, cameraPosition, mlc, this);
|
|
|
|
|
mainPage.setPosition(0, 0);
|
|
|
|
|
stage.addActor(mainPage);
|
|
|
|
|
//End main menu
|
|
|
|
|
|
|
|
|
|
background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keybindPage = new KeybindOptionsPage(core.getDefaultSkin(), core.getAssetManager(), cameraPosition);
|
|
|
|
|
keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
|
|
|
|
|
stage.addActor(keybindPage);
|
|
|
|
@@ -137,12 +224,12 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
super.clicked(event, x, y);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mlc.getMusicList().deleteObservers();
|
|
|
|
|
mlc.deleteObservers();
|
|
|
|
|
mlc.addObserver(musicSelectionPage);
|
|
|
|
|
mlc.addObserver(mainPage);
|
|
|
|
|
mlc.getMusicList().addObserver(mainPage);
|
|
|
|
|
mlc.getMusicList().addObserver(optionsPage);
|
|
|
|
|
mlc.addObserver(musicSelectionPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mlc.getMusicList().isSearched() && mlc.getCurrentMusicManager() != null) {
|
|
|
|
|
MusicManager mManager = mlc.getCurrentMusicManager();
|
|
|
|
|
mainPage.updateVisualsForDifferentSong(mManager);
|
|
|
|
@@ -150,104 +237,6 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void render(float delta) {
|
|
|
|
|
Gdx.gl.glClearColor(0.22f, 0.22f, 0.22f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
stage.act(delta);
|
|
|
|
|
|
|
|
|
|
if (blurlvl > 0) {
|
|
|
|
|
// Begin drawing a normal version of screen
|
|
|
|
|
normalBuffer.begin();
|
|
|
|
|
stage.getViewport().apply();
|
|
|
|
|
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
draw();
|
|
|
|
|
normalBuffer.end();
|
|
|
|
|
|
|
|
|
|
// BEGINNING NORMAL SCREEN RENDER
|
|
|
|
|
screenViewport.apply();
|
|
|
|
|
|
|
|
|
|
// Begin light filtering
|
|
|
|
|
lightFilterBuffer.begin();
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
|
|
|
|
screenBatch.setShader(brightFilterShader);
|
|
|
|
|
screenBatch.setProjectionMatrix(screenViewport.getCamera().combined);
|
|
|
|
|
screenBatch.begin(); //BATCH STARTS HERE
|
|
|
|
|
//TODO Do shader version of background for main menu.
|
|
|
|
|
|
|
|
|
|
screenBatch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
|
|
|
|
screenBatch.flush();
|
|
|
|
|
lightFilterBuffer.end();
|
|
|
|
|
//
|
|
|
|
|
for (int i = 0; i < blurlvl; i++) {
|
|
|
|
|
// Horizontal gaussian blur
|
|
|
|
|
hBlur.begin();
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
|
|
|
|
} else {
|
|
|
|
|
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
|
|
|
|
}
|
|
|
|
|
screenBatch.setShader(gaussianBlurShader);
|
|
|
|
|
gaussianBlurShader.setUniformi("horizontal", 1);
|
|
|
|
|
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
|
|
|
|
screenBatch.flush();
|
|
|
|
|
hBlur.end();
|
|
|
|
|
|
|
|
|
|
// //Vertical gaussian blur
|
|
|
|
|
vBlur.begin();
|
|
|
|
|
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
|
|
|
|
screenBatch.setShader(gaussianBlurShader);
|
|
|
|
|
gaussianBlurShader.setUniformi("horizontal", 0);
|
|
|
|
|
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
|
|
|
|
screenBatch.flush();
|
|
|
|
|
vBlur.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
screenBatch.setShader(combineShader);
|
|
|
|
|
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
|
|
|
|
screenBatch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
|
|
|
|
|
screenBatch.setShader(null);
|
|
|
|
|
screenBatch.end(); //BATCH ENDS HERE
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//move camera
|
|
|
|
|
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
|
|
|
|
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
|
|
|
|
|
stage.getViewport().apply();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.render(delta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void draw() {
|
|
|
|
|
screenBatch.begin();
|
|
|
|
|
screenBatch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
screenBatch.end();
|
|
|
|
|
stage.draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void preAssetLoad() {
|
|
|
|
|
mlc.getMusicList().deleteObservers();
|
|
|
|
|
mlc.deleteObservers();
|
|
|
|
|
|
|
|
|
|
stage.clear();
|
|
|
|
|
mainPage.dispose();
|
|
|
|
|
screenBatch.dispose();
|
|
|
|
|
optionsPage.dispose();
|
|
|
|
|
creditsPage.dispose();
|
|
|
|
|
keybindPage.dispose();
|
|
|
|
|
musicSelectionPage.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void show() {
|
|
|
|
|
Gdx.input.setInputProcessor(stage);
|
|
|
|
@@ -280,31 +269,82 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
@Override
|
|
|
|
|
public void dispose() {
|
|
|
|
|
stage.dispose();
|
|
|
|
|
unloadShaders();
|
|
|
|
|
dismantleShaders();
|
|
|
|
|
mic.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void calcLerpAlpha(int width) {
|
|
|
|
|
if (width <= 3835) {
|
|
|
|
|
lerpAlpha = 5.0f;
|
|
|
|
|
} else {
|
|
|
|
|
lerpAlpha = 5.5f;
|
|
|
|
|
public void setupShaders() {
|
|
|
|
|
Gdx.app.debug("Shader", "Loading glow shaders.");
|
|
|
|
|
batch = new SpriteBatch();
|
|
|
|
|
screenViewport = new ScreenViewport();
|
|
|
|
|
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
if (brightFilterShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", brightFilterShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
|
|
|
|
|
if (!gaussianBlurShader.isCompiled()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
if (gaussianBlurShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", gaussianBlurShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
|
|
|
|
|
if (!combineShader.isCompiled()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", combineShader.getLog());
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
if (combineShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", combineShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Gdx.graphics.getWidth() < 1024) {
|
|
|
|
|
fboSize = 1024;
|
|
|
|
|
} else if (Gdx.graphics.getWidth() < 2048) {
|
|
|
|
|
fboSize = 2048;
|
|
|
|
|
} 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(normalBuffer.getColorBufferTexture());
|
|
|
|
|
fboRegion.flip(false, true);
|
|
|
|
|
|
|
|
|
|
combineShader.begin();
|
|
|
|
|
combineShader.setUniformi("u_texture1", 1);
|
|
|
|
|
combineShader.end();
|
|
|
|
|
|
|
|
|
|
vBlur.getColorBufferTexture().bind(1);
|
|
|
|
|
|
|
|
|
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
|
|
|
|
ShaderProgram.pedantic = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void unloadShaders() {
|
|
|
|
|
Gdx.app.debug("MainMenu", "shader being unloaded.");
|
|
|
|
|
public void dismantleShaders() {
|
|
|
|
|
if (core.getPrefs().getBoolean("glow shader")) {
|
|
|
|
|
if (shaderLoaded) {
|
|
|
|
|
brightFilterShader.dispose();
|
|
|
|
|
combineShader.dispose();
|
|
|
|
|
gaussianBlurShader.dispose();
|
|
|
|
|
normalBuffer.dispose();
|
|
|
|
|
lightFilterBuffer.dispose();
|
|
|
|
|
vBlur.dispose();
|
|
|
|
|
hBlur.dispose();
|
|
|
|
|
}
|
|
|
|
|
brightFilterShader.dispose();
|
|
|
|
|
combineShader.dispose();
|
|
|
|
|
gaussianBlurShader.dispose();
|
|
|
|
|
normalBuffer.dispose();
|
|
|
|
|
lightFilterBuffer.dispose();
|
|
|
|
|
vBlur.dispose();
|
|
|
|
|
hBlur.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
brightFilterShader = null;
|
|
|
|
@@ -315,16 +355,11 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
vBlur = null;
|
|
|
|
|
hBlur = null;
|
|
|
|
|
|
|
|
|
|
shaderLoaded = false;
|
|
|
|
|
setBlurlvl(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBlurlvl(int blurlvl) {
|
|
|
|
|
this.blurlvl = blurlvl;
|
|
|
|
|
if (blurlvl > 0) {
|
|
|
|
|
attemptLoadShaders();
|
|
|
|
|
} else {
|
|
|
|
|
unloadShaders();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector3 getCameraPosition() {
|
|
|
|
@@ -351,78 +386,13 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
|
|
|
|
return optionsPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int attemptLoadShaders() {
|
|
|
|
|
|
|
|
|
|
Gdx.app.debug("MainMenu", "Attempting to load shaders.");
|
|
|
|
|
if (core.getPrefs().getBoolean("glow shader", true) && !shaderLoaded) {
|
|
|
|
|
if (core.getPrefs().getBoolean("enhanced glow", false)) {
|
|
|
|
|
blurlvl = 5;
|
|
|
|
|
} else {
|
|
|
|
|
blurlvl = 1;
|
|
|
|
|
}
|
|
|
|
|
Gdx.app.debug("Shader", "Loading glow shaders.");
|
|
|
|
|
screenViewport = new ScreenViewport();
|
|
|
|
|
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
|
|
|
|
|
if (brightFilterShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", brightFilterShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
setBlurlvl(0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
|
|
|
|
|
if (!gaussianBlurShader.isCompiled()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
|
|
|
|
|
if (gaussianBlurShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", gaussianBlurShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
setBlurlvl(0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
|
|
|
|
|
if (!combineShader.isCompiled()) {
|
|
|
|
|
Gdx.app.error("Shader failed to compile", combineShader.getLog());
|
|
|
|
|
if (combineShader.getLog().length() != 0) {
|
|
|
|
|
Gdx.app.error("Shader", combineShader.getLog());
|
|
|
|
|
}
|
|
|
|
|
setBlurlvl(0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Gdx.graphics.getWidth() < 1024) {
|
|
|
|
|
fboSize = 1024;
|
|
|
|
|
} else if (Gdx.graphics.getWidth() < 2048) {
|
|
|
|
|
fboSize = 2048;
|
|
|
|
|
} 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(normalBuffer.getColorBufferTexture());
|
|
|
|
|
fboRegion.flip(false, true);
|
|
|
|
|
|
|
|
|
|
combineShader.begin();
|
|
|
|
|
combineShader.setUniformi("u_texture1", 1);
|
|
|
|
|
combineShader.end();
|
|
|
|
|
|
|
|
|
|
vBlur.getColorBufferTexture().bind(1);
|
|
|
|
|
|
|
|
|
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
|
|
|
|
ShaderProgram.pedantic = false;
|
|
|
|
|
shaderLoaded = true;
|
|
|
|
|
|
|
|
|
|
private void calcLerpAlpha(int width) {
|
|
|
|
|
if (width <= 3835) {
|
|
|
|
|
lerpAlpha = 5.0f;
|
|
|
|
|
} else {
|
|
|
|
|
lerpAlpha = 5.5f;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|