diff options
Diffstat (limited to 'Assets/Bundle/Shaders/Common')
9 files changed, 141 insertions, 29 deletions
diff --git a/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc b/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc new file mode 100644 index 00000000..04334ee4 --- /dev/null +++ b/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc @@ -0,0 +1,18 @@ +// UnitLensEffectЧ¹û + +sampler2D _MainTex; +float4 _MainTex_ST; + +sampler2D _CameraDepthTexture; +float4 _CameraDepthTexture_ST; + +sampler2D _UnitDepthTexture; // ÅäºÏ_CameraDepthTexture¶¨Î»½ÇÉ« +float4 _UnitDepthTexture_ST; + +sampler2D _UnitWorldNormalTexture; +float4 _UnitWorldNormalTexture_ST; + +sampler2D _UnitMotionVectorTexture; +float4 _UnitMotionVectorTexture_ST; + +float4 _UnitTileOffset; diff --git a/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc.meta b/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc.meta new file mode 100644 index 00000000..8a4c56b7 --- /dev/null +++ b/Assets/Bundle/Shaders/Common/Image/ImageEffect.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7d761d98009111740b1e65e517a71aa5 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc b/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc new file mode 100644 index 00000000..ffe5bc11 --- /dev/null +++ b/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc @@ -0,0 +1,18 @@ + +// µü´úÒ»´Î +fixed4 blur(sampler2D tex, float2 texSize, fixed2 uv, float spread = 1) +{ + fixed2 step = 1 / texSize; + const fixed weight = 0.1111111; + fixed4 color = fixed4(0, 0, 0, 0); + color += tex2D(tex, uv + spread * fixed2(-step.x, step.y)) * weight; + color += tex2D(tex, uv + spread * fixed2(0, step.y)) * weight; + color += tex2D(tex, uv + spread * fixed2(step.x, step.y)) * weight; + color += tex2D(tex, uv + spread * fixed2(-step.x, 0)) * weight; + color += tex2D(tex, uv) * weight; + color += tex2D(tex, uv + spread * fixed2(step.x, 0)) * weight; + color += tex2D(tex, uv + spread * fixed2(-step.x, -step.y)) * weight; + color += tex2D(tex, uv + spread * fixed2(0, -step.y)) * weight; + color += tex2D(tex, uv + spread * fixed2(step.x, -step.y)) * weight; + return color; +} diff --git a/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc.meta b/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc.meta new file mode 100644 index 00000000..d5b4db71 --- /dev/null +++ b/Assets/Bundle/Shaders/Common/Image/ImageHelper.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6186a4071ad9eeb488a67f940291bb9d +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Bundle/Shaders/Common/Image/common_img_blur.shader b/Assets/Bundle/Shaders/Common/Image/common_img_blur.shader index d1e00953..89102da7 100644 --- a/Assets/Bundle/Shaders/Common/Image/common_img_blur.shader +++ b/Assets/Bundle/Shaders/Common/Image/common_img_blur.shader @@ -7,7 +7,7 @@ Shader "Erika/Common/Image/Blur" _MainTex("Texture", 2D) = "white" {} _Angle("Angle", float) = 0 _Distance("Distance", float) = 0 - _TileOffset("TileOffset", Vector) = (1,1,0,0) + _UnitTileOffset("TileOffset", Vector) = (1,1,0,0) _Iterate("Iterate Count", float) = 1 } @@ -29,7 +29,8 @@ Shader "Erika/Common/Image/Blur" #include "UnityCG.cginc" - #include "Assets/Bundle/Shaders/Include/ImageEffect.cginc" + #include "./ImageEffect.cginc" + #include "./ImageHelper.cginc" struct v2f { @@ -37,16 +38,11 @@ Shader "Erika/Common/Image/Blur" float4 vertex : SV_POSITION; }; - sampler2D _MainTex; - float4 _MainTex_ST; - float _Angle; - float4 _TileOffset; // 角色的范围 - fixed _Distance; - float _Iterate; // è¿ä»£æ¬¡æ•° + float _Iterate; v2f vert(appdata_img v) { diff --git a/Assets/Bundle/Shaders/Common/Image/common_img_buzz.shader b/Assets/Bundle/Shaders/Common/Image/common_img_buzz.shader index 467733f9..929a57b7 100644 --- a/Assets/Bundle/Shaders/Common/Image/common_img_buzz.shader +++ b/Assets/Bundle/Shaders/Common/Image/common_img_buzz.shader @@ -5,7 +5,7 @@ Shader "Erika/Common/Image/Buzz" Properties { _MainTex("Texture", 2D) = "white" {} - _TileOffset("TileOffset", Vector) = (1,1,0,0) + _UnitTileOffset("TileOffset", Vector) = (1,1,0,0) } SubShader @@ -26,7 +26,8 @@ Shader "Erika/Common/Image/Buzz" #include "UnityCG.cginc" - #include "Assets/Bundle/Shaders/Include/ImageEffect.cginc" + #include "./ImageEffect.cginc" + #include "./ImageHelper.cginc" struct v2f { @@ -34,17 +35,6 @@ Shader "Erika/Common/Image/Buzz" float4 vertex : SV_POSITION; }; - sampler2D _MainTex; - float4 _MainTex_ST; - - sampler2D _CameraDepthTexture; - float4 _CameraDepthTexture_ST; - - sampler2D _UnitDepthTexture; - float4 _UnitDepthTexture_ST; - - float4 _TileOffset; // 角色的范围 - v2f vert(appdata_img v) { v2f o; diff --git a/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader index 418d7347..2246fda2 100644 --- a/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader +++ b/Assets/Bundle/Shaders/Common/Image/common_img_motionblur.shader @@ -7,7 +7,7 @@ Shader "Erika/Common/Image/MotionBlur" _MainTex("Texture", 2D) = "white" {} _Angle("Angle", float) = 0 _Distance("Distance", float) = 0 - _TileOffset("TileOffset", Vector) = (1,1,0,0) + _UnitTileOffset("TileOffset", Vector) = (1,1,0,0) _Iterate("Iterate Count", float) = 1 } @@ -29,7 +29,7 @@ Shader "Erika/Common/Image/MotionBlur" #include "UnityCG.cginc" - #include "Assets/Bundle/Shaders/Include/ImageEffect.cginc" + #include "./ImageEffect.cginc" struct v2f { @@ -37,13 +37,8 @@ Shader "Erika/Common/Image/MotionBlur" float4 vertex : SV_POSITION; }; - sampler2D _MainTex; - float4 _MainTex_ST; - float _Angle; - float4 _TileOffset; // 角色的范围 - fixed _Distance; float _Iterate; // è¿ä»£æ¬¡æ•° @@ -67,7 +62,7 @@ Shader "Erika/Common/Image/MotionBlur" fixed4 color = fixed4(0,0,0,0); const float count = 20; float step = _Distance / count; - float amount = 0.15; + float amount = 0.2f; for(int i = 0; i < count; ++i) { fixed2 uv = uv0 + step * i * fixed2(cos(radians(_Angle)), sin(radians(_Angle))); diff --git a/Assets/Bundle/Shaders/Common/common_gbuffer.shader b/Assets/Bundle/Shaders/Common/common_gbuffer.shader new file mode 100644 index 00000000..485a52c1 --- /dev/null +++ b/Assets/Bundle/Shaders/Common/common_gbuffer.shader @@ -0,0 +1,68 @@ +Shader "Erika/Common/GBuffer"
+{
+ Properties
+ {
+ _MainTex ("Texture", 2D) = "white" {}
+ }
+ SubShader
+ {
+ Tags { "RenderType"="Opaque" }
+ LOD 100
+
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
+
+ #include "UnityCG.cginc"
+
+ struct appdata
+ {
+ float3 vertex : POSITION;
+ float3 normal : NORMAL;
+ float3 tangent : TANGENT;
+ float2 uv : TEXCOORD0;
+ };
+
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float3 normal : TEXCOORD1;
+ float3 worldPos : TEXCOORD2;
+ float4 vertex : SV_POSITION;
+ };
+
+ struct Output
+ {
+ float4 diffuse : SV_Target0;
+ float4 normal : SV_Target1;
+ float4 position : SV_Target2;
+ float4 texCoord : SV_Target3;
+ };
+
+ sampler2D _MainTex;
+ float4 _MainTex_ST;
+
+ v2f vert (appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = TRANSFORM_TEX(v.uv, _MainTex);
+ o.worldPos = mul(unity_ObjectToWorld, float4(v.vertex, 1)).xyz;
+ return o;
+ }
+
+ Output frag (v2f i)
+ {
+ Output o;
+ fixed4 col = tex2D(_MainTex, i.uv);
+ o.diffuse = fixed4(1,0,0,1);
+ o.normal = fixed4(1,1,0,1);
+ o.position = fixed4(i.worldPos, 1);
+ return o;
+ }
+ ENDCG
+ }
+ }
+}
diff --git a/Assets/Bundle/Shaders/Common/common_gbuffer.shader.meta b/Assets/Bundle/Shaders/Common/common_gbuffer.shader.meta new file mode 100644 index 00000000..b40b2f5a --- /dev/null +++ b/Assets/Bundle/Shaders/Common/common_gbuffer.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1bb32fe6a2152fc45b9badd5cf9ed7ed +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: |