diff options
Diffstat (limited to 'assets/shaders/Taper.vert.glsl')
-rw-r--r-- | assets/shaders/Taper.vert.glsl | 21 |
1 files changed, 13 insertions, 8 deletions
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; | |||
20 | uniform float u_limit2; | 20 | uniform float u_limit2; |
21 | uniform float u_limit3; | 21 | uniform float u_limit3; |
22 | uniform float u_taperAmount; | 22 | uniform float u_taperAmount; |
23 | uniform float u_center; | ||
23 | 24 | ||
24 | uniform vec4 color; | 25 | uniform vec4 color; |
25 | 26 | ||
@@ -31,31 +32,35 @@ uniform mat4 u_worldMatrix; | |||
31 | 32 | ||
32 | varying vec4 v_color; | 33 | varying vec4 v_color; |
33 | 34 | ||
35 | float TaperAmount( float param ) | ||
36 | { | ||
37 | float y0 = 1.0, y1 = 1.0, y2 = 0.0, y3 = 0.0; | ||
38 | float yA0 = y0 + param*(y1 - y0), yA1 = y1 + param*(y2 - y1), yA2 = y2 + param*(y3 - y2); | ||
39 | float yB0 = yA0 + param*(yA1 - yA0), yB1 = yA1 + param*(yA2 - yA1); | ||
40 | float yC0 = yB0 + param*(yB1 - yB0); | ||
41 | |||
42 | return yC0; | ||
43 | } | ||
34 | 44 | ||
35 | void main(void) | 45 | void main(void) |
36 | { | 46 | { |
37 | vec3 pos = vert; | 47 | vec3 pos = vert; |
38 | vec2 uv = texcoord; | 48 | vec2 uv = texcoord; |
39 | 49 | ||
40 | v_color = vec4(0, 1, 0, 1); | 50 | v_color = vec4(texcoord.x, texcoord.y, 0, 1); |
41 | if (uv.x > u_limit1) | 51 | if (uv.x > u_limit1) |
42 | { | 52 | { |
43 | if (uv.x < u_limit2) | 53 | if (uv.x < u_limit2) |
44 | { | 54 | { |
45 | float t = (uv.x - u_limit1)/(u_limit2 - u_limit1); | 55 | float t = (uv.x - u_limit1)/(u_limit2 - u_limit1); |
46 | pos.y = pos.y - t*u_taperAmount; | 56 | pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; |
47 | v_color = vec4( 1, 1, 0, 1 ); | ||
48 | } | 57 | } |
49 | else if (uv.x < u_limit3) | 58 | else if (uv.x < u_limit3) |
50 | { | 59 | { |
51 | float t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); | 60 | float t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); |
52 | pos.y = pos.y - t*u_taperAmount; | 61 | pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; |
53 | v_color = vec4( 0, 1, 1, 1 ); | ||
54 | } | 62 | } |
55 | else | ||
56 | v_color = vec4(0,0,1,1); | ||
57 | } | 63 | } |
58 | 64 | ||
59 | |||
60 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; | 65 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; |
61 | } \ No newline at end of file | 66 | } \ No newline at end of file |