Skip to content

Commit

Permalink
Merge pull request #80 from CyberAgentGameEntertainment/feature/alpha…
Browse files Browse the repository at this point in the history
…_transition

Add Second Texture Reference for Alpha Transition
  • Loading branch information
CA-Tatami authored Aug 8, 2024
2 parents 41ed9fb + f3e9da4 commit 6d7c17a
Show file tree
Hide file tree
Showing 19 changed files with 530 additions and 75 deletions.
24 changes: 24 additions & 0 deletions Assets/Demo/Demo00/Materials/mat_demo_dissolve_edgeemission.mat
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture2DArray:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture3D:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:
m_Texture: {fileID: 2800000, guid: cac707016af934ee5a416cab14da7246, type: 3}
m_Scale: {x: 1, y: 1}
Expand Down Expand Up @@ -156,10 +168,19 @@ Material:
- _AlphaTransitionMapOffsetYCoord: 0
- _AlphaTransitionMapProgress: 0
- _AlphaTransitionMapProgressCoord: 0
- _AlphaTransitionMapSecondTextureChannelsX: 0
- _AlphaTransitionMapSecondTextureOffsetXCoord: 0
- _AlphaTransitionMapSecondTextureOffsetYCoord: 0
- _AlphaTransitionMapSecondTextureProgress: 0
- _AlphaTransitionMapSecondTextureProgressCoord: 0
- _AlphaTransitionMapSecondTextureSliceCount: 4
- _AlphaTransitionMapSliceCount: 4
- _AlphaTransitionMode: 2
- _AlphaTransitionProgress: 0
- _AlphaTransitionProgressCoord: 1
- _AlphaTransitionProgressCoordSecondTexture: 0
- _AlphaTransitionProgressSecondTexture: 0
- _AlphaTransitionSecondTextureBlendMode: 1
- _BaseMapMirrorSampling: 0
- _BaseMapMode: 0
- _BaseMapOffsetXCoord: 0
Expand All @@ -186,6 +207,7 @@ Material:
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DissolveSharpness: 0.913
- _DissolveSharpnessSecondTexture: 0.5
- _DstBlend: 0
- _EmissionAreaType: 3
- _EmissionColorType: 2
Expand Down Expand Up @@ -276,6 +298,8 @@ Material:
- _TintMap3DProgress: 0
- _TintMap3DProgressCoord: 0
- _TintMapMode: 0
- _TintMapOffsetXCoord: 0
- _TintMapOffsetYCoord: 0
- _TintMapSliceCount: 4
- _TintRimProgress: 0.5
- _TintRimProgressCoord: 0
Expand Down
25 changes: 25 additions & 0 deletions Assets/Demo/Demo00/Materials/mat_demo_fade_edgeemission.mat
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture2DArray:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture3D:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:
m_Texture: {fileID: 2800000, guid: cac707016af934ee5a416cab14da7246, type: 3}
m_Scale: {x: 1, y: 1}
Expand Down Expand Up @@ -156,10 +168,19 @@ Material:
- _AlphaTransitionMapOffsetYCoord: 0
- _AlphaTransitionMapProgress: 0
- _AlphaTransitionMapProgressCoord: 0
- _AlphaTransitionMapSecondTextureChannelsX: 1
- _AlphaTransitionMapSecondTextureOffsetXCoord: 0
- _AlphaTransitionMapSecondTextureOffsetYCoord: 0
- _AlphaTransitionMapSecondTextureProgress: 0
- _AlphaTransitionMapSecondTextureProgressCoord: 0
- _AlphaTransitionMapSecondTextureSliceCount: 4
- _AlphaTransitionMapSliceCount: 4
- _AlphaTransitionMode: 1
- _AlphaTransitionProgress: 0
- _AlphaTransitionProgressCoord: 1
- _AlphaTransitionProgressCoordSecondTexture: 0
- _AlphaTransitionProgressSecondTexture: 0
- _AlphaTransitionSecondTextureBlendMode: 0
- _BaseMapMirrorSampling: 0
- _BaseMapMode: 0
- _BaseMapOffsetXCoord: 0
Expand All @@ -186,6 +207,7 @@ Material:
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DissolveSharpness: 0.913
- _DissolveSharpnessSecondTexture: 0.5
- _DstBlend: 0
- _EmissionAreaType: 3
- _EmissionColorType: 2
Expand Down Expand Up @@ -259,6 +281,7 @@ Material:
- _ShadowCasterAlphaEffectedByTransparencyLuminance: 0
- _ShadowCasterAlphaEffectedByTransparencySoftParticles: 0
- _ShadowCasterAlphaTestEnabled: 1
- _ShadowCasterApplyVertexDeformation: 0
- _ShadowCasterEnabled: 1
- _ShadowCasterVertexDeformationEnabled: 0
- _Smoothness: 0.5
Expand All @@ -275,6 +298,8 @@ Material:
- _TintMap3DProgress: 0
- _TintMap3DProgressCoord: 0
- _TintMapMode: 0
- _TintMapOffsetXCoord: 0
- _TintMapOffsetYCoord: 0
- _TintMapSliceCount: 4
- _TintRimProgress: 0.5
- _TintRimProgressCoord: 0
Expand Down
27 changes: 26 additions & 1 deletion Assets/Demo/Demo00/Materials/mat_demo_flowmap.mat
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Material:
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
disabledShaderPasses:
- SHADOWCASTER
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
Expand All @@ -53,6 +54,18 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture2DArray:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AlphaTransitionMapSecondTexture3D:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:
m_Texture: {fileID: 2800000, guid: f4fa818b17f5d4014a924801d07cd980, type: 3}
m_Scale: {x: 1, y: 1}
Expand Down Expand Up @@ -166,10 +179,14 @@ Material:
- _AlphaTransitionMapOffsetYCoord: 0
- _AlphaTransitionMapProgress: 0
- _AlphaTransitionMapProgressCoord: 0
- _AlphaTransitionMapSecondTextureChannelsX: 0
- _AlphaTransitionMapSecondTextureOffsetXCoord: 0
- _AlphaTransitionMapSecondTextureOffsetYCoord: 0
- _AlphaTransitionMapSliceCount: 4
- _AlphaTransitionMode: 0
- _AlphaTransitionProgress: 0
- _AlphaTransitionProgressCoord: 0
- _AlphaTransitionSecondTextureBlendMode: 0
- _BaseMapMirrorSampling: 0
- _BaseMapMode: 0
- _BaseMapOffsetXCoord: 0
Expand Down Expand Up @@ -247,6 +264,14 @@ Material:
- _RimTransparencyProgressCoord: 0
- _RimTransparencySharpness: 0.5
- _RimTransparencySharpnessCoord: 0
- _ShadowCasterAlphaAffectedByAlphaTransitionMap: 0
- _ShadowCasterAlphaAffectedByFlowMap: 0
- _ShadowCasterAlphaAffectedByTintColor: 0
- _ShadowCasterAlphaAffectedByTransparencyLuminance: 0
- _ShadowCasterAlphaCutoff: 0.5
- _ShadowCasterAlphaTestEnabled: 0
- _ShadowCasterApplyVertexDeformation: 0
- _ShadowCasterEnabled: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0
Expand Down
13 changes: 13 additions & 0 deletions Assets/Nova/Editor/Core/Scripts/AlphaTransitionBlendMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// --------------------------------------------------------------
// Copyright 2024 CyberAgent, Inc.
// --------------------------------------------------------------

namespace Nova.Editor.Core.Scripts
{
public enum AlphaTransitionBlendMode
{
None,
Average,
Multiply
}
}
11 changes: 11 additions & 0 deletions Assets/Nova/Editor/Core/Scripts/AlphaTransitionBlendMode.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/Nova/Editor/Core/Scripts/MaterialPropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,22 @@ public static class MaterialPropertyNames
public const string AlphaTransitionMapOffsetYCoord = "_AlphaTransitionMapOffsetYCoord";
public const string AlphaTransitionMapChannelsX = "_AlphaTransitionMapChannelsX";
public const string AlphaTransitionMapSliceCount = "_AlphaTransitionMapSliceCount";
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";
public const string AlphaTransitionMapSecondTextureProgress = "_AlphaTransitionMapSecondTextureProgress";
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";
public const string AlphaTransitionProgressCoordSecondTexture = "_AlphaTransitionProgressCoordSecondTexture";
public const string DissolveSharpnessSecondTexture = "_DissolveSharpnessSecondTexture";

// Emission
public const string EmissionAreaType = "_EmissionAreaType";
Expand Down
76 changes: 69 additions & 7 deletions Assets/Nova/Editor/Core/Scripts/ParticlesUberCommonGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,20 @@ private void InternalDrawAlphaTransitionProperties()
props.AlphaTransitionMapModeProp.Value);
var alphaTransitionMapMode = (AlphaTransitionMapMode)props.AlphaTransitionMapModeProp.Value.floatValue;
MaterialProperty alphaTransitionMapProp;
MaterialProperty alphaTransitionMapSecondTextureProp;
switch (alphaTransitionMapMode)
{
case AlphaTransitionMapMode.SingleTexture:
alphaTransitionMapProp = props.AlphaTransitionMapProp.Value;
alphaTransitionMapSecondTextureProp = props.AlphaTransitionMapSecondTextureProp.Value;
break;
case AlphaTransitionMapMode.FlipBook:
alphaTransitionMapProp = props.AlphaTransitionMap2DArrayProp.Value;
alphaTransitionMapSecondTextureProp = props.AlphaTransitionMapSecondTexture2DArrayProp.Value;
break;
case AlphaTransitionMapMode.FlipBookBlending:
alphaTransitionMapProp = props.AlphaTransitionMap3DProp.Value;
alphaTransitionMapSecondTextureProp = props.AlphaTransitionMapSecondTexture3DProp.Value;
break;
default:
throw new ArgumentOutOfRangeException();
Expand Down Expand Up @@ -427,6 +431,57 @@ 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;
if (alphaTransitionSecondTextureBlendMode != AlphaTransitionBlendMode.None)
{
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
MaterialEditorUtility.DrawTexture(_editor, alphaTransitionMapSecondTextureProp,
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;
}

if (alphaTransitionMapMode == AlphaTransitionMapMode.FlipBookBlending
&& props.AlphaTransitionMapSecondTexture3DProp.Value.textureValue != null)
{
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);

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

if (mode == AlphaTransitionMode.Dissolve)
_editor.ShaderProperty(props.DissolveSharpnessSecondTextureProp.Value, "Edge Sharpness");
}
}
}
}

Expand Down Expand Up @@ -599,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
Loading

0 comments on commit 6d7c17a

Please sign in to comment.