Commit 1308d2de authored by Unicorn369's avatar Unicorn369

update

parent d00f6710
...@@ -2,79 +2,204 @@ ...@@ -2,79 +2,204 @@
Shader "Custom/WaterBlur" { Shader "Custom/WaterBlur" {
Properties { Properties {
_blurSizeXY("BlurSizeXY", Range(0,10)) = 2 _blurSizeXY("BlurSizeXY", Range(0, 20)) = 1
} _Color("Main Color", Color) = (1, 1, 1, 1)
SubShader { _BumpAmt("Distortion", Range(0, 128)) = 10
// Draw ourselves after all opaque geometry _MainTex("Tint Color (RGB)", 2D) = "white" {}
Tags { "Queue" = "Transparent" } _BumpMap("Normalmap", 2D) = "bump" {}
// Grab the screen behind the object into _GrabTexture }
GrabPass { }
// Render the object with the texture generated above Category {
Pass { // We must be transparent, so other objects are drawn before this one.
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque" }
CGPROGRAM
#pragma debug SubShader {
#pragma vertex vert // Horizontal blur
#pragma fragment frag GrabPass {
#pragma target 3.0 Tags { "LightMode" = "Always" }
sampler2D _GrabTexture : register(s0); }
float _blurSizeXY; Pass {
struct data { Tags { "LightMode" = "Always" }
float4 vertex : POSITION;
float3 normal : NORMAL; CGPROGRAM
}; #pragma vertex vert
#pragma fragment frag
struct v2f { #pragma fragmentoption ARB_precision_hint_fastest
float4 position : POSITION; #include "UnityCG.cginc"
float4 screenPos : TEXCOORD0;
}; struct appdata_t {
float4 vertex : POSITION;
v2f vert(data i){ float2 texcoord: TEXCOORD0;
v2f o; };
o.position = UnityObjectToClipPos(i.vertex);
o.screenPos = o.position; struct v2f {
return o; float4 vertex : POSITION;
} float4 uvgrab : TEXCOORD0;
};
half4 frag( v2f i ) : COLOR
{ v2f vert (appdata_t v) {
float2 screenPos = i.screenPos.xy / i.screenPos.w; v2f o;
float depth= _blurSizeXY*0.0005; o.vertex = UnityObjectToClipPos(v.vertex);
screenPos.x = (screenPos.x + 1) * 0.5; #if UNITY_UV_STARTS_AT_TOP
screenPos.y = 1-(screenPos.y + 1) * 0.5; float scale = -1.0;
half4 sum = half4(0.0h,0.0h,0.0h,0.0h); #else
sum += tex2D( _GrabTexture, float2(screenPos.x-5.0 * depth, screenPos.y+5.0 * depth)) * 0.025; float scale = 1.0;
sum += tex2D( _GrabTexture, float2(screenPos.x+5.0 * depth, screenPos.y-5.0 * depth)) * 0.025; #endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
sum += tex2D( _GrabTexture, float2(screenPos.x-4.0 * depth, screenPos.y+4.0 * depth)) * 0.05; o.uvgrab.zw = o.vertex.zw;
sum += tex2D( _GrabTexture, float2(screenPos.x+4.0 * depth, screenPos.y-4.0 * depth)) * 0.05; return o;
}
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; sampler2D _GrabTexture;
float4 _GrabTexture_TexelSize;
sum += tex2D( _GrabTexture, float2(screenPos.x-2.0 * depth, screenPos.y+2.0 * depth)) * 0.12; float _blurSizeXY;
sum += tex2D( _GrabTexture, float2(screenPos.x+2.0 * depth, screenPos.y-2.0 * depth)) * 0.12;
half4 frag( v2f i ) : COLOR {
sum += tex2D( _GrabTexture, float2(screenPos.x-1.0 * depth, screenPos.y+1.0 * depth)) * 0.15; // half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
sum += tex2D( _GrabTexture, float2(screenPos.x+1.0 * depth, screenPos.y-1.0 * depth)) * 0.15; // return col;
half4 sum = half4(0, 0, 0, 0);
sum += tex2D( _GrabTexture, screenPos-5.0 * depth) * 0.025; #define GRABPIXEL(weight,kernelx) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx * _blurSizeXY, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
sum += tex2D( _GrabTexture, screenPos-4.0 * depth) * 0.05; sum += GRABPIXEL(0.05, -4.0);
sum += tex2D( _GrabTexture, screenPos-3.0 * depth) * 0.09; sum += GRABPIXEL(0.09, -3.0);
sum += tex2D( _GrabTexture, screenPos-2.0 * depth) * 0.12; sum += GRABPIXEL(0.12, -2.0);
sum += tex2D( _GrabTexture, screenPos-1.0 * depth) * 0.15; sum += GRABPIXEL(0.15, -1.0);
sum += tex2D( _GrabTexture, screenPos) * 0.16; sum += GRABPIXEL(0.18, 0.0);
sum += tex2D( _GrabTexture, screenPos+5.0 * depth) * 0.15; sum += GRABPIXEL(0.15, +1.0);
sum += tex2D( _GrabTexture, screenPos+4.0 * depth) * 0.12; sum += GRABPIXEL(0.12, +2.0);
sum += tex2D( _GrabTexture, screenPos+3.0 * depth) * 0.09; sum += GRABPIXEL(0.09, +3.0);
sum += tex2D( _GrabTexture, screenPos+2.0 * depth) * 0.05; sum += GRABPIXEL(0.05, +4.0);
sum += tex2D( _GrabTexture, screenPos+1.0 * depth) * 0.025;
return sum;
return sum/2; }
} ENDCG
ENDCG }
// Vertical blur
GrabPass {
Tags { "LightMode" = "Always" }
}
Pass {
Tags { "LightMode" = "Always" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
};
struct v2f {
float4 vertex : POSITION;
float4 uvgrab : TEXCOORD0;
};
v2f vert (appdata_t v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
return o;
}
sampler2D _GrabTexture;
float4 _GrabTexture_TexelSize;
float _blurSizeXY;
half4 frag( v2f i ) : COLOR {
// half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
// return col;
half4 sum = half4(0, 0, 0, 0);
#define GRABPIXEL(weight,kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely * _blurSizeXY, i.uvgrab.z, i.uvgrab.w))) * weight
//G(X) = (1/(sqrt(2 * PI * deviation * deviation))) * exp(-(x*x / (2 * deviation * deviation)))
sum += GRABPIXEL(0.05, -4.0);
sum += GRABPIXEL(0.09, -3.0);
sum += GRABPIXEL(0.12, -2.0);
sum += GRABPIXEL(0.15, -1.0);
sum += GRABPIXEL(0.18, 0.0);
sum += GRABPIXEL(0.15, +1.0);
sum += GRABPIXEL(0.12, +2.0);
sum += GRABPIXEL(0.09, +3.0);
sum += GRABPIXEL(0.05, +4.0);
return sum;
}
ENDCG
}
// Distortion
GrabPass {
Tags { "LightMode" = "Always" }
}
Pass {
Tags { "LightMode" = "Always" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
};
struct v2f {
float4 vertex : POSITION;
float4 uvgrab : TEXCOORD0;
float2 uvbump : TEXCOORD1;
float2 uvmain : TEXCOORD2;
};
float _BumpAmt;
float4 _BumpMap_ST;
float4 _MainTex_ST;
v2f vert (appdata_t v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
o.uvbump = TRANSFORM_TEX( v.texcoord, _BumpMap );
o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
return o;
}
fixed4 _Color;
sampler2D _GrabTexture;
float4 _GrabTexture_TexelSize;
sampler2D _BumpMap;
sampler2D _MainTex;
half4 frag( v2f i ) : COLOR {
// calculate perturbed coordinates
half2 bump = UnpackNormal(tex2D( _BumpMap, i.uvbump )).rg; // we could optimize this by just reading the x y without reconstructing the Z
float2 offset = bump * _BumpAmt * _GrabTexture_TexelSize.xy;
i.uvgrab.xy = offset * i.uvgrab.z + i.uvgrab.xy;
half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
half4 tint = tex2D( _MainTex, i.uvmain ) * _Color;
return col * tint;
}
ENDCG
}
} }
} }
Fallback Off
} }
\ No newline at end of file
...@@ -144,16 +144,17 @@ public class Menu : WindowServantSP ...@@ -144,16 +144,17 @@ public class Menu : WindowServantSP
Application.OpenURL("https://github.com/Unicorn369/pro2_android_closeup/releases/tag/1.0"); Application.OpenURL("https://github.com/Unicorn369/pro2_android_closeup/releases/tag/1.0");
#elif UNITY_ANDROID //Android #elif UNITY_ANDROID //Android
AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API"); AndroidJavaObject jo = new AndroidJavaObject("cn.unicorn369.library.API");
if (!File.Exists("updates/closeup_version1.2.txt")) {//用于检查更新 if (!File.Exists("updates/closeup_version1.3.txt")) {//用于检查更新
if (File.Exists("closeup_version1.2.zip")) {//如果有则直接解压 if (File.Exists("closeup_version1.3.zip")) {//如果有则直接解压
jo.Call("doExtractZipFile", "closeup_version1.2.zip", Program.ANDROID_GAME_PATH); jo.Call("doExtractZipFile", "closeup_version1.3.zip", Program.ANDROID_GAME_PATH);
} else if (File.Exists("updates/closeup_version1.1.txt")){//如果有则下载更新包 } else if (File.Exists("updates/closeup_version1.2.txt")){//如果有则下载更新包
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/up_closeup_version1.2.zip"); jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/up_closeup_version1.3.zip");
} else {//否则下载并解压,锁定目录:ANDROID_GAME_PATH } else {//否则下载并解压,锁定目录:ANDROID_GAME_PATH
jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.2.zip"); jo.Call("doDownloadZipFile", "https://github.com/Unicorn369/pro2_android_closeup/releases/download/1.0/closeup_version1.3.zip");
} }
} else { } else {
jo.Call("showToast", "已下载,无需再次下载!"); jo.Call("showToast", "已是最新,无需再次下载!");
Program.PrintToChat(InterString.Get("已是最新,无需再次下载!"));
} }
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment