Updated OutlineScope;
Reorgnize shader code;
This commit is contained in:
40
Editor/MeterialEditor/Helpers/MaterialHelpers.cs
Normal file
40
Editor/MeterialEditor/Helpers/MaterialHelpers.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal static class MaterialHelpers
|
||||
{
|
||||
public static ShadingMode GetShadingMode(this Material material)
|
||||
{
|
||||
if (!material.HasProperty(SurfaceOptions.SHADING_MODE))
|
||||
{
|
||||
return ShadingMode.Standard;
|
||||
}
|
||||
|
||||
return (ShadingMode)material.GetInteger(SurfaceOptions.SHADING_MODE);
|
||||
}
|
||||
|
||||
public static PBRMode GetPBRMode(this Material material)
|
||||
{
|
||||
if (!material.HasProperty(SurfaceOptions.PBR_MODE))
|
||||
{
|
||||
return PBRMode.Off;
|
||||
}
|
||||
|
||||
return (PBRMode)material.GetInteger(SurfaceOptions.PBR_MODE);
|
||||
}
|
||||
|
||||
public static bool HasFeature(this Material material, SurfaceFeature feature)
|
||||
{
|
||||
if (!material.HasProperty(SurfaceOptions.SURFACE_FEATURE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = (SurfaceFeature)material.GetInteger(SurfaceOptions.SURFACE_FEATURE);
|
||||
return (value & feature) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/Helpers/MaterialHelpers.cs.meta
Normal file
2
Editor/MeterialEditor/Helpers/MaterialHelpers.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b32ea10056de246488796e50f7160a4a
|
||||
@@ -12,9 +12,9 @@ namespace Misaki.HdrpToon.Editor
|
||||
return (PBRMode)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_PBR_Mode").floatValue;
|
||||
}
|
||||
|
||||
public static bool HasFeature(this UTSShaderGUI shaderGUI, SurfaceFeatureFlags feature)
|
||||
public static bool HasFeature(this UTSShaderGUI shaderGUI, SurfaceFeature feature)
|
||||
{
|
||||
return ((SurfaceFeatureFlags)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_Surface_Features").floatValue & feature) != 0;
|
||||
return ((SurfaceFeature)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_Surface_Features").floatValue & feature) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
using var indentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
||||
@@ -91,8 +90,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
|
||||
@@ -100,8 +97,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
using var indentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
if (indirectSpecularMode == IndirectSpecularMode.Matcap)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
||||
@@ -109,8 +105,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
||||
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static readonly GUIContent angelRingOffsetVText = new("Angel Ring Offset V", "Specifies the offset of the angel ring in the V direction.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.AngelRing);
|
||||
protected override bool ShowSection => editor.GetMaterials().All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
|
||||
|
||||
|
||||
@@ -2,12 +2,16 @@ using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.Outline;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty outlineState;
|
||||
|
||||
public static MaterialProperty outlineWidth;
|
||||
public static MaterialProperty outlineWidthMap;
|
||||
|
||||
@@ -25,6 +29,8 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent outlineStateText = new("Outline State", "Enable the outline pass for this material instance.");
|
||||
|
||||
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.");
|
||||
@@ -36,37 +42,43 @@ namespace Misaki.HdrpToon.Editor
|
||||
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.outlineState = FindProperty(OUTLINE_STATE);
|
||||
|
||||
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||
Properties.skyColorAffectOutline = FindProperty("_SkyColorAffectOutline");
|
||||
Properties.skyColorIntensity = FindProperty("_SkyColorIntensity");
|
||||
Properties.outlineWidth = FindProperty(OUTLINE_WIDTH);
|
||||
Properties.outlineWidthMap = FindProperty(OUTLINE_WIDTH_MAP);
|
||||
|
||||
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||
Properties.outlineColor = FindProperty(OUTLINE_COLOR);
|
||||
Properties.outlineColorMap = FindProperty(OUTLINE_COLOR_MAP);
|
||||
Properties.albedoAffectOutline = FindProperty(ALBEDO_AFFECT_OUTLINE);
|
||||
Properties.skyColorAffectOutline = FindProperty(SKY_COLOR_AFFECT_OUTLINE);
|
||||
Properties.skyColorIntensity = FindProperty(SKY_COLOR_INTENSITY);
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty("_UseSmoothedNormal");
|
||||
Properties.fadeIn = FindProperty(OUTLINE_FADE_IN);
|
||||
Properties.fadeOut = FindProperty(OUTLINE_FADE_OUT);
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty(USE_SMOOTHED_NORMAL);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.outlineState, Styles.outlineStateText);
|
||||
|
||||
using var disabledScope = new EditorGUI.DisabledScope(!Properties.outlineState.GetBooleanValue());
|
||||
|
||||
EditorGUILayout.Space();
|
||||
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.skyColorAffectOutline, Styles.skyColorAffectOutlineText);
|
||||
if (Properties.skyColorAffectOutline.GetBooleanValue())
|
||||
{
|
||||
using var skyColorIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -76,6 +77,10 @@ namespace Misaki.HdrpToon.Editor
|
||||
"-1 gives 0% for the Rim Light effect, 0 gives 100% for the Rim Light and Mask effect, 1 gives 100% for the Rim Light and 0% for the Mask effect.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Rimlight;
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Rim Light Settings");
|
||||
protected override bool ShowSection => editor.GetMaterials().All(mat => mat.HasFeature(SurfaceFeature.RimLight));
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.rimLightEnabled = FindProperty("_RimLight");
|
||||
@@ -97,46 +102,32 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.rimLightEnabled, Styles.rimLightEnabledText);
|
||||
EditorGUI.BeginDisabledGroup(Properties.rimLightEnabled.floatValue == 0);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
||||
editor.ShaderProperty(Properties.rimLightStrength, Styles.rimLightStrengthText);
|
||||
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
||||
editor.ShaderProperty(Properties.colorBlendingMode, Styles.colorBlendingModeText);
|
||||
editor.ShaderProperty(Properties.adjustRimLightArea, Styles.adjustRimLightAreaText);
|
||||
editor.ShaderProperty(Properties.rimLightFeatherOff, Styles.rimLightFeatherOffText);
|
||||
editor.ShaderProperty(Properties.lightDirection, Styles.lightDirectionText);
|
||||
EditorGUI.BeginDisabledGroup(Properties.lightDirection.floatValue == 0);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.lightDirectionRimLightLevel,
|
||||
Styles.lightDirectionRimLightLevelText);
|
||||
editor.ShaderProperty(Properties.invertedDirectionRimLight,
|
||||
Styles.invertedDirectionRimLightText);
|
||||
EditorGUI.BeginDisabledGroup(Properties.invertedDirectionRimLight.floatValue == 0);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.invertedRimLightColor, Styles.invertedRimLightColorText);
|
||||
editor.ShaderProperty(Properties.inversedRimLightLevel, Styles.inversedRimLightLevelText);
|
||||
editor.ShaderProperty(Properties.invertedRimLightFeatherOff,
|
||||
Styles.invertedRimLightFeatherOffText);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUI.indentLevel--;
|
||||
editor.TexturePropertySingleLine(Styles.rimLightMaskMapText, Properties.rimLightMaskMap);
|
||||
editor.ShaderProperty(Properties.rimLightMaskLevel, Styles.rimLightMaskLevelText);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
||||
editor.ShaderProperty(Properties.rimLightStrength, Styles.rimLightStrengthText);
|
||||
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
||||
editor.ShaderProperty(Properties.colorBlendingMode, Styles.colorBlendingModeText);
|
||||
editor.ShaderProperty(Properties.adjustRimLightArea, Styles.adjustRimLightAreaText);
|
||||
editor.ShaderProperty(Properties.rimLightFeatherOff, Styles.rimLightFeatherOffText);
|
||||
editor.ShaderProperty(Properties.lightDirection, Styles.lightDirectionText);
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Rimlight;
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Rim Light Settings");
|
||||
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.RimLight);
|
||||
using (var lightDisabledGroup = new EditorGUI.DisabledScope(!Properties.lightDirection.GetBooleanValue()))
|
||||
{
|
||||
using var lightIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
|
||||
editor.ShaderProperty(Properties.lightDirectionRimLightLevel, Styles.lightDirectionRimLightLevelText);
|
||||
editor.ShaderProperty(Properties.invertedDirectionRimLight, Styles.invertedDirectionRimLightText);
|
||||
|
||||
using var invertedDirectionDisabledGroup = new EditorGUI.DisabledScope(!Properties.invertedDirectionRimLight.GetBooleanValue());
|
||||
using var invertedDirectionIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
|
||||
editor.ShaderProperty(Properties.invertedRimLightColor, Styles.invertedRimLightColorText);
|
||||
editor.ShaderProperty(Properties.inversedRimLightLevel, Styles.inversedRimLightLevelText);
|
||||
editor.ShaderProperty(Properties.invertedRimLightFeatherOff, Styles.invertedRimLightFeatherOffText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.rimLightMaskMapText, Properties.rimLightMaskMap);
|
||||
editor.ShaderProperty(Properties.rimLightMaskLevel, Styles.rimLightMaskLevelText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -8,7 +9,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty useShadingRampMap;
|
||||
public static MaterialProperty shadingRampMapState;
|
||||
|
||||
public static MaterialProperty baseColor;
|
||||
public static MaterialProperty baseColorMap;
|
||||
@@ -35,7 +36,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
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 shadingRampMapStateText = new("Shading Ramp Map State", "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.");
|
||||
@@ -53,7 +54,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
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.");
|
||||
public static readonly GUIContent shadingRampMapText = new("Shading Ramp 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;
|
||||
@@ -78,7 +79,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.useShadingRampMap = FindProperty("_Use_Shading_Ramp_Map");
|
||||
Properties.shadingRampMapState = FindProperty("_Use_Shading_Ramp_Map");
|
||||
|
||||
Properties.baseColor = FindProperty("_BaseColor");
|
||||
Properties.baseColorMap = FindProperty("_BaseColorMap");
|
||||
@@ -105,17 +106,17 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.useShadingRampMap, Styles.useShadingRampMapText);
|
||||
editor.ShaderProperty(Properties.shadingRampMapState, Styles.shadingRampMapStateText);
|
||||
editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor);
|
||||
|
||||
if (Properties.useShadingRampMap.GetBooleanValue())
|
||||
if (Properties.shadingRampMapState.GetBooleanValue())
|
||||
{
|
||||
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)
|
||||
if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.Standard))
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
|
||||
|
||||
@@ -127,7 +128,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
}
|
||||
|
||||
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.SDF)
|
||||
if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.SDF))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
@@ -32,42 +33,21 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent NormalMapText =
|
||||
new("Normal Map", "A texture that dictates the bumpiness of the material.");
|
||||
public static readonly GUIContent NormalMapText = new("Normal Map", "A texture that dictates the bumpiness of the material.");
|
||||
public static readonly GUIContent MaskMapText = new("Mask Map", "A texture that dictates the physical properties of the material. R channel for metallic, G channel for ambient occlusion, A channel for smoothness");
|
||||
public static readonly GUIContent MetallicText = new("Metallic", "Specifies the metallic value of the material.");
|
||||
public static readonly GUIContent MetallicRemap = new("Metallic Remap", "Remap the max and min value of metallic");
|
||||
public static readonly GUIContent AORemap = new GUIContent("AO Remap", "Remap the max and min value of ambient occlusion");
|
||||
public static readonly GUIContent RoughnessRemap = new GUIContent("Smoothness Remap", "Remap the max and min value of smoothness");
|
||||
public static readonly GUIContent SmoothnessText = new("Smoothness", "Specifies the smoothness of the material.");
|
||||
|
||||
public static readonly GUIContent MaskMapText = new("Mask Map",
|
||||
"A texture that dictates the physical properties of the material. R channel for metallic, G channel for ambient occlusion, A channel for smoothness");
|
||||
public static readonly GUIContent AnisotropyMapText = new("Anisotropy Map", "Specifies the anisotropy map of the material.");
|
||||
|
||||
public static readonly GUIContent KKColorText = new("KK specular Color", "Specifies the color of KK specular.");
|
||||
public static readonly GUIContent BSDFContributionText = new("BSDF Contribution", "BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation");
|
||||
|
||||
public static readonly GUIContent MetallicText =
|
||||
new("Metallic", "Specifies the metallicness of the material.");
|
||||
|
||||
public static readonly GUIContent MetallicRemap =
|
||||
new("Metallic Remap", "Remap the max and min value of metallic");
|
||||
|
||||
public static readonly GUIContent AORemap =
|
||||
new GUIContent("AO Remap", "Remap the max and min value of ambient occlusion");
|
||||
|
||||
public static readonly GUIContent RoughnessRemap =
|
||||
new GUIContent("Smoothness Remap", "Remap the max and min value of smoothness");
|
||||
|
||||
public static readonly GUIContent SmoothnessText =
|
||||
new("Smoothness", "Specifies the smoothness of the material.");
|
||||
|
||||
public static readonly GUIContent AnisotropyMapText =
|
||||
new("Anisotropy Map", "Specifies the anisotropy map of the material.");
|
||||
|
||||
public static readonly GUIContent KKColorText = new("KK specular Color",
|
||||
"Specifies the color of KK specular.");
|
||||
|
||||
public static readonly GUIContent BSDFContributionText = new("BSDF Contribution",
|
||||
"BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation");
|
||||
|
||||
public static readonly GUIContent SpecularColorMapText = new("Specular Color Map",
|
||||
"Specifies the specular color map of the material.");
|
||||
|
||||
public static readonly GUIContent SpecRemap = new("Specular Remap",
|
||||
"Feather and step value of Toon Specular");
|
||||
public static readonly GUIContent SpecularColorMapText = new("Specular Color Map", "Specifies the specular color map of the material.");
|
||||
public static readonly GUIContent SpecRemap = new("Specular Remap", "Feather and step value of Toon Specular");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs;
|
||||
@@ -99,35 +79,18 @@ namespace Misaki.HdrpToon.Editor
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.KeywordTexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale);
|
||||
//var materials = editor.GetMaterials().ToList();
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"),
|
||||
// Properties.NormalMap.textureValue != null);
|
||||
//}
|
||||
|
||||
var pbrMode = SurfaceOptionsScope.GetPBRMode();
|
||||
if (pbrMode != PBRMode.Off)
|
||||
if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.Off))
|
||||
{
|
||||
if (editor.KeywordTexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap))
|
||||
{
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.EnableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
//}
|
||||
|
||||
editor.MinMaxShaderProperty(Properties.MetallicRemapMin, Properties.MetallicRemapMax, 0, 1, Styles.MetallicRemap);
|
||||
editor.MinMaxShaderProperty(Properties.AORemapMin, Properties.AORemapMax, 0, 1, Styles.AORemap);
|
||||
editor.MinMaxShaderProperty(Properties.RoughnessRemapMin, Properties.RoughnessRemapMax, 0, 1, Styles.RoughnessRemap);
|
||||
}
|
||||
else
|
||||
{
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
//}
|
||||
|
||||
if (pbrMode != PBRMode.KKHair)
|
||||
if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.KKHair))
|
||||
{
|
||||
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
|
||||
}
|
||||
@@ -135,72 +98,24 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.SetKeyword("_MASKMAP", false);
|
||||
editor.SetKeyword("_ANISOTROPY_MAP", false);
|
||||
editor.SetKeyword("_SPECULAR_COLOR_MAP", false);
|
||||
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
//}
|
||||
if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.KKHair))
|
||||
{
|
||||
editor.KeywordTexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap, Properties.Anisotropy);
|
||||
if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.KKHair))
|
||||
{
|
||||
editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
|
||||
editor.ShaderProperty(Properties.BSDFContribution, Styles.BSDFContributionText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Anisotropy Map only ST");
|
||||
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
|
||||
}
|
||||
|
||||
switch (pbrMode)
|
||||
else if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Toon))
|
||||
{
|
||||
case PBRMode.Anisotropy or PBRMode.KKHair:
|
||||
{
|
||||
editor.KeywordTexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap, Properties.Anisotropy);
|
||||
if (pbrMode == PBRMode.KKHair)
|
||||
{
|
||||
editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
|
||||
editor.ShaderProperty(Properties.BSDFContribution, Styles.BSDFContributionText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Anisotropy Map only ST");
|
||||
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
|
||||
//if (Properties.AnisotropyMap.textureValue == null)
|
||||
//{
|
||||
// foreach (var material in materials)
|
||||
// {
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var material in materials)
|
||||
// {
|
||||
// material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
// }
|
||||
//}
|
||||
|
||||
break;
|
||||
}
|
||||
case PBRMode.Toon:
|
||||
{
|
||||
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
|
||||
//if (Properties.SpecularColorMap.textureValue == null)
|
||||
//{
|
||||
// foreach (var material in materials)
|
||||
// {
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var material in materials)
|
||||
// {
|
||||
// material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
// }
|
||||
//}
|
||||
|
||||
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
|
||||
break;
|
||||
}
|
||||
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
|
||||
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,21 +42,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
||||
|
||||
public static ShadingMode GetShadingMode()
|
||||
{
|
||||
return (ShadingMode)Properties.shadingMode.floatValue;
|
||||
}
|
||||
|
||||
public static PBRMode GetPBRMode()
|
||||
{
|
||||
return (PBRMode)Properties.pbrMode.floatValue;
|
||||
}
|
||||
|
||||
public static bool HasFeature(SurfaceFeatureFlags feature)
|
||||
{
|
||||
return ((SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue & feature) != 0;
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||
@@ -100,17 +85,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
}
|
||||
|
||||
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 editor.GetMaterials())
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, HasFeature(SurfaceFeatureFlags.Outline));
|
||||
}
|
||||
}
|
||||
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user