Skip to content

Commit

Permalink
Vertex Deformationの基準点のパラメータの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
CA-Tatami committed Dec 23, 2024
1 parent 73bc0ec commit 9853e21
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 36 deletions.
24 changes: 18 additions & 6 deletions Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------
// Copyright 2022 CyberAgent, Inc.
// Copyright 2024 CyberAgent, Inc.
// --------------------------------------------------------------

namespace Nova.Editor.Core.Scripts
Expand Down Expand Up @@ -128,9 +128,16 @@ public static class MaterialPropertyNames
public const string AlphaTransitionMapSecondTexture2DArray = "_AlphaTransitionMapSecondTexture2DArray";
public const string AlphaTransitionMapSecondTexture3D = "_AlphaTransitionMapSecondTexture3D";
public const string AlphaTransitionMapSecondTextureProgress = "_AlphaTransitionMapSecondTextureProgress";
public const string AlphaTransitionMapSecondTextureProgressCoord = "_AlphaTransitionMapSecondTextureProgressCoord";
public const string AlphaTransitionMapSecondTextureOffsetXCoord = "_AlphaTransitionMapSecondTextureOffsetXCoord";
public const string AlphaTransitionMapSecondTextureOffsetYCoord = "_AlphaTransitionMapSecondTextureOffsetYCoord";

public const string AlphaTransitionMapSecondTextureProgressCoord =
"_AlphaTransitionMapSecondTextureProgressCoord";

public const string AlphaTransitionMapSecondTextureOffsetXCoord =
"_AlphaTransitionMapSecondTextureOffsetXCoord";

public const string AlphaTransitionMapSecondTextureOffsetYCoord =
"_AlphaTransitionMapSecondTextureOffsetYCoord";

public const string AlphaTransitionMapSecondTextureChannelsX = "_AlphaTransitionMapSecondTextureChannelsX";
public const string AlphaTransitionMapSecondTextureSliceCount = "_AlphaTransitionMapSecondTextureSliceCount";
public const string AlphaTransitionProgressSecondTexture = "_AlphaTransitionProgressSecondTexture";
Expand Down Expand Up @@ -187,6 +194,7 @@ public static class MaterialPropertyNames
public const string VertexDeformationMapChannel = "_VertexDeformationMapChannel";
public const string VertexDeformationIntensity = "_VertexDeformationIntensity";
public const string VertexDeformationIntensityCoord = "_VertexDeformationIntensityCoord";
public const string VertexDeformationBaseValue = "_VertexDeformationBaseValue";

// Shadow Caster
public const string ShadowCasterEnabled = "_ShadowCasterEnabled";
Expand All @@ -195,7 +203,11 @@ public static class MaterialPropertyNames
public const string ShadowCasterAlphaCutoff = "_ShadowCasterAlphaCutoff";
public const string ShadowCasterAlphaAffectedByTintColor = "_ShadowCasterAlphaAffectedByTintColor";
public const string ShadowCasterAlphaAffectedByFlowMap = "_ShadowCasterAlphaAffectedByFlowMap";
public const string ShadowCasterAlphaAffectedByAlphaTransitionMap = "_ShadowCasterAlphaAffectedByAlphaTransitionMap";
public const string ShadowCasterAlphaAffectedByTransparencyLuminance = "_ShadowCasterAlphaAffectedByTransparencyLuminance";

public const string ShadowCasterAlphaAffectedByAlphaTransitionMap =
"_ShadowCasterAlphaAffectedByAlphaTransitionMap";

public const string ShadowCasterAlphaAffectedByTransparencyLuminance =
"_ShadowCasterAlphaAffectedByTransparencyLuminance";
}
}
24 changes: 16 additions & 8 deletions Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------
// Copyright 2023 CyberAgent, Inc.
// Copyright 2024 CyberAgent, Inc.
// --------------------------------------------------------------

using System;
Expand Down Expand Up @@ -131,10 +131,11 @@ public void DrawFixNowButton()
public void DrawErrorMessage()
{
if (string.IsNullOrEmpty(_errorMessage)) return;
EditorGUILayout.HelpBox(
_errorMessage, MessageType.Error, true);
EditorGUILayout.HelpBox(
_errorMessage, MessageType.Error, true);
_errorMessage = "";
}

public void DrawProperties(BoolEditorPrefsProperty foldout, string categoryName, Action internalDrawFunction)
{
using var foldoutScope = new MaterialEditorUtility.FoldoutHeaderScope(foldout.Value, categoryName);
Expand Down Expand Up @@ -188,7 +189,8 @@ private void InternalDrawBaseMapProperties()

using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
MaterialEditorUtility.DrawTexture<TCustomCoord>(_editor, baseMapMaterialProp, props.BaseMapOffsetXCoordProp.Value,
MaterialEditorUtility.DrawTexture<TCustomCoord>(_editor, baseMapMaterialProp,
props.BaseMapOffsetXCoordProp.Value,
props.BaseMapOffsetYCoordProp.Value, null, null);

if (changeCheckScope.changed)
Expand Down Expand Up @@ -293,7 +295,7 @@ private void InternalDrawParallaxMapsProperties()
"Target",
props.ParallaxMapTargetProp.Value);
}

private void InternalDrawTintColorProperties()
{
var props = _commonMaterialProperties;
Expand Down Expand Up @@ -344,7 +346,8 @@ private void InternalDrawTintColorProperties()
props.TintMap3DProgressProp.Value, props.TintMap3DProgressCoordProp.Value);
}

MaterialEditorUtility.DrawPropertyAndCustomCoord<TCustomCoord>(_editor, "Blend Rate", props.TintMapBlendRateProp.Value,
MaterialEditorUtility.DrawPropertyAndCustomCoord<TCustomCoord>(_editor, "Blend Rate",
props.TintMapBlendRateProp.Value,
props.TintMapBlendRateCoordProp.Value);
}

Expand Down Expand Up @@ -449,7 +452,8 @@ private void InternalDrawAlphaTransitionProperties()
{
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
MaterialEditorUtility.DrawTexture<TCustomCoord>(_editor, alphaTransitionMapSecondTextureProp,
MaterialEditorUtility.DrawTexture<TCustomCoord>(_editor,
alphaTransitionMapSecondTextureProp,
props.AlphaTransitionMapSecondTextureOffsetXCoordProp.Value,
props.AlphaTransitionMapSecondTextureOffsetYCoordProp.Value,
props.AlphaTransitionMapSecondTextureChannelsXProp.Value, null);
Expand Down Expand Up @@ -477,7 +481,8 @@ private void InternalDrawAlphaTransitionProperties()

if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBook
|| alphaTransitionMapMode == AlphaTransitionMapMode.FlipBookBlending)
MaterialEditorUtility.DrawPropertyAndCustomCoord<TCustomCoord>(_editor, "Flip-Book Progress",
MaterialEditorUtility.DrawPropertyAndCustomCoord<TCustomCoord>(_editor,
"Flip-Book Progress",
props.AlphaTransitionMapSecondTextureProgressProp.Value,
props.AlphaTransitionMapSecondTextureProgressCoordProp.Value);

Expand Down Expand Up @@ -652,6 +657,9 @@ private void InternalDrawVertexDeformationMapProperties()
"Intensity",
props.VertexDeformationIntensityProp.Value,
props.VertexDeformationIntensityCoordProp.Value);
MaterialEditorUtility.DrawFloatRangeProperty(_editor, "Base Value",
props.VertexDeformationBaseValueProp.Value, 0,
1);
}

private void InternalDrawShadowCasterProperties()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------
// Copyright 2023 CyberAgent, Inc.
// Copyright 2024 CyberAgent, Inc.
// --------------------------------------------------------------

using Nova.Editor.Foundation.Scripts;
Expand Down Expand Up @@ -192,6 +192,7 @@ public void Setup(MaterialProperty[] properties)
VertexDeformationMapChannelProp.Setup(properties);
VertexDeformationIntensityProp.Setup(properties);
VertexDeformationIntensityCoordProp.Setup(properties);
VertexDeformationBaseValueProp.Setup(properties);

// Shadow Caster
ShadowCasterEnabledProp.Setup(properties);
Expand Down Expand Up @@ -386,25 +387,27 @@ 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);

public ParticlesGUI.Property AlphaTransitionMapSecondTextureProp { get; } = new(PropertyNames.AlphaTransitionMapSecondTexture);

public ParticlesGUI.Property AlphaTransitionMapSecondTextureProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTexture);

public ParticlesGUI.Property AlphaTransitionMapSecondTexture2DArrayProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTexture2DArray);

public ParticlesGUI.Property AlphaTransitionMapSecondTexture3DProp { get; } = new(PropertyNames.AlphaTransitionMapSecondTexture3D);
public ParticlesGUI.Property AlphaTransitionMapSecondTexture3DProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTexture3D);

public ParticlesGUI.Property AlphaTransitionMapSecondTextureProgressProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTextureProgress);

public ParticlesGUI.Property AlphaTransitionMapSecondTextureProgressCoordProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTextureProgressCoord);

public ParticlesGUI.Property AlphaTransitionMapSecondTextureOffsetXCoordProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTextureOffsetXCoord);

Expand All @@ -416,19 +419,21 @@ public void Setup(MaterialProperty[] properties)

public ParticlesGUI.Property AlphaTransitionMapSecondTextureSliceCountProp { get; } =
new(PropertyNames.AlphaTransitionMapSecondTextureSliceCount);

public ParticlesGUI.Property AlphaTransitionProgressProp { get; } = new(PropertyNames.AlphaTransitionProgress);

public ParticlesGUI.Property AlphaTransitionProgressCoordProp { get; } =
new(PropertyNames.AlphaTransitionProgressCoord);

public ParticlesGUI.Property AlphaTransitionProgressSecondTextureProp { get; } = new(PropertyNames.AlphaTransitionProgressSecondTexture);

public ParticlesGUI.Property AlphaTransitionProgressSecondTextureProp { get; } =
new(PropertyNames.AlphaTransitionProgressSecondTexture);

public ParticlesGUI.Property AlphaTransitionProgressCoordSecondTextureProp { get; } =
new(PropertyNames.AlphaTransitionProgressCoordSecondTexture);

public ParticlesGUI.Property DissolveSharpnessSecondTextureProp { get; } = new(PropertyNames.DissolveSharpnessSecondTexture);

public ParticlesGUI.Property DissolveSharpnessSecondTextureProp { get; } =
new(PropertyNames.DissolveSharpnessSecondTexture);

#endregion

#region Emission Material Properties
Expand Down Expand Up @@ -536,6 +541,9 @@ public ParticlesGUI.Property
public ParticlesGUI.Property VertexDeformationIntensityProp { get; } =
new(PropertyNames.VertexDeformationIntensity);

public ParticlesGUI.Property VertexDeformationBaseValueProp { get; } =
new(PropertyNames.VertexDeformationBaseValue);

public ParticlesGUI.Property VertexDeformationIntensityCoordProp { get; } =
new(PropertyNames.VertexDeformationIntensityCoord);

Expand All @@ -544,13 +552,26 @@ public ParticlesGUI.Property
#region Shadow Caster Material Properties

public ParticlesGUI.Property ShadowCasterEnabledProp { get; } = new(PropertyNames.ShadowCasterEnabled);
public ParticlesGUI.Property ShadowCasterApplyVertexDeformationProp { get; } = new(PropertyNames.ShadowCasterApplyVertexDeformation);
public ParticlesGUI.Property ShadowCasterAlphaTestEnabledProp { get; } = new(PropertyNames.ShadowCasterAlphaTestEnabled);

public ParticlesGUI.Property ShadowCasterApplyVertexDeformationProp { get; } =
new(PropertyNames.ShadowCasterApplyVertexDeformation);

public ParticlesGUI.Property ShadowCasterAlphaTestEnabledProp { get; } =
new(PropertyNames.ShadowCasterAlphaTestEnabled);

public ParticlesGUI.Property ShadowCasterAlphaCutoffProp { get; } = new(PropertyNames.ShadowCasterAlphaCutoff);
public ParticlesGUI.Property ShadowCasterAlphaAffectedByTintColorProp { get; } = new(PropertyNames.ShadowCasterAlphaAffectedByTintColor);
public ParticlesGUI.Property ShadowCasterAlphaAffectedByFlowMapProp { get; } = new(PropertyNames.ShadowCasterAlphaAffectedByFlowMap);
public ParticlesGUI.Property ShadowCasterAlphaAffectedByAlphaTransitionMapProp { get; } = new(PropertyNames.ShadowCasterAlphaAffectedByAlphaTransitionMap);
public ParticlesGUI.Property ShadowCasterAlphaAffectedByTransparencyLuminanceProp { get; } = new(PropertyNames.ShadowCasterAlphaAffectedByTransparencyLuminance);

public ParticlesGUI.Property ShadowCasterAlphaAffectedByTintColorProp { get; } =
new(PropertyNames.ShadowCasterAlphaAffectedByTintColor);

public ParticlesGUI.Property ShadowCasterAlphaAffectedByFlowMapProp { get; } =
new(PropertyNames.ShadowCasterAlphaAffectedByFlowMap);

public ParticlesGUI.Property ShadowCasterAlphaAffectedByAlphaTransitionMapProp { get; } =
new(PropertyNames.ShadowCasterAlphaAffectedByAlphaTransitionMap);

public ParticlesGUI.Property ShadowCasterAlphaAffectedByTransparencyLuminanceProp { get; } =
new(PropertyNames.ShadowCasterAlphaAffectedByTransparencyLuminance);

#endregion
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Nova/Runtime/Core/Shaders/Particles.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ half GetVertexDeformationIntensity(
TEXTURE2D_PARAM(vertexDeformationMap, sampler_vertexDeformationMap),
in float intensity,
in float2 uv,
in half mapChannel)
in half mapChannel,
in float baseValue)
{
#if defined(_VERTEX_DEFORMATION_ENABLED)
half4 vertexDeformation = SAMPLE_TEXTURE2D_LOD(vertexDeformationMap, sampler_vertexDeformationMap, uv, 0);
float mapIntensity = vertexDeformation[(uint)mapChannel];
float mapIntensity = vertexDeformation[(uint)mapChannel] - baseValue;
mapIntensity *= intensity;
return mapIntensity;
#endif
Expand Down
1 change: 1 addition & 0 deletions Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ CBUFFER_START(UnityPerMaterial)
half _VertexDeformationMapChannel;
float _VertexDeformationIntensity;
DECLARE_CUSTOM_COORD(_VertexDeformationIntensityCoord);
float _VertexDeformationBaseValue;

float _SoftParticlesIntensity;
float _DepthFadeNear;
Expand Down
1 change: 1 addition & 0 deletions Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Shader "Nova/Particles/UberLit"
_VertexDeformationMapChannel("VertexDeformation Map Channel", Float) = 0.0
_VertexDeformationIntensity("VertexDeformation Intensity", Float) = 0.1
_VertexDeformationIntensityCoord("VertexDeformation Intensity Coord", Float) = 0.0
_VertexDeformationBaseValue("Vertex Deformation Base Value", Range(0.0, 1.0)) = 0

// Shadow Caster
_ShadowCasterEnabled("Shadow Caster", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ Varyings ShadowPassVertex(Attributes input)
_VertexDeformationMap, sampler_VertexDeformationMap,
vertexDeformationIntensity,
vertexDeformationUVs,
_VertexDeformationMapChannel);
_VertexDeformationMapChannel,
_VertexDeformationBaseValue);
input.positionOS.xyz += normalize(input.normalOS) * vertexDeformationIntensity;
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ Varyings vertUnlit(Attributes input, out float3 positionWS, uniform bool useEmis
_VertexDeformationMap, sampler_VertexDeformationMap,
vertexDeformationIntensity,
vertexDeformationUVs,
_VertexDeformationMapChannel);
_VertexDeformationMapChannel,
_VertexDeformationBaseValue);
input.positionOS.xyz += normalize(input.normalOS) * vertexDeformationIntensity;
#endif

Expand Down
1 change: 1 addition & 0 deletions Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Shader "Nova/Particles/UberUnlit"
_VertexDeformationMapChannel("VertexDeformation Map Channel", Float) = 0.0
_VertexDeformationIntensity("VertexDeformation Intensity", Float) = 0.1
_VertexDeformationIntensityCoord("VertexDeformation Intensity Coord", Float) = 0.0
_VertexDeformationBaseValue("Vertex Deformation Base Value", Range(0.0, 1.0)) = 0

// Shadow Caster
_ShadowCasterEnabled("Shadow Caster", Float) = 0
Expand Down
1 change: 1 addition & 0 deletions Assets/Nova/Runtime/Core/Shaders/UIParticlesUberLit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Shader "Nova/UIParticles/UberLit"
_VertexDeformationMapChannel("VertexDeformation Map Channel", Float) = 0.0
_VertexDeformationIntensity("VertexDeformation Intensity", Float) = 0.1
_VertexDeformationIntensityCoord("VertexDeformation Intensity Coord", Float) = 0.0
_VertexDeformationBaseValue("Vertex Deformation Base Value", Range(0.0, 1.0)) = 0

// Shadow Caster
_ShadowCasterEnabled("Shadow Caster", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Shader "Nova/UIParticles/UberUnlit"
_VertexDeformationMapChannel("VertexDeformation Map Channel", Float) = 0.0
_VertexDeformationIntensity("VertexDeformation Intensity", Float) = 0.1
_VertexDeformationIntensityCoord("VertexDeformation Intensity Coord", Float) = 0.0
_VertexDeformationBaseValue("Vertex Deformation Base Value", Range(0.0, 1.0)) = 0

// Shadow Caster
_ShadowCasterEnabled("Shadow Caster", Float) = 0
Expand Down

0 comments on commit 9853e21

Please sign in to comment.