Added SurfaceFeatureFlags;
Added OutlineScope; Added AngelRingScope; Change up Outline pass
This commit is contained in:
44
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
44
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class AngelRingScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty angelRingColor;
|
||||
public static MaterialProperty angelRingColorMap;
|
||||
public static MaterialProperty angelRingIntensity;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent angelRingColorText = new("Angel Ring Color", "Specifies the color of the angel ring.");
|
||||
public static readonly GUIContent angelRingIntensityText = new("Angel Ring Intensity", "Specifies the intensity of the angel ring.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => owner.GetUIScope<SurfaceOptionsScope>().HasFeature(SurfaceFeatureFlags.AngelRing);
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Angel Ring Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.angelRingColor = FindProperty("_AngelRingColor");
|
||||
Properties.angelRingColorMap = FindProperty("_AngelRingColorMap");
|
||||
Properties.angelRingIntensity = FindProperty("_AngelRingIntensity");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.angelRingColorText, Properties.angelRingColorMap, Properties.angelRingColor);
|
||||
editor.ShaderProperty(Properties.angelRingIntensity, Styles.angelRingIntensityText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.TextureScaleOffsetProperty(Properties.angelRingColorMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f21124eb2f73ac14e8cda9a0340191cd
|
||||
65
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
65
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty outlineWidth;
|
||||
public static MaterialProperty outlineWidthMap;
|
||||
|
||||
public static MaterialProperty outlineColor;
|
||||
public static MaterialProperty outlineColorMap;
|
||||
public static MaterialProperty albedoAffectOutline;
|
||||
|
||||
public static MaterialProperty fadeIn;
|
||||
public static MaterialProperty fadeOut;
|
||||
|
||||
public static MaterialProperty useSmoothedNormal;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline.");
|
||||
public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline.");
|
||||
public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color.");
|
||||
public static readonly GUIContent fadeInText = new("Fade In Distance", "Specify the nearest distance, where the outline width changes with the distance between the camera and the object. The outline will be the maximum width at this distance.");
|
||||
public static readonly GUIContent fadeOutText = new("Fade Out Distance", "Specify the furthest distance, where the outline width changes with the distance between the camera and the object. The outline will be zero at this distance.");
|
||||
public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => owner.GetUIScope<SurfaceOptionsScope>().HasFeature(SurfaceFeatureFlags.Outline);
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.outlineWidth = FindProperty("_OutlineWidth");
|
||||
Properties.outlineWidthMap = FindProperty("_OutlineWidthMap");
|
||||
|
||||
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||
|
||||
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty("_UseSmoothedNormal");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||
editor.ShaderProperty(Properties.fadeIn, Styles.fadeInText);
|
||||
editor.ShaderProperty(Properties.fadeOut, Styles.fadeOutText);
|
||||
editor.ShaderProperty(Properties.useSmoothedNormal, Styles.useSmoothedNormalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac42903bc14e05f41a9a06d1e6cf5cd9
|
||||
@@ -19,6 +19,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public static MaterialProperty receiveHairShadow;
|
||||
public static MaterialProperty hairBlendingTarget;
|
||||
public static MaterialProperty surfaceFeatures;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
@@ -34,12 +35,18 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
||||
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
||||
|
||||
public bool HasFeature(SurfaceFeatureFlags feature)
|
||||
{
|
||||
return ((SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue & feature) == feature;
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||
@@ -53,6 +60,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
@@ -82,6 +90,18 @@ namespace Misaki.HdrpToon.Editor
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
var surfaceFeatures = (SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
surfaceFeatures = (SurfaceFeatureFlags)EditorGUILayout.EnumFlagsField(Styles.surfaceFeaturesText, surfaceFeatures);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Properties.surfaceFeatures.floatValue = (float)surfaceFeatures;
|
||||
foreach (var material in GetMaterials())
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, HasFeature(SurfaceFeatureFlags.Outline));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user