Ver Fonte

导入shader需要的urp管线

SZAND\msx_2 há 1 ano atrás
pai
commit
19e1edf78b

+ 2 - 2
ActionTowerDefense/Assets/Resources/Prefab/FloatEffectRange.prefab

@@ -48,7 +48,7 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 30, y: 100, z: 1}
+  m_Size: {x: 22, y: 100, z: 1}
   m_Center: {x: 0, y: 0, z: 0}
 --- !u!114 &3655836912165546929
 MonoBehaviour:
@@ -14816,7 +14816,7 @@ Transform:
   m_GameObject: {fileID: 8738166163358563370}
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
   m_LocalPosition: {x: -0.0248, y: 0.896, z: 0}
-  m_LocalScale: {x: 30.040564, y: 143.94612, z: 1}
+  m_LocalScale: {x: 22, y: 143.94612, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 6831563428749086452}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Shader.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 80b2b037e648f0f4190b904acebecbf5
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 36 - 0
ActionTowerDefense/Assets/Scripts/Shader/outline.mat

@@ -0,0 +1,36 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+  serializedVersion: 8
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: outline
+  m_Shader: {fileID: 4800000, guid: 1f512c0ec5932a04ba9fc013e709ec6e, type: 3}
+  m_ValidKeywords:
+  - _ShowOutline
+  m_InvalidKeywords: []
+  m_LightmapFlags: 4
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: -1
+  stringTagMap: {}
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - _MainTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Ints: []
+    m_Floats:
+    - _DualGrid: 1
+    - _EdgeAlphaThreshold: 1
+    - _EdgeDampRate: 5
+    - _OriginAlphaThreshold: 0.82
+    m_Colors:
+    - _EdgeColor: {r: 1, g: 1, b: 1, a: 1}
+  m_BuildTextureStacks: []

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Shader/outline.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 10a8bf81d8e77484a9cb8430e9a2d095
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 2100000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 94 - 0
ActionTowerDefense/Assets/Scripts/Shader/outline.shader

@@ -0,0 +1,94 @@
+// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
+ 
+Shader "Custom/ShaderForTest"
+{
+	Properties
+	{
+		_MainTex("Main Texture", 2D) = "white"{}									//主纹理
+		_EdgeAlphaThreshold("Edge Alpha Threshold", Float) = 1.0					//边界透明度和的阈值
+		_EdgeColor("Edge Color", Color) = (0,0,0,1)									//边界颜色
+		_EdgeDampRate("Edge Damp Rate", Float) = 2									//边缘渐变的分母
+		_OriginAlphaThreshold("OriginAlphaThreshold", range(0.1, 1)) = 0.2			//原始颜色透明度剔除的阈值
+		[Toggle(_ShowOutline)] _DualGrid ("Show Outline", Int) = 0					//Toggle开关来控制是否显示边缘
+	}
+ 
+	SubShader
+	{
+		Tags{ "RenderType"="Transparent" "Queue"="Transparent" }
+		Blend SrcAlpha OneMinusSrcAlpha
+ 
+		Pass
+		{
+			Ztest Always Cull Off ZWrite Off
+			CGPROGRAM
+ 
+			#pragma vertex vert
+			#pragma fragment frag
+			#pragma shader_feature _ShowOutline
+			#include "UnityCG.cginc"
+			sampler2D _MainTex;
+			half4 _MainTex_TexelSize;
+			fixed _EdgeAlphaThreshold;
+			fixed4 _EdgeColor;
+			float _EdgeDampRate;
+			float _OriginAlphaThreshold;
+ 
+			struct v2f
+			{
+				float4 vertex : SV_POSITION;
+				float2 uv[9] : TEXCOORD0;
+			};
+ 
+			half CalculateAlphaSumAround(v2f i)
+			{
+				half texAlpha;
+				half alphaSum = 0;
+				for(int it = 0; it < 9; it ++)
+				{
+					texAlpha = tex2D(_MainTex, i.uv[it]).w;
+					alphaSum += texAlpha;
+				}
+ 
+				return alphaSum;
+			}
+ 
+			v2f vert(appdata_img v)
+			{
+				v2f o;
+				o.vertex = UnityObjectToClipPos(v.vertex);
+				
+				half2 uv = v.texcoord;
+ 
+				o.uv[0] = uv + _MainTex_TexelSize.xy * half2(-1, -1);
+				o.uv[1] = uv + _MainTex_TexelSize.xy * half2(0, -1);
+				o.uv[2] = uv + _MainTex_TexelSize.xy * half2(1, -1);
+				o.uv[3] = uv + _MainTex_TexelSize.xy * half2(-1, 0);
+				o.uv[4] = uv + _MainTex_TexelSize.xy * half2(0, 0);
+				o.uv[5] = uv + _MainTex_TexelSize.xy * half2(1, 0);
+				o.uv[6] = uv + _MainTex_TexelSize.xy * half2(-1, 1);
+				o.uv[7] = uv + _MainTex_TexelSize.xy * half2(0, 1);
+				o.uv[8] = uv + _MainTex_TexelSize.xy * half2(1, 1);
+ 
+				return o;
+			}
+ 
+			fixed4 frag(v2f i) : SV_Target
+			{
+				#if defined(_ShowOutline)
+					half alphaSum = CalculateAlphaSumAround(i);
+					float isNeedShow = alphaSum > _EdgeAlphaThreshold;
+					float damp = saturate((alphaSum - _EdgeAlphaThreshold) * _EdgeDampRate);
+					fixed4 orign = tex2D(_MainTex, i.uv[4]);
+					float isOrigon = orign.a > _OriginAlphaThreshold;
+					fixed3 finalColor = lerp(_EdgeColor.rgb, orign.rgb, isOrigon);
+ 
+					return fixed4(finalColor.rgb, isNeedShow * damp);
+				#endif
+ 
+				return tex2D(_MainTex, i.uv[4]);
+			}
+ 
+			ENDCG
+		}
+	}
+}

+ 10 - 0
ActionTowerDefense/Assets/Scripts/Shader/outline.shader.meta

@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 1f512c0ec5932a04ba9fc013e709ec6e
+ShaderImporter:
+  externalObjects: {}
+  defaultTextures: []
+  nonModifiableTextures: []
+  preprocessorOverride: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 18 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs

@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Spirits_Cook : MonoBehaviour
+{
+    // Start is called before the first frame update
+    void Start()
+    {
+        
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ae4045519d0e38e48a91f50e3593ed41
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 15 - 0
ActionTowerDefense/ProjectSettings/URPProjectSettings.asset

@@ -0,0 +1,15 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &1
+MonoBehaviour:
+  m_ObjectHideFlags: 61
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_LastMaterialVersion: 5