| @@ -0,0 +1,16 @@ | |||
| 1 | + | uniform mat4 u_Color; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | varying vec2 v_TexCoord2; | |
| 4 | + | varying vec2 v_TexCoord3; | |
| 5 | + | uniform sampler2D u_Tex0; | |
| 6 | + | uniform sampler2D u_Tex1; | |
| 7 | + | void main() | |
| 8 | + | { | |
| 9 | + | gl_FragColor = texture2D(u_Tex0, v_TexCoord); | |
| 10 | + | vec4 texcolor = texture2D(u_Tex0, v_TexCoord2); | |
| 11 | + | vec4 effectColor = texture2D(u_Tex1, v_TexCoord3); | |
| 12 | + | if(texcolor.a > 0.9) { | |
| 13 | + | gl_FragColor *= effectColor; | |
| 14 | + | } | |
| 15 | + | if(gl_FragColor.a < 0.01) discard; | |
| 16 | + | } |
| @@ -0,0 +1,40 @@ | |||
| 1 | + | attribute vec2 a_TexCoord; | |
| 2 | + | uniform mat3 u_TextureMatrix; | |
| 3 | + | varying vec2 v_TexCoord; | |
| 4 | + | varying vec2 v_TexCoord2; | |
| 5 | + | varying vec2 v_TexCoord3; | |
| 6 | + | attribute vec2 a_Vertex; | |
| 7 | + | uniform mat3 u_TransformMatrix; | |
| 8 | + | uniform mat3 u_ProjectionMatrix; | |
| 9 | + | uniform vec2 u_Offset; | |
| 10 | + | uniform float u_Time; | |
| 11 | + | uniform vec2 u_Center; | |
| 12 | + | ||
| 13 | + | vec2 effectTextureSize = vec2(144.0, 100.0); | |
| 14 | + | vec2 direction = vec2(1.0,1.0); | |
| 15 | + | float speed = 10.0; | |
| 16 | + | ||
| 17 | + | void main() | |
| 18 | + | { | |
| 19 | + | vec2 offset = direction * speed * u_Time; | |
| 20 | + | gl_Position = vec4((u_ProjectionMatrix * u_TransformMatrix * vec3(a_Vertex.xy, 1.0)).xy, 1.0, 1.0); | |
| 21 | + | v_TexCoord = (u_TextureMatrix * vec3(a_TexCoord,1.0)).xy; | |
| 22 | + | v_TexCoord2 = (u_TextureMatrix * vec3(a_TexCoord + u_Offset,1.0)).xy; | |
| 23 | + | ||
| 24 | + | vec2 vertex = a_Vertex; | |
| 25 | + | if(vertex.x < u_Center.x) { | |
| 26 | + | vertex.x = effectTextureSize.x / 10.0; | |
| 27 | + | } | |
| 28 | + | if(vertex.x > u_Center.x) { | |
| 29 | + | vertex.x = effectTextureSize.x - effectTextureSize.x / 10.0; | |
| 30 | + | } | |
| 31 | + | if(vertex.y < u_Center.y) { | |
| 32 | + | vertex.y = effectTextureSize.y / 10.0; | |
| 33 | + | } | |
| 34 | + | if(vertex.y > u_Center.y) { | |
| 35 | + | vertex.y = effectTextureSize.y - effectTextureSize.y / 10.0; | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | v_TexCoord3 = ((vertex) / effectTextureSize); | |
| 39 | + | } | |
| 40 | + |
| @@ -0,0 +1,60 @@ | |||
| 1 | + | #if __VERSION__ < 130 | |
| 2 | + | #define TEXTURE2D texture2D | |
| 3 | + | #else | |
| 4 | + | #define TEXTURE2D texture | |
| 5 | + | #endif | |
| 6 | + | ||
| 7 | + | uniform float u_Time; | |
| 8 | + | uniform sampler2D u_Tex0; | |
| 9 | + | uniform sampler2D u_Tex1; | |
| 10 | + | uniform sampler2D u_Tex2; | |
| 11 | + | varying vec2 v_TexCoord; | |
| 12 | + | varying vec2 v_TexCoord2; | |
| 13 | + | ||
| 14 | + | uniform vec2 u_Resolution; | |
| 15 | + | uniform float u_float1; | |
| 16 | + | uniform float u_float2; | |
| 17 | + | uniform float u_float3; | |
| 18 | + | varying vec2 v_TexCoord3; | |
| 19 | + | varying vec2 v_TexCoord4; | |
| 20 | + | uniform float u_float4; | |
| 21 | + | ||
| 22 | + | float _OutlineAlpha = 1.0; | |
| 23 | + | float _OutlineGlow = 1.0; | |
| 24 | + | float outline_thickness = 0.05; | |
| 25 | + | vec4 _OutlineColor = vec4(1.0,1.0,0.0,0.0); | |
| 26 | + | ||
| 27 | + | void main() | |
| 28 | + | { | |
| 29 | + | vec4 _MainTex = TEXTURE2D(u_Tex0, v_TexCoord); | |
| 30 | + | vec2 destUv = vec2(0.01 * _MainTex.x, 0.01 * _MainTex.y); | |
| 31 | + | ||
| 32 | + | float outDistortAmnt = (TEXTURE2D(u_Tex1, v_TexCoord4).r - 0.5) * outline_thickness; | |
| 33 | + | destUv.x += outDistortAmnt; | |
| 34 | + | destUv.y += outDistortAmnt; | |
| 35 | + | ||
| 36 | + | float spriteLeft = TEXTURE2D(u_Tex0, v_TexCoord + vec2(destUv.x, 0)).a; | |
| 37 | + | float spriteRight = TEXTURE2D(u_Tex0, v_TexCoord - vec2(destUv.x, 0)).a; | |
| 38 | + | float spriteBottom = TEXTURE2D(u_Tex0, v_TexCoord + vec2(0, destUv.y)).a; | |
| 39 | + | float spriteTop = TEXTURE2D(u_Tex0, v_TexCoord - vec2(0, destUv.y)).a; | |
| 40 | + | float result = spriteLeft + spriteRight + spriteBottom + spriteTop; | |
| 41 | + | ||
| 42 | + | float spriteTopLeft = TEXTURE2D(u_Tex0, v_TexCoord + vec2(destUv.x, destUv.y)).a; | |
| 43 | + | float spriteTopRight = TEXTURE2D(u_Tex0, v_TexCoord + vec2(-destUv.x, destUv.y)).a; | |
| 44 | + | float spriteBotLeft = TEXTURE2D(u_Tex0, v_TexCoord + vec2(destUv.x, -destUv.y)).a; | |
| 45 | + | float spriteBotRight = TEXTURE2D(u_Tex0, v_TexCoord + vec2(-destUv.x, -destUv.y)).a; | |
| 46 | + | result = result + spriteTopLeft + spriteTopRight + spriteBotLeft + spriteBotRight; | |
| 47 | + | ||
| 48 | + | result = step(0.05, clamp(result,0.0,1.0)); | |
| 49 | + | vec4 tempOutColor = TEXTURE2D(u_Tex2, v_TexCoord4); | |
| 50 | + | //tempOutColor *= _OutlineColor; | |
| 51 | + | _OutlineColor = tempOutColor; | |
| 52 | + | ||
| 53 | + | result *= (1.0 - _MainTex.a) * _OutlineAlpha; | |
| 54 | + | ||
| 55 | + | ||
| 56 | + | vec4 outline = _OutlineColor; | |
| 57 | + | //outline.rgb *= _OutlineGlow; | |
| 58 | + | //outline.a = result; | |
| 59 | + | gl_FragColor = mix(_MainTex, outline, result); | |
| 60 | + | } |
| @@ -0,0 +1,75 @@ | |||
| 1 | + | attribute vec2 a_Vertex; | |
| 2 | + | attribute vec2 a_TexCoord; | |
| 3 | + | uniform mat3 u_TextureMatrix; | |
| 4 | + | varying vec2 v_TexCoord; | |
| 5 | + | varying vec2 v_TexCoord2; | |
| 6 | + | uniform mat3 u_TransformMatrix; | |
| 7 | + | uniform mat3 u_ProjectionMatrix; | |
| 8 | + | varying vec2 v_TexCoord3; | |
| 9 | + | varying vec2 v_TexCoord4; | |
| 10 | + | uniform vec2 u_Offset; | |
| 11 | + | uniform vec2 u_Center; | |
| 12 | + | uniform float u_Time; | |
| 13 | + | vec2 direction = vec2(0.5,1.0); | |
| 14 | + | float speed = 100.0; | |
| 15 | + | ||
| 16 | + | vec2 effectTextureSize = vec2(256.0, 256.0); | |
| 17 | + | void main() | |
| 18 | + | { | |
| 19 | + | vec2 vertex = a_Vertex; | |
| 20 | + | if(vertex.x < u_Center.x) { | |
| 21 | + | vertex.x = effectTextureSize.x / 10.0; | |
| 22 | + | } | |
| 23 | + | if(vertex.x > u_Center.x) { | |
| 24 | + | vertex.x = effectTextureSize.x - effectTextureSize.x / 10.0; | |
| 25 | + | } | |
| 26 | + | if(vertex.y < u_Center.y) { | |
| 27 | + | vertex.y = effectTextureSize.y / 1.0; | |
| 28 | + | } | |
| 29 | + | if(vertex.y > u_Center.y) { | |
| 30 | + | vertex.y = effectTextureSize.y - effectTextureSize.y / 10.0; | |
| 31 | + | } | |
| 32 | + | v_TexCoord3.x = ((vertex.x + direction.x * u_Time * speed) / effectTextureSize.x); | |
| 33 | + | v_TexCoord3.y = ((vertex.y + direction.y * u_Time * (speed*6.0055)) / effectTextureSize.y); | |
| 34 | + | ||
| 35 | + | effectTextureSize = vec2(600.0, 550.0); | |
| 36 | + | vertex = a_Vertex; | |
| 37 | + | if(vertex.x < u_Center.x) { | |
| 38 | + | vertex.x = effectTextureSize.x / 10.0; | |
| 39 | + | } | |
| 40 | + | if(vertex.x > u_Center.x) { | |
| 41 | + | vertex.x = effectTextureSize.x - effectTextureSize.x / 10.0; | |
| 42 | + | } | |
| 43 | + | if(vertex.y < u_Center.y) { | |
| 44 | + | vertex.y = effectTextureSize.y / 10.0; | |
| 45 | + | } | |
| 46 | + | if(vertex.y > u_Center.y) { | |
| 47 | + | vertex.y = effectTextureSize.y - effectTextureSize.y / 10.0; | |
| 48 | + | } | |
| 49 | + | v_TexCoord4.x = ((vertex.x + direction.x * u_Time * speed) / effectTextureSize.x); | |
| 50 | + | v_TexCoord4.y = ((vertex.y + direction.y * u_Time * (speed*1.75)) / effectTextureSize.y); | |
| 51 | + | ||
| 52 | + | vertex = a_Vertex; | |
| 53 | + | vec2 text = a_TexCoord; | |
| 54 | + | vec2 text2 = a_TexCoord; | |
| 55 | + | if(a_Vertex.x < u_Center.x) { | |
| 56 | + | vertex.x -= 5.0; | |
| 57 | + | text.x -= 3.0; | |
| 58 | + | } | |
| 59 | + | if(a_Vertex.x > u_Center.x) { | |
| 60 | + | vertex.x += 5.0; | |
| 61 | + | text.x += 3.0; | |
| 62 | + | } | |
| 63 | + | if(a_Vertex.y < u_Center.y) { | |
| 64 | + | vertex.y -= 5.0; | |
| 65 | + | text.y -= 3.0; | |
| 66 | + | } | |
| 67 | + | if(a_Vertex.y > u_Center.y) { | |
| 68 | + | vertex.y += 5.0; | |
| 69 | + | text.y += 3.0; | |
| 70 | + | } | |
| 71 | + | gl_Position = vec4((u_ProjectionMatrix * u_TransformMatrix * vec3(a_Vertex.xy, 1.0)).xy, 1.0, 1.0); | |
| 72 | + | v_TexCoord = (u_TextureMatrix * vec3(text,1.0)).xy; | |
| 73 | + | v_TexCoord2 = (u_TextureMatrix * vec3(text + u_Offset,1.0)).xy; | |
| 74 | + | } | |
| 75 | + |
| @@ -0,0 +1,29 @@ | |||
| 1 | + | uniform mat4 u_Color; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | varying vec2 v_TexCoord2; | |
| 4 | + | varying vec2 v_TexCoord3; | |
| 5 | + | varying vec2 v_Position; | |
| 6 | + | uniform sampler2D u_Tex0; | |
| 7 | + | uniform float u_Time; | |
| 8 | + | uniform vec2 u_Resolution; | |
| 9 | + | ||
| 10 | + | void main() | |
| 11 | + | { | |
| 12 | + | gl_FragColor = texture2D(u_Tex0, v_TexCoord); | |
| 13 | + | vec4 texcolor = texture2D(u_Tex0, v_TexCoord2); | |
| 14 | + | vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3); | |
| 15 | + | if(texcolor.r > 0.9) { | |
| 16 | + | gl_FragColor *= texcolor.g > 0.9 ? u_Color[0] : u_Color[1]; | |
| 17 | + | } else if(texcolor.g > 0.9) { | |
| 18 | + | gl_FragColor *= u_Color[2]; | |
| 19 | + | } else if(texcolor.b > 0.9) { | |
| 20 | + | gl_FragColor *= u_Color[3]; | |
| 21 | + | } | |
| 22 | + | if(gl_FragColor.a < 0.01) { | |
| 23 | + | if(texcolor2.a > 0.01) { | |
| 24 | + | gl_FragColor = vec4(0.5 + abs(0.5 - mod(u_Time, 1.0)), 0.0, 1.0, 1.0); | |
| 25 | + | } else { | |
| 26 | + | discard; | |
| 27 | + | } | |
| 28 | + | } | |
| 29 | + | } |
| @@ -0,0 +1,41 @@ | |||
| 1 | + | attribute vec2 a_TexCoord; | |
| 2 | + | uniform mat3 u_TextureMatrix; | |
| 3 | + | varying vec2 v_TexCoord; | |
| 4 | + | varying vec2 v_TexCoord2; | |
| 5 | + | varying vec2 v_TexCoord3; | |
| 6 | + | varying vec2 v_Position; | |
| 7 | + | attribute vec2 a_Vertex; | |
| 8 | + | uniform mat3 u_TransformMatrix; | |
| 9 | + | uniform mat3 u_ProjectionMatrix; | |
| 10 | + | uniform vec2 u_Offset; | |
| 11 | + | uniform vec2 u_Resolution; | |
| 12 | + | uniform vec2 u_Center; | |
| 13 | + | ||
| 14 | + | void main() | |
| 15 | + | { | |
| 16 | + | vec2 vertex = a_Vertex; | |
| 17 | + | vec2 text = a_TexCoord; | |
| 18 | + | vec2 text2 = a_TexCoord; | |
| 19 | + | if(vertex.x < u_Center.x) { | |
| 20 | + | vertex.x -= 1.0; | |
| 21 | + | text.x -= 1.0; | |
| 22 | + | } | |
| 23 | + | if(vertex.x > u_Center.x) { | |
| 24 | + | vertex.x += 1.0; | |
| 25 | + | text.x += 1.0; | |
| 26 | + | } | |
| 27 | + | if(vertex.y < u_Center.y) { | |
| 28 | + | vertex.y -= 1.0; | |
| 29 | + | text.y -= 1.0; | |
| 30 | + | } | |
| 31 | + | if(vertex.y > u_Center.y) { | |
| 32 | + | vertex.y += 1.0; | |
| 33 | + | text.y += 1.0; | |
| 34 | + | } | |
| 35 | + | gl_Position = vec4((u_ProjectionMatrix * u_TransformMatrix * vec3(vertex.xy, 1.0)).xy, 1.0, 1.0); | |
| 36 | + | v_Position = a_Vertex.xy - u_Center; | |
| 37 | + | v_TexCoord = (u_TextureMatrix * vec3(text,1.0)).xy; | |
| 38 | + | v_TexCoord2 = (u_TextureMatrix * vec3(text + u_Offset,1.0)).xy; | |
| 39 | + | v_TexCoord3 = (u_TextureMatrix * vec3(text2,1.0)).xy; | |
| 40 | + | } | |
| 41 | + |
| @@ -0,0 +1,16 @@ | |||
| 1 | + | attribute vec2 a_TexCoord; | |
| 2 | + | attribute vec2 a_Vertex; | |
| 3 | + | uniform mat3 u_TextureMatrix; | |
| 4 | + | uniform mat3 u_TransformMatrix; | |
| 5 | + | uniform mat3 u_ProjectionMatrix; | |
| 6 | + | varying vec2 v_TexCoord; | |
| 7 | + | ||
| 8 | + | vec4 calculatePosition() { | |
| 9 | + | return vec4(u_ProjectionMatrix * u_TransformMatrix * vec3(a_Vertex.xy, 1.0), 1.0); | |
| 10 | + | } | |
| 11 | + | ||
| 12 | + | void main() | |
| 13 | + | { | |
| 14 | + | gl_Position = calculatePosition(); | |
| 15 | + | v_TexCoord = (u_TextureMatrix * vec3(a_TexCoord,1.0)).xy; | |
| 16 | + | } |
| @@ -0,0 +1,55 @@ | |||
| 1 | + | uniform mat4 u_Color; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | varying vec2 v_TexCoord2; | |
| 4 | + | varying vec2 v_TexCoord3; | |
| 5 | + | varying vec2 v_Position; | |
| 6 | + | uniform sampler2D u_Tex0; | |
| 7 | + | uniform float u_Time; | |
| 8 | + | uniform vec2 u_Resolution; | |
| 9 | + | ||
| 10 | + | // CONFIG | |
| 11 | + | float speed = 10.0; | |
| 12 | + | float height = 10.0; | |
| 13 | + | float angle = 45.0; // degrees | |
| 14 | + | float intensity = 2.0; | |
| 15 | + | // CONFIG END | |
| 16 | + | ||
| 17 | + | vec2 rotate(vec2 v, float a) { | |
| 18 | + | float s = sin(a); | |
| 19 | + | float c = cos(a); | |
| 20 | + | mat2 m = mat2(c, -s, s, c); | |
| 21 | + | return m * v; | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | void main() | |
| 25 | + | { | |
| 26 | + | gl_FragColor = texture2D(u_Tex0, v_TexCoord); | |
| 27 | + | vec4 texcolor = texture2D(u_Tex0, v_TexCoord2); | |
| 28 | + | vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3); | |
| 29 | + | if(texcolor.r > 0.9) { | |
| 30 | + | gl_FragColor *= texcolor.g > 0.9 ? u_Color[0] : u_Color[1]; | |
| 31 | + | } else if(texcolor.g > 0.9) { | |
| 32 | + | gl_FragColor *= u_Color[2]; | |
| 33 | + | } else if(texcolor.b > 0.9) { | |
| 34 | + | gl_FragColor *= u_Color[3]; | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | vec4 col; | |
| 38 | + | col.r = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 0.) * 0.5 + 0.5; | |
| 39 | + | col.g = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 2.) * 0.5 + 0.5; | |
| 40 | + | col.b = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 4.) * 0.5 + 0.5; | |
| 41 | + | col.a = 1.0; | |
| 42 | + | ||
| 43 | + | if(gl_FragColor.a < 0.01) { | |
| 44 | + | if(texcolor2.a > 0.01) { | |
| 45 | + | vec2 p = rotate(v_Position, (angle / 180.0) * 3.14); | |
| 46 | + | float frame = mod(p.y, height); | |
| 47 | + | float timeFrame = mod(u_Time * speed, height); | |
| 48 | + | float dist = min(abs(frame - timeFrame), min(abs(frame - timeFrame - height), abs(frame - timeFrame + height))); | |
| 49 | + | gl_FragColor.xyz *= intensity / sqrt(max(2.0, dist)); | |
| 50 | + | gl_FragColor = col; | |
| 51 | + | } else { | |
| 52 | + | discard; | |
| 53 | + | } | |
| 54 | + | } | |
| 55 | + | } |
| @@ -0,0 +1,43 @@ | |||
| 1 | + | attribute vec2 a_TexCoord; | |
| 2 | + | uniform mat3 u_TextureMatrix; | |
| 3 | + | varying vec2 v_TexCoord; | |
| 4 | + | varying vec2 v_TexCoord2; | |
| 5 | + | varying vec2 v_TexCoord3; | |
| 6 | + | varying vec2 v_Position; | |
| 7 | + | attribute vec2 a_Vertex; | |
| 8 | + | uniform mat3 u_TransformMatrix; | |
| 9 | + | uniform mat3 u_ProjectionMatrix; | |
| 10 | + | uniform vec2 u_Offset; | |
| 11 | + | uniform vec2 u_Resolution; | |
| 12 | + | uniform vec2 u_Center; | |
| 13 | + | ||
| 14 | + | void main() | |
| 15 | + | { | |
| 16 | + | vec2 vertex = a_Vertex; | |
| 17 | + | vec2 text = a_TexCoord; | |
| 18 | + | vec2 text2 = a_TexCoord; | |
| 19 | + | if(vertex.x < u_Center.x) { | |
| 20 | + | vertex.x -= 1.0; | |
| 21 | + | text.x -= 1.0; | |
| 22 | + | } | |
| 23 | + | if(vertex.x > u_Center.x) { | |
| 24 | + | vertex.x += 1.0; | |
| 25 | + | text.x += 1.0; | |
| 26 | + | } | |
| 27 | + | if(vertex.y < u_Center.y) { | |
| 28 | + | vertex.y -= 1.0; | |
| 29 | + | text.y -= 1.0; | |
| 30 | + | } | |
| 31 | + | if(vertex.y > u_Center.y) { | |
| 32 | + | vertex.y += 1.0; | |
| 33 | + | text.y += 1.0; | |
| 34 | + | } | |
| 35 | + | ||
| 36 | + | gl_Position = vec4((u_ProjectionMatrix * u_TransformMatrix * vec3(vertex.xy, 1.0)).xy, 1.0, 1.0); | |
| 37 | + | v_TexCoord = (u_TextureMatrix * vec3(text,1.0)).xy; | |
| 38 | + | v_TexCoord2 = (u_TextureMatrix * vec3(text + u_Offset,1.0)).xy; | |
| 39 | + | v_TexCoord3 = (u_TextureMatrix * vec3(text2,1.0)).xy; | |
| 40 | + | ||
| 41 | + | ||
| 42 | + | } | |
| 43 | + |
| @@ -0,0 +1,13 @@ | |||
| 1 | + | uniform float u_Time; | |
| 2 | + | uniform sampler2D u_Tex0; | |
| 3 | + | varying vec2 v_TexCoord; | |
| 4 | + | ||
| 5 | + | void main() | |
| 6 | + | { | |
| 7 | + | vec4 col = texture2D(u_Tex0, v_TexCoord); | |
| 8 | + | float d = u_Time * 2.0; | |
| 9 | + | col.x += (1.0 + sin(d))*0.25; | |
| 10 | + | col.y += (1.0 + sin(d*2.0))*0.25; | |
| 11 | + | col.z += (1.0 + sin(d*4.0))*0.25; | |
| 12 | + | gl_FragColor = col; | |
| 13 | + | } |
| @@ -0,0 +1,33 @@ | |||
| 1 | + | uniform mat4 u_Color; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | varying vec2 v_TexCoord2; | |
| 4 | + | varying vec2 v_TexCoord3; | |
| 5 | + | varying vec2 v_Position; | |
| 6 | + | uniform sampler2D u_Tex0; | |
| 7 | + | uniform float u_Time; | |
| 8 | + | uniform vec2 u_Resolution; | |
| 9 | + | ||
| 10 | + | void main() | |
| 11 | + | { | |
| 12 | + | gl_FragColor = texture2D(u_Tex0, v_TexCoord); | |
| 13 | + | vec4 texcolor = texture2D(u_Tex0, v_TexCoord2); | |
| 14 | + | vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3); | |
| 15 | + | if(texcolor.r > 0.9) { | |
| 16 | + | gl_FragColor *= texcolor.g > 0.9 ? u_Color[0] : u_Color[1]; | |
| 17 | + | } else if(texcolor.g > 0.9) { | |
| 18 | + | gl_FragColor *= u_Color[2]; | |
| 19 | + | } else if(texcolor.b > 0.9) { | |
| 20 | + | gl_FragColor *= u_Color[3]; | |
| 21 | + | } | |
| 22 | + | if(gl_FragColor.a < 0.01) { | |
| 23 | + | if(texcolor2.a > 0.01) { | |
| 24 | + | // Interpolate between green and orange based on time | |
| 25 | + | float t = 0.5 + abs(0.5 - mod(u_Time, 1.0)); | |
| 26 | + | gl_FragColor = mix(vec4(1.0, 0.2, 1.0, 1.0), vec4(1.0, 0.7, 1.0, 1.0), t); | |
| 27 | + | } else { | |
| 28 | + | discard; | |
| 29 | + | } | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | ||
| 33 | + | } |
| @@ -0,0 +1,41 @@ | |||
| 1 | + | attribute vec2 a_TexCoord; | |
| 2 | + | uniform mat3 u_TextureMatrix; | |
| 3 | + | varying vec2 v_TexCoord; | |
| 4 | + | varying vec2 v_TexCoord2; | |
| 5 | + | varying vec2 v_TexCoord3; | |
| 6 | + | varying vec2 v_Position; | |
| 7 | + | attribute vec2 a_Vertex; | |
| 8 | + | uniform mat3 u_TransformMatrix; | |
| 9 | + | uniform mat3 u_ProjectionMatrix; | |
| 10 | + | uniform vec2 u_Offset; | |
| 11 | + | uniform vec2 u_Resolution; | |
| 12 | + | uniform vec2 u_Center; | |
| 13 | + | ||
| 14 | + | void main() | |
| 15 | + | { | |
| 16 | + | vec2 vertex = a_Vertex; | |
| 17 | + | vec2 text = a_TexCoord; | |
| 18 | + | vec2 text2 = a_TexCoord; | |
| 19 | + | if(vertex.x < u_Center.x) { | |
| 20 | + | vertex.x -= 1.0; | |
| 21 | + | text.x -= 1.0; | |
| 22 | + | } | |
| 23 | + | if(vertex.x > u_Center.x) { | |
| 24 | + | vertex.x += 1.0; | |
| 25 | + | text.x += 1.0; | |
| 26 | + | } | |
| 27 | + | if(vertex.y < u_Center.y) { | |
| 28 | + | vertex.y -= 1.0; | |
| 29 | + | text.y -= 1.0; | |
| 30 | + | } | |
| 31 | + | if(vertex.y > u_Center.y) { | |
| 32 | + | vertex.y += 1.0; | |
| 33 | + | text.y += 1.0; | |
| 34 | + | } | |
| 35 | + | gl_Position = vec4((u_ProjectionMatrix * u_TransformMatrix * vec3(vertex.xy, 1.0)).xy, 1.0, 1.0); | |
| 36 | + | v_Position = a_Vertex.xy - u_Center; | |
| 37 | + | v_TexCoord = (u_TextureMatrix * vec3(text,1.0)).xy; | |
| 38 | + | v_TexCoord2 = (u_TextureMatrix * vec3(text + u_Offset,1.0)).xy; | |
| 39 | + | v_TexCoord3 = (u_TextureMatrix * vec3(text2,1.0)).xy; | |
| 40 | + | } | |
| 41 | + |
| @@ -0,0 +1,19 @@ | |||
| 1 | + | uniform float u_Time; | |
| 2 | + | uniform vec2 u_Resolution; | |
| 3 | + | uniform sampler2D u_Tex0; | |
| 4 | + | varying vec2 v_TexCoord; | |
| 5 | + | ||
| 6 | + | void main(void) | |
| 7 | + | { | |
| 8 | + | vec2 halfres = u_Resolution.xy/2.0; | |
| 9 | + | vec2 cPos = v_TexCoord.xy * u_Resolution; | |
| 10 | + | ||
| 11 | + | cPos.x -= 0.5*halfres.x*sin(u_Time/2.0)+0.3*halfres.x*cos(u_Time)+halfres.x; | |
| 12 | + | cPos.y -= 0.4*halfres.y*sin(u_Time/5.0)+0.3*halfres.y*cos(u_Time)+halfres.y; | |
| 13 | + | float cLength = length(cPos); | |
| 14 | + | ||
| 15 | + | vec2 uv = v_TexCoord.xy+ ((cPos/cLength)*sin(cLength/30.0-u_Time*10.0)/25.0)*0.15; | |
| 16 | + | vec3 col = texture2D(u_Tex0,uv).xyz * 250.0/cLength; | |
| 17 | + | ||
| 18 | + | gl_FragColor = vec4(col,1.0); | |
| 19 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 2.2; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 1.5; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 1.8; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 2.0; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 2.4; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 2.8; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 3.2; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 3.6; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 4.0; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | uniform sampler2D u_Tex0; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | ||
| 4 | + | // some const, tweak for best look | |
| 5 | + | const float sampleDist = 1.0; | |
| 6 | + | const float sampleStrength = 4.4; | |
| 7 | + | ||
| 8 | + | void main(void) | |
| 9 | + | { | |
| 10 | + | // 0.5,0.5 is the center of the screen | |
| 11 | + | // so substracting v_TexCoord from it will result in | |
| 12 | + | // a vector pointing to the middle of the screen | |
| 13 | + | vec2 dir = 0.5 - v_TexCoord; | |
| 14 | + | ||
| 15 | + | // calculate the distance to the center of the screen | |
| 16 | + | float dist = sqrt(dir.x*dir.x + dir.y*dir.y); | |
| 17 | + | ||
| 18 | + | // normalize the direction (reuse the distance) | |
| 19 | + | dir = dir/dist; | |
| 20 | + | ||
| 21 | + | // this is the original colour of this fragment | |
| 22 | + | // using only this would result in a nonblurred version | |
| 23 | + | vec4 color = texture2D(u_Tex0,v_TexCoord); | |
| 24 | + | ||
| 25 | + | vec4 sum = color; | |
| 26 | + | ||
| 27 | + | // take 10 additional blur samples in the direction towards | |
| 28 | + | // the center of the screen | |
| 29 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); | |
| 30 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); | |
| 31 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); | |
| 32 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); | |
| 33 | + | sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); | |
| 34 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); | |
| 35 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); | |
| 36 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); | |
| 37 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); | |
| 38 | + | sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); | |
| 39 | + | ||
| 40 | + | // we have taken eleven samples | |
| 41 | + | sum *= 1.0/11.0; | |
| 42 | + | ||
| 43 | + | // weighten the blur effect with the distance to the | |
| 44 | + | // center of the screen ( further out is blurred more) | |
| 45 | + | float t = dist * sampleStrength; | |
| 46 | + | t = clamp(t ,0.0,1.0); //0 <= t <= 1 | |
| 47 | + | ||
| 48 | + | //Blend the original color with the averaged pixels | |
| 49 | + | gl_FragColor = mix(color, sum, t); | |
| 50 | + | } |
| @@ -0,0 +1,53 @@ | |||
| 1 | + | #ifdef GL_ES | |
| 2 | + | precision mediump float; | |
| 3 | + | #endif | |
| 4 | + | ||
| 5 | + | uniform float u_Time; | |
| 6 | + | uniform sampler2D u_Tex0; // Escena del juego | |
| 7 | + | uniform sampler2D u_Tex1; // Textura rain.png | |
| 8 | + | varying vec2 v_TexCoord; | |
| 9 | + | uniform vec2 u_WalkOffset; | |
| 10 | + | uniform float u_Floor; | |
| 11 | + | ||
| 12 | + | void main(void) | |
| 13 | + | { | |
| 14 | + | // 1. Restricción de piso (solo superficie y arriba) | |
| 15 | + | if (u_Floor > 7.0) discard; | |
| 16 | + | ||
| 17 | + | // 2. Coordenadas de la escena | |
| 18 | + | vec4 Game = texture2D(u_Tex0, v_TexCoord); | |
| 19 | + | ||
| 20 | + | // 3. Coordenadas para la lluvia (Screen Space + Movimiento) | |
| 21 | + | // Usamos gl_FragCoord para que sea independiente de los tiles del mapa. | |
| 22 | + | vec2 screenUV = gl_FragCoord.xy / 512.0; | |
| 23 | + | ||
| 24 | + | // u_WalkOffset normalizado para fluidez al caminar | |
| 25 | + | vec2 smoothWalk = u_WalkOffset / 32.0; | |
| 26 | + | ||
| 27 | + | // Desplazamiento de la textura para caída a 135º (diagonal \) | |
| 28 | + | float speed = u_Time * 1.5; | |
| 29 | + | vec2 rainUV = screenUV * 1.2 + vec2(speed * 0.4, -speed) + (smoothWalk * 0.05); | |
| 30 | + | ||
| 31 | + | // Leemos la textura de lluvia cargada en u_Tex1 | |
| 32 | + | vec4 RainTex = texture2D(u_Tex1, rainUV); | |
| 33 | + | ||
| 34 | + | // 4. EFECTO REBOTE (Splashes) | |
| 35 | + | // Generamos ondas circulares procedurales para simular el impacto en el suelo | |
| 36 | + | float splash = 0.0; | |
| 37 | + | vec2 splashGrid = fract(screenUV * 6.0 + vec2(u_Time * 0.1, 0.0)); | |
| 38 | + | float t = fract(u_Time * 3.0); | |
| 39 | + | ||
| 40 | + | if (t > 0.85) { | |
| 41 | + | float dist = length(splashGrid - 0.5); | |
| 42 | + | float circle = abs(dist - (t - 0.85) * 2.5); | |
| 43 | + | splash = smoothstep(0.04, 0.0, circle) * smoothstep(1.0, 0.85, t); | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | // Resultado Final | |
| 47 | + | // El canal rojo de la textura rain.png suele ser el que tiene la información de la gota. | |
| 48 | + | float intensity = RainTex.r * 0.8; | |
| 49 | + | vec3 rainColor = RainTex.rgb + (splash * 0.5); | |
| 50 | + | ||
| 51 | + | float opacity = 0.4; | |
| 52 | + | gl_FragColor = vec4(Game.rgb + rainColor * intensity * opacity, Game.a); | |
| 53 | + | } |
| @@ -0,0 +1,41 @@ | |||
| 1 | + | uniform mat4 u_Color; | |
| 2 | + | varying vec2 v_TexCoord; | |
| 3 | + | varying vec2 v_TexCoord2; | |
| 4 | + | varying vec2 v_TexCoord3; | |
| 5 | + | varying vec2 v_Position; | |
| 6 | + | uniform sampler2D u_Tex0; | |
| 7 | + | uniform float u_Time; | |
| 8 | + | uniform vec2 u_Resolution; | |
| 9 | + | uniform float u_spriteSize; | |
| 10 | + | ||
| 11 | + | float line_thickness = 0.5; | |
| 12 | + | ||
| 13 | + | void main() | |
| 14 | + | { | |
| 15 | + | vec2 size = line_thickness * vec2(1.0 / 512.0, 1.0 / 512.0); | |
| 16 | + | ||
| 17 | + | float outline = texture2D(u_Tex0, v_TexCoord + vec2(-size.x, 0)).a; | |
| 18 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(0, size.y)).a; | |
| 19 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(size.x, 0)).a; | |
| 20 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(0, -size.y)).a; | |
| 21 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(-size.x, size.y)).a; | |
| 22 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(size.x, size.y)).a; | |
| 23 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(-size.x, -size.y)).a; | |
| 24 | + | outline += texture2D(u_Tex0, v_TexCoord + vec2(size.x, -size.y)).a; | |
| 25 | + | outline = min(outline, 1.0); | |
| 26 | + | ||
| 27 | + | vec4 outline_colour; | |
| 28 | + | outline_colour.r = sin(.6 * (v_TexCoord.y * 150.0) + mod(u_Time, 3600.0) * 10. + 0.5) * 0.7 + 0.3; | |
| 29 | + | outline_colour.g = sin(.6 * (v_TexCoord.y * 150.0) + mod(u_Time, 3600.0) * 10. + 2.0) * 0.6 + 0.4; | |
| 30 | + | outline_colour.b = sin(.6 * (v_TexCoord.y * 150.0) + mod(u_Time, 3600.0) * 10. + 4.0) * 0.6 + 0.4; | |
| 31 | + | outline_colour.a = 1.0; | |
| 32 | + | ||
| 33 | + | // Introduce a wavy pattern effect | |
| 34 | + | float wave = sin(u_Time + v_TexCoord.x * 10.0); | |
| 35 | + | outline_colour.rgb += wave * 0.1; | |
| 36 | + | ||
| 37 | + | gl_FragColor = texture2D(u_Tex0, v_TexCoord); | |
| 38 | + | gl_FragColor = mix(gl_FragColor, outline_colour, outline - gl_FragColor.a); | |
| 39 | + | ||
| 40 | + | if (gl_FragColor.a < 0.01) discard; | |
| 41 | + | } |