Added HairBlending shader pass;
Added HairBlendingSetting in UTSRenderPassSetting; Added MaterialType to UTS; Added MaterialFeature scope to UTS material editor; Merged HairBlendingPass and HairShadowPass into UTSPass; Fixed the bug that character box light can not update rotation correctly according to bound light source;
This commit is contained in:
@@ -108,7 +108,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderPropReceiveHairShadow = "_Is_ReceiveHairShadow";
|
||||
|
||||
internal const string ShaderPropEyeParallax = "_Is_EyeParallax";
|
||||
internal const string ShaderPropEyebrowSeethrough = "_Is_EyebrowSeethrough";
|
||||
internal const string ShaderPropHairBlendingTarget = "_Is_HairBlendingTarget";
|
||||
|
||||
internal const string ShaderPropSimpleUI = "_simpleUI";
|
||||
internal const string ShaderPropAutoRenderQueue = "_AutoRenderQueue";
|
||||
@@ -128,6 +128,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderPropUtsVersionZ = "_utsVersionZ";
|
||||
internal const string ShaderPropIsUnityToonShader = "_isUnityToonshader";
|
||||
internal const string ShaderPropShadowMode = "_Shadow_Mode";
|
||||
internal const string ShaderPropMaterialType = "_Material_Type";
|
||||
internal const string ShaderPropPBR = "_PBR_Mode";
|
||||
internal const string ShaderPropOutline = "_OUTLINE";
|
||||
internal const string ShaderPropNormalMapToHighColor = "_Is_NormalMapToHighColor";
|
||||
@@ -211,6 +212,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
protected readonly string[] ClippingModeNames = { "Off", "On", "Clip Transparency" };
|
||||
protected readonly string[] StencilModeNames = { "Off", "Draw If Not Equal to", "Replace Stencil Buffer with" };
|
||||
protected readonly string[] ZTestModeNames = { "Disabled", "Never", "Less", "Equal", "LessEqual", "Greater", "NotEqual", "GreaterEqual", "Always" };
|
||||
|
||||
protected readonly string[] materialTypeDefines = { "MATERIAL_TYPE_STANDARD", "MATERIAL_TYPE_FRONT_HAIR", "MATERIAL_TYPE_FACE", "MATERIAL_TYPE_EYE" };
|
||||
protected readonly string[] PbrModeDefines = { "_PBR_Mode_OFF", "_PBR_Mode_ST", "_PBR_Mode_ANISO", "_PBR_Mode_KK", "_PBR_Mode_TOON" };
|
||||
|
||||
public enum UTS_ClippingMode
|
||||
@@ -279,6 +282,14 @@ namespace UnityEditor.Rendering.Toon
|
||||
Normal, SDF
|
||||
}
|
||||
|
||||
public enum MaterialType
|
||||
{
|
||||
Standard,
|
||||
FrontHair,
|
||||
Face,
|
||||
Eye
|
||||
}
|
||||
|
||||
public enum PBRMode
|
||||
{
|
||||
Off, Standard, Anisotropy, KKHair, Toon
|
||||
@@ -314,18 +325,19 @@ namespace UnityEditor.Rendering.Toon
|
||||
Shader = 1 << 0,
|
||||
Basic = 1 << 1,
|
||||
ShadingStepAndFeather = 1 << 2,
|
||||
NormalMap = 1 << 3,
|
||||
Highlight = 1 << 4,
|
||||
Rimlight = 1 << 5,
|
||||
MatCap = 1 << 6,
|
||||
AngelRing = 1 << 7,
|
||||
Emission = 1 << 8,
|
||||
Outline = 1 << 9,
|
||||
TessellationLegacy = 1 << 10,
|
||||
TessellationHDRP = 1 << 11,
|
||||
SceneLight = 1 << 12,
|
||||
EnvironmentalLightEffectiveness = 1 << 13,
|
||||
MetaverseSettings = 1 << 14,
|
||||
MaterialFeature = 1 << 3,
|
||||
PBR = 1 << 4,
|
||||
Highlight = 1 << 5,
|
||||
Rimlight = 1 << 6,
|
||||
MatCap = 1 << 7,
|
||||
AngelRing = 1 << 8,
|
||||
Emission = 1 << 9,
|
||||
Outline = 1 << 10,
|
||||
TessellationLegacy = 1 << 11,
|
||||
TessellationHDRP = 1 << 12,
|
||||
SceneLight = 1 << 13,
|
||||
EnvironmentalLightEffectiveness = 1 << 14,
|
||||
MetaverseSettings = 1 << 15,
|
||||
}
|
||||
|
||||
// variables which must be gotten from shader at the beggning of GUI
|
||||
@@ -333,6 +345,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal int m_renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry;
|
||||
// variables which just to be held.
|
||||
internal ShadowMode m_shadowMode;
|
||||
internal MaterialType m_materialType;
|
||||
internal PBRMode m_pbrMode;
|
||||
internal OutlineMode m_outlineMode;
|
||||
internal CullingMode m_cullingMode;
|
||||
@@ -397,7 +410,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
protected MaterialProperty set_2nd_ShadePosition = null;
|
||||
protected MaterialProperty shadingGradeMap = null;
|
||||
|
||||
|
||||
protected MaterialProperty hairBlendingMap = null;
|
||||
|
||||
protected MaterialProperty highColor_Tex = null;
|
||||
protected MaterialProperty highColor = null;
|
||||
@@ -491,6 +504,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
set_2nd_ShadePosition = FindProperty(ShaderProp_Set_2nd_ShadePosition, props, false);
|
||||
shadingGradeMap = FindProperty(ShaderProp_ShadingGradeMap, props, false);
|
||||
|
||||
hairBlendingMap = FindProperty("_HairBlendingMap", props);
|
||||
|
||||
highColor_Tex = FindProperty(ShaderProp_HighColor_Tex, props);
|
||||
highColor = FindProperty("_HighColor", props);
|
||||
@@ -615,7 +629,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent shaderFoldout = EditorGUIUtility.TrTextContent("Shader Settings", "Shader Settings provides basic settings that are not specific to cel-shading but are needed for general CG.");
|
||||
public static readonly GUIContent basicColorFoldout = EditorGUIUtility.TrTextContent("Shading Color Settings", "Three Color Map and Control Map Settings provide very basic settings for cel-shading in Unity Toon Shader.");
|
||||
public static readonly GUIContent shadingStepAndFeatherFoldout = EditorGUIUtility.TrTextContent("Shading Step and Feather Settings", "Basic 3 color step and feather settings.");
|
||||
public static readonly GUIContent normalMapFoldout = EditorGUIUtility.TrTextContent("PBR Settings", "PBR settings. The settings for PBR effect, such as specular and IBL.");
|
||||
public static readonly GUIContent materialFeatureFoldout = EditorGUIUtility.TrTextContent("Material Feature", "Material Feature Setting. The settings for special material feature like hair shadow, hair blending, etc");
|
||||
public static readonly GUIContent pbrFoldout = EditorGUIUtility.TrTextContent("PBR Settings", "PBR settings. The settings for PBR effect, such as specular and IBL.");
|
||||
public static readonly GUIContent highlightFoldout = EditorGUIUtility.TrTextContent("Highlight Settings", "Highlight settings. Such as power, show or hide, light shape and so on.");
|
||||
public static readonly GUIContent rimLightFoldout = EditorGUIUtility.TrTextContent("Rim Light Settings", "Rim Light Settings. Such as color, direction, inverted rim light and so on.");
|
||||
public static readonly GUIContent matCapFoldout = EditorGUIUtility.TrTextContent("Material Capture (MatCap) Settings", "MatCap settings. Sphere maps for metallic or unusual expressions.");
|
||||
@@ -635,6 +650,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent SDFShadowText = new GUIContent("SDF Shadow Map", "Specify SDF shadow map");
|
||||
public static readonly GUIContent firstShadeColorText = new GUIContent("1st Shading Map", "The map used for the brighter portions of the shadow.");
|
||||
public static readonly GUIContent secondShadeColorText = new GUIContent("2nd Shading Map", "The map used for the darker portions of the shadow.");
|
||||
public static readonly GUIContent materialTypeText = new GUIContent("Material Type", "Specifies the material type.");
|
||||
public static readonly GUIContent hairBlendingTargetMapText = new GUIContent("Blending Map", "Specifies the texture to blend with hair.");
|
||||
public static readonly GUIContent normalMapText = new GUIContent("Normal Map", "A texture that dictates the bumpiness of the material.");
|
||||
public static readonly GUIContent pbrModeText = new GUIContent("PBR Mode", "Specifies PBR model mode.");
|
||||
public static readonly GUIContent highColorText = new GUIContent("Highlight", "Highlight : Texture(sRGB) x Color(RGB) Default:White");
|
||||
@@ -660,7 +677,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent transparentModeText = new GUIContent("Transparency", "Enable different modes that allow the simulation of a variety of transparent objects. ");
|
||||
public static readonly GUIContent stencilVauleText = new GUIContent("Stencil Value", "Stencil value that is submitted to the stencil buffer for controlling the per-pixel drawing.");
|
||||
public static readonly GUIContent workflowModeText = new GUIContent("Mode", "The UTS mode that controls what settings are exposed in the shader.");
|
||||
public static readonly GUIContent materialTypeText = new GUIContent("Material Type", "The PBR model type of the material");
|
||||
|
||||
// -----------------------------------------------------
|
||||
public static readonly GUIContent clippingmodeModeText = new GUIContent("Trans Clipping", "Select trans clipping mode that fits your purpose. ");
|
||||
@@ -686,6 +702,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
public static readonly GUIContent hairShadowCasterText = new GUIContent("Hair Shadow Caster", "Enable to cast hair shadow");
|
||||
public static readonly GUIContent receiveHairShadowText = new GUIContent("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
public static readonly GUIContent hairBlendingTargetShadowText = new GUIContent("Hair Blending Target", "Enable to be blended with hair");
|
||||
public static readonly GUIContent eyeParallaxText = new GUIContent("Eye Parallax Correction", "Enables parallax correction for eye material");
|
||||
public static readonly GUIContent eyebrowSeethroughText = new GUIContent("Eyebrow Seethrough", "Enable for eyebrow material to be blended with hair. Must configure HairShadowPass to work.");
|
||||
|
||||
@@ -822,9 +839,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
label: "Eye Parallax Amount", tooltip: "Distance of parallax correction",
|
||||
propName: "_EyeParallaxAmount", defaultValue: 0.1f, min: 0.0f, max: 0.4f);
|
||||
|
||||
public static readonly RangeProperty eyeBrowBlendingFactor = new RangeProperty(
|
||||
label: "Eyebrow Blending Factor", tooltip: "Blend Factor of Eyebrows on Hair",
|
||||
propName: "_EyeBrowBlendingFactor", defaultValue: 0.5f, min: 0.0f, max: 1.0f);
|
||||
public static readonly RangeProperty hairBlendingFactor = new RangeProperty(
|
||||
label: "Hair Blending Factor", tooltip: "Blend Factor of Hair Blending Target on Hair",
|
||||
propName: "_HairBlendingFactor", defaultValue: 0.5f, min: 0.0f, max: 1.0f);
|
||||
|
||||
public static readonly RangeProperty shaderPropStepOffsetText = new RangeProperty(
|
||||
label: "Step Offset", tooltip: "Fine tunes light steps (boundaries) added in the ForwardAdd pass, such as real-time point lights.",
|
||||
@@ -1003,7 +1020,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.shaderFoldout, Expandable.Shader, DrawShaderOptions, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.basicColorFoldout, Expandable.Basic, GUI_BasicThreeColors, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.shadingStepAndFeatherFoldout, Expandable.ShadingStepAndFeather, GUI_StepAndFeather, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.normalMapFoldout, Expandable.NormalMap, GUI_PBRSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.materialFeatureFoldout, Expandable.MaterialFeature, GUI_MaterialFeature, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.pbrFoldout, Expandable.PBR, GUI_PBRSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.highlightFoldout, Expandable.Highlight, GUI_HighlightSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.rimLightFoldout, Expandable.Rimlight, GUI_RimLight, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.matCapFoldout, Expandable.MatCap, GUI_MatCap, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
@@ -1494,13 +1512,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
{
|
||||
GUI_AdditionalLookdevs(material);
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
GUI_HairShadow(material);
|
||||
|
||||
GUI_EyeParallax(material);
|
||||
|
||||
GUI_EyebrowSeethrough(material);
|
||||
}
|
||||
|
||||
void GUI_SystemShadows(Material material)
|
||||
@@ -1518,69 +1529,71 @@ namespace UnityEditor.Rendering.Toon
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
void GUI_HairShadow(Material material)
|
||||
void GUI_MaterialFeature(Material material)
|
||||
{
|
||||
var isCastEnable = GUI_Toggle(material, Styles.hairShadowCasterText, ShaderPropCastHairShadow,
|
||||
MaterialGetInt(material, ShaderPropCastHairShadow) != 0);
|
||||
var materialTypeSetting = MaterialGetInt(material, ShaderPropMaterialType);
|
||||
m_materialType = (MaterialType)materialTypeSetting;
|
||||
|
||||
var isReceiveEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
m_materialType = (MaterialType)EditorGUILayout.EnumPopup(Styles.materialTypeText, m_materialType);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
switch (m_materialType)
|
||||
{
|
||||
case MaterialType.FrontHair:
|
||||
GUI_FrontHair(material);
|
||||
break;
|
||||
case MaterialType.Eye:
|
||||
GUI_EyeParallax(material);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
var isReceiveHairShadowEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
MaterialGetInt(material, ShaderPropReceiveHairShadow) != 0);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"), isReceiveHairShadowEnabled);
|
||||
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, isCastEnable);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"), isReceiveEnabled);
|
||||
var isHairBlendingTargetEnabled = GUI_Toggle(material, Styles.hairBlendingTargetShadowText, ShaderPropHairBlendingTarget,
|
||||
MaterialGetInt(material, ShaderPropHairBlendingTarget) != 0);
|
||||
if (isHairBlendingTargetEnabled)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.hairBlendingTargetMapText, hairBlendingMap);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, isHairBlendingTargetEnabled);
|
||||
|
||||
SwitchKeyword(m_materialType);
|
||||
material.SetFloat(ShaderPropMaterialType, (float)m_materialType);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, m_materialType == MaterialType.FrontHair);
|
||||
|
||||
void SwitchKeyword(MaterialType target)
|
||||
{
|
||||
for (var i = 0; i < materialTypeDefines.Length; i++)
|
||||
{
|
||||
var localKeyword = new LocalKeyword(material.shader, materialTypeDefines[i]);
|
||||
if ((int)target == i)
|
||||
{
|
||||
material.EnableKeyword(localKeyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(localKeyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_FrontHair(Material material)
|
||||
{
|
||||
GUI_RangeProperty(material, Styles.hairBlendingFactor);
|
||||
}
|
||||
|
||||
void GUI_EyeParallax(Material material)
|
||||
{
|
||||
var isEnabled = GUI_Toggle(material, Styles.eyeParallaxText, ShaderPropEyeParallax,
|
||||
MaterialGetInt(material, ShaderPropEyeParallax) != 0);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!isEnabled);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
GUI_RangeProperty(material, Styles.eyeParallaxAmount);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_EYE_PARALLAX"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_EYE_PARALLAX"));
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_EyebrowSeethrough(Material material)
|
||||
{
|
||||
var isEnabled = GUI_Toggle(material, Styles.eyebrowSeethroughText, ShaderPropEyebrowSeethrough,
|
||||
MaterialGetInt(material, ShaderPropEyebrowSeethrough) != 0);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!isEnabled);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
GUI_RangeProperty(material, Styles.eyeBrowBlendingFactor);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_EYEBROW_SEETHROUGH"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_EYEBROW_SEETHROUGH"));
|
||||
}
|
||||
GUI_RangeProperty(material, Styles.eyeParallaxAmount);
|
||||
}
|
||||
|
||||
void GUI_ShadingStepAndFeatherSettings(Material material)
|
||||
|
||||
Reference in New Issue
Block a user