Changing UI style;

Updating RImeLight;
This commit is contained in:
2025-02-03 23:01:57 +09:00
parent 886432db7b
commit de370f845e
11 changed files with 157 additions and 79 deletions

View File

@@ -75,9 +75,11 @@ namespace Misaki.HdrpToon.Editor
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
}
using var indentLevelScope = new EditorGUI.IndentLevelScope();
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
{
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
@@ -95,9 +97,11 @@ namespace Misaki.HdrpToon.Editor
if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
}
using var indentLevelScope = new EditorGUI.IndentLevelScope();
if (indirectSpecularMode == IndirectSpecularMode.Matcap)
{
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);

View File

@@ -9,7 +9,6 @@ namespace Misaki.HdrpToon.Editor
{
private static class Properties
{
public static MaterialProperty rimLightEnabled;
public static MaterialProperty rimLightColor;
public static MaterialProperty rimLightStrength;
public static MaterialProperty rimLightLevel;
@@ -28,9 +27,6 @@ namespace Misaki.HdrpToon.Editor
private static class Styles
{
public static readonly GUIContent rimLightEnabledText = new("Rim Light",
"A light that hits the 3D model from behind and emphasizes the contours of the model from the front.");
public static readonly GUIContent rimLightColorText =
new("Rim Light Color", "Specifies the color of rim light.");
@@ -83,10 +79,9 @@ namespace Misaki.HdrpToon.Editor
public override void LoadMaterialProperties()
{
Properties.rimLightEnabled = FindProperty("_RimLight");
Properties.rimLightColor = FindProperty("_RimLightColor");
Properties.rimLightStrength = FindProperty("_RimLight_Strength");
Properties.rimLightLevel = FindProperty("_RimLight_Power");
Properties.rimLightStrength = FindProperty("_RimLightStrength");
Properties.rimLightLevel = FindProperty("_RimLightLevel");
Properties.colorBlendingMode = FindProperty("_Is_BlendAddToRimColor");
Properties.adjustRimLightArea = FindProperty("_RimLight_InsideMask");
Properties.rimLightFeatherOff = FindProperty("_RimLight_FeatherOff");

View File

@@ -4,6 +4,8 @@ using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
using static Misaki.HdrpToon.UtsShaderPropertyName.SurfaceInputs;
namespace Misaki.HdrpToon.Editor
{
public class SurfaceInputsScope : MaterialUIScope<ShaderGUIExpandable>
@@ -12,23 +14,33 @@ namespace Misaki.HdrpToon.Editor
{
public static MaterialProperty NormalMap;
public static MaterialProperty NormalMapScale;
public static MaterialProperty MaskMap;
public static MaterialProperty Metallic;
public static MaterialProperty MetallicRemapMin;
public static MaterialProperty MetallicRemapMax;
public static MaterialProperty AORemapMin;
public static MaterialProperty AORemapMax;
public static MaterialProperty RoughnessRemapMin;
public static MaterialProperty RoughnessRemapMax;
public static MaterialProperty Smoothness;
public static MaterialProperty SmoothnessRemapMin;
public static MaterialProperty SmoothnessRemapMax;
public static MaterialProperty AnisotropyMap;
public static MaterialProperty Anisotropy;
public static MaterialProperty KKColor;
public static MaterialProperty BSDFContribution;
public static MaterialProperty SpecularColorMap;
public static MaterialProperty SpecularColor;
public static MaterialProperty SpecularFeather;
public static MaterialProperty SpecularStep;
public static MaterialProperty emissiveColorLDR;
public static MaterialProperty emissiveColorMap;
public static MaterialProperty emissiveIntensity;
public static MaterialProperty albedoAffectEmissive;
public static MaterialProperty emissiveExposureWeight;
}
private static class Styles
@@ -37,9 +49,9 @@ namespace Misaki.HdrpToon.Editor
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 AORemap = new("AO Remap", "Remap the max and min value of ambient occlusion");
public static readonly GUIContent SmoothnessText = new("Smoothness", "Specifies the smoothness of the material.");
public static readonly GUIContent SmoothnessRemapText = new("Smoothness Remap", "Remap the max and min value of smoothness");
public static readonly GUIContent AnisotropyMapText = new("Anisotropy Map", "Specifies the anisotropy map of the material.");
@@ -48,6 +60,12 @@ namespace Misaki.HdrpToon.Editor
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 emissiveColorText = new("Emissive Color", "The color and color map to set for emissive effect.");
public static readonly GUIContent albedoAffectEmissiveText = new("Albedo Affect Emissive", "Enable to affect emissive color with base color");
public static readonly GUIContent emissiveIntensityText = new("Emissive Intensity", "Set the intensity of the emissive color,in Nits");
public static readonly GUIContent emissiveExposureWeightText = new("Exposure Weight", "Controls how the camera exposure influences the perceived intensity of the emissivity. A weight of 0 means that the emissive intensity is calculated ignoring the exposure; increasing this weight progressively increases the influence of exposure on the final emissive value.");
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs;
@@ -57,23 +75,33 @@ namespace Misaki.HdrpToon.Editor
{
Properties.NormalMap = FindProperty("_NormalMap");
Properties.NormalMapScale = FindProperty("_NormalScale");
Properties.MaskMap = FindProperty("_MaskMap");
Properties.Metallic = FindProperty("_Metallic");
Properties.MetallicRemapMin = FindProperty("_MetallicRemapMin");
Properties.MetallicRemapMax = FindProperty("_MetallicRemapMax");
Properties.AORemapMin = FindProperty("_AORemapMin");
Properties.AORemapMax = FindProperty("_AORemapMax");
Properties.RoughnessRemapMin = FindProperty("_SmoothnessRemapMin");
Properties.RoughnessRemapMax = FindProperty("_SmoothnessRemapMax");
Properties.SmoothnessRemapMin = FindProperty("_SmoothnessRemapMin");
Properties.SmoothnessRemapMax = FindProperty("_SmoothnessRemapMax");
Properties.Smoothness = FindProperty("_Smoothness");
Properties.AnisotropyMap = FindProperty("_AnisotropyMap");
Properties.Anisotropy = FindProperty("_Anisotropy");
Properties.KKColor = FindProperty("_KKColor");
Properties.BSDFContribution = FindProperty("_BSDFContribution");
Properties.SpecularColorMap = FindProperty("_SpecularColorMap");
Properties.SpecularColor = FindProperty("_SpecularColor");
Properties.SpecularFeather = FindProperty("_ToonSpecularFeather");
Properties.SpecularStep = FindProperty("_ToonSpecularStep");
Properties.emissiveColorLDR = FindProperty(EMISSIVE_COLOR_LDR);
Properties.emissiveColorMap = FindProperty(EMISSIVE_COLOR_MAP);
Properties.albedoAffectEmissive = FindProperty(ALBEDO_AFFECT_EMISSIVE);
Properties.emissiveIntensity = FindProperty(EMISSIVE_INTENSITY);
Properties.emissiveExposureWeight = FindProperty(EMISSIVE_EXPOSURE_WEIGHT);
}
protected override void DrawContent()
@@ -86,7 +114,7 @@ namespace Misaki.HdrpToon.Editor
{
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.MinMaxShaderProperty(Properties.SmoothnessRemapMin, Properties.SmoothnessRemapMax, 0, 1, Styles.SmoothnessRemapText);
}
else
{
@@ -117,6 +145,34 @@ namespace Misaki.HdrpToon.Editor
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
}
EditorGUILayout.Space();
using (var EmissiveIntentLevel = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Emissive", EditorStyles.boldLabel);
}
EditorGUI.BeginChangeCheck();
editor.KeywordTexturePropertySingleLine(Styles.emissiveColorText, Properties.emissiveColorMap, Properties.emissiveColorLDR, "_EMISSIVE_COLOR_MAP");
editor.ShaderProperty(Properties.emissiveIntensity, Styles.emissiveIntensityText);
if (EditorGUI.EndChangeCheck())
{
editor.ApplyChange(material =>
{
if (material.HasProperty(EMISSIVE_COLOR_LDR) && material.HasProperty(EMISSIVE_INTENSITY) && material.HasProperty(EMISSIVE_COLOR))
{
// Important: The color picker for kEmissiveColorLDR is LDR and in sRGB color space but Unity don't perform any color space conversion in the color
// picker BUT only when sending the color data to the shader... So as we are doing our own calculation here in C#, we must do the conversion ourselves.
var emissiveColorLDR = material.GetColor(EMISSIVE_COLOR_LDR);
var emissiveColorLDRLinear = new Color(Mathf.GammaToLinearSpace(emissiveColorLDR.r), Mathf.GammaToLinearSpace(emissiveColorLDR.g), Mathf.GammaToLinearSpace(emissiveColorLDR.b));
material.SetColor(EMISSIVE_COLOR, emissiveColorLDRLinear * material.GetFloat(EMISSIVE_INTENSITY));
}
});
}
EditorGUILayout.Space();
editor.ShaderProperty(Properties.albedoAffectEmissive, Styles.albedoAffectEmissiveText);
editor.ShaderProperty(Properties.emissiveExposureWeight, Styles.emissiveExposureWeightText);
}
}
}