diff --git a/Assets/Shaders/PostEffectShader.shader b/Assets/Shaders/PostEffectShader.shader new file mode 100644 index 0000000..35b3ec4 --- /dev/null +++ b/Assets/Shaders/PostEffectShader.shader @@ -0,0 +1,89 @@ + Shader "Custom/PostEffectShader" +{ + Properties + { + _Blindness("Blindness", Float) = 0.6 + _MainTex("Texture", 2D) = "white" {} + + } + SubShader + { + // No culling or depth + Cull Off ZWrite Off ZTest Always + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float4 position : POSITION; + + float4 screenPos : TEXCOORD0; + }; + + v2f vert (appdata v) + { + v2f o; + + o.position = mul(UNITY_MATRIX_MVP, v.vertex); + + o.screenPos = o.position; + + return o; + } + + sampler2D _MainTex; + float _Blindness; + + fixed4 frag (v2f i) : SV_Target + { + float2 screenPos = i.screenPos.xy / i.screenPos.w; + float depth = _Blindness*0.0025; + + screenPos.x = (screenPos.x + 1) * 0.5; + + screenPos.y = 1 - (screenPos.y + 1) * 0.5; + + half4 sum = half4(0.0h, 0.0h, 0.0h, 0.0h); + sum += tex2D(_MainTex, float2(screenPos.x - 3.0 * depth, screenPos.y + 3.0 * depth)) * 0.09; + sum += tex2D(_MainTex, float2(screenPos.x + 3.0 * depth, screenPos.y - 3.0 * depth)) * 0.09; + + sum += tex2D(_MainTex, float2(screenPos.x - 2.0 * depth, screenPos.y + 2.0 * depth)) * 0.12; + sum += tex2D(_MainTex, float2(screenPos.x + 2.0 * depth, screenPos.y - 2.0 * depth)) * 0.12; + + sum += tex2D(_MainTex, float2(screenPos.x - 1.0 * depth, screenPos.y + 1.0 * depth)) * 0.15; + sum += tex2D(_MainTex, float2(screenPos.x + 1.0 * depth, screenPos.y - 1.0 * depth)) * 0.15; + + sum += tex2D(_MainTex, screenPos - 5.0 * depth) * 0.025; + sum += tex2D(_MainTex, screenPos - 4.0 * depth) * 0.05; + sum += tex2D(_MainTex, screenPos - 3.0 * depth) * 0.09; + sum += tex2D(_MainTex, screenPos - 2.0 * depth) * 0.12; + sum += tex2D(_MainTex, screenPos - 1.0 * depth) * 0.15; + sum += tex2D(_MainTex, screenPos) * 0.16; + sum += tex2D(_MainTex, screenPos + 5.0 * depth) * 0.15; + sum += tex2D(_MainTex, screenPos + 4.0 * depth) * 0.12; + sum += tex2D(_MainTex, screenPos + 3.0 * depth) * 0.09; + sum += tex2D(_MainTex, screenPos + 2.0 * depth) * 0.05; + sum += tex2D(_MainTex, screenPos + 1.0 * depth) * 0.025; + + return sum / 2; + //col.a = (c.r + c.b + c.g) / 3; + // just invert the colors + //col = 1 - col; + //return col; + } + ENDCG + } + } +} diff --git a/Assets/Shaders/PostEffectShader.shader.meta b/Assets/Shaders/PostEffectShader.shader.meta new file mode 100644 index 0000000..257c427 --- /dev/null +++ b/Assets/Shaders/PostEffectShader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8af73b3d4929e6c4bbf312b61e959c45 +timeCreated: 1466858754 +licenseType: Free +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/WaterBlurFinal.shader b/Assets/Shaders/WaterBlurFinal.shader new file mode 100644 index 0000000..862fd8d --- /dev/null +++ b/Assets/Shaders/WaterBlurFinal.shader @@ -0,0 +1,118 @@ +Shader "Custom/WaterBlur" { + Properties { + _blurSizeXY("BlurSizeXY", Range(0,10)) = 0 +} + SubShader { + + // Draw ourselves after all opaque geometry + Tags { "Queue" = "Transparent" } + + // Grab the screen behind the object into _GrabTexture + GrabPass { } + + // Render the object with the texture generated above + Pass { + + +CGPROGRAM +#pragma debug +#pragma vertex vert +#pragma fragment frag +#ifndef SHADER_API_D3D11 + + #pragma target 3.0 + +#else + + #pragma target 4.0 + +#endif + + sampler2D _GrabTexture : register(s0); + float _blurSizeXY; + +struct data { + + float4 vertex : POSITION; + + float3 normal : NORMAL; + +}; + + + +struct v2f { + + float4 position : POSITION; + + float4 screenPos : TEXCOORD0; + +}; + + + +v2f vert(data i){ + + v2f o; + + o.position = mul(UNITY_MATRIX_MVP, i.vertex); + + o.screenPos = o.position; + + return o; + +} + + + +half4 frag( v2f i ) : COLOR + +{ + + float2 screenPos = i.screenPos.xy / i.screenPos.w; + float depth= _blurSizeXY*0.0005; + + screenPos.x = (screenPos.x + 1) * 0.5; + + screenPos.y = 1-(screenPos.y + 1) * 0.5; + + half4 sum = half4(0.0h,0.0h,0.0h,0.0h); + sum += tex2D( _GrabTexture, float2(screenPos.x-5.0 * depth, screenPos.y+5.0 * depth)) * 0.025; + sum += tex2D( _GrabTexture, float2(screenPos.x+5.0 * depth, screenPos.y-5.0 * depth)) * 0.025; + + sum += tex2D( _GrabTexture, float2(screenPos.x-4.0 * depth, screenPos.y+4.0 * depth)) * 0.05; + sum += tex2D( _GrabTexture, float2(screenPos.x+4.0 * depth, screenPos.y-4.0 * depth)) * 0.05; + + + sum += tex2D( _GrabTexture, float2(screenPos.x-3.0 * depth, screenPos.y+3.0 * depth)) * 0.09; + sum += tex2D( _GrabTexture, float2(screenPos.x+3.0 * depth, screenPos.y-3.0 * depth)) * 0.09; + + sum += tex2D( _GrabTexture, float2(screenPos.x-2.0 * depth, screenPos.y+2.0 * depth)) * 0.12; + sum += tex2D( _GrabTexture, float2(screenPos.x+2.0 * depth, screenPos.y-2.0 * depth)) * 0.12; + + sum += tex2D( _GrabTexture, float2(screenPos.x-1.0 * depth, screenPos.y+1.0 * depth)) * 0.15; + sum += tex2D( _GrabTexture, float2(screenPos.x+1.0 * depth, screenPos.y-1.0 * depth)) * 0.15; + + + + sum += tex2D( _GrabTexture, screenPos-5.0 * depth) * 0.025; + sum += tex2D( _GrabTexture, screenPos-4.0 * depth) * 0.05; + sum += tex2D( _GrabTexture, screenPos-3.0 * depth) * 0.09; + sum += tex2D( _GrabTexture, screenPos-2.0 * depth) * 0.12; + sum += tex2D( _GrabTexture, screenPos-1.0 * depth) * 0.15; + sum += tex2D( _GrabTexture, screenPos) * 0.16; + sum += tex2D( _GrabTexture, screenPos+5.0 * depth) * 0.15; + sum += tex2D( _GrabTexture, screenPos+4.0 * depth) * 0.12; + sum += tex2D( _GrabTexture, screenPos+3.0 * depth) * 0.09; + sum += tex2D( _GrabTexture, screenPos+2.0 * depth) * 0.05; + sum += tex2D( _GrabTexture, screenPos+1.0 * depth) * 0.025; + + return sum/2; + +} +ENDCG + } + } + +Fallback Off +} \ No newline at end of file diff --git a/Assets/Shaders/WaterBlurFinal.shader.meta b/Assets/Shaders/WaterBlurFinal.shader.meta new file mode 100644 index 0000000..7bda910 --- /dev/null +++ b/Assets/Shaders/WaterBlurFinal.shader.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eed3ece10d3b3404e8b077c5851019b9 +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/WaterBlurModified.shader b/Assets/Shaders/WaterBlurModified.shader new file mode 100644 index 0000000..b5aab51 --- /dev/null +++ b/Assets/Shaders/WaterBlurModified.shader @@ -0,0 +1,194 @@ +Shader "Custom/WaterBlurGaussian" { + Properties { + _blurSizeXY("BlurSizeXY", Range(0,20)) = 0 +} + SubShader { + + // Draw ourselves after all opaque geometry + Tags { "Queue" = "Transparent" } + + // Grab the screen behind the object into _GrabTexture + GrabPass { } + + // Render the object with the texture generated above + Pass { + + +CGPROGRAM +#pragma vertex vert +#pragma fragment frag +#ifndef SHADER_API_D3D11 + + #pragma target 3.0 + +#else + + #pragma target 4.0 + +#endif + sampler2D _GrabTexture : register(s0); + float _blurSizeXY; + +struct data { + + float4 vertex : POSITION; + + float3 normal : NORMAL; + +}; + + + +struct v2f { + + float4 position : POSITION; + + float4 screenPos : TEXCOORD0; + +}; + + + +v2f vert(data i){ + + v2f o; + + o.position = mul(UNITY_MATRIX_MVP, i.vertex); + + o.screenPos = o.position; + + + return o; + +} + + + +half4 frag( v2f i ) : COLOR + +{ + + float2 screenPos = i.screenPos.xy / i.screenPos.w; + float depth= _blurSizeXY*0.0005; + + screenPos.x = (screenPos.x + 1) * 0.5; + + screenPos.y = 1-(screenPos.y + 1) * 0.5; + + //horizontal + + half4 sum = half4(0.0h,0.0h,0.0h,0.0h); + sum += tex2D( _GrabTexture, float2(screenPos.x-5.0 * depth, screenPos.y )) * 0.025; + sum += tex2D( _GrabTexture, float2(screenPos.x+5.0 * depth, screenPos.y )) * 0.025; + + sum += tex2D( _GrabTexture, float2(screenPos.x-4.0 * depth, screenPos.y)) * 0.05; + sum += tex2D( _GrabTexture, float2(screenPos.x+4.0 * depth, screenPos.y)) * 0.05; + + + sum += tex2D( _GrabTexture, float2(screenPos.x-3.0 * depth, screenPos.y)) * 0.09; + sum += tex2D( _GrabTexture, float2(screenPos.x+3.0 * depth, screenPos.y)) * 0.09; + + sum += tex2D( _GrabTexture, float2(screenPos.x-2.0 * depth, screenPos.y)) * 0.12; + sum += tex2D( _GrabTexture, float2(screenPos.x+2.0 * depth, screenPos.y)) * 0.12; + + sum += tex2D( _GrabTexture, float2(screenPos.x-1.0 * depth, screenPos.y)) * 0.15; + sum += tex2D( _GrabTexture, float2(screenPos.x+1.0 * depth, screenPos.y)) * 0.15; + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y)) * 0.16; + + return sum/2; + +} +ENDCG + } + + Pass { + Blend One One + + +CGPROGRAM +#pragma vertex vert +#pragma fragment frag +#pragma target 3.0 + + sampler2D _GrabTexture : register(s0); + float _blurSizeXY; + +struct data { + + float4 vertex : POSITION; + + float3 normal : NORMAL; + +}; + + + +struct v2f { + + float4 position : POSITION; + + float4 screenPos : TEXCOORD0; + +}; + + + +v2f vert(data i){ + + v2f o; + + o.position = mul(UNITY_MATRIX_MVP, i.vertex); + + o.screenPos = o.position; + + return o; + +} + + + +half4 frag( v2f i ) : COLOR + +{ + + float2 screenPos = i.screenPos.xy / i.screenPos.w; + float depth= _blurSizeXY*0.0005; + + screenPos.x = (screenPos.x + 1) * 0.5; + + screenPos.y = 1-(screenPos.y + 1) * 0.5; + + half4 sum = half4(0.0h,0.0h,0.0h,0.0h); + + //vertical + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y+5.0 * depth)) * 0.025; + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y-5.0 * depth)) * 0.025; + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y+4.0 * depth)) * 0.05; + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y-4.0 * depth)) * 0.05; + + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y+3.0 * depth)) * 0.09; + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y-3.0 * depth)) * 0.09; + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y+2.0 * depth)) * 0.12; + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y-2.0 * depth)) * 0.12; + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y+1.0 * depth)) * 0.15; + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y-1.0 * depth)) * 0.15; + + sum += tex2D( _GrabTexture, float2(screenPos.x, screenPos.y)) * 0.16; + + + return sum/2; + +} +ENDCG + } + + } + +Fallback Off +} \ No newline at end of file diff --git a/Assets/Shaders/WaterBlurModified.shader.meta b/Assets/Shaders/WaterBlurModified.shader.meta new file mode 100644 index 0000000..c8ce7c8 --- /dev/null +++ b/Assets/Shaders/WaterBlurModified.shader.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8f30c3b629e0d9c4b971df2848b5e3f3 +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: