aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Taper.vert.glsl
diff options
context:
space:
mode:
authorhwc4872012-07-09 16:08:02 -0700
committerhwc4872012-07-09 16:08:02 -0700
commit5085d0f67df89a21715308956004164597a6ba79 (patch)
tree2c896163143a66331205a39b0a3b1b45d51bf12a /assets/shaders/Taper.vert.glsl
parent51f1691f792dbda9b740ded8aa0457c9406db156 (diff)
parent84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff)
downloadninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts: js/helper-classes/3D/StageLine.js
Diffstat (limited to 'assets/shaders/Taper.vert.glsl')
-rw-r--r--assets/shaders/Taper.vert.glsl152
1 files changed, 76 insertions, 76 deletions
diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl
index 5fe173b2..e55aeede 100644
--- a/assets/shaders/Taper.vert.glsl
+++ b/assets/shaders/Taper.vert.glsl
@@ -60,85 +60,85 @@ varying vec4 v_color;
60 60
61float TaperAmount( float param ) 61float TaperAmount( float param )
62{ 62{
63 // Bezier coordinates of the X coordinate. 63 // Bezier coordinates of the X coordinate.
64 // Adjust these to get tighter or looser 64 // Adjust these to get tighter or looser
65 float tightness = 0.8; 65 float tightness = 0.8;
66 66
67 float x0, y0, x1, y1, x2, y2; 67 float x0, y0, x1, y1, x2, y2;
68 float t; 68 float t;
69 if (param < 0.5) 69 if (param < 0.5)
70 { 70 {
71 t = 2.0*param; 71 t = 2.0*param;
72 x0 = 0.0; y0 = 0.0; 72 x0 = 0.0; y0 = 0.0;
73 x1 = tightness; y1 = 0.0; 73 x1 = tightness; y1 = 0.0;
74 x2 = 1.0; y2 = 0.5; 74 x2 = 1.0; y2 = 0.5;
75 } 75 }
76 else 76 else
77 { 77 {
78 t = (param - 0.5)*2.0; 78 t = (param - 0.5)*2.0;
79 x0 = 0.0; y0 = 0.5; 79 x0 = 0.0; y0 = 0.5;
80 x1 = 1.0 - tightness; y1 = 1.0; 80 x1 = 1.0 - tightness; y1 = 1.0;
81 x2 = 1.0; y2 = 1.0; 81 x2 = 1.0; y2 = 1.0;
82 } 82 }
83 83
84 float a = x0 - 2.0*x1 + x2; 84 float a = x0 - 2.0*x1 + x2;
85 float b = 2.0*(x1 - x0); 85 float b = 2.0*(x1 - x0);
86 float c = x0 - t; 86 float c = x0 - t;
87 87
88 float descr = sqrt( b*b - 4.0*a*c ); 88 float descr = sqrt( b*b - 4.0*a*c );
89 float denom = 2.0*a; 89 float denom = 2.0*a;
90 float n1 = (-b + descr)/denom; 90 float n1 = (-b + descr)/denom;
91 float n2 = (-b - descr)/denom; 91 float n2 = (-b - descr)/denom;
92 if ((n1 >= 0.0) || (n1 <= 1.0)) t = n1; 92 if ((n1 >= 0.0) || (n1 <= 1.0)) t = n1;
93 else if ((n2 >= 0.0) || (n2 <= 1.0)) t = n2; 93 else if ((n2 >= 0.0) || (n2 <= 1.0)) t = n2;
94 else 94 else
95 t = 0.0; 95 t = 0.0;
96 96
97 float ya = y0 + t*(y1 - y0); 97 float ya = y0 + t*(y1 - y0);
98 float yb = y1 + t*(y2 - y1); 98 float yb = y1 + t*(y2 - y1);
99 float yc = ya + t*(yb - ya); 99 float yc = ya + t*(yb - ya);
100 100
101 return yc; 101 return yc;
102} 102}
103 103
104 104
105void main(void) 105void main(void)
106{ 106{
107 vec3 pos = vert; 107 vec3 pos = vert;
108 vec2 uv = texcoord; 108 vec2 uv = texcoord;
109 109
110 110
111 float limit1 = u_limit1, 111 float limit1 = u_limit1,
112 limit2 = u_limit2, 112 limit2 = u_limit2,
113 limit3 = u_limit2; 113 limit3 = u_limit2;
114 114
115 v_color = vec4(texcoord.x, texcoord.y, 0, 1); 115 v_color = vec4(texcoord.x, texcoord.y, 0, 1);
116 if ((uv.x > u_limit1) && (uv.x < u_limit3)) 116 if ((uv.x > u_limit1) && (uv.x < u_limit3))
117 { 117 {
118 float t; 118 float t;
119 if (uv.x < u_limit2) 119 if (uv.x < u_limit2)
120 { 120 {
121 t = (uv.x - u_limit1)/(u_limit2 - u_limit1); 121 t = (uv.x - u_limit1)/(u_limit2 - u_limit1);
122 } 122 }
123 else 123 else
124 { 124 {
125 t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); 125 t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2);
126 } 126 }
127 t = TaperAmount( t ); 127 t = TaperAmount( t );
128 128
129 float maxVal; 129 float maxVal;
130 if (pos.y > u_center) 130 if (pos.y > u_center)
131 { 131 {
132 maxVal = u_maxVal; 132 maxVal = u_maxVal;
133 } 133 }
134 else 134 else
135 { 135 {
136 maxVal = u_minVal; 136 maxVal = u_minVal;
137 } 137 }
138 138
139 float yFrac = (pos.y - u_center)/(maxVal-u_center); 139 float yFrac = (pos.y - u_center)/(maxVal-u_center);
140 pos.y = pos.y - yFrac * (maxVal - u_center)*t*u_taperAmount; 140 pos.y = pos.y - yFrac * (maxVal - u_center)*t*u_taperAmount;
141 } 141 }
142 142
143 gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; 143 gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ;
144} 144}