From c0aa5e88890fbf74124d019df96c33215da99f17 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 16 Apr 2012 05:59:01 -0700 Subject: Cloud material --- assets/shaders/Cloud.frag.glsl | 5 +++-- assets/shaders/Cloud.vert.glsl | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'assets') diff --git a/assets/shaders/Cloud.frag.glsl b/assets/shaders/Cloud.frag.glsl index ba1ef39e..c21dcf97 100644 --- a/assets/shaders/Cloud.frag.glsl +++ b/assets/shaders/Cloud.frag.glsl @@ -17,7 +17,8 @@ varying vec2 v_texCoord0; void main() { - gl_FragColor = texture2D(u_tex0, v_texCoord0) * u_surfaceAlpha; - //gl_FragColor = texture2D(u_tex0, v_texCoord0); + vec4 c = texture2D(u_tex0, v_texCoord0); + //c.a *= u_surfaceAlpha; + gl_FragColor = c; } \ No newline at end of file diff --git a/assets/shaders/Cloud.vert.glsl b/assets/shaders/Cloud.vert.glsl index 9a235349..c8ca9f3f 100644 --- a/assets/shaders/Cloud.vert.glsl +++ b/assets/shaders/Cloud.vert.glsl @@ -28,14 +28,22 @@ uniform mat4 u_worldMatrix; varying vec2 v_texCoord0; // constants -const float zSpeed = 1.0; +const float zSpeed = 2.0; void main() { // Transform position vec4 pos = vec4(a_pos,1); - //pos.z += u_time*zSpeed; + float dz = u_time*zSpeed; + float n = floor( dz/(u_zmax-u_zmin) ); + dz -= n*(u_zmax - u_zmin); + float z = pos.z + dz; + if (z > u_zmax) + { + z = u_zmin + (z - u_zmax); + } + pos.z = z; gl_Position = u_projMatrix * u_mvMatrix * pos; v_texCoord0 = texcoord; -- cgit v1.2.3