Update ShadingColorScope;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Linq;
|
||||
using Misaki.ShaderGUI;
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
@@ -75,6 +75,18 @@ namespace Misaki.HdrpToon.Editor
|
||||
"Feather and step value of Toon Specular");
|
||||
}
|
||||
|
||||
private enum PBRMode
|
||||
{
|
||||
Off,
|
||||
Standard,
|
||||
Anisotropy,
|
||||
KKHair,
|
||||
Toon
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.PBR;
|
||||
protected override GUIContent Header => new("PBR Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.PbrMode = FindProperty("_PBR_Mode");
|
||||
@@ -104,21 +116,21 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.ShaderProperty(Properties.PbrMode, Styles.PbrModeText);
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale);
|
||||
var materials = GetMaterials().ToList();
|
||||
foreach (Material material in materials)
|
||||
var materials = editor.GetMaterials().ToList();
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"),
|
||||
Properties.NormalMap.textureValue != null);
|
||||
}
|
||||
|
||||
PBRMode pbrMode = (PBRMode)Properties.PbrMode.floatValue;
|
||||
var pbrMode = (PBRMode)Properties.PbrMode.floatValue;
|
||||
if (pbrMode != PBRMode.Off)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap);
|
||||
|
||||
if (Properties.MaskMap.textureValue == null)
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
}
|
||||
@@ -129,7 +141,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
}
|
||||
@@ -143,7 +155,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
@@ -168,14 +180,14 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
|
||||
if (Properties.AnisotropyMap.textureValue == null)
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
}
|
||||
@@ -189,14 +201,14 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.SpecularColor);
|
||||
if (Properties.SpecularColorMap.textureValue == null)
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Material material in materials)
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
@@ -208,17 +220,5 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum PBRMode
|
||||
{
|
||||
Off,
|
||||
Standard,
|
||||
Anisotropy,
|
||||
KKHair,
|
||||
Toon
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.PBR;
|
||||
protected override GUIContent Header => new("PBR Settings");
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty useShadingRampMap;
|
||||
|
||||
public static MaterialProperty baseColor;
|
||||
public static MaterialProperty baseColorMap;
|
||||
public static MaterialProperty applyTo1stShadingMapEnable;
|
||||
@@ -17,91 +19,67 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static MaterialProperty secondShadingColor;
|
||||
public static MaterialProperty secondShadingMap;
|
||||
|
||||
public static MaterialProperty sdfShadowMap;
|
||||
public static MaterialProperty firstShadeColorStep;
|
||||
public static MaterialProperty firstShadeColorFeather;
|
||||
public static MaterialProperty secondShadeColorStep;
|
||||
public static MaterialProperty secondShadeColorFeather;
|
||||
|
||||
public static MaterialProperty shadingRampMap;
|
||||
public static MaterialProperty shadingIndex;
|
||||
|
||||
public static MaterialProperty sdfShadingMap;
|
||||
public static MaterialProperty sdfShadowLevel;
|
||||
public static MaterialProperty sdfSmoothLevel;
|
||||
public static MaterialProperty sdfHighlightStrength;
|
||||
public static MaterialProperty sdfHighlightSmoothLevel;
|
||||
|
||||
public static MaterialProperty shadingGradeMap;
|
||||
public static MaterialProperty shadingIndex;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent baseMapText = new("Base Map", "Base Color : Texture(sRGB) x Color(RGB) Default:White");
|
||||
public static readonly GUIContent useShadingRampMapText = new("Use Shading Ramp Map", "Use Shading Ramp Map to control the shading color instead of manually setting the shading color.");
|
||||
|
||||
public static readonly GUIContent baseColorText = new("Base Map", "Base Color : Texture(sRGB) x Color(RGB) Default:White");
|
||||
public static readonly GUIContent applyTo1stShadingMapText = new("Apply to 1st shading map", "Apply Base map to the 1st shading map.");
|
||||
public static readonly GUIContent firstShadingMapText = new("1st Shading Map", "The map used for the brighter portions of the shadow.");
|
||||
|
||||
public static readonly GUIContent applyTo2ndShadingMapText = new("Apply to 2nd shading map", "Apply Base map or the 1st shading map to the 2st shading map.");
|
||||
public static readonly GUIContent secondShadingMapText = new("2nd Shading Map", "The map used for the darker portions of the shadow.");
|
||||
|
||||
public static readonly GUIContent sdfShadowMapText = new("SDF Shadow Map", "SDF Shadow Map");
|
||||
public static readonly GUIContent sdfShadowLevelText = new("SDF Shadow Level", "SDF Shadow Level");
|
||||
public static readonly GUIContent sdfSmoothLevelText = new("SDF Smooth Level", "SDF Smooth Level");
|
||||
public static readonly GUIContent sdfHighlightStrengthText = new("SDF Highlight Strength", "SDF Highlight Strength");
|
||||
public static readonly GUIContent sdfHighlightSmoothLevelText = new("SDF Highlight Smooth Level", "SDF Highlight Smooth Level");
|
||||
public static readonly GUIContent firstShadeColorStepText = new("1st Shade Color Step", "Sets the step between the Base color and 1st Shade Color, the same as the BaseColor_Step property.");
|
||||
public static readonly GUIContent firstShadeColorFeatherText = new("1st Shade Color Feather", "Sets the feather between the Base color and 1st Shade Color, the same as the BaseColor_Feather property.");
|
||||
public static readonly GUIContent secondShadeColorStepText = new("2nd Shade Color Step", "Sets the step between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorStep property.");
|
||||
public static readonly GUIContent secondShadeColorFeatherText = new("2nd Shade Color Feather", "Sets the feather between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorFeather property.");
|
||||
|
||||
public static readonly GUIContent shadingGradeMapText = new("Shading Grade Map", "Shading Grade Map");
|
||||
public static readonly GUIContent shadingIndexText = new("Shading Index", "The index to choose when sampling the texture 2d array.");
|
||||
public static readonly GUIContent sdfShadingMapText = new("SDF Shading Map", "The map used for the SDF shading. R channel for SDF shadow, G channel for highlight, B channel for fixed shadow.");
|
||||
public static readonly GUIContent sdfShadowLevelText = new("SDF Shadow Level", "Control the sampling position of the shadow in the SDF shading map.");
|
||||
public static readonly GUIContent sdfSmoothLevelText = new("SDF Smooth Level", "Control the smoothness of the shadow edge.");
|
||||
public static readonly GUIContent sdfHighlightStrengthText = new("SDF Highlight Strength", "Control the strength of the highlight in the SDF shading map.");
|
||||
|
||||
public static readonly GUIContent shadingRampMapText = new("Shading Grade Map", "A texture 2D array that contains a ramp color in each slice, and the index to choose when sampling the shading ramp map.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor;
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Color Settings");
|
||||
|
||||
private void DrawSecondShadingMapProperties()
|
||||
private void DrawShadingProperties(MaterialProperty inheritProperty, MaterialProperty colorProperty, MaterialProperty colorMapProperty, GUIContent inheritText, GUIContent colorText)
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ShaderProperty(Properties.applyTo2ndShadingMapEnable, Styles.applyTo2ndShadingMapText);
|
||||
editor.ShaderProperty(inheritProperty, inheritText);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
if (Mathf.Approximately(Properties.applyTo2ndShadingMapEnable.floatValue, 1))
|
||||
if (Mathf.Approximately(inheritProperty.floatValue, 1))
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ColorProperty(Properties.secondShadingColor, Styles.secondShadingMapText.text);
|
||||
editor.ShaderProperty(colorProperty, colorText);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.secondShadingMapText, Properties.secondShadingMap,
|
||||
Properties.secondShadingColor);
|
||||
editor.TexturePropertySingleLine(colorText, colorMapProperty, colorProperty);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFirstShadingMapProperties()
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ShaderProperty(Properties.applyTo1stShadingMapEnable, Styles.applyTo1stShadingMapText);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
if (Mathf.Approximately(Properties.applyTo1stShadingMapEnable.floatValue, 1))
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ColorProperty(Properties.firstShadingColor, Styles.firstShadingMapText.text);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.firstShadingMapText, Properties.firstShadingMap,
|
||||
Properties.firstShadingColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSDFProperties()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.sdfShadowMapText, Properties.sdfShadowMap);
|
||||
editor.ShaderProperty(Properties.sdfShadowLevel, Styles.sdfShadowLevelText);
|
||||
editor.ShaderProperty(Properties.sdfSmoothLevel, Styles.sdfSmoothLevelText);
|
||||
editor.ShaderProperty(Properties.sdfHighlightStrength, Styles.sdfHighlightStrengthText);
|
||||
editor.ShaderProperty(Properties.sdfHighlightSmoothLevel, Styles.sdfHighlightSmoothLevelText);
|
||||
}
|
||||
|
||||
private void DrawShadingGradeProperties()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.shadingGradeMapText, Properties.shadingGradeMap);
|
||||
editor.ShaderProperty(Properties.shadingIndex, Styles.shadingIndexText);
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.useShadingRampMap = FindProperty("_Use_Shading_Ramp_Map");
|
||||
|
||||
Properties.baseColor = FindProperty("_BaseColor");
|
||||
Properties.baseColorMap = FindProperty("_BaseColorMap");
|
||||
Properties.applyTo1stShadingMapEnable = FindProperty("_UseBaseAs1st");
|
||||
@@ -111,34 +89,51 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.secondShadingColor = FindProperty("_2ndShadeColor");
|
||||
Properties.secondShadingMap = FindProperty("_2ndShadeColorMap");
|
||||
|
||||
Properties.sdfShadowMap = FindProperty("_SDFShadowMap");
|
||||
Properties.sdfShadowLevel = FindProperty("_SDFShadowLevel");
|
||||
Properties.sdfSmoothLevel = FindProperty("_SDFSmoothLevel");
|
||||
Properties.sdfHighlightStrength = FindProperty("_SDFHighlightStrength");
|
||||
Properties.sdfHighlightSmoothLevel = FindProperty("_SDFHighlightSmoothLevel");
|
||||
Properties.firstShadeColorStep = FindProperty("_1stShadeColorStep");
|
||||
Properties.firstShadeColorFeather = FindProperty("_1stShadeColorFeather");
|
||||
Properties.secondShadeColorStep = FindProperty("_2ndShadeColorStep");
|
||||
Properties.secondShadeColorFeather = FindProperty("_2ndShadeColorFeather");
|
||||
|
||||
Properties.shadingGradeMap = FindProperty("_ShadingGradeMap");
|
||||
Properties.sdfShadingMap = FindProperty("_SDFShadingMap");
|
||||
Properties.sdfShadowLevel = FindProperty("_SDFShadowLevel");
|
||||
Properties.sdfSmoothLevel = FindProperty("_SDFShadowSmoothLevel");
|
||||
Properties.sdfHighlightStrength = FindProperty("_SDFHighlightStrength");
|
||||
|
||||
Properties.shadingRampMap = FindProperty("_ShadingRampMap");
|
||||
Properties.shadingIndex = FindProperty("_ShadingIndex");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.baseMapText, Properties.baseColorMap, Properties.baseColor);
|
||||
editor.ShaderProperty(Properties.useShadingRampMap, Styles.useShadingRampMapText);
|
||||
editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor);
|
||||
|
||||
switch (SurfaceOptionsScope.GetShadingMode())
|
||||
if (Properties.useShadingRampMap.GetBooleanValue())
|
||||
{
|
||||
case ShadingMode.ThreeColorStep:
|
||||
DrawFirstShadingMapProperties();
|
||||
DrawSecondShadingMapProperties();
|
||||
break;
|
||||
case ShadingMode.SDF:
|
||||
DrawSDFProperties();
|
||||
break;
|
||||
case ShadingMode.Ramp:
|
||||
DrawShadingGradeProperties();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
editor.TexturePropertySingleLine(Styles.shadingRampMapText, Properties.shadingRampMap, Properties.shadingIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText);
|
||||
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.Standard)
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.firstShadeColorStep, Styles.firstShadeColorStepText);
|
||||
editor.ShaderProperty(Properties.firstShadeColorFeather, Styles.firstShadeColorFeatherText);
|
||||
editor.ShaderProperty(Properties.secondShadeColorStep, Styles.secondShadeColorStepText);
|
||||
editor.ShaderProperty(Properties.secondShadeColorFeather, Styles.secondShadeColorFeatherText);
|
||||
}
|
||||
}
|
||||
|
||||
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.SDF)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);
|
||||
editor.ShaderProperty(Properties.sdfShadowLevel, Styles.sdfShadowLevelText);
|
||||
editor.ShaderProperty(Properties.sdfSmoothLevel, Styles.sdfSmoothLevelText);
|
||||
editor.ShaderProperty(Properties.sdfHighlightStrength, Styles.sdfHighlightStrengthText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class ShadingGradeScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingGrade;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Grade Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faf2eabd1c2767d40a2ecfe89cb56d28
|
||||
Reference in New Issue
Block a user