From d6596e06f82a3cdb8d96de3254b7211c2ca3e400 Mon Sep 17 00:00:00 2001 From: cd <-> Date: Mon, 12 Jun 2023 21:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=BD=93=E6=B6=88=E8=9E=8Dshader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generated/ArticyEditorSettings.asset | 2 +- .../Assets/Game/Arts/Material/Character.mat | 10 +++++++ client/Assets/Game/Arts/Material/DeadBody.mat | 6 +++- .../Assets/Game/Arts/Shader/Character.shader | 27 +++++++++++++++-- .../Assets/Game/Arts/Shader/DeadBody.shader | 27 +++++++++-------- .../Game/Scripts/ECS/System/DieSystem.cs | 2 +- .../Timeline/TimelineClip/ClipAttack.cs | 2 -- .../CastShadow/CastShadowDeadBody.prefab | 6 ++-- .../Textures/Noise/Noise1.png.meta | 30 +++++++++++++++---- 9 files changed, 85 insertions(+), 27 deletions(-) diff --git a/client/Assets/ArticyImporter/Content/Generated/ArticyEditorSettings.asset b/client/Assets/ArticyImporter/Content/Generated/ArticyEditorSettings.asset index ad79e3d..c061298 100644 --- a/client/Assets/ArticyImporter/Content/Generated/ArticyEditorSettings.asset +++ b/client/Assets/ArticyImporter/Content/Generated/ArticyEditorSettings.asset @@ -21,6 +21,6 @@ MonoBehaviour: mLastUsedPackagesHash: 1177269412 mLastUsedPackagesCount: 1 mLastBuildCode: 1 - mLastEditorStartupTimeTicks: 638214577828442584 + mLastEditorStartupTimeTicks: 638214577847877530 mNewVersionAvailable: 1 mLastAttachedFlowPlayerValue: 0 diff --git a/client/Assets/Game/Arts/Material/Character.mat b/client/Assets/Game/Arts/Material/Character.mat index 326bcad..ee1d72f 100644 --- a/client/Assets/Game/Arts/Material/Character.mat +++ b/client/Assets/Game/Arts/Material/Character.mat @@ -43,6 +43,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _FadingTex: + m_Texture: {fileID: 2800000, guid: 98b64212b777b704896163bb7d44c346, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _MainTex: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -51,6 +55,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _NoiseTex: + m_Texture: {fileID: 2800000, guid: 98b64212b777b704896163bb7d44c346, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _OcclusionMap: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -84,6 +92,7 @@ Material: - _DetailNormalMapScale: 1 - _DstBlend: 0 - _EnableExternalAlpha: 0 + - _FadingWidth: 0.1 - _Flash: 0 - _GlossMapScale: 1 - _Glossiness: 0.358 @@ -113,6 +122,7 @@ Material: - _Color: {r: 1, g: 1, b: 1, a: 1} - _Direction: {r: 2, g: 1, b: 0, a: 0} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _FadingColor: {r: 1, g: 1, b: 0.5518868, a: 1} - _FlashColor: {r: 1, g: 1, b: 1, a: 1} - _Flip: {r: 1, g: 1, b: 1, a: 1} - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/client/Assets/Game/Arts/Material/DeadBody.mat b/client/Assets/Game/Arts/Material/DeadBody.mat index f5ea0b2..09e1446 100644 --- a/client/Assets/Game/Arts/Material/DeadBody.mat +++ b/client/Assets/Game/Arts/Material/DeadBody.mat @@ -67,6 +67,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _NoiseTex: + m_Texture: {fileID: 2800000, guid: 89aee6e5903b6a343b5d3533c4a48949, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _Normal: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -119,7 +123,7 @@ Material: - _UVSec: 0 - _UseUIAlphaClip: 0 - _Use_Gradient: 1 - - _Width: 4 + - _Width: 1 - _ZWrite: 1 - _cutoff: 0 m_Colors: diff --git a/client/Assets/Game/Arts/Shader/Character.shader b/client/Assets/Game/Arts/Shader/Character.shader index 649d541..23d6aaa 100644 --- a/client/Assets/Game/Arts/Shader/Character.shader +++ b/client/Assets/Game/Arts/Shader/Character.shader @@ -13,6 +13,9 @@ Shader "Custom/Character" _Direction ("Direction", Vector) = (0, 1, 0, 0) _Intensity ("Intensity", Range(0.0, 1.0)) = 0 _UV ("UV", Vector) = (0, 0, 0, 0)//uv中心xy,uv边界 + _FadingTex ("FadingTex", 2D) = "white" {} + _FadingColor ("FadingColor", Color) = (1,1,1,1) + _FadingWidth ("FadingWidth", Range(0,1)) = 0 } SubShader { @@ -30,6 +33,7 @@ Shader "Custom/Character" sampler2D _MainTex; sampler2D _PaletteTex; sampler2D _ReplaceTex; + sampler2D _FadingTex; fixed4 _Color; fixed _Flash; fixed4 _FlashColor; @@ -38,6 +42,8 @@ Shader "Custom/Character" fixed4 _Direction; fixed _Intensity; fixed4 _UV; + fixed4 _FadingColor; + fixed _FadingWidth; struct Input { @@ -81,8 +87,25 @@ Shader "Custom/Character" { rgb = rgb * (_Flash + 1) * _FlashColor; } - o.Albedo = rgb * _Color; - o.Alpha = _Alpha * c.a; + + //消融 + fixed2 nioseUV = fixed2((bound.x + uv.x) / (bound.y - bound.x), (bound.z + uv.y) / (bound.w - bound.z)); + fixed4 noise = tex2D(_FadingTex, nioseUV * 40); + if (_Alpha < noise.r - _FadingWidth) + { + discard; + } + if (_Alpha < noise.r) + { + o.Albedo = _FadingColor; + o.Emission = _FadingColor; + } + else + { + o.Albedo = rgb * _Color; + } + + o.Alpha = c.a; clip(o.Alpha - 0.5); } ENDCG diff --git a/client/Assets/Game/Arts/Shader/DeadBody.shader b/client/Assets/Game/Arts/Shader/DeadBody.shader index 6334f9c..16b74f4 100644 --- a/client/Assets/Game/Arts/Shader/DeadBody.shader +++ b/client/Assets/Game/Arts/Shader/DeadBody.shader @@ -2,25 +2,27 @@ Shader "Custom/DeadBody" { Properties { - _Color ("Color", Color) = (1,1,1,1) [PerRendererData]_MainTex ("Sprite Texture", 2D) = "white" {} + _NoiseTex ("Noise Texture", 2D) = "white" {} _Alpha ("_Alpha", Range(0,1)) = 1 + _Width ("_Width", Range(0,1)) = 1 } SubShader { - Tags {"Queue" = "Transparent" "RenderType"="Transparent" } - - ZWrite Off + Tags + { + "Queue" = "Geometry" + } Cull Off + ZWrite On CGPROGRAM - #pragma surface surf Lambert alpha:fade + #pragma surface surf Lambert addshadow fullforwardshadows #pragma target 3.0 sampler2D _MainTex; - fixed4 _Color; - fixed _Cutoff; - fixed _Flash; + sampler2D _NoiseTex; fixed _Alpha; + fixed _Width; struct Input { @@ -28,10 +30,11 @@ Shader "Custom/DeadBody" }; void surf (Input IN, inout SurfaceOutput o) { - fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; - fixed3 rgb = (_Color.rgb*(_Flash+1))*(c.rgb); - o.Albedo = rgb; - o.Alpha = _Alpha*c.a; + fixed4 c = tex2D (_MainTex, IN.uv_MainTex); + fixed4 noise = tex2D(_NoiseTex, IN.uv_MainTex); + o.Albedo = c; + o.Alpha = c.a; + clip(o.Alpha - 0.5); } ENDCG } diff --git a/client/Assets/Game/Scripts/ECS/System/DieSystem.cs b/client/Assets/Game/Scripts/ECS/System/DieSystem.cs index 6e6cc5e..4cb876f 100644 --- a/client/Assets/Game/Scripts/ECS/System/DieSystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/DieSystem.cs @@ -47,7 +47,7 @@ public class DieSystem : IExecuteSystem, IInitializeSystem else { //创建尸体特效 - entity.CastShadow(2000, ECastShadowType.DeadBody); + entity.CastShadow(1000, ECastShadowType.DeadBody); //掉落pt CreatePt(entity.Pos()); //死亡事件通知 diff --git a/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs b/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs index a58def4..c754dfc 100644 --- a/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs +++ b/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs @@ -104,8 +104,6 @@ namespace Game { info.Continue = true; } - - Util.Print(info.Continue); skill.HitInfo.Enqueue(info); } } diff --git a/client/Assets/Resources/Prefab/Effect/CastShadow/CastShadowDeadBody.prefab b/client/Assets/Resources/Prefab/Effect/CastShadow/CastShadowDeadBody.prefab index 492f1e2..bb36a3e 100644 --- a/client/Assets/Resources/Prefab/Effect/CastShadow/CastShadowDeadBody.prefab +++ b/client/Assets/Resources/Prefab/Effect/CastShadow/CastShadowDeadBody.prefab @@ -50,7 +50,7 @@ SpriteRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 673285d80149b5c4e914c503fa048f1b, type: 2} + - {fileID: 2100000, guid: 8b75e4f77efb4b942bff540369576f7d, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -71,13 +71,13 @@ SpriteRenderer: m_SortingLayerID: -248419617 m_SortingLayer: 3 m_SortingOrder: -1 - m_Sprite: {fileID: 9044786021765537137, guid: 8142b0399fe09a14c929e8dfcba09863, + m_Sprite: {fileID: -6357392960514800984, guid: 51ef05ddfb1119e40b42882a835844a9, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 m_DrawMode: 0 - m_Size: {x: 2, y: 1} + m_Size: {x: 2, y: 2} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 diff --git a/client/Assets/Resources/Prefab/Effect/Pack2/Demo & Assets/Textures/Noise/Noise1.png.meta b/client/Assets/Resources/Prefab/Effect/Pack2/Demo & Assets/Textures/Noise/Noise1.png.meta index 2ef485a..0e33a90 100644 --- a/client/Assets/Resources/Prefab/Effect/Pack2/Demo & Assets/Textures/Noise/Noise1.png.meta +++ b/client/Assets/Resources/Prefab/Effect/Pack2/Demo & Assets/Textures/Noise/Noise1.png.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 guid: 98b64212b777b704896163bb7d44c346 TextureImporter: - fileIDToRecycleName: {} + internalIDToNameTable: [] externalObjects: {} - serializedVersion: 9 + serializedVersion: 11 mipmaps: mipMapMode: 0 enableMipMap: 0 @@ -23,6 +23,7 @@ TextureImporter: isReadable: 0 streamingMipmaps: 0 streamingMipmapsPriority: 0 + vTOnly: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -31,7 +32,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 0 aniso: -1 mipBias: -100 wrapU: -1 @@ -54,21 +55,38 @@ TextureImporter: textureType: 0 textureShape: 1 singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 maxTextureSizeSet: 0 compressionQualitySet: 0 textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 1 platformSettings: - - serializedVersion: 2 + - serializedVersion: 3 buildTarget: DefaultTexturePlatform maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 - textureCompression: 1 + textureCompression: 0 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -76,10 +94,12 @@ TextureImporter: physicsShape: [] bones: [] spriteID: + internalID: 0 vertices: [] indices: edges: [] weights: [] + secondaryTextures: [] spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0