Skip to content

Commit

Permalink
converted over most shaders so that they will work with OpenGLES (squ…
Browse files Browse the repository at this point in the history
…ares and wind still need some mods)
  • Loading branch information
prime31 committed Nov 11, 2014
1 parent 185dc86 commit 812263f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
21 changes: 10 additions & 11 deletions Assets/Plugins/TransitionKit/transitions/shaders/Blur.shader
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ uniform float _BlurSize;

fixed4 frag( v2f_img i ) : COLOR
{
vec2 vTexCoord = i.uv;
vec4 sum = vec4( 0.0 );
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y - 4.0 * _BlurSize ) ) * 0.05;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y - 3.0 * _BlurSize ) ) * 0.09;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y - 2.0 * _BlurSize ) ) * 0.12;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y - _BlurSize ) ) * 0.15;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y ) ) * 0.16;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y + _BlurSize ) ) * 0.15;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y + 2.0 * _BlurSize ) ) * 0.12;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y + 3.0 * _BlurSize ) ) * 0.09;
sum += tex2D( _MainTex, vec2( vTexCoord.x, vTexCoord.y + 4.0 * _BlurSize ) ) * 0.05;
half4 sum = half4( 0.0 );
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y - 4.0 * _BlurSize ) ) * 0.05;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y - 3.0 * _BlurSize ) ) * 0.09;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y - 2.0 * _BlurSize ) ) * 0.12;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y - _BlurSize ) ) * 0.15;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y ) ) * 0.16;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y + _BlurSize ) ) * 0.15;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y + 2.0 * _BlurSize ) ) * 0.12;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y + 3.0 * _BlurSize ) ) * 0.09;
sum += tex2D( _MainTex, half2( i.uv.x, i.uv.y + 4.0 * _BlurSize ) ) * 0.05;

return sum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fixed4 frag( v2f_img i ) : COLOR
pfr.y += d / 2.;
}

float size = mix( 1.0, _Depth, 1.0 - _Progress );
float size = lerp( 1.0, _Depth, 1.0 - _Progress );
pto = ( i.uv + half2( -0.5, -0.5 ) ) * half2( size, size ) + half2( 0.5, 0.5 );

if( inBounds( pfr ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ uniform float _ColorSeparation;
fixed4 frag( v2f_img i ) : COLOR
{
float inv = 1.0 - _Progress;
vec2 disp = _Size * half2( cos( _Zoom * i.uv.x ), sin( _Zoom * i.uv.y ) );
float2 disp = _Size * half2( cos( _Zoom * i.uv.x ), sin( _Zoom * i.uv.y ) );
half4 texTo = half4( 0.0 );

vec4 texFrom = vec4
half4 texFrom = half4
(
tex2D( _MainTex, i.uv + _Progress * disp * ( 1.0 - _ColorSeparation ) ).r,
tex2D( _MainTex, i.uv + _Progress * disp ).g,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ uniform float _Speed;

fixed4 frag( v2f_img i ) : COLOR
{
half2 dir = i.uv - vec2( 0.5 );
half2 dir = i.uv - half2( 0.5 );
float dist = length( dir );
half2 offset = dir * ( sin( _Time.x * dist * _Amplitude - _Progress * _Speed ) + 0.5 ) / 30.0;

return mix( tex2D( _MainTex, i.uv + offset ), half4( 0.0 ), smoothstep( 0.5, 1.0, _Progress ) );
return lerp( tex2D( _MainTex, i.uv + offset ), half4( 0.0 ), smoothstep( 0.5, 1.0, _Progress ) );
}

ENDCG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ CGPROGRAM
uniform sampler2D _MainTex;
uniform fixed4 _Color;
uniform half _Progress;
uniform vec2 _Size;
uniform float2 _Size;
uniform float _Smoothness;



float rand( float2 co )
float rand( half2 co )
{
return fract( sin( dot( co.xy , float2( 12.9898, 78.233 ) ) ) * 43758.5453 );
float x = sin( dot( co.xy, half2( 12.9898,78.233 ) ) ) * 43758.5453;
return x - floor( x );
}


Expand All @@ -46,7 +47,7 @@ fixed4 frag( v2f_img i ) : COLOR
float r = rand( floor( _Size.xy * i.uv ) );
float m = smoothstep( 0.0, -_Smoothness, r - ( _Progress * ( 1.0 + _Smoothness ) ) );

return mix( tex2D( _MainTex, i.uv ), _Color, m );
return lerp( tex2D( _MainTex, i.uv ), _Color, m );
}

ENDCG
Expand Down
9 changes: 5 additions & 4 deletions Assets/Plugins/TransitionKit/transitions/shaders/Wind.shader
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ uniform float _Progress;
uniform float _Size;


float rand( vec2 co )
float rand( half2 co )
{
return fract( sin( dot( co.xy, vec2( 12.9898,78.233 ) ) ) * 43758.5453 );
float x = sin( dot( co.xy, half2( 12.9898,78.233 ) ) ) * 43758.5453;
return x - floor( x );
}


fixed4 frag( v2f_img i ) : COLOR
{
float r = rand( vec2( 0, i.uv.y ) );
float r = rand( half2( 0, i.uv.y ) );
float m = smoothstep( 0.0, -_Size, i.uv.x * ( 1.0 - _Size ) + _Size * r - ( _Progress * ( 1.0 + _Size ) ) );
return mix( tex2D( _MainTex, i.uv ), half4( 0.0 ), m );
return lerp( tex2D( _MainTex, i.uv ), half4( 0.0 ), m );
}

ENDCG
Expand Down
Binary file modified ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TransitionKit

Modular, extensible transitions in-scene and between scenes. TransitionKit aims to make transitions easy. The main gist of how it works is that when invoked it snaps a screenshot and sticks it on a quad (by default but you can override this behavior). This means that you can reuse any of your full screen image effects with TransitionKit since it works in fundamentally the exact same way.

Side note: if you make any neat transitions feel free to send over a pull request so we can build up a nice library of useful transitions!
Side notes: if you make any neat transitions feel free to send over a pull request so we can build up a nice library of useful transitions! If the shaders used in your transitions (or the included transitions) are not used anywhere else you have to tell Unity to still included them in the build. You can do this by opening Edit -> Project Settings -> Graphics and stick the shaders in the "Always Included Shaders" section like so: ![Graphics Settings](http://cl.ly/YTh4/Screen%20Shot%202014-11-11%20at%209.11.14%20AM.png)



Expand Down

0 comments on commit 812263f

Please sign in to comment.