From 67dd4bdd47a0324507bed232d22068aa198549fe Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 11 Jul 2012 09:48:19 -0700 Subject: re-wrote the radial blur shader. Changed tolerances in the deformation shaders. --- assets/shaders/radialBlur.frag.glsl | 81 +++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 26 deletions(-) (limited to 'assets') 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 @@ +/* +Copyright (c) 2012, Motorola Mobility LLC. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef GL_ES precision highp float; +#endif uniform vec2 u_resolution; uniform float u_time; uniform float u_speed; uniform sampler2D u_tex0; -vec3 deform( in vec2 p ) -{ - vec2 uv; - - float time = u_time * u_speed; - vec2 q = vec2( sin(1.1*time+p.x),sin(1.2*time+p.y) ); - - float a = atan(q.y,q.x); - float r = sqrt(dot(q,q)); - - uv.x = sin(0.0+1.0*time)+p.x*sqrt(r*r+1.0); - uv.y = sin(0.6+1.1*time)+p.y*sqrt(r*r+1.0); - - return texture2D(u_tex0,uv*.5).xyz; -} void main(void) { vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - //vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / vec2(500,500).xy; vec2 s = p; - vec3 total = vec3(0.0); - vec2 d = (vec2(0.0,0.0)-p)/40.0; - float w = 1.0; - for( int i=0; i<40; i++ ) + float time = u_time * u_speed; + float c1 = 1.1*time, c2 = 1.2*time, c3 = 0.6+1.1*time; + float sc3 = sin(c3), st = sin(time); + + const float iterCount = 40.0; + const int iIterCount = int( iterCount ); + + vec3 sum = vec3(0.0); + vec2 delta = -p/iterCount; + vec2 uv; + for( int i=0; i