summaryrefslogtreecommitdiff
path: root/Assets/Bundle/Shaders/Common
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-09-29 19:55:57 +0800
committerchai <chaifix@163.com>2021-09-29 19:55:57 +0800
commit61d6e9bf192ffa54abc57bab69b1bd88c3b8d62b (patch)
tree47071b43d583ced63b1b6cc4a9e4c2c6100ffe3f /Assets/Bundle/Shaders/Common
parent16e4a47beaf7786b63404d4a8356e45d70a393b5 (diff)
*misc
Diffstat (limited to 'Assets/Bundle/Shaders/Common')
-rw-r--r--Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader83
-rw-r--r--Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader.meta9
-rw-r--r--Assets/Bundle/Shaders/Common/common_solid_color.shader2
3 files changed, 93 insertions, 1 deletions
diff --git a/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader
new file mode 100644
index 00000000..702bbd4b
--- /dev/null
+++ b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader
@@ -0,0 +1,83 @@
+// 高斯模糊
+
+Shader "Erika/Common/Image/MotionBlur"
+{
+ Properties
+ {
+ _MainTex("Texture", 2D) = "white" {}
+ _Angle("Angle", float) = 0
+ _Distance("Distance", float) = 0
+ _TileOffset("TileOffset", Vector) = (1,1,0,0)
+ _Iterate("Iterate Count", float) = 1
+ }
+
+ SubShader
+ {
+ Tags { "RenderType" = "Opaque" "Queue" = "Transparent-1"}
+ LOD 100
+
+ ZWrite Off
+ ZTest LEqual
+
+ Blend SrcAlpha OneMinusSrcAlpha
+
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
+
+ #include "UnityCG.cginc"
+
+ #include "Assets/Bundle/Shaders/Include/ImageEffect.cginc"
+
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
+
+ sampler2D _MainTex;
+ float4 _MainTex_ST;
+
+ float _Angle;
+
+ float4 _TileOffset; // 角色的范围
+
+ fixed _Distance;
+
+ float _Iterate; // 迭代次数
+
+ v2f vert(appdata_img v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
+ return o;
+ }
+
+ fixed4 frag(v2f i) : SV_Target
+ {
+ _Distance = 0.1;
+
+ fixed2 uv0 = i.uv;
+
+ //fixed4 color = blur(_MainTex, _ScreenParams.xy, uv);
+ fixed4 color = fixed4(0,0,0,0);
+ const float count = 20;
+ float step = _Distance / count;
+ for(int i = 0; i < count; ++i)
+ {
+ fixed2 uv = uv0 + step * i * fixed2(cos(radians(_Angle)), sin(radians(_Angle)));
+ if(uv.x > 1) continue;
+ if(uv.x < 0) continue;
+ color += tex2D(_MainTex, uv) * 1 / count;
+ }
+
+ return color;
+ }
+ ENDCG
+ }
+ }
+
+} // shader
diff --git a/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader.meta b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader.meta
new file mode 100644
index 00000000..cc5320fa
--- /dev/null
+++ b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: d68c264cf01a43b4c8503bd7bbe2fbda
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Bundle/Shaders/Common/common_solid_color.shader b/Assets/Bundle/Shaders/Common/common_solid_color.shader
index 92daaa30..69b25500 100644
--- a/Assets/Bundle/Shaders/Common/common_solid_color.shader
+++ b/Assets/Bundle/Shaders/Common/common_solid_color.shader
@@ -71,7 +71,7 @@
if (diff < 0.0001)
{
c = _Color;
- // c = tex2D(_MainTex, i.uv);
+ c = tex2D(_MainTex, i.uv);
}
return c;