Skip to content

Commit

Permalink
Transition ProgressとEdgeSharpnessの項目をテクスチャ毎に設定するようよう変更
Browse files Browse the repository at this point in the history
  • Loading branch information
CA-Tatami committed Aug 7, 2024
1 parent ae150fa commit 84d4dcc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -482,33 +483,33 @@ 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)
half GetTransitionAlpha(half2 transitionMapUv, half transitionMapProgress, half transitionProgress, half2 transitionMapSecondUv, half transitionProgressSecond)
{
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;
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -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) = "" {}
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -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) = "" {}
Expand All @@ -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
Expand Down

0 comments on commit 84d4dcc

Please sign in to comment.