diff options
Diffstat (limited to 'assets/shaders/linearGradient.frag.glsl')
-rw-r--r-- | assets/shaders/linearGradient.frag.glsl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/assets/shaders/linearGradient.frag.glsl b/assets/shaders/linearGradient.frag.glsl new file mode 100644 index 00000000..64cf56ff --- /dev/null +++ b/assets/shaders/linearGradient.frag.glsl | |||
@@ -0,0 +1,52 @@ | |||
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 | #ifdef GL_ES | ||
8 | precision highp float; | ||
9 | #endif | ||
10 | |||
11 | |||
12 | uniform vec4 u_color1; | ||
13 | uniform vec4 u_color2; | ||
14 | uniform vec4 u_color3; | ||
15 | uniform vec4 u_color4; | ||
16 | uniform float u_colorStop1; | ||
17 | uniform float u_colorStop2; | ||
18 | uniform float u_colorStop3; | ||
19 | uniform float u_colorStop4; | ||
20 | uniform vec2 u_cos_sin_angle; | ||
21 | //uniform int u_colorCount; // currently using 4 | ||
22 | |||
23 | varying vec2 v_uv; | ||
24 | |||
25 | |||
26 | void main(void) | ||
27 | { | ||
28 | float t = dot(v_uv, u_cos_sin_angle); | ||
29 | |||
30 | vec4 color; | ||
31 | if (t < u_colorStop1) | ||
32 | color = u_color1; | ||
33 | else if (t < u_colorStop2) | ||
34 | { | ||
35 | float tLocal = (t - u_colorStop1)/(u_colorStop2 - u_colorStop1); | ||
36 | color = mix(u_color1,u_color2,tLocal); | ||
37 | } | ||
38 | else if (t < u_colorStop3) | ||
39 | { | ||
40 | float tLocal = (t - u_colorStop2)/(u_colorStop3 - u_colorStop2); | ||
41 | color = mix(u_color2,u_color3,tLocal); | ||
42 | } | ||
43 | else if (t < u_colorStop4) | ||
44 | { | ||
45 | float tLocal = (t - u_colorStop3)/(u_colorStop4 - u_colorStop3); | ||
46 | color = mix(u_color3,u_color4,tLocal); | ||
47 | } | ||
48 | else | ||
49 | color = u_color4; | ||
50 | |||
51 | gl_FragColor =color; | ||
52 | } \ No newline at end of file | ||