Removed the dependency of layer mask of hair shadow caster;
Added HairShadowCaster pass;
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//#define USE_SIMPLE_UI
|
||||
|
||||
|
||||
using Misaki.HdrpToon;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
@@ -51,24 +52,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
}
|
||||
}
|
||||
|
||||
internal static string OutlineLightingModeName
|
||||
{
|
||||
get
|
||||
{
|
||||
const string legacyDefaultLightModeName = "Always";
|
||||
const string OutlineLightingModeName = "Outline";
|
||||
|
||||
if (currentRenderPipeline == RenderPipeline.Legacy)
|
||||
{
|
||||
return legacyDefaultLightModeName; // default.
|
||||
}
|
||||
|
||||
return OutlineLightingModeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal void RenderingPerChennelsSetting(Material material)
|
||||
{
|
||||
if (currentRenderPipeline == RenderPipeline.HDRP)
|
||||
@@ -121,6 +104,12 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderProp_OutlineTex = "_OutlineTex";
|
||||
internal const string ShaderProp_Outline_Sampler = "_Outline_Sampler";
|
||||
|
||||
internal const string ShaderPropCastHairShadow = "_Is_CastHairShadow";
|
||||
internal const string ShaderPropReceiveHairShadow = "_Is_ReceiveHairShadow";
|
||||
|
||||
internal const string ShaderPropEyeParallax = "_Is_EyeParallax";
|
||||
internal const string ShaderPropEyebrowSeethrough = "_Is_EyebrowSeethrough";
|
||||
|
||||
internal const string ShaderPropSimpleUI = "_simpleUI";
|
||||
internal const string ShaderPropAutoRenderQueue = "_AutoRenderQueue";
|
||||
internal const string ShaderPropStencilMode = "_StencilMode";
|
||||
@@ -216,17 +205,13 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
internal const string ShaderDefineIS_CLIPPING_MATTE = "_IS_CLIPPING_MATTE";
|
||||
|
||||
internal const string ShaderPropReceiveHairShadow = "_Is_ReceiveHairShadow";
|
||||
|
||||
internal const string ShaderPropEyeParallax = "_Is_EyeParallax";
|
||||
internal const string ShaderPropEyebrowSeethrough = "_Is_EyebrowSeethrough";
|
||||
|
||||
|
||||
protected readonly string[] UtsModeNames = { "Standard", "PBR" };
|
||||
protected readonly string[] EmissiveScrollMode = { "UV Coordinate Scroll", "View Coordinate Scroll" };
|
||||
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[] PbrModeDefines = { "_PBR_Mode_OFF", "_PBR_Mode_ST", "_PBR_Mode_ANISO", "_PBR_Mode_KK", "_PBR_Mode_TOON" };
|
||||
|
||||
public enum UTS_ClippingMode
|
||||
{
|
||||
@@ -699,7 +684,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent highlightOnShadowText = new GUIContent("Highlight Blending on Shadows", "Control the blending for the highlights in shadows, this also control the rim light.");
|
||||
public static readonly GUIContent lightColorEffectiveness = EditorGUIUtility.TrTextContent("Light Color Effectiveness", "light color effectiveness to each parameter.");
|
||||
|
||||
public static readonly GUIContent receiveHairShadowText = new GUIContent("Receive Hair Shadow", "Do you want this material to receive hair shadow");
|
||||
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 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.");
|
||||
|
||||
@@ -1012,17 +998,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
}
|
||||
// --------------------------------
|
||||
|
||||
public UTS3GUI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnClosed(Material material)
|
||||
{
|
||||
|
||||
base.OnClosed(material);
|
||||
}
|
||||
|
||||
void OnOpenGUI(Material material, MaterialEditor materialEditor, MaterialProperty[] props)
|
||||
{
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.shaderFoldout, Expandable.Shader, DrawShaderOptions, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
@@ -1383,22 +1358,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
//If the value changes, write to the material.
|
||||
if (_CullMode_Setting != (int)m_cullingMode)
|
||||
{
|
||||
switch (m_cullingMode)
|
||||
{
|
||||
case CullingMode.Off:
|
||||
MaterialSetInt(material, _CullMode, 0);
|
||||
break;
|
||||
case CullingMode.Frontface:
|
||||
MaterialSetInt(material, _CullMode, 1);
|
||||
break;
|
||||
default:
|
||||
MaterialSetInt(material, _CullMode, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
MaterialSetInt(material, _CullMode, (int)m_cullingMode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void GUI_Tranparent(Material material)
|
||||
{
|
||||
@@ -1559,17 +1520,14 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
void GUI_HairShadow(Material material)
|
||||
{
|
||||
var isEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
var isCastEnable = GUI_Toggle(material, Styles.hairShadowCasterText, ShaderPropCastHairShadow,
|
||||
MaterialGetInt(material, ShaderPropCastHairShadow) != 0);
|
||||
|
||||
var isReceiveEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
MaterialGetInt(material, ShaderPropReceiveHairShadow) != 0);
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"));
|
||||
}
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, isCastEnable);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"), isReceiveEnabled);
|
||||
}
|
||||
|
||||
void GUI_EyeParallax(Material material)
|
||||
@@ -1718,65 +1676,24 @@ namespace UnityEditor.Rendering.Toon
|
||||
m_pbrMode = (PBRMode)EditorGUILayout.EnumPopup(Styles.pbrModeText, m_pbrMode);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
switch (m_pbrMode)
|
||||
void SwitchPbrMode(string targetMode)
|
||||
{
|
||||
case PBRMode.Off:
|
||||
foreach (var pbrMode in PbrModeDefines)
|
||||
{
|
||||
material.SetFloat(ShaderPropPBR, (int)PBRMode.Off);
|
||||
|
||||
material.EnableKeyword("_PBR_Mode_OFF");
|
||||
material.DisableKeyword("_PBR_Mode_ST");
|
||||
material.DisableKeyword("_PBR_Mode_ANISO");
|
||||
material.DisableKeyword("_PBR_Mode_KK");
|
||||
material.DisableKeyword("_PBR_Mode_TOON");
|
||||
if (targetMode == pbrMode)
|
||||
{
|
||||
material.EnableKeyword(pbrMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(pbrMode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PBRMode.Standard:
|
||||
{
|
||||
material.SetFloat(ShaderPropPBR, (int)PBRMode.Standard);
|
||||
|
||||
material.DisableKeyword("_PBR_Mode_OFF");
|
||||
material.EnableKeyword("_PBR_Mode_ST");
|
||||
material.DisableKeyword("_PBR_Mode_ANISO");
|
||||
material.DisableKeyword("_PBR_Mode_KK");
|
||||
material.DisableKeyword("_PBR_Mode_TOON");
|
||||
}
|
||||
break;
|
||||
case PBRMode.Anisotropy:
|
||||
{
|
||||
material.SetFloat(ShaderPropPBR, (int)PBRMode.Anisotropy);
|
||||
|
||||
material.DisableKeyword("_PBR_Mode_OFF");
|
||||
material.DisableKeyword("_PBR_Mode_ST");
|
||||
material.EnableKeyword("_PBR_Mode_ANISO");
|
||||
material.DisableKeyword("_PBR_Mode_KK");
|
||||
material.DisableKeyword("_PBR_Mode_TOON");
|
||||
}
|
||||
break;
|
||||
case PBRMode.KKHair:
|
||||
{
|
||||
material.SetFloat(ShaderPropPBR, (int)PBRMode.KKHair);
|
||||
|
||||
material.DisableKeyword("_PBR_Mode_OFF");
|
||||
material.DisableKeyword("_PBR_Mode_ST");
|
||||
material.DisableKeyword("_PBR_Mode_ANISO");
|
||||
material.EnableKeyword("_PBR_Mode_KK");
|
||||
material.DisableKeyword("_PBR_Mode_TOON");
|
||||
}
|
||||
break;
|
||||
case PBRMode.Toon:
|
||||
{
|
||||
material.SetFloat(ShaderPropPBR, (int)PBRMode.Toon);
|
||||
|
||||
material.DisableKeyword("_PBR_Mode_OFF");
|
||||
material.DisableKeyword("_PBR_Mode_ST");
|
||||
material.DisableKeyword("_PBR_Mode_ANISO");
|
||||
material.DisableKeyword("_PBR_Mode_KK");
|
||||
material.EnableKeyword("_PBR_Mode_TOON");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
material.SetFloat(ShaderPropPBR, (int)m_pbrMode);
|
||||
SwitchPbrMode(PbrModeDefines[(int)m_pbrMode]);
|
||||
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
|
||||
|
||||
if (m_pbrMode != PBRMode.Off)
|
||||
@@ -2406,18 +2323,18 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
internal static void SetupOverDrawTransparentObject(Material material)
|
||||
{
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, OutlineLightingModeName);
|
||||
if (srpDefaultLightModeTag == OutlineLightingModeName)
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, UtsShaderPassName.OUTLINE_PASS_NAME);
|
||||
if (srpDefaultLightModeTag == UtsShaderPassName.OUTLINE_PASS_NAME)
|
||||
{
|
||||
material.SetShaderPassEnabled(OutlineLightingModeName, true);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, true);
|
||||
MaterialSetInt(material, srpDefaultColorMask, 0);
|
||||
MaterialSetInt(material, srpDefaultCullMode, (int)CullingMode.Backface);
|
||||
}
|
||||
}
|
||||
internal static void SetupOutline(Material material)
|
||||
{
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, OutlineLightingModeName);
|
||||
if (srpDefaultLightModeTag == OutlineLightingModeName)
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, UtsShaderPassName.OUTLINE_PASS_NAME);
|
||||
if (srpDefaultLightModeTag == UtsShaderPassName.OUTLINE_PASS_NAME)
|
||||
{
|
||||
MaterialSetInt(material, srpDefaultColorMask, 15);
|
||||
MaterialSetInt(material, srpDefaultCullMode, (int)CullingMode.Frontface);
|
||||
@@ -2427,15 +2344,12 @@ namespace UnityEditor.Rendering.Toon
|
||||
{
|
||||
EditorGUILayout.HelpBox("You need to add OutlinePass in custom pass to make outline work properly", MessageType.Warning);
|
||||
|
||||
const string kDisableOutlineKeyword = "_DISABLE_OUTLINE";
|
||||
var isLegacy = (OutlineLightingModeName == "Always");
|
||||
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, OutlineLightingModeName);
|
||||
var srpDefaultLightModeTag = material.GetTag("LightMode", false, UtsShaderPassName.OUTLINE_PASS_NAME);
|
||||
var isOutlineEnabled = true;
|
||||
if (srpDefaultLightModeTag == OutlineLightingModeName)
|
||||
if (srpDefaultLightModeTag == UtsShaderPassName.OUTLINE_PASS_NAME)
|
||||
{
|
||||
const string kOutline = "Outline";
|
||||
isOutlineEnabled = material.GetShaderPassEnabled(OutlineLightingModeName);
|
||||
isOutlineEnabled = material.GetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
isOutlineEnabled = EditorGUILayout.Toggle(kOutline, isOutlineEnabled);
|
||||
@@ -2444,20 +2358,11 @@ namespace UnityEditor.Rendering.Toon
|
||||
m_MaterialEditor.RegisterPropertyChangeUndo(kOutline);
|
||||
if (isOutlineEnabled)
|
||||
{
|
||||
if (isLegacy)
|
||||
{
|
||||
material.DisableKeyword(kDisableOutlineKeyword);
|
||||
}
|
||||
|
||||
material.SetShaderPassEnabled(OutlineLightingModeName, true);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isLegacy)
|
||||
{
|
||||
material.EnableKeyword(kDisableOutlineKeyword);
|
||||
}
|
||||
material.SetShaderPassEnabled(OutlineLightingModeName, false);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user