diff options
author | John Mayhew | 2012-02-10 16:04:19 -0800 |
---|---|---|
committer | John Mayhew | 2012-02-10 16:04:19 -0800 |
commit | 730c1e191e36b8ab8dba576c481a6585e0dfa69e (patch) | |
tree | c86445ff8d1981e97096ec5e9f6cc5301dc9ea40 /assets/shaders/radialGradient.frag.glsl | |
parent | cde1dd9a9156b9682fdf85ce2cd4acdd94124c37 (diff) | |
parent | 48977780443d97b9e97b047066639c9056788041 (diff) | |
download | ninja-730c1e191e36b8ab8dba576c481a6585e0dfa69e.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/ninja.reel/ninja.html
Diffstat (limited to 'assets/shaders/radialGradient.frag.glsl')
-rw-r--r-- | assets/shaders/radialGradient.frag.glsl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/assets/shaders/radialGradient.frag.glsl b/assets/shaders/radialGradient.frag.glsl new file mode 100644 index 00000000..cd751750 --- /dev/null +++ b/assets/shaders/radialGradient.frag.glsl | |||
@@ -0,0 +1,51 @@ | |||
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 | uniform vec4 u_color1; | ||
12 | uniform vec4 u_color2; | ||
13 | uniform vec4 u_color3; | ||
14 | uniform vec4 u_color4; | ||
15 | uniform float u_colorStop1; | ||
16 | uniform float u_colorStop2; | ||
17 | uniform float u_colorStop3; | ||
18 | uniform float u_colorStop4; | ||
19 | uniform vec2 u_cos_sin_angle; | ||
20 | //uniform int u_colorCount; // currently using all 4 | ||
21 | |||
22 | varying vec2 v_uv; | ||
23 | |||
24 | void main(void) | ||
25 | { | ||
26 | vec2 pt = vec2( v_uv.x - 0.5, v_uv.y - 0.5); | ||
27 | float t = sqrt( dot(pt, pt) ); | ||
28 | |||
29 | vec4 color; | ||
30 | if (t < u_colorStop1) | ||
31 | color = u_color1; | ||
32 | else if (t < u_colorStop2) | ||
33 | { | ||
34 | float tLocal = (t - u_colorStop1)/(u_colorStop2 - u_colorStop1); | ||
35 | color = mix(u_color1,u_color2,tLocal); | ||
36 | } | ||
37 | else if (t < u_colorStop3) | ||
38 | { | ||
39 | float tLocal = (t - u_colorStop2)/(u_colorStop3 - u_colorStop2); | ||
40 | color = mix(u_color2,u_color3,tLocal); | ||
41 | } | ||
42 | else if (t < u_colorStop4) | ||
43 | { | ||
44 | float tLocal = (t - u_colorStop3)/(u_colorStop4 - u_colorStop3); | ||
45 | color = mix(u_color3,u_color4,tLocal); | ||
46 | } | ||
47 | else | ||
48 | color = u_color4; | ||
49 | |||
50 | gl_FragColor = color; | ||
51 | } | ||