diff --git a/android/assets/shaders/bg_frag.glsl b/android/assets/shaders/bg_frag.glsl index 4229bb3..cc042a0 100755 --- a/android/assets/shaders/bg_frag.glsl +++ b/android/assets/shaders/bg_frag.glsl @@ -2,7 +2,6 @@ precision mediump float; #endif - uniform float time; uniform vec2 mouse; uniform vec2 resolution; diff --git a/android/assets/shaders/bg_vert.glsl b/android/assets/shaders/bg_vert.glsl index 86c08a8..f0b6c23 100755 --- a/android/assets/shaders/bg_vert.glsl +++ b/android/assets/shaders/bg_vert.glsl @@ -4,9 +4,11 @@ attribute vec2 a_texCoord0; uniform mat4 u_projTrans; +varying vec4 vColor; varying vec2 vTexCoord; -void main() { - vTexCoord = a_texCoord0; +void main() { + vColor = a_color; + vTexCoord = a_texCoord0; gl_Position = u_projTrans * a_position; } diff --git a/android/assets/shaders/glow_frag.glsl b/android/assets/shaders/glow_frag.glsl index cb17cec..d31d8a0 100755 --- a/android/assets/shaders/glow_frag.glsl +++ b/android/assets/shaders/glow_frag.glsl @@ -1,33 +1,37 @@ +#ifdef GL_ES +#define LOWP lowp + precision mediump float; +#else + #define LOWP +#endif +varying LOWP vec4 vColor; +varying vec2 vTexCoord; + uniform sampler2D u_texture; +uniform float resolution; +uniform float radius; +uniform vec2 dir; -uniform vec2 vTexCoord; -void main() -{ - vec4 sum = vec4(0); - vec2 texcoord = vTexCoord; - int j; - int i; +void main() { - for( i= -4 ;i < 4; i++) - { - for (j = -3; j < 3; j++) - { - sum += texture2D(u_texture, texcoord + vec2(j, i)*0.004) * 0.25; - } - } - if (texture2D(u_texture, texcoord).r < 0.3) - { - gl_FragColor = sum*sum*0.012 + texture2D(u_texture, texcoord); - } - else - { - if (texture2D(u_texture, texcoord).r < 0.5) - { - gl_FragColor = sum*sum*0.009 + texture2D(u_texture, texcoord); - } - else - { - gl_FragColor = sum*sum*0.0075 + texture2D(u_texture, texcoord); - } - } + vec4 sum = vec4(0.0); + vec2 tc = vTexCoord; + float blur = radius/resolution; + + float hstep = dir.x; + float vstep = dir.y; + + sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.05; + sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.09; + sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.12; + sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.15; + + sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.16; + + sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.15; + sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.12; + sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.09; + sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.05; + + gl_FragColor = vColor * vec4(sum.rgb, 1.0); } diff --git a/android/assets/shaders/glow_vert.glsl b/android/assets/shaders/glow_vert.glsl index 86c08a8..f0b6c23 100755 --- a/android/assets/shaders/glow_vert.glsl +++ b/android/assets/shaders/glow_vert.glsl @@ -4,9 +4,11 @@ attribute vec2 a_texCoord0; uniform mat4 u_projTrans; +varying vec4 vColor; varying vec2 vTexCoord; -void main() { - vTexCoord = a_texCoord0; +void main() { + vColor = a_color; + vTexCoord = a_texCoord0; gl_Position = u_projTrans * a_position; } diff --git a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java index bb029a3..1025cff 100755 --- a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java +++ b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java @@ -73,7 +73,7 @@ public class AudioAnalyzer { UMBinBegin = 200; UMBinEnd = 512; - bassThresholdCalcRange = thresholdRangeCalc(0.3f); + bassThresholdCalcRange = thresholdRangeCalc(0.28f); UMThresholdCalcRange = thresholdRangeCalc(0.3f); Gdx.app.debug("Read freq", String.valueOf(audioData.getFormat().getSampleRate())); diff --git a/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java b/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java index 90e447b..d19bdd9 100755 --- a/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java +++ b/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java @@ -56,7 +56,7 @@ public class RhythmMapAlgorithm implements Runnable { map.beginBuild(); for (int index = 0; index < bassPeaks.size; index++) { if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) { - if (bassPeaks.get(index) >= avgBass*0.9f) { + if (bassPeaks.get(index) >= avgBass) { //TODO basic void circle spawning float warningTime = map.goBack((int) (windowPerSecond*1.5f))/windowPerSecond; float endRadius = (bassPeaks.get(index)/bassMax)*(Polyjet.GAME_AREA_HEIGHT/4f); @@ -67,7 +67,6 @@ public class RhythmMapAlgorithm implements Runnable { endRadius/(avgSPB*0.7f), warningTime ); - map.resetIndex(); } if (UMPeaks.get(index) >= avgUM) { diff --git a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java index 5ac88d3..7c7f6e6 100755 --- a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java +++ b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java @@ -31,7 +31,7 @@ public class GamePlayArea extends Stage { private float yTeleport = Polyjet.GAME_AREA_HEIGHT/2; private int score; - private ShaderProgram invert; + private ShaderProgram glowShader; private ShaderProgram bgShader; private Texture background; @@ -60,18 +60,16 @@ public class GamePlayArea extends Stage { * @param prefs */ public void loadShaders(Preferences prefs) { - if (prefs.getBoolean("invert shader")) { - Gdx.app.debug("Shader", "using inversion shader"); - invert = new ShaderProgram(Gdx.files.internal("shaders/invert_vert.glsl").readString(), Gdx.files.internal("shaders/invert_frag.glsl").readString()); - ShaderProgram.pedantic = false; - if (!invert.isCompiled()) { - System.err.println(invert.getLog()); + if (prefs.getBoolean("glow shader")) { + Gdx.app.debug("Shader", "using glow shader"); + glowShader = new ShaderProgram(Gdx.files.internal("shaders/glow_vert.glsl").readString(), Gdx.files.internal("shaders/glow_frag.glsl").readString()); + if (!glowShader.isCompiled()) { + System.err.println(glowShader.getLog()); System.exit(0); } - if (invert.getLog().length()!=0) { - System.out.println(invert.getLog()); + if (glowShader.getLog().length()!=0) { + System.out.println(glowShader.getLog()); } - getBatch().setShader(invert); } @@ -108,9 +106,11 @@ public class GamePlayArea extends Stage { getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT); getBatch().end(); - - - getBatch().setShader(null); + if (glowShader != null) { + getBatch().setShader(glowShader); + } else { + getBatch().setShader(null); + } super.draw(); }