diff options
Diffstat (limited to 'assets/shaders/Flag.vert.glsl')
-rw-r--r-- | assets/shaders/Flag.vert.glsl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/assets/shaders/Flag.vert.glsl b/assets/shaders/Flag.vert.glsl index 7dc932a7..a5e8b2f7 100644 --- a/assets/shaders/Flag.vert.glsl +++ b/assets/shaders/Flag.vert.glsl | |||
@@ -16,20 +16,32 @@ attribute vec2 texcoord; | |||
16 | 16 | ||
17 | // scalar uniforms | 17 | // scalar uniforms |
18 | uniform float u_time; | 18 | uniform float u_time; |
19 | uniform float u_waveWidth; | ||
20 | uniform float u_waveHeight; | ||
19 | 21 | ||
20 | // matrix uniforms | 22 | // matrix uniforms |
21 | uniform mat4 u_mvMatrix; | 23 | uniform mat4 u_mvMatrix; |
22 | uniform mat4 u_projMatrix; | 24 | uniform mat4 u_projMatrix; |
23 | uniform mat4 u_worldMatrix; | 25 | uniform mat4 u_worldMatrix; |
24 | 26 | ||
27 | // varying variables | ||
28 | varying vec2 v_uv; | ||
29 | |||
30 | |||
25 | void main() | 31 | void main() |
26 | { | 32 | { |
27 | float angle = (u_time%360)*2; | 33 | float pi = 3.14159; |
34 | float angle = u_time; | ||
35 | |||
36 | v_uv = texcoord; | ||
28 | 37 | ||
29 | a_pos.z = sin( a_pos.x + angle); | 38 | float x = 2.0*pi*texcoord.x/u_waveWidth; |
30 | a_pos.z += sin( a_pos.y/2 + angle); | 39 | float y = 2.0*pi*texcoord.y; |
31 | a_pos.z *= a_pos.x * 0.09; | ||
32 | gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0) ; | ||
33 | 40 | ||
34 | gl_FragColor = v_color; | 41 | vec3 v = a_pos; |
42 | v.z = sin( x + angle ) - 2.0*u_waveHeight; | ||
43 | v.z += sin( 0.2*y + angle); | ||
44 | v.z *= x * 0.09 * u_waveHeight; | ||
45 | |||
46 | gl_Position = u_projMatrix * u_mvMatrix * vec4(v,1.0) ; | ||
35 | } | 47 | } |