Code Cleanup;

This commit is contained in:
Misaki
2025-01-23 23:56:32 +09:00
parent e6b58cb321
commit 6a8095d7e0
69 changed files with 2466 additions and 3533 deletions

View File

@@ -0,0 +1,23 @@
namespace Misaki.HdrpToon.Editor
{
public enum ShaderGUIExpandable : uint
{
SurfaceOptions = 1 << 0,
Basic = 1 << 1,
ShadingStepAndFeather = 1 << 2,
MaterialFeature = 1 << 3,
PBR = 1 << 4,
AmbientMode = 1 << 5,
Highlight = 1 << 6,
Rimlight = 1 << 7,
MatCap = 1 << 8,
AngelRing = 1 << 9,
Emission = 1 << 10,
Outline = 1 << 11,
TessellationLegacy = 1 << 12,
TessellationHDRP = 1 << 13,
SceneLight = 1 << 14,
EnvironmentalLightEffectiveness = 1 << 15,
MetaverseSettings = 1 << 16,
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 63067f176ae106c459bcb9cc105f626d

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc8d991d265341a4598574f90fc0e21c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using Misaki.ShaderGUI;
using UnityEditor;
using UnityEngine;
namespace Misaki.HdrpToon.Editor
{
internal class SurfaceOptionsScope : MaterialUIScope<ShaderGUIExpandable>
{
private static class Properties
{
public static MaterialProperty transparentMode;
public static MaterialProperty alphaClipEnable;
public static MaterialProperty alphaClip;
public static MaterialProperty cullMode;
public static MaterialProperty materialType;
public static MaterialProperty pbrMode;
public static MaterialProperty receiveHairShadow;
public static MaterialProperty hairBlendingTarget;
}
private static class Styles
{
public readonly static GUIContent transparentModeText = new("Transparent Mode", "Enable different modes that allow the simulation of a variety of transparent objects.");
public readonly static GUIContent alphaClipEnableText = new("Alpha Clipping", "Enable alpha clipping.");
public readonly static GUIContent alphaClipText = new("Alpha Clipping Threshold", "Threshold for alpha clipping.");
public readonly static GUIContent cullingModeText = new("Culling Mode", "Controls the sides of polygons that should not be drawn (culled).");
public static readonly GUIContent materialTypeText = new("Material Type", "Specifies the material type.");
public static readonly GUIContent pbrModeText = new("PBR Mode", "Specifies PBR model mode.");
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");
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
public override void LoadMaterialProperties()
{
Properties.transparentMode = FindProperty("_TransparentEnabled");
Properties.alphaClipEnable = FindProperty("_AlphaCutoffEnable");
Properties.alphaClip = FindProperty("_AlphaCutoff");
Properties.cullMode = FindProperty("_CullMode");
Properties.materialType = FindProperty("_Material_Type");
Properties.pbrMode = FindProperty("_PBR_Mode");
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
}
protected override void DrawContent()
{
editor.ShaderProperty(Properties.transparentMode, Styles.transparentModeText);
editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText);
if (Properties.alphaClipEnable.floatValue == 1.0f)
{
EditorGUI.indentLevel++;
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
EditorGUI.indentLevel--;
}
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
editor.ShaderProperty(Properties.receiveHairShadow, Styles.receiveHairShadowText);
EditorGUI.BeginChangeCheck();
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
if (EditorGUI.EndChangeCheck())
{
foreach (var material in GetMaterials())
{
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f62b264626a3bbd42a7b45b899084983

View File

@@ -99,7 +99,7 @@ namespace UnityEditor.Rendering.Toon
internal const string ShaderProp_Set_RimLightMask = "_Set_RimLightMask";
internal const string ShaderProp_HighColor_Tex = "_HighColor_Tex";
internal const string ShaderProp_Set_HighColorMask = "_Set_HighColorMask";
internal const string ShaderProp_MatCap_Sampler = "_MatCap_Sampler";
internal const string ShaderProp_MatCapMap = "_MatCapMap";
internal const string ShaderProp_Set_MatcapMask = "_Set_MatcapMask";
internal const string ShaderProp_OutlineTex = "_OutlineTex";
internal const string ShaderProp_Outline_Sampler = "_Outline_Sampler";
@@ -130,6 +130,8 @@ namespace UnityEditor.Rendering.Toon
internal const string ShaderPropShadowMode = "_Shadow_Mode";
internal const string ShaderPropMaterialType = "_Material_Type";
internal const string ShaderPropPBR = "_PBR_Mode";
internal const string ShaderPropIDMode = "_Indirect_Diffuse_Mode";
internal const string ShaderPropISMode = "_Indirect_Specular_Mode";
internal const string ShaderPropOutline = "_OUTLINE";
internal const string ShaderPropNormalMapToHighColor = "_Is_NormalMapToHighColor";
internal const string ShaderPropIsNormalMapToRimLight = "_Is_NormalMapToRimLight";
@@ -156,7 +158,6 @@ namespace UnityEditor.Rendering.Toon
internal const string ShaderPropInvert_MatcapMask = "_Inverse_MatcapMask";
internal const string ShaderPropUse_BaseAs1st = "_Use_BaseAs1st";
internal const string ShaderPropUse_1stAs2nd = "_Use_1stAs2nd";
internal const string ShaderPropIs_NormalMapToBase = "_Is_NormalMapToBase";
internal const string ShaderPropIs_ColorShift = "_Is_ColorShift";
internal const string ShaderPropRimLight = "_RimLight";
internal const string ShaderPropRimLight_FeatherOff = "_RimLight_FeatherOff";
@@ -214,7 +215,9 @@ namespace UnityEditor.Rendering.Toon
protected readonly string[] ZTestModeNames = { "Disabled", "Never", "Less", "Equal", "LessEqual", "Greater", "NotEqual", "GreaterEqual", "Always" };
protected readonly string[] materialTypeDefines = { "MATERIAL_TYPE_STANDARD", "MATERIAL_TYPE_FRONT_HAIR", "MATERIAL_TYPE_FACE", "MATERIAL_TYPE_EYE" };
protected readonly string[] PbrModeDefines = { "_PBR_Mode_OFF", "_PBR_Mode_ST", "_PBR_Mode_ANISO", "_PBR_Mode_KK", "_PBR_Mode_TOON" };
protected readonly string[] PbrModeDefines = { "PBR_Mode_OFF", "PBR_Mode_ST", "PBR_Mode_ANISO", "PBR_Mode_KK", "PBR_Mode_TOON" };
protected readonly string[] IndirectDiffuseModeDefines = { "INDIRECT_DIFFUSE_OFF", "INDIRECT_DIFFUSE_IBL", "INDIRECT_DIFFUSE_MATCAP", "INDIRECT_DIFFUSE_RAMP" };
protected readonly string[] IndirectSpecularModeDefines = { "INDIRECT_SPECULAR_OFF", "INDIRECT_SPECULAR_IBL", "INDIRECT_SPECULAR_MATCAP" };
public enum UTS_ClippingMode
{
@@ -295,6 +298,17 @@ namespace UnityEditor.Rendering.Toon
Off, Standard, Anisotropy, KKHair, Toon
}
public enum IndirectDiffuseMode
{
Off, IBL, Matcap, Ramp
}
public enum IndirectSpecularMode
{
Off, IBL, Matcap
}
public enum OutlineMode
{
NormalDirection, PositionScaling
@@ -327,17 +341,18 @@ namespace UnityEditor.Rendering.Toon
ShadingStepAndFeather = 1 << 2,
MaterialFeature = 1 << 3,
PBR = 1 << 4,
Highlight = 1 << 5,
Rimlight = 1 << 6,
MatCap = 1 << 7,
AngelRing = 1 << 8,
Emission = 1 << 9,
Outline = 1 << 10,
TessellationLegacy = 1 << 11,
TessellationHDRP = 1 << 12,
SceneLight = 1 << 13,
EnvironmentalLightEffectiveness = 1 << 14,
MetaverseSettings = 1 << 15,
AmbientMode = 1 << 5,
Highlight = 1 << 6,
Rimlight = 1 << 7,
MatCap = 1 << 8,
AngelRing = 1 << 9,
Emission = 1 << 10,
Outline = 1 << 11,
TessellationLegacy = 1 << 12,
TessellationHDRP = 1 << 13,
SceneLight = 1 << 14,
EnvironmentalLightEffectiveness = 1 << 15,
MetaverseSettings = 1 << 16,
}
// variables which must be gotten from shader at the beggning of GUI
@@ -347,6 +362,8 @@ namespace UnityEditor.Rendering.Toon
internal ShadowMode m_shadowMode;
internal MaterialType m_materialType;
internal PBRMode m_pbrMode;
internal IndirectDiffuseMode m_IndirectDiffuseMode;
internal IndirectSpecularMode m_IndirectSpecularMode;
internal OutlineMode m_outlineMode;
internal CullingMode m_cullingMode;
internal EmissionMode m_emissionMode;
@@ -422,7 +439,7 @@ namespace UnityEditor.Rendering.Toon
protected MaterialProperty ap_RimLight_Power = null;
protected MaterialProperty set_RimLightMask = null;
protected MaterialProperty matCap_Sampler = null;
protected MaterialProperty matCapMap = null;
protected MaterialProperty matCapColor = null;
protected MaterialProperty normalMapForMatCap = null;
protected MaterialProperty bumpScaleMatcap = null;
@@ -515,7 +532,7 @@ namespace UnityEditor.Rendering.Toon
set_RimLightMask = FindProperty(ShaderProp_Set_RimLightMask, props);
matCap_Sampler = FindProperty(ShaderProp_MatCap_Sampler, props);
matCapMap = FindProperty(ShaderProp_MatCapMap, props);
matCapColor = FindProperty("_MatCapColor", props);
normalMapForMatCap = FindProperty("_NormalMapForMatCap", props);
@@ -631,6 +648,7 @@ namespace UnityEditor.Rendering.Toon
public static readonly GUIContent shadingStepAndFeatherFoldout = EditorGUIUtility.TrTextContent("Shading Step and Feather Settings", "Basic 3 color step and feather settings.");
public static readonly GUIContent materialFeatureFoldout = EditorGUIUtility.TrTextContent("Material Feature", "Material Feature Setting. The settings for special material feature like hair shadow, hair blending, etc");
public static readonly GUIContent pbrFoldout = EditorGUIUtility.TrTextContent("PBR Settings", "PBR settings. The settings for PBR effect, such as specular and IBL.");
public static readonly GUIContent ambientModeFoldout = EditorGUIUtility.TrTextContent("Ambient Settings", "Ambient settings. The settings for ambient lighting like IBL, Matcap, etc.");
public static readonly GUIContent highlightFoldout = EditorGUIUtility.TrTextContent("Highlight Settings", "Highlight settings. Such as power, show or hide, light shape and so on.");
public static readonly GUIContent rimLightFoldout = EditorGUIUtility.TrTextContent("Rim Light Settings", "Rim Light Settings. Such as color, direction, inverted rim light and so on.");
public static readonly GUIContent matCapFoldout = EditorGUIUtility.TrTextContent("Material Capture (MatCap) Settings", "MatCap settings. Sphere maps for metallic or unusual expressions.");
@@ -654,8 +672,9 @@ namespace UnityEditor.Rendering.Toon
public static readonly GUIContent hairBlendingTargetMapText = new GUIContent("Blending Map", "Specifies the texture to blend with hair.");
public static readonly GUIContent normalMapText = new GUIContent("Normal Map", "A texture that dictates the bumpiness of the material.");
public static readonly GUIContent pbrModeText = new GUIContent("PBR Mode", "Specifies PBR model mode.");
public static readonly GUIContent ambientModeModeText = new GUIContent("Ambient Mode", "Specifies ambient calculation mode.");
public static readonly GUIContent highColorText = new GUIContent("Highlight", "Highlight : Texture(sRGB) x Color(RGB) Default:White");
public static readonly GUIContent highColorMaskText = new GUIContent("Highlight Mask", "A grayscale texture which utilises its brightness to control intensity.");
public static readonly GUIContent highColorMaskText = new GUIContent("Highlight Mask", "A grayscale texture which utilizes its brightness to control intensity.");
public static readonly GUIContent rimLightMaskText = new GUIContent("Rim Light Mask", "Rim Light Mask : Texture(linear). The white part of the texture is displayed as Rim Light, and the black part is masked and not displayed.");
public static readonly GUIContent matCapSamplerText = new GUIContent("MatCap Map", "MatCap Color : Texture(sRGB) x Color(RGB) Default:White");
public static readonly GUIContent matCapMaskText = new GUIContent("MatCap Mask", "The MatCap mask is positioned with respect to the UV coordinates of the mesh onto which the MatCap is projected, and the pixels on black areas are hidden.");
@@ -667,7 +686,7 @@ namespace UnityEditor.Rendering.Toon
public static readonly GUIContent outlineSamplerText = new GUIContent("Outline Width Map", "Outline Width Map as Grayscale Texture : Texture(linear). In the case of white, the Outline Width is displayed as it is. In black, the width is 0.");
public static readonly GUIContent outlineTexText = new GUIContent("Outline Color Map", "Outline texture : Texture(sRGB) Default:White");
public static readonly GUIContent bakedNormalOutlineText = new GUIContent("Baked Normal Map for Outline", "Unpacked Normal Map : Texture(linear) .Note that this is not a standard NORMAL MAP.");
public static readonly GUIContent clippingMaskText = new GUIContent("Clipping Mask", "A grayscale texture which utilises its brightness to control transparency.");
public static readonly GUIContent clippingMaskText = new GUIContent("Clipping Mask", "A grayscale texture which utilizes its brightness to control transparency.");
public static readonly GUIContent specularModeText = new GUIContent("Specular Mode", "Specular light mode. Hard or Soft.");
public static readonly GUIContent specularBlendModeText = new GUIContent("Color Blending Mode", "Specular color blending mode. Multiply or Add.");
@@ -947,12 +966,12 @@ namespace UnityEditor.Rendering.Toon
propName: "_RimLight_InsideMask", defaultValue: 0.0001f, min: 0.0001f, max: 1);
public static readonly RangeProperty SSAOFactorText = new RangeProperty(
label: "SSAO Minimum", "The minimum value of SSAO.",
propName: "_AOMin", defaultValue: 0.0f, min: 0, max: 1);
label: "SSAO Factor", "The weight of SSAO.",
propName: "_AO_Factor", defaultValue: 0.0f, min: 0, max: 1);
public static readonly RangeProperty SSGIFactorText = new RangeProperty(
label: "SSGI Factor", "The multiplier of SSGI.",
propName: "_GIMultiplier", defaultValue: 1.0f, min: 1, max: 10);
label: "SSGI Factor", "The weight of SSGI.",
propName: "_GI_Factor", defaultValue: 1.0f, min: 1, max: 10);
public static readonly RangeProperty BSDFContribution = new RangeProperty(
label: "BSDF Contribution", "BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation",
@@ -1022,6 +1041,7 @@ namespace UnityEditor.Rendering.Toon
m_MaterialScopeList.RegisterHeaderScope(Styles.shadingStepAndFeatherFoldout, Expandable.ShadingStepAndFeather, GUI_StepAndFeather, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.materialFeatureFoldout, Expandable.MaterialFeature, GUI_MaterialFeature, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.pbrFoldout, Expandable.PBR, GUI_PBRSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.ambientModeFoldout, Expandable.AmbientMode, GUI_AmbientMode, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.highlightFoldout, Expandable.Highlight, GUI_HighlightSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.rimLightFoldout, Expandable.Rimlight, GUI_RimLight, (uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.matCapFoldout, Expandable.MatCap, GUI_MatCap, (uint)UTS_TransparentMode.Off, isTessellation: 0);
@@ -1529,6 +1549,71 @@ namespace UnityEditor.Rendering.Toon
EditorGUI.EndDisabledGroup();
}
void GUI_ShadingStepAndFeatherSettings(Material material)
{
var shadowMode_Setting = MaterialGetInt(material, ShaderPropShadowMode);
//Convert it to Enum format and store it in the offlineMode variable.
switch (shadowMode_Setting)
{
case (int)ShadowMode.Normal:
m_shadowMode = ShadowMode.Normal;
break;
case (int)ShadowMode.SDF:
m_shadowMode = ShadowMode.SDF;
break;
}
m_shadowMode = (ShadowMode)EditorGUILayout.EnumPopup(Styles.shadowModeText, m_shadowMode);
EditorGUILayout.Space();
switch (m_shadowMode)
{
case ShadowMode.Normal:
{
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.Normal);
material.DisableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_StepText);
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_FeatherText);
GUI_RangeProperty(material, Styles.shaderProp2nd_ShadeColor_StepText);
GUI_RangeProperty(material, Styles.shaderProp2nd_ShadeColor_FeatherText);
//Share variables with DoubleWithFeather method.
material.SetFloat(ShaderPropBaseColor_Step, material.GetFloat(ShaderProp1st_ShadeColor_Step));
material.SetFloat(ShaderPropBaseShade_Feather, material.GetFloat(ShaderProp1st_ShadeColor_Feather));
material.SetFloat(ShaderPropShadeColor_Step, material.GetFloat(ShaderProp2nd_ShadeColor_Step));
material.SetFloat(ShaderProp1st2nd_Shades_Feather, material.GetFloat(ShaderProp2nd_ShadeColor_Feather));
}
break;
case ShadowMode.SDF:
{
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.SDF);
material.EnableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
m_MaterialEditor.TexturePropertySingleLine(Styles.SDFShadowText, SDFShadowMap);
GUI_RangeProperty(material, Styles.SDFShadowLevelText);
GUI_RangeProperty(material, Styles.SDFSmoothGammaText);
GUI_RangeProperty(material, Styles.SDFNoseHighlightCoefText);
GUI_RangeProperty(material, Styles.SDFNoseHighlightSmoothRange);
}
break;
}
EditorGUILayout.Space();
}
void GUI_AdditionalLookdevs(Material material)
{
EditorGUI.indentLevel++;
GUI_RangeProperty(material, Styles.shaderPropStepOffsetText);
GUI_Toggle(material, Styles.filterPointLightText, ShaderPropIsFilterHiCutPointLightColor, MaterialGetInt(material, ShaderPropIsFilterHiCutPointLightColor) != 0);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
void GUI_MaterialFeature(Material material)
{
var materialTypeSetting = MaterialGetInt(material, ShaderPropMaterialType);
@@ -1595,117 +1680,30 @@ namespace UnityEditor.Rendering.Toon
{
GUI_RangeProperty(material, Styles.eyeParallaxAmount);
}
void GUI_ShadingStepAndFeatherSettings(Material material)
void SwitchKeywrod(Material material, string targetKeywrod, string[] sources)
{
var shadowMode_Setting = MaterialGetInt(material, ShaderPropShadowMode);
//Convert it to Enum format and store it in the offlineMode variable.
switch (shadowMode_Setting)
foreach (var keywrod in sources)
{
case (int)ShadowMode.Normal:
m_shadowMode = ShadowMode.Normal;
break;
case (int)ShadowMode.SDF:
m_shadowMode = ShadowMode.SDF;
break;
}
m_shadowMode = (ShadowMode)EditorGUILayout.EnumPopup(Styles.shadowModeText, m_shadowMode);
EditorGUILayout.Space();
switch (m_shadowMode)
{
case ShadowMode.Normal:
if (targetKeywrod == keywrod)
{
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.Normal);
material.DisableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_StepText);
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_FeatherText);
GUI_RangeProperty(material, Styles.shaderProp2nd_ShadeColor_StepText);
GUI_RangeProperty(material, Styles.shaderProp2nd_ShadeColor_FeatherText);
//Share variables with DoubleWithFeather method.
material.SetFloat(ShaderPropBaseColor_Step, material.GetFloat(ShaderProp1st_ShadeColor_Step));
material.SetFloat(ShaderPropBaseShade_Feather, material.GetFloat(ShaderProp1st_ShadeColor_Feather));
material.SetFloat(ShaderPropShadeColor_Step, material.GetFloat(ShaderProp2nd_ShadeColor_Step));
material.SetFloat(ShaderProp1st2nd_Shades_Feather, material.GetFloat(ShaderProp2nd_ShadeColor_Feather));
material.EnableKeyword(keywrod);
}
break;
case ShadowMode.SDF:
else
{
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.SDF);
material.EnableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
m_MaterialEditor.TexturePropertySingleLine(Styles.SDFShadowText, SDFShadowMap);
GUI_RangeProperty(material, Styles.SDFShadowLevelText);
GUI_RangeProperty(material, Styles.SDFSmoothGammaText);
GUI_RangeProperty(material, Styles.SDFNoseHighlightCoefText);
GUI_RangeProperty(material, Styles.SDFNoseHighlightSmoothRange);
material.DisableKeyword(keywrod);
}
break;
}
EditorGUILayout.Space();
}
void GUI_AdditionalLookdevs(Material material)
{
EditorGUI.indentLevel++;
GUI_RangeProperty(material, Styles.shaderPropStepOffsetText);
GUI_Toggle(material, Styles.filterPointLightText, ShaderPropIsFilterHiCutPointLightColor, MaterialGetInt(material, ShaderPropIsFilterHiCutPointLightColor) != 0);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
void GUI_PBRSettings(Material material)
{
var PBRMode_Setting = MaterialGetInt(material, ShaderPropPBR);
//Convert it to Enum format and store it in the offlineMode variable.
switch (PBRMode_Setting)
{
case (int)PBRMode.Off:
m_pbrMode = PBRMode.Off;
break;
case (int)PBRMode.Standard:
m_pbrMode = PBRMode.Standard;
break;
case (int)PBRMode.Anisotropy:
m_pbrMode = PBRMode.Anisotropy;
break;
case (int)PBRMode.KKHair:
m_pbrMode = PBRMode.KKHair;
break;
case (int)PBRMode.Toon:
m_pbrMode = PBRMode.Toon;
break;
}
//GUI description with EnumPopup.
m_pbrMode = (PBRMode)MaterialGetInt(material, ShaderPropPBR);
m_pbrMode = (PBRMode)EditorGUILayout.EnumPopup(Styles.pbrModeText, m_pbrMode);
EditorGUILayout.Space();
void SwitchPbrMode(string targetMode)
{
foreach (var pbrMode in PbrModeDefines)
{
if (targetMode == pbrMode)
{
material.EnableKeyword(pbrMode);
}
else
{
material.DisableKeyword(pbrMode);
}
}
}
material.SetFloat(ShaderPropPBR, (int)m_pbrMode);
SwitchPbrMode(PbrModeDefines[(int)m_pbrMode]);
SwitchKeywrod(material, PbrModeDefines[(int)m_pbrMode], PbrModeDefines);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
@@ -1815,6 +1813,22 @@ namespace UnityEditor.Rendering.Toon
MaterialSetInt(material, "_Use_SSSLut", 0);
}
}
void GUI_AmbientMode(Material material)
{
m_IndirectDiffuseMode = (IndirectDiffuseMode)MaterialGetInt(material, ShaderPropIDMode);
m_IndirectDiffuseMode = (IndirectDiffuseMode)EditorGUILayout.EnumPopup(Styles.ambientModeModeText, m_IndirectDiffuseMode);
material.SetFloat(ShaderPropIDMode, (int)m_IndirectDiffuseMode);
SwitchKeywrod(material, IndirectDiffuseModeDefines[(int)m_IndirectDiffuseMode], IndirectDiffuseModeDefines);
m_IndirectSpecularMode = (IndirectSpecularMode)MaterialGetInt(material, ShaderPropISMode);
m_IndirectSpecularMode = (IndirectSpecularMode)EditorGUILayout.EnumPopup(Styles.ambientModeModeText, m_IndirectSpecularMode);
material.SetFloat(ShaderPropISMode, (int)m_IndirectSpecularMode);
SwitchKeywrod(material, IndirectSpecularModeDefines[(int)m_IndirectSpecularMode], IndirectSpecularModeDefines);
}
void GUI_HighlightSettings(Material material)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.highColorText, highColor_Tex, highColor);
@@ -1893,7 +1907,6 @@ namespace UnityEditor.Rendering.Toon
void GUI_RimLight(Material material)
{
EditorGUILayout.BeginHorizontal();
var rimLightEnabled = GUI_Toggle(material, Styles.rimlightText, ShaderPropRimLight, MaterialGetInt(material, ShaderPropRimLight) != 0);
EditorGUILayout.EndHorizontal();
@@ -1973,10 +1986,6 @@ namespace UnityEditor.Rendering.Toon
EditorGUILayout.Space();
EditorGUI.EndDisabledGroup();
}
void GUI_MatCap(Material material)
@@ -1986,9 +1995,9 @@ namespace UnityEditor.Rendering.Toon
EditorGUILayout.EndHorizontal();
EditorGUI.BeginDisabledGroup(!matcapEnabled);
m_MaterialEditor.TexturePropertySingleLine(Styles.matCapSamplerText, matCap_Sampler, matCapColor);
m_MaterialEditor.TexturePropertySingleLine(Styles.matCapSamplerText, matCapMap, matCapColor);
EditorGUI.indentLevel++;
m_MaterialEditor.TextureScaleOffsetProperty(matCap_Sampler);
m_MaterialEditor.TextureScaleOffsetProperty(matCapMap);
if (!_SimpleUI)
{

View File

@@ -0,0 +1,35 @@
using Misaki.ShaderGUI;
using UnityEditor;
using UnityEngine;
namespace Misaki.HdrpToon.Editor
{
public class UTSShaderGUI : ScopedShaderGUI
{
private GUIStyle _headerStyle;
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
if (!initialized)
{
OnInitialize(materialEditor, properties);
}
EditorGUILayout.Space(10);
EditorGUILayout.LabelField("HDRP Toon Shader", _headerStyle);
EditorGUILayout.Space(20);
DrawShaderGUI(properties);
}
private void OnInitialize(MaterialEditor materialEditor, MaterialProperty[] properties)
{
AddUIScope(new SurfaceOptionsScope());
Initialize(materialEditor, properties);
_headerStyle = new GUIStyle() { fontSize = 25, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter };
_headerStyle.normal.textColor = GUI.skin.label.normal.textColor;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 41e8a43d8ee32f04cbf2ac4d1db45948