Skip to content

Commit

Permalink
コード整形
Browse files Browse the repository at this point in the history
  • Loading branch information
CA-Tatami committed Aug 8, 2024
1 parent d267505 commit e1f25d2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 45 deletions.
56 changes: 35 additions & 21 deletions Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private void InternalDrawAlphaTransitionProperties()
}
}
}

if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBook
|| alphaTransitionMapMode == AlphaTransitionMapMode.FlipBookBlending)
MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Flip-Book Progress",
Expand All @@ -431,46 +431,53 @@ private void InternalDrawAlphaTransitionProperties()
props.AlphaTransitionProgressProp.Value, props.AlphaTransitionProgressCoordProp.Value);
if (mode == AlphaTransitionMode.Dissolve)
_editor.ShaderProperty(props.DissolveSharpnessProp.Value, "Edge Sharpness");

// 2nd Texture
{
MaterialEditorUtility.DrawEnumProperty<AlphaTransitionBlendMode>(_editor, "2nd Texture Blend Mode",
props.AlphaTransitionSecondTextureBlendModeProp.Value);
var alphaTransitionSecondTextureBlendMode = (AlphaTransitionBlendMode)props.AlphaTransitionSecondTextureBlendModeProp.Value.floatValue;
props.AlphaTransitionSecondTextureBlendModeProp.Value);
var alphaTransitionSecondTextureBlendMode =
(AlphaTransitionBlendMode)props.AlphaTransitionSecondTextureBlendModeProp.Value.floatValue;
if (alphaTransitionSecondTextureBlendMode != AlphaTransitionBlendMode.None)
{
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
MaterialEditorUtility.DrawTexture(_editor, alphaTransitionMapSecondTextureProp,
props.AlphaTransitionMapSecondTextureOffsetXCoordProp.Value, props.AlphaTransitionMapSecondTextureOffsetYCoordProp.Value,
props.AlphaTransitionMapSecondTextureChannelsXProp.Value, null);
props.AlphaTransitionMapSecondTextureOffsetXCoordProp.Value,
props.AlphaTransitionMapSecondTextureOffsetYCoordProp.Value,
props.AlphaTransitionMapSecondTextureChannelsXProp.Value, null);

if (changeCheckScope.changed)
{
if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBook
&& props.AlphaTransitionMapSecondTexture2DArrayProp.Value.textureValue != null)
{
var tex2DArray = (Texture2DArray)props.AlphaTransitionMapSecondTexture2DArrayProp.Value.textureValue;
props.AlphaTransitionMapSecondTextureSliceCountProp.Value.floatValue = tex2DArray.depth;
var tex2DArray = (Texture2DArray)props.AlphaTransitionMapSecondTexture2DArrayProp
.Value.textureValue;
props.AlphaTransitionMapSecondTextureSliceCountProp.Value.floatValue =
tex2DArray.depth;
}

if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBookBlending
&& props.AlphaTransitionMapSecondTexture3DProp.Value.textureValue != null)
{
var tex3D = (Texture3D)props.AlphaTransitionMapSecondTexture3DProp.Value.textureValue;
var tex3D = (Texture3D)props.AlphaTransitionMapSecondTexture3DProp.Value
.textureValue;
props.AlphaTransitionMapSecondTextureSliceCountProp.Value.floatValue = tex3D.depth;
}
}
}

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

props.AlphaTransitionMapSecondTextureProgressProp.Value,
props.AlphaTransitionMapSecondTextureProgressCoordProp.Value);

MaterialEditorUtility.DrawPropertyAndCustomCoord(_editor, "Transition Progress",
props.AlphaTransitionProgressSecondTextureProp.Value, props.AlphaTransitionProgressCoordSecondTextureProp.Value);

props.AlphaTransitionProgressSecondTextureProp.Value,
props.AlphaTransitionProgressCoordSecondTextureProp.Value);

if (mode == AlphaTransitionMode.Dissolve)
_editor.ShaderProperty(props.DissolveSharpnessSecondTextureProp.Value, "Edge Sharpness");
}
Expand Down Expand Up @@ -647,22 +654,29 @@ private void InternalDrawShadowCasterProperties()
if (props.ShadowCasterEnabledProp.Value.floatValue < 0.5f)
return;

MaterialEditorUtility.DrawToggleProperty(_editor, "Apply Vertex Deformation", props.ShadowCasterApplyVertexDeformationProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Apply Vertex Deformation",
props.ShadowCasterApplyVertexDeformationProp.Value);

MaterialEditorUtility.DrawToggleProperty(_editor, "Alpha Test Enable", props.ShadowCasterAlphaTestEnabledProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Alpha Test Enable",
props.ShadowCasterAlphaTestEnabledProp.Value);
if (props.ShadowCasterAlphaTestEnabledProp.Value.floatValue < 0.5f)
return;

EditorGUI.indentLevel++;
MaterialEditorUtility.DrawFloatRangeProperty(_editor, "Cutoff", props.ShadowCasterAlphaCutoffProp.Value, 0, 1);
MaterialEditorUtility.DrawFloatRangeProperty(_editor, "Cutoff", props.ShadowCasterAlphaCutoffProp.Value, 0,
1);
EditorGUI.indentLevel--;

EditorGUI.LabelField(EditorGUILayout.GetControlRect(), "Alpha Affected By");
EditorGUI.indentLevel++;
MaterialEditorUtility.DrawToggleProperty(_editor, "Tint Color", props.ShadowCasterAlphaAffectedByTintColorProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Flow Map", props.ShadowCasterAlphaAffectedByFlowMapProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Alpha Transition Map", props.ShadowCasterAlphaAffectedByAlphaTransitionMapProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Transparency Luminance", props.ShadowCasterAlphaAffectedByTransparencyLuminanceProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Tint Color",
props.ShadowCasterAlphaAffectedByTintColorProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Flow Map",
props.ShadowCasterAlphaAffectedByFlowMapProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Alpha Transition Map",
props.ShadowCasterAlphaAffectedByAlphaTransitionMapProp.Value);
MaterialEditorUtility.DrawToggleProperty(_editor, "Transparency Luminance",
props.ShadowCasterAlphaAffectedByTransparencyLuminanceProp.Value);
EditorGUI.indentLevel--;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ public static class ParticlesUberUnlitMaterialPostProcessor

private static readonly int BaseMapRotationCoordId =
Shader.PropertyToID(MaterialPropertyNames.BaseMapRotationCoord);

private static readonly int TintAreaModeId = Shader.PropertyToID(MaterialPropertyNames.TintAreaMode);
private static readonly int TintMapModeId = Shader.PropertyToID(MaterialPropertyNames.TintColorMode);
private static readonly int FlowMapId = Shader.PropertyToID(MaterialPropertyNames.FlowMap);
private static readonly int FlowMapTargetId = Shader.PropertyToID(MaterialPropertyNames.FlowMapTarget);

private static readonly int FlowIntensityCoordId =
Shader.PropertyToID(MaterialPropertyNames.FlowIntensityCoord);

private static readonly int ParallaxMapModeId = Shader.PropertyToID(MaterialPropertyNames.ParallaxMapMode);
private static readonly int ParallaxMapId = Shader.PropertyToID(MaterialPropertyNames.ParallaxMap);
private static readonly int ParallaxMap2DArrayId = Shader.PropertyToID(MaterialPropertyNames.ParallaxMap2DArray);

private static readonly int ParallaxMap2DArrayId =
Shader.PropertyToID(MaterialPropertyNames.ParallaxMap2DArray);

private static readonly int ParallaxMap3DId = Shader.PropertyToID(MaterialPropertyNames.ParallaxMap3D);
private static readonly int ParallaxMapTargetId = Shader.PropertyToID(MaterialPropertyNames.ParallaxMapTarget);

Expand All @@ -53,7 +56,7 @@ public static class ParticlesUberUnlitMaterialPostProcessor

private static readonly int AlphaTransitionMap3DId =
Shader.PropertyToID(MaterialPropertyNames.AlphaTransitionMap3D);

private static readonly int AlphaTransitionMapSecondTextureId =
Shader.PropertyToID(MaterialPropertyNames.AlphaTransitionMapSecondTexture);

Expand Down Expand Up @@ -87,7 +90,7 @@ public static class ParticlesUberUnlitMaterialPostProcessor

private static readonly int SoftParticlesEnabledId =
Shader.PropertyToID(MaterialPropertyNames.SoftParticlesEnabled);

private static readonly int VertexDeformationMapId =
Shader.PropertyToID(MaterialPropertyNames.VertexDeformationMap);

Expand All @@ -101,9 +104,10 @@ public static class ParticlesUberUnlitMaterialPostProcessor

private static readonly int TransparentBlendModeId =
Shader.PropertyToID(MaterialPropertyNames.TransparentBlendMode);
private static readonly int ShadowCasterEnabledId =

private static readonly int ShadowCasterEnabledId =
Shader.PropertyToID(MaterialPropertyNames.ShadowCasterEnabled);

private static readonly int ShadowCasterAlphaTestEnabledId =
Shader.PropertyToID(MaterialPropertyNames.ShadowCasterAlphaTestEnabled);

Expand Down Expand Up @@ -223,20 +227,20 @@ private static void SetupFlowMapMaterialKeywords(Material material)
{
//NOTE: Remove the keyword because it is obsolete.
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FlowMapEnabled, false);

var flowMapTarget = (FlowMapTarget)material.GetFloat(FlowMapTargetId);
var hasFlowMap = material.GetTexture(FlowMapId) != null;

var baseEnabled = hasFlowMap && (flowMapTarget & FlowMapTarget.BaseMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FlowMapTargetBase, baseEnabled);

var tintEnabled = hasFlowMap && (flowMapTarget & FlowMapTarget.TintMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FlowMapTargetTint, tintEnabled);

var alphaTransitionEnabled = hasFlowMap && (flowMapTarget & FlowMapTarget.AlphaTransitionMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FlowMapTargetAlphaTransition,
alphaTransitionEnabled);

var emissionEnabled = hasFlowMap && (flowMapTarget & FlowMapTarget.EmissionMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FlowMapTargetEmission, emissionEnabled);
}
Expand All @@ -250,8 +254,8 @@ private static void SetupParallaxMapMaterialKeywords(Material material)
var keyword = value.GetShaderKeyword();
MaterialEditorUtility.SetKeyword(material, keyword, isOn);
}
bool hasParallaxMap = false;

var hasParallaxMap = false;
switch (parallaxMapMode)
{
case ParallaxMapMode.SingleTexture:
Expand All @@ -268,7 +272,7 @@ private static void SetupParallaxMapMaterialKeywords(Material material)
var parallaxMapTarget = (ParallaxMapTarget)material.GetFloat(ParallaxMapTargetId);
var baseEnabled = hasParallaxMap && (parallaxMapTarget & ParallaxMapTarget.BaseMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.ParallaxMapTargetBase, baseEnabled);

var tintEnabled = hasParallaxMap && (parallaxMapTarget & ParallaxMapTarget.TintMap) != 0;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.ParallaxMapTargetTint, tintEnabled);

Expand All @@ -288,20 +292,20 @@ private static void SetupAlphaTransitionMaterialKeywords(Material material)
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.FadeTransitionEnabled, fadeTransitionEnabled);
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.DissolveTransitionEnabled,
dissolveTransitionEnabled);

var alphaTransitionMapMode = (AlphaTransitionMapMode)material.GetFloat(AlphaTransitionMapModeId);
foreach (AlphaTransitionMapMode value in Enum.GetValues(typeof(AlphaTransitionMapMode)))
{
var isOn = alphaTransitionMapMode == value;
var keyword = value.GetShaderKeyword();
MaterialEditorUtility.SetKeyword(material, keyword, isOn);
}

// 2nd Texture
{
bool secondTexEnabled = material.GetTexture(AlphaTransitionMapSecondTextureId) != null
|| material.GetTexture(AlphaTransitionMapSecondTexture2DArrayId) != null
|| material.GetTexture(AlphaTransitionMapSecondTexture3DId) != null;
var secondTexEnabled = material.GetTexture(AlphaTransitionMapSecondTextureId) != null
|| material.GetTexture(AlphaTransitionMapSecondTexture2DArrayId) != null
|| material.GetTexture(AlphaTransitionMapSecondTexture3DId) != null;
var blendMode = (AlphaTransitionBlendMode)material.GetFloat(AlphaTransitionSecondTextureBlendMode);
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.AlphaTransitionBlendSecondTexAdditive,
secondTexEnabled && blendMode == AlphaTransitionBlendMode.Additive);
Expand Down Expand Up @@ -356,21 +360,23 @@ private static void SetupTransparencyMaterialKeywords(Material material)
var depthFadeEnabled = material.GetFloat(DepthFadeEnabledId) > 0.5f;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.DepthFadeEnabled, depthFadeEnabled);
}

private static void SetupVertexDeformationMaterialKeywords(Material material)
{
var vertexDeformationEnabled = material.GetTexture(VertexDeformationMapId) != null;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.VertexDeformationEnabled, vertexDeformationEnabled);
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.VertexDeformationEnabled,
vertexDeformationEnabled);
}

private static void SetupShadowCasterMaterialKeywords(Material material)
{
bool shadowCasterEnabled = material.GetFloat(ShadowCasterEnabledId) > 0.5f;
var shadowCasterEnabled = material.GetFloat(ShadowCasterEnabledId) > 0.5f;
material.SetShaderPassEnabled("ShadowCaster", shadowCasterEnabled);
if (shadowCasterEnabled)
{
bool alphaTestEnabled = material.GetFloat(ShadowCasterAlphaTestEnabledId) > 0.5f;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.ShadowCasterAlphaTestEnable, alphaTestEnabled);
var alphaTestEnabled = material.GetFloat(ShadowCasterAlphaTestEnabledId) > 0.5f;
MaterialEditorUtility.SetKeyword(material, ShaderKeywords.ShadowCasterAlphaTestEnable,
alphaTestEnabled);
}
}

Expand Down

0 comments on commit e1f25d2

Please sign in to comment.