diff options
author | hwc487 | 2012-04-03 09:36:14 -0700 |
---|---|---|
committer | hwc487 | 2012-04-03 09:36:14 -0700 |
commit | 4b199cf04af83f59895d4d1e9a2d8443c1ec8e06 (patch) | |
tree | a1875bed6d6c225304bb2fa286d1ab435c2b9633 /assets | |
parent | 19c975cfb16f1cccc9e9f86255575499315d421e (diff) | |
download | ninja-4b199cf04af83f59895d4d1e9a2d8443c1ec8e06.tar.gz |
started the flag material
Diffstat (limited to 'assets')
-rw-r--r-- | assets/images/us_flag.png | bin | 0 -> 9946 bytes | |||
-rw-r--r-- | assets/shaders/Flag.frag.glsl | 13 | ||||
-rw-r--r-- | assets/shaders/Flag.vert.glsl | 29 |
3 files changed, 34 insertions, 8 deletions
diff --git a/assets/images/us_flag.png b/assets/images/us_flag.png new file mode 100644 index 00000000..1545edc2 --- /dev/null +++ b/assets/images/us_flag.png | |||
Binary files differ | |||
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 | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform sampler2D u_tex0; | ||
6 | |||
7 | varying vec2 v_uv; | ||
8 | |||
9 | void 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 |
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 | |||
25 | void main() | 30 | void 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 | } |