Fixed the engergy conservation problem when pbr mode is toon.

This commit is contained in:
2025-05-13 21:35:52 +09:00
parent 961db806e9
commit d19322b768
11 changed files with 72 additions and 53 deletions

View File

@@ -10,6 +10,8 @@ namespace Misaki.HdrpToon.Editor
{
private static class Properties
{
public static MaterialProperty diffuseMin;
public static MaterialProperty lightIntensityMultiplier;
public static MaterialProperty clampLightColor;
@@ -18,6 +20,8 @@ namespace Misaki.HdrpToon.Editor
private static class Styles
{
public static readonly GUIContent diffuseMinText = new("Minimal diffuse contribution", "Specifies the minimum contribution of the base color to the diffuse light. Keep it 0 to make sure energy conservation.");
public static readonly GUIContent lightIntensityMultiplierText = new("Light Intensity Multiplier", "Specifies the intensity multiplier of the light.");
public static readonly GUIContent clampLightColorText = new("Clamp Light Color", "Specifies whether to clamp the light color.");
@@ -30,6 +34,8 @@ namespace Misaki.HdrpToon.Editor
public override void LoadMaterialProperties()
{
Properties.diffuseMin = FindProperty(MINIMAL_DIFFUSE_CONTRIBUTION);
Properties.lightIntensityMultiplier = FindProperty(LIGHT_INTENSITY_MULTIPLIER);
Properties.clampLightColor = FindProperty(CLAMP_LIGHT_COLOR);
@@ -38,10 +44,12 @@ namespace Misaki.HdrpToon.Editor
protected override void DrawContent()
{
editor.ShaderProperty(Properties.diffuseMin, Styles.diffuseMinText);
editor.ShaderProperty(Properties.lightIntensityMultiplier, Styles.lightIntensityMultiplierText);
editor.ShaderProperty(Properties.clampLightColor, Styles.clampLightColorText);
editor.ShaderProperty(Properties.lightLoopMode, Styles.lightLoopModeText);
}
}
}
}

View File

@@ -124,7 +124,11 @@ namespace Misaki.HdrpToon.Editor
}
else
{
if (materials.All(mat => mat.GetPBRMode() != PBRMode.KKHair))
if (materials.All(mat =>
{
var pbrMode = mat.GetPBRMode();
return pbrMode != PBRMode.KKHair && pbrMode != PBRMode.Toon;
}))
{
editor.ShaderProperty(Properties.metallic, Styles.metallicText);
}

View File

@@ -8,6 +8,12 @@ namespace Misaki.HdrpToon.Editor
{
private GUIStyle _headerStyle;
public override void ValidateMaterial(Material material)
{
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, (MaterialType)material.GetInteger("_Material_Type") == MaterialType.FrontHair);
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, material.GetInteger("_HairBlendingTarget") == 1);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
if (!initialized)