Added ShadowScope;
Renamed PBRScope to SurfaceInputsScope;
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f611f3d462b5414f9241ed80e4f1d0bb
|
||||
timeCreated: 1738325165
|
||||
57
Editor/MeterialEditor/UIScopes/ShadowScope.cs
Normal file
57
Editor/MeterialEditor/UIScopes/ShadowScope.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class ShadowScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty receiveLightShadow;
|
||||
public static MaterialProperty receiveScreenSpaceShadow;
|
||||
public static MaterialProperty receiveHairShadow;
|
||||
|
||||
public static MaterialProperty shadowDistanceBias;
|
||||
public static MaterialProperty shadowNormalBias;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent receiveLightShadowText = new("Receive Light Shadow", "Enable to receive shadow from light.");
|
||||
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
|
||||
public static readonly GUIContent receiveScreenSpaceShadowText = new("Receive Screen Space Shadow", "Enable to receive screen space shadow.");
|
||||
public static readonly GUIContent lightShadowBiasText = new("Light Shadow Bias", "Specifies the bias of the light shadow.");
|
||||
public static readonly GUIContent lightShadowNormalBiasText = new("Light Shadow Normal Bias", "Specifies the normal bias of the light shadow.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Shadow;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shadow Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.receiveLightShadow = FindProperty("_Receive_Light_Shadow");
|
||||
Properties.receiveScreenSpaceShadow = FindProperty("_Receive_Screen_Space_Shadow");
|
||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||
|
||||
Properties.shadowDistanceBias = FindProperty("_ShadowDistanceBias");
|
||||
Properties.shadowNormalBias = FindProperty("_ShadowNormalBias");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.receiveLightShadow, Styles.receiveLightShadowText);
|
||||
if (Properties.receiveLightShadow.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.receiveScreenSpaceShadow, Styles.receiveScreenSpaceShadowText);
|
||||
}
|
||||
editor.ShaderProperty(Properties.receiveHairShadow, Styles.receiveHairShadowText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.shadowDistanceBias, Styles.lightShadowBiasText);
|
||||
editor.ShaderProperty(Properties.shadowNormalBias, Styles.lightShadowNormalBiasText);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/ShadowScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/ShadowScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f9bb5393aec4e648a1c3b2ba0d566c3
|
||||
@@ -1,17 +1,14 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class PBRScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
public class SurfaceInputsScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty PbrMode;
|
||||
public static MaterialProperty NormalMap;
|
||||
public static MaterialProperty NormalMapScale;
|
||||
public static MaterialProperty MaskMap;
|
||||
@@ -35,13 +32,11 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent PbrModeText = new("PBR Mode", "PBR Mode");
|
||||
|
||||
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: Metallic, G: Occlusion, A: Smoothness");
|
||||
"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 =
|
||||
@@ -75,21 +70,11 @@ 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");
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs;
|
||||
protected override GUIContent Header => new("Surface Inputs");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.PbrMode = FindProperty("_PBR_Mode");
|
||||
Properties.NormalMap = FindProperty("_NormalMap");
|
||||
Properties.NormalMapScale = FindProperty("_NormalScale");
|
||||
Properties.MaskMap = FindProperty("_MaskMap");
|
||||
@@ -113,62 +98,62 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.PbrMode, Styles.PbrModeText);
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(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);
|
||||
}
|
||||
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 = (PBRMode)Properties.PbrMode.floatValue;
|
||||
var pbrMode = SurfaceOptionsScope.GetPBRMode();
|
||||
if (pbrMode != PBRMode.Off)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap);
|
||||
|
||||
if (Properties.MaskMap.textureValue == null)
|
||||
if (editor.KeywordTexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap))
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
}
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.EnableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
//}
|
||||
|
||||
if (pbrMode != PBRMode.KKHair)
|
||||
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
|
||||
editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText);
|
||||
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)
|
||||
//foreach (var material in materials)
|
||||
//{
|
||||
// material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
//}
|
||||
|
||||
if (pbrMode != PBRMode.KKHair)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
|
||||
}
|
||||
|
||||
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);
|
||||
editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
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"));
|
||||
//}
|
||||
}
|
||||
|
||||
switch (pbrMode)
|
||||
{
|
||||
case PBRMode.Anisotropy or PBRMode.KKHair:
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap,
|
||||
Properties.Anisotropy);
|
||||
editor.KeywordTexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap, Properties.Anisotropy);
|
||||
if (pbrMode == PBRMode.KKHair)
|
||||
{
|
||||
editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
|
||||
@@ -178,44 +163,42 @@ namespace Misaki.HdrpToon.Editor
|
||||
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"));
|
||||
}
|
||||
}
|
||||
//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.TexturePropertySingleLine(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.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);
|
||||
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 184fb730617fcf24592d8e6c49e2029a
|
||||
@@ -18,7 +18,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static MaterialProperty materialType;
|
||||
public static MaterialProperty pbrMode;
|
||||
|
||||
public static MaterialProperty receiveHairShadow;
|
||||
public static MaterialProperty hairBlendingTarget;
|
||||
public static MaterialProperty surfaceFeatures;
|
||||
}
|
||||
@@ -35,7 +34,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
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");
|
||||
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
||||
}
|
||||
@@ -49,6 +47,11 @@ namespace Misaki.HdrpToon.Editor
|
||||
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;
|
||||
@@ -66,7 +69,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.materialType = FindProperty("_Material_Type");
|
||||
Properties.pbrMode = FindProperty("_PBR_Mode");
|
||||
|
||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||
}
|
||||
@@ -88,8 +90,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user