From 2d4da18a778471b02e188ad668752e331ee76127 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 7 Feb 2012 14:35:55 -0800 Subject: test code for deformation shader --- assets/shaders/Taper.vert.glsl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'assets/shaders/Taper.vert.glsl') diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl index 46f04fb3..82151f13 100644 --- a/assets/shaders/Taper.vert.glsl +++ b/assets/shaders/Taper.vert.glsl @@ -20,6 +20,7 @@ uniform float u_limit1; uniform float u_limit2; uniform float u_limit3; uniform float u_taperAmount; +uniform float u_center; uniform vec4 color; @@ -31,31 +32,35 @@ uniform mat4 u_worldMatrix; varying vec4 v_color; +float TaperAmount( float param ) +{ + float y0 = 1.0, y1 = 1.0, y2 = 0.0, y3 = 0.0; + float yA0 = y0 + param*(y1 - y0), yA1 = y1 + param*(y2 - y1), yA2 = y2 + param*(y3 - y2); + float yB0 = yA0 + param*(yA1 - yA0), yB1 = yA1 + param*(yA2 - yA1); + float yC0 = yB0 + param*(yB1 - yB0); + + return yC0; +} void main(void) { vec3 pos = vert; vec2 uv = texcoord; - v_color = vec4(0, 1, 0, 1); + v_color = vec4(texcoord.x, texcoord.y, 0, 1); if (uv.x > u_limit1) { if (uv.x < u_limit2) { float t = (uv.x - u_limit1)/(u_limit2 - u_limit1); - pos.y = pos.y - t*u_taperAmount; - v_color = vec4( 1, 1, 0, 1 ); + pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; } else if (uv.x < u_limit3) { float t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); - pos.y = pos.y - t*u_taperAmount; - v_color = vec4( 0, 1, 1, 1 ); + pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; } - else - v_color = vec4(0,0,1,1); } - gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; } \ No newline at end of file -- cgit v1.2.3