different glow shader test?

This commit is contained in:
Harrison Deng 2017-07-18 00:14:53 -05:00
parent 97faafa327
commit 5f1958e62d
2 changed files with 32 additions and 27 deletions

View File

@ -1,37 +1,42 @@
#ifdef GL_ES #ifdef GL_ES
#define LOWP lowp #define LOWP lowp
precision mediump float; precision mediump float;
#else #else
#define LOWP #define LOWP
#endif #endif
varying LOWP vec4 vColor; varying LOWP vec4 vColor;
varying vec2 vTexCoord; varying vec2 vTexCoord;
uniform sampler2D u_texture; uniform sampler2D u_texture;
uniform float resolution;
uniform float radius;
uniform vec2 dir;
void main() { void main()
{
vec4 sum = vec4(0);
vec2 texcoord = vTexCoord;
int j;
int i;
vec4 sum = vec4(0.0); for( i= -4 ;i < 4; i++)
vec2 tc = vTexCoord; {
float blur = radius/resolution; for (j = -3; j < 3; j++)
{
float hstep = dir.x; sum += texture2D(u_texture, texcoord + vec2(j, i)*0.004) * 0.25;
float vstep = dir.y; }
}
sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.05; if (texture2D(u_texture, texcoord).r < 0.3)
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; gl_FragColor = sum*sum*0.012 + texture2D(u_texture, texcoord);
sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.15; }
else
sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.16; {
if (texture2D(u_texture, texcoord).r < 0.5)
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; gl_FragColor = sum*sum*0.009 + texture2D(u_texture, texcoord);
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; else
{
gl_FragColor = vColor * vec4(sum.rgb, 1.0); gl_FragColor = sum*sum*0.0075 + texture2D(u_texture, texcoord);
}
}
} }

View File

@ -100,8 +100,8 @@ public class GamePlayArea extends Stage {
if (bgShader != null) { if (bgShader != null) {
getBatch().setShader(bgShader); getBatch().setShader(bgShader);
bgShader.setUniformf("resolution", background.getWidth(), background.getHeight());
bgShader.setUniformf("time", time); bgShader.setUniformf("time", time);
bgShader.setUniformf("resolution", background.getWidth(), background.getHeight());
} }
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT); getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
getBatch().end(); getBatch().end();