From 9853e21677cd2189556d3d18b399a2c77c3467b2 Mon Sep 17 00:00:00 2001 From: CA-Tatami Date: Mon, 23 Dec 2024 18:00:14 +0900 Subject: [PATCH] =?UTF-8?q?Vertex=20Deformation=E3=81=AE=E5=9F=BA=E6=BA=96?= =?UTF-8?q?=E7=82=B9=E3=81=AE=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Scripts/MaterialPropertyNames.cs | 24 ++++++-- .../Core/Scripts/ParticlesUberCommonGUI.cs | 24 +++++--- .../ParticlesUberCommonMaterialProperties.cs | 57 +++++++++++++------ .../Nova/Runtime/Core/Shaders/Particles.hlsl | 5 +- .../Runtime/Core/Shaders/ParticlesUber.hlsl | 1 + .../Core/Shaders/ParticlesUberLit.shader | 1 + .../Shaders/ParticlesUberShadowCaster.hlsl | 3 +- .../Core/Shaders/ParticlesUberUnlit.hlsl | 3 +- .../Core/Shaders/ParticlesUberUnlit.shader | 1 + .../Core/Shaders/UIParticlesUberLit.shader | 1 + .../Core/Shaders/UIParticlesUberUnlit.shader | 1 + 11 files changed, 85 insertions(+), 36 deletions(-) diff --git a/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs b/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs index 8160c386..1de38028 100644 --- a/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs +++ b/Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------- -// Copyright 2022 CyberAgent, Inc. +// Copyright 2024 CyberAgent, Inc. // -------------------------------------------------------------- namespace Nova.Editor.Core.Scripts @@ -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"; @@ -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"; @@ -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"; } } diff --git a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs index eff54abb..eb4d74b1 100644 --- a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs +++ b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------- -// Copyright 2023 CyberAgent, Inc. +// Copyright 2024 CyberAgent, Inc. // -------------------------------------------------------------- using System; @@ -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); @@ -188,7 +189,8 @@ private void InternalDrawBaseMapProperties() using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) { - MaterialEditorUtility.DrawTexture(_editor, baseMapMaterialProp, props.BaseMapOffsetXCoordProp.Value, + MaterialEditorUtility.DrawTexture(_editor, baseMapMaterialProp, + props.BaseMapOffsetXCoordProp.Value, props.BaseMapOffsetYCoordProp.Value, null, null); if (changeCheckScope.changed) @@ -293,7 +295,7 @@ private void InternalDrawParallaxMapsProperties() "Target", props.ParallaxMapTargetProp.Value); } - + private void InternalDrawTintColorProperties() { var props = _commonMaterialProperties; @@ -344,7 +346,8 @@ private void InternalDrawTintColorProperties() props.TintMap3DProgressProp.Value, props.TintMap3DProgressCoordProp.Value); } - MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Blend Rate", props.TintMapBlendRateProp.Value, + MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Blend Rate", + props.TintMapBlendRateProp.Value, props.TintMapBlendRateCoordProp.Value); } @@ -449,7 +452,8 @@ private void InternalDrawAlphaTransitionProperties() { using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) { - MaterialEditorUtility.DrawTexture(_editor, alphaTransitionMapSecondTextureProp, + MaterialEditorUtility.DrawTexture(_editor, + alphaTransitionMapSecondTextureProp, props.AlphaTransitionMapSecondTextureOffsetXCoordProp.Value, props.AlphaTransitionMapSecondTextureOffsetYCoordProp.Value, props.AlphaTransitionMapSecondTextureChannelsXProp.Value, null); @@ -477,7 +481,8 @@ private void InternalDrawAlphaTransitionProperties() if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBook || alphaTransitionMapMode == AlphaTransitionMapMode.FlipBookBlending) - MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Flip-Book Progress", + MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, + "Flip-Book Progress", props.AlphaTransitionMapSecondTextureProgressProp.Value, props.AlphaTransitionMapSecondTextureProgressCoordProp.Value); @@ -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() diff --git a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs index 69d4a951..69e505f3 100644 --- a/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs +++ b/Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonMaterialProperties.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------- -// Copyright 2023 CyberAgent, Inc. +// Copyright 2024 CyberAgent, Inc. // -------------------------------------------------------------- using Nova.Editor.Foundation.Scripts; @@ -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); @@ -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); @@ -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 @@ -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); @@ -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 } diff --git a/Assets/Nova/Runtime/Core/Shaders/Particles.hlsl b/Assets/Nova/Runtime/Core/Shaders/Particles.hlsl index 6090a8a0..43f2c761 100644 --- a/Assets/Nova/Runtime/Core/Shaders/Particles.hlsl +++ b/Assets/Nova/Runtime/Core/Shaders/Particles.hlsl @@ -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 diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl b/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl index e1e3ffd8..56a0fd58 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl @@ -172,6 +172,7 @@ CBUFFER_START(UnityPerMaterial) half _VertexDeformationMapChannel; float _VertexDeformationIntensity; DECLARE_CUSTOM_COORD(_VertexDeformationIntensityCoord); + float _VertexDeformationBaseValue; float _SoftParticlesIntensity; float _DepthFadeNear; diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader index f9a258f1..975f71ba 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberLit.shader @@ -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 diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberShadowCaster.hlsl b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberShadowCaster.hlsl index 8e77a9ba..64a3971d 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberShadowCaster.hlsl +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberShadowCaster.hlsl @@ -87,7 +87,8 @@ Varyings ShadowPassVertex(Attributes input) _VertexDeformationMap, sampler_VertexDeformationMap, vertexDeformationIntensity, vertexDeformationUVs, - _VertexDeformationMapChannel); + _VertexDeformationMapChannel, + _VertexDeformationBaseValue); input.positionOS.xyz += normalize(input.normalOS) * vertexDeformationIntensity; } #endif diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.hlsl b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.hlsl index fce33c52..f8d04d49 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.hlsl +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.hlsl @@ -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 diff --git a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader index f1d31c46..8da4c150 100644 --- a/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/ParticlesUberUnlit.shader @@ -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 diff --git a/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberLit.shader b/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberLit.shader index 30474914..893fee11 100644 --- a/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberLit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberLit.shader @@ -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 diff --git a/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberUnlit.shader b/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberUnlit.shader index 86f824c5..08642cf2 100644 --- a/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberUnlit.shader +++ b/Assets/Nova/Runtime/Core/Shaders/UIParticlesUberUnlit.shader @@ -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