Update ShadingColorScope;

This commit is contained in:
Misaki
2025-02-01 14:44:23 +09:00
parent 27e743755d
commit a9b989fb19
9 changed files with 123 additions and 146 deletions

View File

@@ -1,5 +1,5 @@
using System.Linq; using Misaki.ShaderGUI;
using Misaki.ShaderGUI; using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditor.Rendering; using UnityEditor.Rendering;
using UnityEngine; using UnityEngine;
@@ -75,6 +75,18 @@ namespace Misaki.HdrpToon.Editor
"Feather and step value of Toon Specular"); "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");
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.PbrMode = FindProperty("_PBR_Mode"); Properties.PbrMode = FindProperty("_PBR_Mode");
@@ -104,21 +116,21 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.PbrMode, Styles.PbrModeText); editor.ShaderProperty(Properties.PbrMode, Styles.PbrModeText);
EditorGUILayout.Space(); EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale); editor.TexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale);
var materials = GetMaterials().ToList(); var materials = editor.GetMaterials().ToList();
foreach (Material material in materials) foreach (var material in materials)
{ {
material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"), material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"),
Properties.NormalMap.textureValue != null); Properties.NormalMap.textureValue != null);
} }
PBRMode pbrMode = (PBRMode)Properties.PbrMode.floatValue; var pbrMode = (PBRMode)Properties.PbrMode.floatValue;
if (pbrMode != PBRMode.Off) if (pbrMode != PBRMode.Off)
{ {
editor.TexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap); editor.TexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap);
if (Properties.MaskMap.textureValue == null) if (Properties.MaskMap.textureValue == null)
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
} }
@@ -129,7 +141,7 @@ namespace Misaki.HdrpToon.Editor
} }
else else
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
} }
@@ -143,7 +155,7 @@ namespace Misaki.HdrpToon.Editor
} }
else else
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
@@ -168,14 +180,14 @@ namespace Misaki.HdrpToon.Editor
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap); editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
if (Properties.AnisotropyMap.textureValue == null) if (Properties.AnisotropyMap.textureValue == null)
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
} }
} }
else else
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
} }
@@ -189,14 +201,14 @@ namespace Misaki.HdrpToon.Editor
Properties.SpecularColor); Properties.SpecularColor);
if (Properties.SpecularColorMap.textureValue == null) if (Properties.SpecularColorMap.textureValue == null)
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
} }
} }
else else
{ {
foreach (Material material in materials) foreach (var material in materials)
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
} }
@@ -208,17 +220,5 @@ namespace Misaki.HdrpToon.Editor
} }
} }
} }
private enum PBRMode
{
Off,
Standard,
Anisotropy,
KKHair,
Toon
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.PBR;
protected override GUIContent Header => new("PBR Settings");
} }
} }

View File

@@ -8,6 +8,8 @@ namespace Misaki.HdrpToon.Editor
{ {
private static class Properties private static class Properties
{ {
public static MaterialProperty useShadingRampMap;
public static MaterialProperty baseColor; public static MaterialProperty baseColor;
public static MaterialProperty baseColorMap; public static MaterialProperty baseColorMap;
public static MaterialProperty applyTo1stShadingMapEnable; public static MaterialProperty applyTo1stShadingMapEnable;
@@ -17,91 +19,67 @@ namespace Misaki.HdrpToon.Editor
public static MaterialProperty secondShadingColor; public static MaterialProperty secondShadingColor;
public static MaterialProperty secondShadingMap; public static MaterialProperty secondShadingMap;
public static MaterialProperty sdfShadowMap; public static MaterialProperty firstShadeColorStep;
public static MaterialProperty firstShadeColorFeather;
public static MaterialProperty secondShadeColorStep;
public static MaterialProperty secondShadeColorFeather;
public static MaterialProperty shadingRampMap;
public static MaterialProperty shadingIndex;
public static MaterialProperty sdfShadingMap;
public static MaterialProperty sdfShadowLevel; public static MaterialProperty sdfShadowLevel;
public static MaterialProperty sdfSmoothLevel; public static MaterialProperty sdfSmoothLevel;
public static MaterialProperty sdfHighlightStrength; public static MaterialProperty sdfHighlightStrength;
public static MaterialProperty sdfHighlightSmoothLevel;
public static MaterialProperty shadingGradeMap;
public static MaterialProperty shadingIndex;
} }
private static class Styles private static class Styles
{ {
public static readonly GUIContent baseMapText = new("Base Map", "Base Color : Texture(sRGB) x Color(RGB) Default:White"); 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 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."); public static readonly GUIContent applyTo1stShadingMapText = new("Apply to 1st shading map", "Apply Base map to the 1st shading map.");
public static readonly GUIContent firstShadingMapText = new("1st Shading Map", "The map used for the brighter portions of the shadow."); public static readonly GUIContent firstShadingMapText = new("1st Shading Map", "The map used for the brighter portions of the shadow.");
public static readonly GUIContent applyTo2ndShadingMapText = new("Apply to 2nd shading map", "Apply Base map or the 1st shading map to the 2st shading map."); public static readonly GUIContent applyTo2ndShadingMapText = new("Apply to 2nd shading map", "Apply Base map or the 1st shading map to the 2st shading map.");
public static readonly GUIContent secondShadingMapText = new("2nd Shading Map", "The map used for the darker portions of the shadow."); public static readonly GUIContent secondShadingMapText = new("2nd Shading Map", "The map used for the darker portions of the shadow.");
public static readonly GUIContent sdfShadowMapText = new("SDF Shadow Map", "SDF Shadow Map"); public static readonly GUIContent firstShadeColorStepText = new("1st Shade Color Step", "Sets the step between the Base color and 1st Shade Color, the same as the BaseColor_Step property.");
public static readonly GUIContent sdfShadowLevelText = new("SDF Shadow Level", "SDF Shadow Level"); public static readonly GUIContent firstShadeColorFeatherText = new("1st Shade Color Feather", "Sets the feather between the Base color and 1st Shade Color, the same as the BaseColor_Feather property.");
public static readonly GUIContent sdfSmoothLevelText = new("SDF Smooth Level", "SDF Smooth Level"); public static readonly GUIContent secondShadeColorStepText = new("2nd Shade Color Step", "Sets the step between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorStep property.");
public static readonly GUIContent sdfHighlightStrengthText = new("SDF Highlight Strength", "SDF Highlight Strength"); public static readonly GUIContent secondShadeColorFeatherText = new("2nd Shade Color Feather", "Sets the feather between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorFeather property.");
public static readonly GUIContent sdfHighlightSmoothLevelText = new("SDF Highlight Smooth Level", "SDF Highlight Smooth Level");
public static readonly GUIContent shadingGradeMapText = new("Shading Grade Map", "Shading Grade Map"); 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 shadingIndexText = new("Shading Index", "The index to choose when sampling the texture 2d array."); 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 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.");
} }
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor; protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Color Settings"); protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Color Settings");
private void DrawSecondShadingMapProperties() private void DrawShadingProperties(MaterialProperty inheritProperty, MaterialProperty colorProperty, MaterialProperty colorMapProperty, GUIContent inheritText, GUIContent colorText)
{ {
EditorGUI.indentLevel += 2; EditorGUI.indentLevel += 2;
editor.ShaderProperty(Properties.applyTo2ndShadingMapEnable, Styles.applyTo2ndShadingMapText); editor.ShaderProperty(inheritProperty, inheritText);
EditorGUI.indentLevel -= 2; EditorGUI.indentLevel -= 2;
if (Mathf.Approximately(Properties.applyTo2ndShadingMapEnable.floatValue, 1)) if (Mathf.Approximately(inheritProperty.floatValue, 1))
{ {
EditorGUI.indentLevel += 2; EditorGUI.indentLevel += 2;
editor.ColorProperty(Properties.secondShadingColor, Styles.secondShadingMapText.text); editor.ShaderProperty(colorProperty, colorText);
EditorGUI.indentLevel -= 2; EditorGUI.indentLevel -= 2;
} }
else else
{ {
editor.TexturePropertySingleLine(Styles.secondShadingMapText, Properties.secondShadingMap, editor.TexturePropertySingleLine(colorText, colorMapProperty, colorProperty);
Properties.secondShadingColor);
} }
} }
private void DrawFirstShadingMapProperties()
{
EditorGUI.indentLevel += 2;
editor.ShaderProperty(Properties.applyTo1stShadingMapEnable, Styles.applyTo1stShadingMapText);
EditorGUI.indentLevel -= 2;
if (Mathf.Approximately(Properties.applyTo1stShadingMapEnable.floatValue, 1))
{
EditorGUI.indentLevel += 2;
editor.ColorProperty(Properties.firstShadingColor, Styles.firstShadingMapText.text);
EditorGUI.indentLevel -= 2;
}
else
{
editor.TexturePropertySingleLine(Styles.firstShadingMapText, Properties.firstShadingMap,
Properties.firstShadingColor);
}
}
private void DrawSDFProperties()
{
editor.TexturePropertySingleLine(Styles.sdfShadowMapText, Properties.sdfShadowMap);
editor.ShaderProperty(Properties.sdfShadowLevel, Styles.sdfShadowLevelText);
editor.ShaderProperty(Properties.sdfSmoothLevel, Styles.sdfSmoothLevelText);
editor.ShaderProperty(Properties.sdfHighlightStrength, Styles.sdfHighlightStrengthText);
editor.ShaderProperty(Properties.sdfHighlightSmoothLevel, Styles.sdfHighlightSmoothLevelText);
}
private void DrawShadingGradeProperties()
{
editor.TexturePropertySingleLine(Styles.shadingGradeMapText, Properties.shadingGradeMap);
editor.ShaderProperty(Properties.shadingIndex, Styles.shadingIndexText);
}
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.useShadingRampMap = FindProperty("_Use_Shading_Ramp_Map");
Properties.baseColor = FindProperty("_BaseColor"); Properties.baseColor = FindProperty("_BaseColor");
Properties.baseColorMap = FindProperty("_BaseColorMap"); Properties.baseColorMap = FindProperty("_BaseColorMap");
Properties.applyTo1stShadingMapEnable = FindProperty("_UseBaseAs1st"); Properties.applyTo1stShadingMapEnable = FindProperty("_UseBaseAs1st");
@@ -111,34 +89,51 @@ namespace Misaki.HdrpToon.Editor
Properties.secondShadingColor = FindProperty("_2ndShadeColor"); Properties.secondShadingColor = FindProperty("_2ndShadeColor");
Properties.secondShadingMap = FindProperty("_2ndShadeColorMap"); Properties.secondShadingMap = FindProperty("_2ndShadeColorMap");
Properties.sdfShadowMap = FindProperty("_SDFShadowMap"); Properties.firstShadeColorStep = FindProperty("_1stShadeColorStep");
Properties.sdfShadowLevel = FindProperty("_SDFShadowLevel"); Properties.firstShadeColorFeather = FindProperty("_1stShadeColorFeather");
Properties.sdfSmoothLevel = FindProperty("_SDFSmoothLevel"); Properties.secondShadeColorStep = FindProperty("_2ndShadeColorStep");
Properties.sdfHighlightStrength = FindProperty("_SDFHighlightStrength"); Properties.secondShadeColorFeather = FindProperty("_2ndShadeColorFeather");
Properties.sdfHighlightSmoothLevel = FindProperty("_SDFHighlightSmoothLevel");
Properties.shadingGradeMap = FindProperty("_ShadingGradeMap"); Properties.sdfShadingMap = FindProperty("_SDFShadingMap");
Properties.sdfShadowLevel = FindProperty("_SDFShadowLevel");
Properties.sdfSmoothLevel = FindProperty("_SDFShadowSmoothLevel");
Properties.sdfHighlightStrength = FindProperty("_SDFHighlightStrength");
Properties.shadingRampMap = FindProperty("_ShadingRampMap");
Properties.shadingIndex = FindProperty("_ShadingIndex"); Properties.shadingIndex = FindProperty("_ShadingIndex");
} }
protected override void DrawContent() protected override void DrawContent()
{ {
editor.TexturePropertySingleLine(Styles.baseMapText, Properties.baseColorMap, Properties.baseColor); editor.ShaderProperty(Properties.useShadingRampMap, Styles.useShadingRampMapText);
editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor);
switch (SurfaceOptionsScope.GetShadingMode()) if (Properties.useShadingRampMap.GetBooleanValue())
{ {
case ShadingMode.ThreeColorStep: editor.TexturePropertySingleLine(Styles.shadingRampMapText, Properties.shadingRampMap, Properties.shadingIndex);
DrawFirstShadingMapProperties(); }
DrawSecondShadingMapProperties(); else
break; {
case ShadingMode.SDF: DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText);
DrawSDFProperties(); if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.Standard)
break; {
case ShadingMode.Ramp: DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
DrawShadingGradeProperties();
break; EditorGUILayout.Space();
default: editor.ShaderProperty(Properties.firstShadeColorStep, Styles.firstShadeColorStepText);
break; editor.ShaderProperty(Properties.firstShadeColorFeather, Styles.firstShadeColorFeatherText);
editor.ShaderProperty(Properties.secondShadeColorStep, Styles.secondShadeColorStepText);
editor.ShaderProperty(Properties.secondShadeColorFeather, Styles.secondShadeColorFeatherText);
}
}
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.SDF)
{
EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);
editor.ShaderProperty(Properties.sdfShadowLevel, Styles.sdfShadowLevelText);
editor.ShaderProperty(Properties.sdfSmoothLevel, Styles.sdfSmoothLevelText);
editor.ShaderProperty(Properties.sdfHighlightStrength, Styles.sdfHighlightStrengthText);
} }
EditorGUILayout.Space(); EditorGUILayout.Space();

View File

@@ -1,23 +0,0 @@
using Misaki.ShaderGUI;
using UnityEditor;
using UnityEngine;
namespace Misaki.HdrpToon.Editor
{
public class ShadingGradeScope : MaterialUIScope<ShaderGUIExpandable>
{
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingGrade;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Grade Settings");
public override void LoadMaterialProperties()
{
throw new System.NotImplementedException();
}
protected override void DrawContent()
{
throw new System.NotImplementedException();
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: faf2eabd1c2767d40a2ecfe89cb56d28

View File

@@ -265,7 +265,7 @@ Shader "HDRP/Toon"
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
[Enum(Off, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(Off, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK
[KeywordEnum(ThreeColorStep, SDF, Ramp)] _Shading_Mode("Shade Grade mode", Float) = 0 [KeywordEnum(Standard, SDF)] _Shading_Mode("Shade Grade mode", Float) = 0
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", int) = 0 [KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", int) = 0
[KeywordEnum(Off, Standard, Anisotropy, KKHair, Toon)] _PBR_Mode("PBR Mode", int) = 0 [KeywordEnum(Off, Standard, Anisotropy, KKHair, Toon)] _PBR_Mode("PBR Mode", int) = 0
[Toggle] _Receive_Hair_Shadow("Receive HairS hadow", Float) = 0 [Toggle] _Receive_Hair_Shadow("Receive HairS hadow", Float) = 0
@@ -273,6 +273,8 @@ Shader "HDRP/Toon"
_SurfaceFeatures("Surface Features", Float) = 0 _SurfaceFeatures("Surface Features", Float) = 0
// Shading Color // Shading Color
[Popup] _Use_Shading_Ramp_Map("Use Shading Ramp Map", Integer) = 0
_BaseColor("BaseColor", Color) = (1,1,1,1) _BaseColor("BaseColor", Color) = (1,1,1,1)
_BaseColorMap("BaseColorMap", 2D) = "white" {} _BaseColorMap("BaseColorMap", 2D) = "white" {}
[HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0)
@@ -283,14 +285,19 @@ Shader "HDRP/Toon"
_2ndShadeColorMap("2nd_ShadeMap", 2D) = "white" {} _2ndShadeColorMap("2nd_ShadeMap", 2D) = "white" {}
[ToggleUI] _Use1stAs2nd("Use 1st_ShadeMap as 2nd_ShadeMap", Float) = 1 [ToggleUI] _Use1stAs2nd("Use 1st_ShadeMap as 2nd_ShadeMap", Float) = 1
_SDFShadowMap("SDFShadowMap", 2D) = "white" {} _1stShadeColorStep("1st ShadeColor Step", Range(0, 1)) = 0.5
_SDFShadowLevel("SDFShadowLevel", Range(0.0, 1.0)) = 0.25 _1stShadeColorFeather("1st ShadeColor Feather", Range(0.0001, 1)) = 0.0001
_SDFSmoothLevel("SDFSmoothGamma", Range(0.0, 0.1)) = 0.02 _2ndShadeColorStep("2nd ShadeColor Step", Range(0, 1)) = 0
_SDFHighlightStrength("SDFHighlightStrength", Range(0.0, 5.0)) = 1.25 _2ndShadeColorFeather("2nd ShadeColor Feather", Range(0.0001, 1)) = 0.0001
_SDFHighlightSmoothLevel("SDFHighlightSmoothLevel", Range(0.0, 0.1)) = 0.02
_ShadingRampMap("ShadingRampMap", 2DArray) = "white" {}
_ShadingIndex("ShadingIndex", Integer) = 0
_SDFShadingMap("SDFShadingMap", 2D) = "white" {}
_SDFShadowLevel("SDFShadowLevel", Range(0.0, 1.0)) = 0.25
_SDFShadowSmoothLevel("SDFShadowSmoothLevel", Range(0.0, 0.1)) = 0.02
_SDFHighlightStrength("SDFHighlightStrength", Range(0.0, 1.0)) = 0.75
_ShadingGradeMap("ShadingGradeMap", 2DArray) = "white" {}
_ShadingIndex("ShadingIndex", Int) = 0
// Angel Rings // Angel Rings
_AngelRingColor("Angel Ring Color", Color) = (1, 1, 1, 1) _AngelRingColor("Angel Ring Color", Color) = (1, 1, 1, 1)
@@ -374,10 +381,7 @@ Shader "HDRP/Toon"
_BaseShade_Feather("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _BaseShade_Feather("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001
_ShadeColor_Step("ShadeColor_Step", Range(0, 1)) = 0 _ShadeColor_Step("ShadeColor_Step", Range(0, 1)) = 0
_1st2nd_Shades_Feather("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 _1st2nd_Shades_Feather("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001
[HideInInspector] _1st_ShadeColor_Step("1st_ShadeColor_Step", Range(0, 1)) = 0.5
[HideInInspector] _1st_ShadeColor_Feather("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001
[HideInInspector] _2nd_ShadeColor_Step("2nd_ShadeColor_Step", Range(0, 1)) = 0
[HideInInspector] _2nd_ShadeColor_Feather("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001
//v.2.0.5 //v.2.0.5
_StepOffset("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 _StepOffset("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0
[Toggle(_)] _Is_Filter_HiCutPointLightColor("PointLights HiCut_Filter (ForwardAdd Only)", Float) = 1 [Toggle(_)] _Is_Filter_HiCutPointLightColor("PointLights HiCut_Filter (ForwardAdd Only)", Float) = 1
@@ -991,10 +995,12 @@ Shader "HDRP/Toon"
#pragma shader_feature ENABLE_UTS_HAIR_SHAOW #pragma shader_feature ENABLE_UTS_HAIR_SHAOW
#pragma shader_feature ENABLE_UTS_HAIR_BLENDING #pragma shader_feature ENABLE_UTS_HAIR_BLENDING
#pragma shader_feature_local_fragment _SHADING_MODE_THREECOLORSTEP _SHADING_MODE_SDF _SHADING_MODE_RAMP #pragma shader_feature_local_fragment _SHADING_MODE_STANDARD _SHADING_MODE_SDF
#pragma shader_feature_local_fragment _MATERIAL_TYPE_STANDARD _MATERIAL_TYPE_FRONTHAIR _MATERIAL_TYPE_FACE _MATERIAL_TYPE_EYE #pragma shader_feature_local_fragment _MATERIAL_TYPE_STANDARD _MATERIAL_TYPE_FRONTHAIR _MATERIAL_TYPE_FACE _MATERIAL_TYPE_EYE
#pragma shader_feature_local_fragment _PBR_MODE_OFF _PBR_MODE_STANDARD _PBR_MODE_ANISOTROPY _PBR_MODE_HAIR _PBR_MODE_TOON #pragma shader_feature_local_fragment _PBR_MODE_OFF _PBR_MODE_STANDARD _PBR_MODE_ANISOTROPY _PBR_MODE_HAIR _PBR_MODE_TOON
#pragma shader_feature_local_fragment _USE_SHADING_RAMP_MAP_ON
#pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_OFF _INDIRECT_DIFFUSE_IBL _INDIRECT_DIFFUSE_MATCAP _INDIRECT_DIFFUSE_RAMP #pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_OFF _INDIRECT_DIFFUSE_IBL _INDIRECT_DIFFUSE_MATCAP _INDIRECT_DIFFUSE_RAMP
#pragma shader_feature_local_fragment _INDIRECT_SPECULAR_OFF _INDIRECT_SPECULAR_IBL _INDIRECT_SPECULAR_MATCAP #pragma shader_feature_local_fragment _INDIRECT_SPECULAR_OFF _INDIRECT_SPECULAR_IBL _INDIRECT_SPECULAR_MATCAP

View File

@@ -116,7 +116,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
output.baseColor = mainTexture.rgb * _BaseColor.rgb; output.baseColor = mainTexture.rgb * _BaseColor.rgb;
output.alpha = mainTexture.a; output.alpha = mainTexture.a;
#if _USE_RAMP_COLOR_MAP_ON #if _USE_SHADING_RAMP_MAP_ON
output.firstShadingColor = 0.0; output.firstShadingColor = 0.0;
output.secondShadingColor = 0.0; output.secondShadingColor = 0.0;
#else #else

View File

@@ -114,8 +114,8 @@ half3 FitWithCurveApprox(half NdotL, half Curvature)
float3 SampleSDFTexture(float3 L, float2 uv, out float angle) float3 SampleSDFTexture(float3 L, float2 uv, out float angle)
{ {
float2 right_uv = float2(1 - uv.x, uv.y); float2 right_uv = float2(1 - uv.x, uv.y);
float3 left_SDFTex = SAMPLE_TEXTURE2D(_SDFShadowMap, sampler_SDFShadowMap, uv).rgb; float3 left_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, uv).rgb;
float3 right_SDFTex = SAMPLE_TEXTURE2D(_SDFShadowMap, sampler_SDFShadowMap, right_uv).rgb; float3 right_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, right_uv).rgb;
float2 leftVector = normalize(mul(UNITY_MATRIX_M, float4(1.0, 0.0, 0.0, 0.0)).xz); float2 leftVector = normalize(mul(UNITY_MATRIX_M, float4(1.0, 0.0, 0.0, 0.0)).xz);
float2 forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0.0, 0.0, 1.0, 0.0)).xz); float2 forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0.0, 0.0, 1.0, 0.0)).xz);
@@ -176,13 +176,14 @@ DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, Pr
#if _SHADING_MODE_SDF #if _SHADING_MODE_SDF
float angle; float angle;
float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf highlight, b: fixed shadow float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf highlight, b: fixed shadow
float sdfShadowMask = smoothstep(angle - _SDFSmoothLevel, angle + _SDFSmoothLevel, sdfTexture.r); float shadowSmoothLevel = _SDFShadowSmoothLevel / 10.0;
float sdfShadowMask = smoothstep(angle - shadowSmoothLevel, angle + shadowSmoothLevel, sdfTexture.r);
float sdfHighlight = sdfTexture.g * _SDFHighlightStrength; float sdfHighlight = sdfTexture.g * _SDFHighlightStrength;
#endif #endif
float3 diffuseTerm = 0.0; float3 diffuseTerm = 0.0;
float3 specularTerm = ComputeSpecularTerm(bsdfData, preLightData, V, L); float3 specularTerm = ComputeSpecularTerm(bsdfData, preLightData, V, L);
#if _USE_RAMP_COLOR_MAP_ON #if _USE_SHADING_RAMP_MAP_ON
#if _SHADING_MODE_STANDARD #if _SHADING_MODE_STANDARD
float NdotL = dot(bsdfData.normalWS, L); float NdotL = dot(bsdfData.normalWS, L);
float halfLambert = 0.5 * NdotL + 0.5; float halfLambert = 0.5 * NdotL + 0.5;

View File

@@ -4,8 +4,8 @@ SAMPLER(sampler_MainTex);
TEXTURE2D(_1stShadeColorMap); TEXTURE2D(_1stShadeColorMap);
TEXTURE2D(_2ndShadeColorMap); TEXTURE2D(_2ndShadeColorMap);
TEXTURE2D(_SDFShadowMap); TEXTURE2D(_SDFShadingMap);
SAMPLER(sampler_SDFShadowMap); SAMPLER(sampler_SDFShadingMap);
TEXTURE2D_ARRAY(_ShadingRampMap); TEXTURE2D_ARRAY(_ShadingRampMap);

View File

@@ -12,15 +12,15 @@ float4 _2ndShadeColor;
fixed _UseBaseAs1st; fixed _UseBaseAs1st;
fixed _Use1stAs2nd; fixed _Use1stAs2nd;
float _SDFShadowLevel;
float _SDFSmoothLevel;
float _SDFHighlightStrength;
float _1stShadeColorStep; float _1stShadeColorStep;
float _1stShadeColorFeather; float _1stShadeColorFeather;
float _2ndShadeColorStep; float _2ndShadeColorStep;
float _2ndShadeColorFeather; float _2ndShadeColorFeather;
float _SDFShadowLevel;
float _SDFShadowSmoothLevel;
float _SDFHighlightStrength;
float _utsTechnique; float _utsTechnique;
float4 _Color; float4 _Color;