From 84d4dccd334ce36c247c3833154e36e3cd51dfab Mon Sep 17 00:00:00 2001 From: CA-Tatami Date: Wed, 7 Aug 2024 10:55:07 +0900 Subject: [PATCH] =?UTF-8?q?Transition=20Progress=E3=81=A8EdgeSharpness?= =?UTF-8?q?=E3=81=AE=E9=A0=85=E7=9B=AE=E3=82=92=E3=83=86=E3=82=AF=E3=82=B9?= =?UTF-8?q?=E3=83=81=E3=83=A3=E6=AF=8E=E3=81=AB=E8=A8=AD=E5=AE=9A=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Scripts/MaterialPropertyNames.cs | 3 ++- .../Core/Scripts/ParticlesUberCommonGUI.cs | 2 ++ .../ParticlesUberCommonMaterialProperties.cs | 9 ++++++--- .../Runtime/Core/Shaders/ParticlesUber.hlsl | 17 +++++++++-------- .../Core/Shaders/ParticlesUberLit.shader | 3 ++- .../Core/Shaders/ParticlesUberUnlit.shader | 3 ++- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs b/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs index 70a92fa8..1bd593c5 100644 --- a/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs +++ b/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs @@ -123,6 +123,7 @@ public static class MaterialPropertyNames public const string AlphaTransitionSecondTextureBlendMode = "_AlphaTransitionSecondTextureBlendMode"; public const string AlphaTransitionProgress = "_AlphaTransitionProgress"; public const string AlphaTransitionProgressCoord = "_AlphaTransitionProgressCoord"; + public const string DissolveSharpness = "_DissolveSharpness"; public const string AlphaTransitionMapSecondTexture = "_AlphaTransitionMapSecondTexture"; public const string AlphaTransitionMapSecondTexture2DArray = "_AlphaTransitionMapSecondTexture2DArray"; public const string AlphaTransitionMapSecondTexture3D = "_AlphaTransitionMapSecondTexture3D"; @@ -131,7 +132,7 @@ public static class MaterialPropertyNames public const string AlphaTransitionMapSecondTextureChannelsX = "_AlphaTransitionMapSecondTextureChannelsX"; public const string AlphaTransitionProgressSecondTexture = "_AlphaTransitionProgressSecondTexture"; public const string AlphaTransitionProgressCoordSecondTexture = "_AlphaTransitionProgressCoordSecondTexture"; - public const string DissolveSharpness = "_DissolveSharpness"; + public const string DissolveSharpnessSecondTexture = "_DissolveSharpnessSecondTexture"; // Emission public const string EmissionAreaType = "_EmissionAreaType"; diff --git a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs index d6049690..d93a4887 100644 --- a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs +++ b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs @@ -444,6 +444,8 @@ private void InternalDrawAlphaTransitionProperties() props.AlphaTransitionMapSecondTextureChannelsXProp.Value, null); MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Transition Progress", props.AlphaTransitionProgressSecondTextureProp.Value, props.AlphaTransitionProgressCoordSecondTextureProp.Value); + if (mode == AlphaTransitionMode.Dissolve) + _editor.ShaderProperty(props.DissolveSharpnessSecondTextureProp.Value, "Edge Sharpness"); } } } diff --git a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs index 43e1e06d..c75a902c 100644 --- a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs +++ b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs @@ -131,6 +131,7 @@ public void Setup(MaterialProperty[] properties) AlphaTransitionMapSliceCountProp.Setup(properties); AlphaTransitionProgressProp.Setup(properties); AlphaTransitionProgressCoordProp.Setup(properties); + DissolveSharpnessProp.Setup(properties); AlphaTransitionSecondTextureBlendModeProp.Setup(properties); AlphaTransitionMapSecondTextureProp.Setup(properties); AlphaTransitionMapSecondTexture2DArrayProp.Setup(properties); @@ -140,7 +141,7 @@ public void Setup(MaterialProperty[] properties) AlphaTransitionMapSecondTextureChannelsXProp.Setup(properties); AlphaTransitionProgressSecondTextureProp.Setup(properties); AlphaTransitionProgressCoordSecondTextureProp.Setup(properties); - DissolveSharpnessProp.Setup(properties); + DissolveSharpnessSecondTextureProp.Setup(properties); // Emission EmissionAreaTypeProp.Setup(properties); @@ -383,6 +384,8 @@ public void Setup(MaterialProperty[] properties) public ParticlesGUI.Property AlphaTransitionMapSliceCountProp { get; } = new(PropertyNames.AlphaTransitionMapSliceCount); + public ParticlesGUI.Property DissolveSharpnessProp { get; } = new(PropertyNames.DissolveSharpness); + public ParticlesGUI.Property AlphaTransitionSecondTextureBlendModeProp { get; } = new(PropertyNames.AlphaTransitionSecondTextureBlendMode); @@ -412,8 +415,8 @@ public void Setup(MaterialProperty[] properties) public ParticlesGUI.Property AlphaTransitionProgressCoordSecondTextureProp { get; } = new(PropertyNames.AlphaTransitionProgressCoordSecondTexture); - public ParticlesGUI.Property DissolveSharpnessProp { get; } = new(PropertyNames.DissolveSharpness); - + public ParticlesGUI.Property DissolveSharpnessSecondTextureProp { get; } = new(PropertyNames.DissolveSharpnessSecondTexture); + #endregion #region Emission Material Properties diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl b/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl index 2e29d10e..9bcfdf9f 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl @@ -127,12 +127,13 @@ DECLARE_CUSTOM_COORD(_AlphaTransitionMapOffsetYCoord); DECLARE_CUSTOM_COORD(_AlphaTransitionMapSecondTextureOffsetXCoord); DECLARE_CUSTOM_COORD(_AlphaTransitionMapSecondTextureOffsetYCoord); half _AlphaTransitionMapChannelsX; +float _DissolveSharpness; half _AlphaTransitionMapSecondTextureChannelsX; float _AlphaTransitionProgress; DECLARE_CUSTOM_COORD(_AlphaTransitionProgressCoord); float _AlphaTransitionProgressSecondTexture; DECLARE_CUSTOM_COORD(_AlphaTransitionProgressCoordSecondTexture); -float _DissolveSharpness; +float _DissolveSharpnessSecondTexture; float4 _EmissionMap_ST; float4 _EmissionMap2DArray_ST; @@ -482,24 +483,24 @@ void ModulateAlphaTransitionProgress(in out half progress, half vertexAlpha) #endif } -half ApplyAlphaTransitionProgress(in out half transitionAlpha, half transitionProgress) +half ApplyAlphaTransitionProgress(in out half transitionAlpha, half transitionProgress, float dissolveSharpness) { #ifdef _FADE_TRANSITION_ENABLED transitionProgress = (transitionProgress * 2 - 1) * -1; transitionAlpha += transitionProgress; transitionAlpha = saturate(transitionAlpha); #elif _DISSOLVE_TRANSITION_ENABLED - half dissolveWidth = lerp(0.5, 0.0001, _DissolveSharpness); + half dissolveWidth = lerp(0.5, 0.0001, dissolveSharpness); transitionProgress = lerp(-dissolveWidth, 1.0 + dissolveWidth, transitionProgress); transitionAlpha = smoothstep(transitionProgress - dissolveWidth, transitionProgress + dissolveWidth, transitionAlpha); #endif return transitionAlpha; } -half GetTransitionAlphaImpl(half4 map, uint channel, half transitionProgress) +half GetTransitionAlphaImpl(half4 map, uint channel, half transitionProgress, float dissolveSharpness) { half transitionAlpha = map[channel]; - return ApplyAlphaTransitionProgress(transitionAlpha, transitionProgress); + return ApplyAlphaTransitionProgress(transitionAlpha, transitionProgress, dissolveSharpness); } #if defined(_ALPHA_TRANSITION_BLEND_SECOND_TEX_ADDITIVE) || defined(_ALPHA_TRANSITION_BLEND_SECOND_TEX_MULTIPLY) @@ -507,8 +508,8 @@ half GetTransitionAlpha(half2 transitionMapUv, half transitionMapProgress, half { half4 mainTexMap = SAMPLE_ALPHA_TRANSITION_MAP(transitionMapUv, transitionMapProgress); half4 secondTexMap = SAMPLE_ALPHA_TRANSITION_MAP_SECOND(transitionMapSecondUv, transitionMapProgress); - half mainTexAlpha = GetTransitionAlphaImpl(mainTexMap, (uint)_AlphaTransitionMapChannelsX, transitionProgress); - half secondTexAlpha = GetTransitionAlphaImpl(secondTexMap, (uint)_AlphaTransitionMapSecondTextureChannelsX, transitionProgressSecond); + half mainTexAlpha = GetTransitionAlphaImpl(mainTexMap, (uint)_AlphaTransitionMapChannelsX, transitionProgress, _DissolveSharpness); + half secondTexAlpha = GetTransitionAlphaImpl(secondTexMap, (uint)_AlphaTransitionMapSecondTextureChannelsX, transitionProgressSecond, _DissolveSharpnessSecondTexture); #if defined(_ALPHA_TRANSITION_BLEND_SECOND_TEX_ADDITIVE) mainTexAlpha = (mainTexAlpha + secondTexAlpha) * 0.5; @@ -523,7 +524,7 @@ half GetTransitionAlpha(half2 transitionMapUv, half transitionMapProgress, half half GetTransitionAlpha(half2 transitionMapUv, half transitionMapProgress, half transitionProgress) { half4 mainTexMap = SAMPLE_ALPHA_TRANSITION_MAP(transitionMapUv, transitionMapProgress); - return GetTransitionAlphaImpl(mainTexMap, (uint)_AlphaTransitionMapChannelsX, transitionProgress); + return GetTransitionAlphaImpl(mainTexMap, (uint)_AlphaTransitionMapChannelsX, transitionProgress, _DissolveSharpness); } #endif diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader index e6f0ece4..835f6ae7 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader @@ -116,6 +116,7 @@ Shader "Nova/Particles/UberLit" _AlphaTransitionMapSliceCount("Alpha Transition Map Slice Count", Float) = 4.0 _AlphaTransitionProgress("Alpha Transition Progress", Range(0.0, 1.0)) = 0.0 _AlphaTransitionProgressCoord("Alpha Transition Progress Coord", Float) = 0.0 + _DissolveSharpness("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 _AlphaTransitionSecondTextureBlendMode("Alpha Transition Second Texture BlendMode", Float) = 0.0 _AlphaTransitionMapSecondTexture("Alpha Transition Second Texture Map", 2D) = "white" {} _AlphaTransitionMapSecondTexture2DArray("Alpha Transition Second Texture Map 2D Array", 2DArray) = "" {} @@ -125,7 +126,7 @@ Shader "Nova/Particles/UberLit" _AlphaTransitionMapSecondTextureChannelsX("Alpha Transition Second Texture Map Channes X", Float) = 0.0 _AlphaTransitionProgressSecondTexture("Alpha Transition Second Texture Progress", Range(0.0, 1.0)) = 0.0 _AlphaTransitionProgressCoordSecondTexture("Alpha Transition Second Texture Progress Coord", Float) = 0.0 - _DissolveSharpness("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 + _DissolveSharpnessSecondTexture("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 // Emission _EmissionAreaType("Emission Area Type", Float) = 0.0 diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader index c76322ad..1291d623 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader @@ -91,6 +91,7 @@ Shader "Nova/Particles/UberUnlit" _AlphaTransitionMapSliceCount("Alpha Transition Map Slice Count", Float) = 4.0 _AlphaTransitionProgress("Alpha Transition Progress", Range(0.0, 1.0)) = 0.0 _AlphaTransitionProgressCoord("Alpha Transition Progress Coord", Float) = 0.0 + _DissolveSharpness("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 _AlphaTransitionSecondTextureBlendMode("Alpha Transition Second Texture BlendMode", Float) = 0.0 _AlphaTransitionMapSecondTexture("Alpha Transition Second Texture Map", 2D) = "white" {} _AlphaTransitionMapSecondTexture2DArray("Alpha Transition Second Texture Map 2D Array", 2DArray) = "" {} @@ -100,7 +101,7 @@ Shader "Nova/Particles/UberUnlit" _AlphaTransitionMapSecondTextureChannelsX("Alpha Transition Second Texture Map Channes X", Float) = 0.0 _AlphaTransitionProgressSecondTexture("Alpha Transition Second Texture Progress", Range(0.0, 1.0)) = 0.0 _AlphaTransitionProgressCoordSecondTexture("Alpha Transition Second Texture Progress Coord", Float) = 0.0 - _DissolveSharpness("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 + _DissolveSharpnessSecondTexture("Dissolve Sharpness", Range(0.0, 1.0)) = 0.5 // Emission _EmissionAreaType("Emission Area Type", Float) = 0.0