diff options
author | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
commit | 53051672a62208fbc96957719d8285fac6431ed6 (patch) | |
tree | 79d542ee811044e8af2ef84aa0d6662c6eb895c4 /assets/shaders/radialBlur.frag.glsl | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | 5146f224258929415adf4a8022e492454b4e2476 (diff) | |
download | ninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts:
js/panels/Timeline/DragDrop.js
js/panels/Timeline/Keyframe.reel/Keyframe.js
js/panels/Timeline/Layer.reel/Layer.js
js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
js/panels/Timeline/Span.reel/Span.js
js/panels/Timeline/Style.reel/Style.js
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
js/panels/Timeline/Track.reel/Track.html
js/panels/Timeline/Track.reel/Track.js
js/panels/Timeline/Track.reel/css/Track.css
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js
js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css
js/panels/Timeline/Tween.reel/Tween.js
Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'assets/shaders/radialBlur.frag.glsl')
-rw-r--r-- | assets/shaders/radialBlur.frag.glsl | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/assets/shaders/radialBlur.frag.glsl b/assets/shaders/radialBlur.frag.glsl index c4520e58..953e6f07 100644 --- a/assets/shaders/radialBlur.frag.glsl +++ b/assets/shaders/radialBlur.frag.glsl | |||
@@ -1,46 +1,75 @@ | |||
1 | 1 | ||
2 | /* <copyright> | ||
3 | Copyright (c) 2012, Motorola Mobility LLC. | ||
4 | All Rights Reserved. | ||
5 | |||
6 | Redistribution and use in source and binary forms, with or without | ||
7 | modification, are permitted provided that the following conditions are met: | ||
8 | |||
9 | * Redistributions of source code must retain the above copyright notice, | ||
10 | this list of conditions and the following disclaimer. | ||
11 | |||
12 | * Redistributions in binary form must reproduce the above copyright notice, | ||
13 | this list of conditions and the following disclaimer in the documentation | ||
14 | and/or other materials provided with the distribution. | ||
15 | |||
16 | * Neither the name of Motorola Mobility LLC nor the names of its | ||
17 | contributors may be used to endorse or promote products derived from this | ||
18 | software without specific prior written permission. | ||
19 | |||
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
30 | POSSIBILITY OF SUCH DAMAGE. | ||
31 | </copyright> */ | ||
32 | |||
33 | #ifdef GL_ES | ||
2 | precision highp float; | 34 | precision highp float; |
35 | #endif | ||
3 | 36 | ||
4 | uniform vec2 u_resolution; | 37 | uniform vec2 u_resolution; |
5 | uniform float u_time; | 38 | uniform float u_time; |
6 | uniform float u_speed; | 39 | uniform float u_speed; |
7 | uniform sampler2D u_tex0; | 40 | uniform sampler2D u_tex0; |
8 | 41 | ||
9 | vec3 deform( in vec2 p ) | ||
10 | { | ||
11 | vec2 uv; | ||
12 | |||
13 | float time = u_time * u_speed; | ||
14 | vec2 q = vec2( sin(1.1*time+p.x),sin(1.2*time+p.y) ); | ||
15 | |||
16 | float a = atan(q.y,q.x); | ||
17 | float r = sqrt(dot(q,q)); | ||
18 | |||
19 | uv.x = sin(0.0+1.0*time)+p.x*sqrt(r*r+1.0); | ||
20 | uv.y = sin(0.6+1.1*time)+p.y*sqrt(r*r+1.0); | ||
21 | |||
22 | return texture2D(u_tex0,uv*.5).xyz; | ||
23 | } | ||
24 | 42 | ||
25 | void main(void) | 43 | void main(void) |
26 | { | 44 | { |
27 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | 45 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; |
28 | //vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / vec2(500,500).xy; | ||
29 | vec2 s = p; | 46 | vec2 s = p; |
30 | 47 | ||
31 | vec3 total = vec3(0.0); | 48 | float time = u_time * u_speed; |
32 | vec2 d = (vec2(0.0,0.0)-p)/40.0; | 49 | float c1 = 1.1*time, c2 = 1.2*time, c3 = 0.6+1.1*time; |
33 | float w = 1.0; | 50 | float sc3 = sin(c3), st = sin(time); |
34 | for( int i=0; i<40; i++ ) | 51 | |
52 | const float iterCount = 40.0; | ||
53 | const int iIterCount = int( iterCount ); | ||
54 | |||
55 | vec3 sum = vec3(0.0); | ||
56 | vec2 delta = -p/iterCount; | ||
57 | vec2 uv; | ||
58 | for( int i=0; i<iIterCount; i++ ) | ||
35 | { | 59 | { |
36 | vec3 res = deform(s); | 60 | vec2 q = vec2( sin(c1 + s.x), sin(c2 + s.y) ); |
61 | float a = atan(q.y,q.x); | ||
62 | float rsq = abs(dot(q,q)) + 1.0; | ||
63 | uv.x = st + s.x*rsq; | ||
64 | uv.y = sc3 + s.y*rsq; | ||
65 | vec3 res = texture2D(u_tex0, uv*.5).xyz; | ||
66 | |||
37 | res = smoothstep(0.1,1.0,res*res); | 67 | res = smoothstep(0.1,1.0,res*res); |
38 | total += w*res; | 68 | sum += res; |
39 | w *= .99; | 69 | s += delta; |
40 | s += d; | ||
41 | } | 70 | } |
42 | total /= 40.0; | 71 | sum /= iterCount; |
43 | float r = 1.5/(1.0+dot(p,p)); | 72 | float r = 1.5/(1.0+dot(p,p)); |
44 | 73 | ||
45 | gl_FragColor = vec4( total*r,1.0); | 74 | gl_FragColor = vec4( sum*r, 1.0); |
46 | } \ No newline at end of file | 75 | } \ No newline at end of file |