aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/Flag.frag.glsl13
-rw-r--r--assets/shaders/Flag.vert.glsl29
2 files changed, 34 insertions, 8 deletions
diff --git a/assets/shaders/Flag.frag.glsl b/assets/shaders/Flag.frag.glsl
new file mode 100644
index 00000000..79d4bec3
--- /dev/null
+++ b/assets/shaders/Flag.frag.glsl
@@ -0,0 +1,13 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4
5uniform sampler2D u_tex0;
6
7varying vec2 v_uv;
8
9void main(void)
10{
11 vec3 col = texture2D(u_tex0, v_uv).xyz;
12 gl_FragColor = vec4(col,1.0);
13} \ No newline at end of file
diff --git a/assets/shaders/Flag.vert.glsl b/assets/shaders/Flag.vert.glsl
index 7dc932a7..9da0ee1c 100644
--- a/assets/shaders/Flag.vert.glsl
+++ b/assets/shaders/Flag.vert.glsl
@@ -16,20 +16,33 @@ attribute vec2 texcoord;
16 16
17// scalar uniforms 17// scalar uniforms
18uniform float u_time; 18uniform float u_time;
19uniform float u_waveWidth;
20uniform float u_waveHeight;
19 21
20// matrix uniforms 22// matrix uniforms
21uniform mat4 u_mvMatrix; 23uniform mat4 u_mvMatrix;
22uniform mat4 u_projMatrix; 24uniform mat4 u_projMatrix;
23uniform mat4 u_worldMatrix; 25uniform mat4 u_worldMatrix;
24 26
27// varying variables
28varying vec2 v_uv;
29
25void main() 30void main()
26{ 31{
27 float angle = (u_time%360)*2; 32 float pi = 3.14159;
28 33 float angle = mod(u_time, pi)*2.0;
29 a_pos.z = sin( a_pos.x + angle); 34
30 a_pos.z += sin( a_pos.y/2 + angle); 35 vec3 v = a_pos;
31 a_pos.z *= a_pos.x * 0.09; 36 v_uv = texcoord;
32 gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0) ; 37
33 38 vec2 pos = texcoord;
34 gl_FragColor = v_color; 39 float tmp = pos.x; pos.x = pos.y; pos.y = tmp;
40 pos.x = pos.x * 1.0*pi * u_waveWidth;
41 pos.y = pos.y * 1.0*pi * u_waveWidth;
42
43 v.z = sin( pos.x + angle);
44 v.z += sin( pos.y/2.0 + angle);
45 v.z *= v.y * 0.09 * u_waveHeight;
46
47 gl_Position = u_projMatrix * u_mvMatrix * vec4(v,1.0) ;
35} 48}