diff options
Diffstat (limited to 'assets/shaders/Taper.vert.glsl')
-rw-r--r-- | assets/shaders/Taper.vert.glsl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl new file mode 100644 index 00000000..82151f13 --- /dev/null +++ b/assets/shaders/Taper.vert.glsl | |||
@@ -0,0 +1,66 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | #ifdef GL_ES | ||
9 | precision highp float; | ||
10 | #endif | ||
11 | |||
12 | |||
13 | // attributes | ||
14 | attribute vec3 vert; | ||
15 | attribute vec3 normal; | ||
16 | attribute vec2 texcoord; | ||
17 | |||
18 | // scalar uniforms | ||
19 | uniform float u_limit1; | ||
20 | uniform float u_limit2; | ||
21 | uniform float u_limit3; | ||
22 | uniform float u_taperAmount; | ||
23 | uniform float u_center; | ||
24 | |||
25 | uniform vec4 color; | ||
26 | |||
27 | |||
28 | // matrix uniforms | ||
29 | uniform mat4 u_mvMatrix; | ||
30 | uniform mat4 u_projMatrix; | ||
31 | uniform mat4 u_worldMatrix; | ||
32 | |||
33 | varying vec4 v_color; | ||
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 | } | ||
44 | |||
45 | void main(void) | ||
46 | { | ||
47 | vec3 pos = vert; | ||
48 | vec2 uv = texcoord; | ||
49 | |||
50 | v_color = vec4(texcoord.x, texcoord.y, 0, 1); | ||
51 | if (uv.x > u_limit1) | ||
52 | { | ||
53 | if (uv.x < u_limit2) | ||
54 | { | ||
55 | float t = (uv.x - u_limit1)/(u_limit2 - u_limit1); | ||
56 | pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; | ||
57 | } | ||
58 | else if (uv.x < u_limit3) | ||
59 | { | ||
60 | float t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); | ||
61 | pos.y = pos.y - pos.y*TaperAmount(t)*u_taperAmount; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; | ||
66 | } \ No newline at end of file | ||