Added UtsSingleLightLoop

This commit is contained in:
2025-03-23 17:53:36 +09:00
parent ee0b720b6d
commit ea3e83157c
18 changed files with 142 additions and 234 deletions

View File

@@ -3,6 +3,8 @@ using System.Linq;
using UnityEditor;
using UnityEngine;
using static Misaki.HdrpToon.UtsShaderPropertyName.AngelRing;
namespace Misaki.HdrpToon.Editor
{
internal class AngelRingScope : MaterialUIScope<ShaderGUIExpandable>
@@ -24,7 +26,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 => editor.GetMaterials().All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
protected override bool ShowSection => materials.All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
@@ -32,11 +34,11 @@ namespace Misaki.HdrpToon.Editor
public override void LoadMaterialProperties()
{
Properties.angelRingColor = FindProperty("_AngelRingColor");
Properties.angelRingColorMap = FindProperty("_AngelRingColorMap");
Properties.angelRingIntensity = FindProperty("_AngelRingIntensity");
Properties.angelRingOffsetU = FindProperty("_AngelRingOffsetU");
Properties.angelRingOffsetV = FindProperty("_AngelRingOffsetV");
Properties.angelRingColor = FindProperty(ANGEL_RING_COLOR);
Properties.angelRingColorMap = FindProperty(ANGEL_RING_COLOR_MAP);
Properties.angelRingIntensity = FindProperty(ANGEL_RING_INTENSITY);
Properties.angelRingOffsetU = FindProperty(ANGEL_RING_OFFSET_U);
Properties.angelRingOffsetV = FindProperty(ANGEL_RING_OFFSET_V);
}
protected override void DrawContent()

View File

@@ -21,14 +21,6 @@ namespace Misaki.HdrpToon.Editor
public static MaterialProperty lightBaseRimLight;
public static MaterialProperty lightDirectionRimLightLevel;
//public static MaterialProperty lightDirection;
//public static MaterialProperty invertedDirectionRimLight;
//public static MaterialProperty invertedRimLightColor;
//public static MaterialProperty inversedRimLightLevel;
//public static MaterialProperty invertedRimLightFeatherOff;
//public static MaterialProperty rimLightMaskMap;
//public static MaterialProperty rimLightMaskLevel;
}
private static class Styles
@@ -43,35 +35,11 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent lightBaseRimLightText = new("Light Base Rim Light", "Enable to let rim light calculate per light.");
public static readonly GUIContent lightDirectionRimLightLevelText = new("Light Direction Level", "Specifies intensity of Rim Light in the light source direction,");
//public static readonly GUIContent lightDirectionText =
// new("Light Direction",
// "When Enabled, rim light is generated only in the direction of the light source.");
//public static readonly GUIContent invertedDirectionRimLightText =
// new("Inverted Direction Rim Light", "Rim light from inverted/antipodean direction.");
//public static readonly GUIContent invertedRimLightColorText =
// new("Inverted Rim Light Color", "Specifies the color of inverted/antipodean rim light.");
//public static readonly GUIContent inversedRimLightLevelText =
// new("Inversed Rim Light Level", "Specifies Inverted/Antipodean Rim Light Level.");
//public static readonly GUIContent invertedRimLightFeatherOffText =
// new("Inverted Rim Light Feather Off", "Disable Inverted Rim light feather.");
//public static readonly GUIContent rimLightMaskMapText = new("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 rimLightMaskLevelText =
// new("Rim Light Mask Level",
// "-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));
protected override bool ShowSection => materials.All(mat => mat.HasFeature(SurfaceFeature.RimLight));
public override void LoadMaterialProperties()
{
@@ -85,14 +53,6 @@ namespace Misaki.HdrpToon.Editor
Properties.lightBaseRimLight = FindProperty(LIGHT_BASE_RIM_LIGHT);
Properties.lightDirectionRimLightLevel = FindProperty(LIGHT_DIRECTION_RIM_LIGHT_LEVEL);
//Properties.lightDirection = FindProperty(LIGHT_DIRECTION);
//Properties.invertedDirectionRimLight = FindProperty(INVERTED_DIRECTION_RIM_LIGHT);
//Properties.invertedRimLightColor = FindProperty(INVERTED_RIM_LIGHT_COLOR);
//Properties.inversedRimLightLevel = FindProperty(INVERSED_RIM_LIGHT_LEVEL);
//Properties.invertedRimLightFeatherOff = FindProperty(INVERTED_RIM_LIGHT_FEATHER_OFF);
//Properties.rimLightMaskMap = FindProperty(RIM_LIGHT_MASK_MAP);
//Properties.rimLightMaskLevel = FindProperty(RIM_LIGHT_MASK_LEVEL);
}
protected override void DrawContent()
@@ -119,25 +79,6 @@ namespace Misaki.HdrpToon.Editor
{
editor.ShaderProperty(Properties.lightDirectionRimLightLevel, Styles.lightDirectionRimLightLevelText);
}
//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);
}
}
}
}

View File

@@ -27,6 +27,8 @@ namespace Misaki.HdrpToon.Editor
public static MaterialProperty shadingRampMap;
public static MaterialProperty shadingIndex;
public static MaterialProperty shadingRampMaskMap;
public static MaterialProperty shadingRampMask;
public static MaterialProperty sdfShadingMap;
public static MaterialProperty sdfShadowLevel;
@@ -52,9 +54,11 @@ namespace Misaki.HdrpToon.Editor
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 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.");
public static readonly GUIContent shadingRampMaskMapText = new("Shading Ramp Mask Map", "A texture that contains the mask for the shading ramp map.");
public static readonly GUIContent sdfHighlightStrengthText = new("SDF Highlight Strength", "Control the strength of the highlight in the SDF shading map.");
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor;
@@ -95,13 +99,15 @@ namespace Misaki.HdrpToon.Editor
Properties.secondShadeColorStep = FindProperty("_2ndShadeColorStep");
Properties.secondShadeColorFeather = FindProperty("_2ndShadeColorFeather");
Properties.shadingRampMap = FindProperty("_ShadingRampMap");
Properties.shadingIndex = FindProperty("_ShadingIndex");
Properties.shadingRampMaskMap = FindProperty("_ShadingRampMaskMap");
Properties.shadingRampMask = FindProperty("_ShadingRampMask");
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()
@@ -112,11 +118,12 @@ namespace Misaki.HdrpToon.Editor
if (Properties.shadingRampMapState.GetBooleanValue())
{
editor.TexturePropertySingleLine(Styles.shadingRampMapText, Properties.shadingRampMap, Properties.shadingIndex);
editor.KeywordTexturePropertySingleLine(Styles.shadingRampMaskMapText, Properties.shadingRampMaskMap, Properties.shadingRampMask, "_SHADING_RAMP_MASK_MAP");
}
else
{
DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText);
if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.Standard))
if (materials.All(material => material.GetShadingMode() == ShadingMode.Standard))
{
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
@@ -128,7 +135,7 @@ namespace Misaki.HdrpToon.Editor
}
}
if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.SDF))
if (materials.All(material => material.GetShadingMode() == ShadingMode.SDF))
{
EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);

View File

@@ -108,7 +108,7 @@ namespace Misaki.HdrpToon.Editor
{
editor.KeywordTexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale);
if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.Off))
if (materials.All(mat => mat.GetPBRMode() != PBRMode.Off))
{
if (editor.KeywordTexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap))
{
@@ -118,7 +118,7 @@ namespace Misaki.HdrpToon.Editor
}
else
{
if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.KKHair))
if (materials.All(mat => mat.GetPBRMode() != PBRMode.KKHair))
{
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
}
@@ -127,10 +127,10 @@ namespace Misaki.HdrpToon.Editor
}
}
if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.KKHair))
if (materials.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))
if (materials.All(mat => mat.GetPBRMode() == PBRMode.KKHair))
{
editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
editor.ShaderProperty(Properties.BSDFContribution, Styles.BSDFContributionText);
@@ -140,7 +140,7 @@ namespace Misaki.HdrpToon.Editor
EditorGUILayout.LabelField("Anisotropy Map only ST");
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
}
else if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Toon))
else if (materials.All(mat => mat.GetPBRMode() == PBRMode.Toon))
{
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
@@ -157,7 +157,7 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.emissiveIntensity, Styles.emissiveIntensityText);
if (EditorGUI.EndChangeCheck())
{
foreach (var material in editor.GetMaterials())
foreach (var material in materials)
{
if (material.HasProperty(EMISSIVE_COLOR_LDR) && material.HasProperty(EMISSIVE_INTENSITY) && material.HasProperty(EMISSIVE_COLOR))
{

View File

@@ -76,7 +76,7 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
if (EditorGUI.EndChangeCheck())
{
foreach (var material in editor.GetMaterials())
foreach (var material in materials)
{
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, Properties.materialType.GetEnumValue<MaterialType>() == MaterialType.FrontHair);
}
@@ -88,7 +88,7 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
if (EditorGUI.EndChangeCheck())
{
foreach (var material in editor.GetMaterials())
foreach (var material in materials)
{
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
}