66 lines
3.4 KiB
C#
66 lines
3.4 KiB
C#
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 => 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);
|
|
}
|
|
}
|
|
}
|