Changing UI style;

Updating RImeLight;
This commit is contained in:
2025-02-03 23:01:57 +09:00
parent 886432db7b
commit de370f845e
11 changed files with 157 additions and 79 deletions

View File

@@ -75,9 +75,11 @@ namespace Misaki.HdrpToon.Editor
if (indirectDiffuseMode != IndirectDiffuseMode.Off) if (indirectDiffuseMode != IndirectDiffuseMode.Off)
{ {
EditorGUILayout.Space(); EditorGUILayout.Space();
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel); EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
}
using var indentLevelScope = new EditorGUI.IndentLevelScope();
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap) if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
{ {
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod); editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
@@ -95,9 +97,11 @@ namespace Misaki.HdrpToon.Editor
if (indirectSpecularMode != (int)IndirectSpecularMode.Off) if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
{ {
EditorGUILayout.Space(); EditorGUILayout.Space();
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel); EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
}
using var indentLevelScope = new EditorGUI.IndentLevelScope();
if (indirectSpecularMode == IndirectSpecularMode.Matcap) if (indirectSpecularMode == IndirectSpecularMode.Matcap)
{ {
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod); editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);

View File

@@ -9,7 +9,6 @@ namespace Misaki.HdrpToon.Editor
{ {
private static class Properties private static class Properties
{ {
public static MaterialProperty rimLightEnabled;
public static MaterialProperty rimLightColor; public static MaterialProperty rimLightColor;
public static MaterialProperty rimLightStrength; public static MaterialProperty rimLightStrength;
public static MaterialProperty rimLightLevel; public static MaterialProperty rimLightLevel;
@@ -28,9 +27,6 @@ namespace Misaki.HdrpToon.Editor
private static class Styles private static class Styles
{ {
public static readonly GUIContent rimLightEnabledText = new("Rim Light",
"A light that hits the 3D model from behind and emphasizes the contours of the model from the front.");
public static readonly GUIContent rimLightColorText = public static readonly GUIContent rimLightColorText =
new("Rim Light Color", "Specifies the color of rim light."); new("Rim Light Color", "Specifies the color of rim light.");
@@ -83,10 +79,9 @@ namespace Misaki.HdrpToon.Editor
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.rimLightEnabled = FindProperty("_RimLight");
Properties.rimLightColor = FindProperty("_RimLightColor"); Properties.rimLightColor = FindProperty("_RimLightColor");
Properties.rimLightStrength = FindProperty("_RimLight_Strength"); Properties.rimLightStrength = FindProperty("_RimLightStrength");
Properties.rimLightLevel = FindProperty("_RimLight_Power"); Properties.rimLightLevel = FindProperty("_RimLightLevel");
Properties.colorBlendingMode = FindProperty("_Is_BlendAddToRimColor"); Properties.colorBlendingMode = FindProperty("_Is_BlendAddToRimColor");
Properties.adjustRimLightArea = FindProperty("_RimLight_InsideMask"); Properties.adjustRimLightArea = FindProperty("_RimLight_InsideMask");
Properties.rimLightFeatherOff = FindProperty("_RimLight_FeatherOff"); Properties.rimLightFeatherOff = FindProperty("_RimLight_FeatherOff");

View File

@@ -4,6 +4,8 @@ using UnityEditor;
using UnityEditor.Rendering; using UnityEditor.Rendering;
using UnityEngine; using UnityEngine;
using static Misaki.HdrpToon.UtsShaderPropertyName.SurfaceInputs;
namespace Misaki.HdrpToon.Editor namespace Misaki.HdrpToon.Editor
{ {
public class SurfaceInputsScope : MaterialUIScope<ShaderGUIExpandable> public class SurfaceInputsScope : MaterialUIScope<ShaderGUIExpandable>
@@ -12,23 +14,33 @@ namespace Misaki.HdrpToon.Editor
{ {
public static MaterialProperty NormalMap; public static MaterialProperty NormalMap;
public static MaterialProperty NormalMapScale; public static MaterialProperty NormalMapScale;
public static MaterialProperty MaskMap; public static MaterialProperty MaskMap;
public static MaterialProperty Metallic; public static MaterialProperty Metallic;
public static MaterialProperty MetallicRemapMin; public static MaterialProperty MetallicRemapMin;
public static MaterialProperty MetallicRemapMax; public static MaterialProperty MetallicRemapMax;
public static MaterialProperty AORemapMin; public static MaterialProperty AORemapMin;
public static MaterialProperty AORemapMax; public static MaterialProperty AORemapMax;
public static MaterialProperty RoughnessRemapMin;
public static MaterialProperty RoughnessRemapMax;
public static MaterialProperty Smoothness; public static MaterialProperty Smoothness;
public static MaterialProperty SmoothnessRemapMin;
public static MaterialProperty SmoothnessRemapMax;
public static MaterialProperty AnisotropyMap; public static MaterialProperty AnisotropyMap;
public static MaterialProperty Anisotropy; public static MaterialProperty Anisotropy;
public static MaterialProperty KKColor; public static MaterialProperty KKColor;
public static MaterialProperty BSDFContribution; public static MaterialProperty BSDFContribution;
public static MaterialProperty SpecularColorMap; public static MaterialProperty SpecularColorMap;
public static MaterialProperty SpecularColor; public static MaterialProperty SpecularColor;
public static MaterialProperty SpecularFeather; public static MaterialProperty SpecularFeather;
public static MaterialProperty SpecularStep; public static MaterialProperty SpecularStep;
public static MaterialProperty emissiveColorLDR;
public static MaterialProperty emissiveColorMap;
public static MaterialProperty emissiveIntensity;
public static MaterialProperty albedoAffectEmissive;
public static MaterialProperty emissiveExposureWeight;
} }
private static class Styles private static class Styles
@@ -37,9 +49,9 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent MaskMapText = new("Mask Map", "A texture that dictates the physical properties of the material. R channel for metallic, G channel for ambient occlusion, A channel for smoothness"); public static readonly GUIContent MaskMapText = new("Mask Map", "A texture that dictates the physical properties of the material. R channel for metallic, G channel for ambient occlusion, A channel for smoothness");
public static readonly GUIContent MetallicText = new("Metallic", "Specifies the metallic value of the material."); public static readonly GUIContent MetallicText = new("Metallic", "Specifies the metallic value of the material.");
public static readonly GUIContent MetallicRemap = new("Metallic Remap", "Remap the max and min value of metallic"); public static readonly GUIContent MetallicRemap = new("Metallic Remap", "Remap the max and min value of metallic");
public static readonly GUIContent AORemap = new GUIContent("AO Remap", "Remap the max and min value of ambient occlusion"); public static readonly GUIContent AORemap = new("AO Remap", "Remap the max and min value of ambient occlusion");
public static readonly GUIContent RoughnessRemap = new GUIContent("Smoothness Remap", "Remap the max and min value of smoothness");
public static readonly GUIContent SmoothnessText = new("Smoothness", "Specifies the smoothness of the material."); public static readonly GUIContent SmoothnessText = new("Smoothness", "Specifies the smoothness of the material.");
public static readonly GUIContent SmoothnessRemapText = new("Smoothness Remap", "Remap the max and min value of smoothness");
public static readonly GUIContent AnisotropyMapText = new("Anisotropy Map", "Specifies the anisotropy map of the material."); public static readonly GUIContent AnisotropyMapText = new("Anisotropy Map", "Specifies the anisotropy map of the material.");
@@ -48,6 +60,12 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent SpecularColorMapText = new("Specular Color Map", "Specifies the specular color map of the material."); public static readonly GUIContent SpecularColorMapText = new("Specular Color Map", "Specifies the specular color map of the material.");
public static readonly GUIContent SpecRemap = new("Specular Remap", "Feather and step value of Toon Specular"); public static readonly GUIContent SpecRemap = new("Specular Remap", "Feather and step value of Toon Specular");
public static readonly GUIContent emissiveColorText = new("Emissive Color", "The color and color map to set for emissive effect.");
public static readonly GUIContent albedoAffectEmissiveText = new("Albedo Affect Emissive", "Enable to affect emissive color with base color");
public static readonly GUIContent emissiveIntensityText = new("Emissive Intensity", "Set the intensity of the emissive color,in Nits");
public static readonly GUIContent emissiveExposureWeightText = new("Exposure Weight", "Controls how the camera exposure influences the perceived intensity of the emissivity. A weight of 0 means that the emissive intensity is calculated ignoring the exposure; increasing this weight progressively increases the influence of exposure on the final emissive value.");
} }
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs; protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs;
@@ -57,23 +75,33 @@ namespace Misaki.HdrpToon.Editor
{ {
Properties.NormalMap = FindProperty("_NormalMap"); Properties.NormalMap = FindProperty("_NormalMap");
Properties.NormalMapScale = FindProperty("_NormalScale"); Properties.NormalMapScale = FindProperty("_NormalScale");
Properties.MaskMap = FindProperty("_MaskMap"); Properties.MaskMap = FindProperty("_MaskMap");
Properties.Metallic = FindProperty("_Metallic"); Properties.Metallic = FindProperty("_Metallic");
Properties.MetallicRemapMin = FindProperty("_MetallicRemapMin"); Properties.MetallicRemapMin = FindProperty("_MetallicRemapMin");
Properties.MetallicRemapMax = FindProperty("_MetallicRemapMax"); Properties.MetallicRemapMax = FindProperty("_MetallicRemapMax");
Properties.AORemapMin = FindProperty("_AORemapMin"); Properties.AORemapMin = FindProperty("_AORemapMin");
Properties.AORemapMax = FindProperty("_AORemapMax"); Properties.AORemapMax = FindProperty("_AORemapMax");
Properties.RoughnessRemapMin = FindProperty("_SmoothnessRemapMin"); Properties.SmoothnessRemapMin = FindProperty("_SmoothnessRemapMin");
Properties.RoughnessRemapMax = FindProperty("_SmoothnessRemapMax"); Properties.SmoothnessRemapMax = FindProperty("_SmoothnessRemapMax");
Properties.Smoothness = FindProperty("_Smoothness"); Properties.Smoothness = FindProperty("_Smoothness");
Properties.AnisotropyMap = FindProperty("_AnisotropyMap"); Properties.AnisotropyMap = FindProperty("_AnisotropyMap");
Properties.Anisotropy = FindProperty("_Anisotropy"); Properties.Anisotropy = FindProperty("_Anisotropy");
Properties.KKColor = FindProperty("_KKColor"); Properties.KKColor = FindProperty("_KKColor");
Properties.BSDFContribution = FindProperty("_BSDFContribution"); Properties.BSDFContribution = FindProperty("_BSDFContribution");
Properties.SpecularColorMap = FindProperty("_SpecularColorMap"); Properties.SpecularColorMap = FindProperty("_SpecularColorMap");
Properties.SpecularColor = FindProperty("_SpecularColor"); Properties.SpecularColor = FindProperty("_SpecularColor");
Properties.SpecularFeather = FindProperty("_ToonSpecularFeather"); Properties.SpecularFeather = FindProperty("_ToonSpecularFeather");
Properties.SpecularStep = FindProperty("_ToonSpecularStep"); Properties.SpecularStep = FindProperty("_ToonSpecularStep");
Properties.emissiveColorLDR = FindProperty(EMISSIVE_COLOR_LDR);
Properties.emissiveColorMap = FindProperty(EMISSIVE_COLOR_MAP);
Properties.albedoAffectEmissive = FindProperty(ALBEDO_AFFECT_EMISSIVE);
Properties.emissiveIntensity = FindProperty(EMISSIVE_INTENSITY);
Properties.emissiveExposureWeight = FindProperty(EMISSIVE_EXPOSURE_WEIGHT);
} }
protected override void DrawContent() protected override void DrawContent()
@@ -86,7 +114,7 @@ namespace Misaki.HdrpToon.Editor
{ {
editor.MinMaxShaderProperty(Properties.MetallicRemapMin, Properties.MetallicRemapMax, 0, 1, Styles.MetallicRemap); editor.MinMaxShaderProperty(Properties.MetallicRemapMin, Properties.MetallicRemapMax, 0, 1, Styles.MetallicRemap);
editor.MinMaxShaderProperty(Properties.AORemapMin, Properties.AORemapMax, 0, 1, Styles.AORemap); editor.MinMaxShaderProperty(Properties.AORemapMin, Properties.AORemapMax, 0, 1, Styles.AORemap);
editor.MinMaxShaderProperty(Properties.RoughnessRemapMin, Properties.RoughnessRemapMax, 0, 1, Styles.RoughnessRemap); editor.MinMaxShaderProperty(Properties.SmoothnessRemapMin, Properties.SmoothnessRemapMax, 0, 1, Styles.SmoothnessRemapText);
} }
else else
{ {
@@ -117,6 +145,34 @@ namespace Misaki.HdrpToon.Editor
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor); editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap); editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
} }
EditorGUILayout.Space();
using (var EmissiveIntentLevel = new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.LabelField("Emissive", EditorStyles.boldLabel);
}
EditorGUI.BeginChangeCheck();
editor.KeywordTexturePropertySingleLine(Styles.emissiveColorText, Properties.emissiveColorMap, Properties.emissiveColorLDR, "_EMISSIVE_COLOR_MAP");
editor.ShaderProperty(Properties.emissiveIntensity, Styles.emissiveIntensityText);
if (EditorGUI.EndChangeCheck())
{
editor.ApplyChange(material =>
{
if (material.HasProperty(EMISSIVE_COLOR_LDR) && material.HasProperty(EMISSIVE_INTENSITY) && material.HasProperty(EMISSIVE_COLOR))
{
// Important: The color picker for kEmissiveColorLDR is LDR and in sRGB color space but Unity don't perform any color space conversion in the color
// picker BUT only when sending the color data to the shader... So as we are doing our own calculation here in C#, we must do the conversion ourselves.
var emissiveColorLDR = material.GetColor(EMISSIVE_COLOR_LDR);
var emissiveColorLDRLinear = new Color(Mathf.GammaToLinearSpace(emissiveColorLDR.r), Mathf.GammaToLinearSpace(emissiveColorLDR.g), Mathf.GammaToLinearSpace(emissiveColorLDR.b));
material.SetColor(EMISSIVE_COLOR, emissiveColorLDRLinear * material.GetFloat(EMISSIVE_INTENSITY));
}
});
}
EditorGUILayout.Space();
editor.ShaderProperty(Properties.albedoAffectEmissive, Styles.albedoAffectEmissiveText);
editor.ShaderProperty(Properties.emissiveExposureWeight, Styles.emissiveExposureWeightText);
} }
} }
} }

View File

@@ -9,6 +9,18 @@ namespace Misaki.HdrpToon
public const string SURFACE_FEATURE = "_SurfaceFeatures"; public const string SURFACE_FEATURE = "_SurfaceFeatures";
} }
public static class SurfaceInputs
{
public const string EMISSIVE_COLOR = "_EmissiveColor";
public const string EMISSIVE_COLOR_LDR = "_EmissiveColorLDR";
public const string EMISSIVE_COLOR_MAP = "_EmissiveColorMap";
public const string ALBEDO_AFFECT_EMISSIVE = "_AlbedoAffectEmissive";
public const string EMISSIVE_INTENSITY = "_EmissiveIntensity";
public const string EMISSIVE_EXPOSURE_WEIGHT = "_EmissiveExposureWeight";
}
public static class Outline public static class Outline
{ {
public const string OUTLINE_STATE = "_OutlineState"; public const string OUTLINE_STATE = "_OutlineState";

View File

@@ -80,19 +80,6 @@ Shader "HDRP/Toon"
// These option below will cause different compilation flag. // These option below will cause different compilation flag.
[Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1
[HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
// Used only to serialize the LDR and HDR emissive color in the material UI,
// in the shader only the _EmissiveColor should be used
[HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
[HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0
[ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0
_EmissiveIntensity("Emissive Intensity", Float) = 1
_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMappingEmissive("Mapping space", Float) = 0.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0
@@ -294,12 +281,25 @@ Shader "HDRP/Toon"
_AlphaRemapMax("AlphaRemapMax", Float) = 1.0 _AlphaRemapMax("AlphaRemapMax", Float) = 1.0
_AORemapMin("AORemapMin", Float) = 0.0 _AORemapMin("AORemapMin", Float) = 0.0
_AORemapMax("AORemapMax", Float) = 1.0 _AORemapMax("AORemapMax", Float) = 1.0
[ToggleUI] _Use_SSSLut("Use SSSLut", Int) = 0 [ToggleUI] _Use_SSSLut("Use SSSLut", Integer) = 0
_SSSLutMap("SSSLutMap", 2D) = "white" {} _SSSLutMap("SSSLutMap", 2D) = "white" {}
_SSSIntensity("SSSIntensity", Range(0.0, 3.0)) = 1.0 _SSSIntensity("SSSIntensity", Range(0.0, 3.0)) = 1.0
_HairBlendingMap("HairBlendingMap", 2D) = "black" {} _HairBlendingMap("HairBlendingMap", 2D) = "black" {}
// Emissive
[HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
// Used only to serialize the LDR and HDR emissive color in the material UI,
// in the shader only the _EmissiveColor should be used
[HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("Emissive Intensity", Float) = 1
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMappingEmissive("Mapping space", Float) = 0.0
// Ambient // Ambient
[KeywordEnum(Off, IBL, MatCap, Ramp)]_Indirect_Diffuse_Mode("_Indirect_Diffuse_Mode", Integer) = 1 [KeywordEnum(Off, IBL, MatCap, Ramp)]_Indirect_Diffuse_Mode("_Indirect_Diffuse_Mode", Integer) = 1
[KeywordEnum(Off, IBL, MatCap)]_Indirect_Specular_Mode("_Indirect_Specular_Mode", Integer) = 1 [KeywordEnum(Off, IBL, MatCap)]_Indirect_Specular_Mode("_Indirect_Specular_Mode", Integer) = 1
@@ -317,6 +317,30 @@ Shader "HDRP/Toon"
_IndirectSpecularIntensity("Indirect Specular Intensity", Range(0, 5)) = 1.0 _IndirectSpecularIntensity("Indirect Specular Intensity", Range(0, 5)) = 1.0
_SSRWeight("SSR Weight", Range(0.0, 1.0)) = 1.0 _SSRWeight("SSR Weight", Range(0.0, 1.0)) = 1.0
// Rim Light
//_Set_HighColorMask("Set_HighColorMask", 2D) = "white" {}
//_Tweak_HighColorMaskLevel("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0
//[Toggle(_)] _RimLight("RimLight", Float) = 0
_RimLightColor("RimLightColor", Color) = (1, 1, 1, 1)
_RimLightStrength("RimLight_Strength", Range(0, 10)) = 1
[ToggleUI] _Is_LightColor_RimLight("Is_LightColor_RimLight", Float) = 1
[ToggleUI] _Is_NormalMapToRimLight("Is_NormalMapToRimLight", Float) = 0
_RimLightLevel("RimLight Level", Range(0, 1)) = 0.1
_RimLight_InsideMask("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001
[ToggleUI] _RimLight_FeatherOff("RimLight_FeatherOff", Float) = 0
[ToggleUI] _LightDirection_MaskOn("LightDirection_MaskOn", Float) = 0
_Tweak_LightDirection_MaskLevel("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0
[ToggleUI] _Add_Antipodean_RimLight("Add_Antipodean_RimLight", Float) = 0
_Ap_RimLightColor("Ap_RimLightColor", Color) = (1, 1, 1, 1)
[ToggleUI] _Is_LightColor_Ap_RimLight("Is_LightColor_Ap_RimLight", Float) = 1
_Ap_RimLight_Power("Ap_RimLight_Power", Range(0, 1)) = 0.1
[ToggleUI] _Ap_RimLight_FeatherOff("Ap_RimLight_FeatherOff", Float) = 0
_Set_RimLightMask("Set_RimLightMask", 2D) = "white" {}
_Tweak_RimLightMaskLevel("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0
// Angel Rings // Angel Rings
_AngelRingColor("Angel Ring Color", Color) = (1, 1, 1, 1) _AngelRingColor("Angel Ring Color", Color) = (1, 1, 1, 1)
_AngelRingColorMap("Angel Ring Color Map", 2D) = "black" {} _AngelRingColorMap("Angel Ring Color Map", 2D) = "black" {}
@@ -340,6 +364,9 @@ Shader "HDRP/Toon"
[Toggle(_)] _Cast_Hair_Shadow("CastHairShadow", Float) = 0 [Toggle(_)] _Cast_Hair_Shadow("CastHairShadow", Float) = 0
[HideInInspector] _utsTechnique("Technique", int) = 0 //DWF [HideInInspector] _utsTechnique("Technique", int) = 0 //DWF
@@ -419,28 +446,6 @@ Shader "HDRP/Toon"
[Enum(Multiply,0, Add,1)] _Is_BlendAddToRimColor("Is_BlendAddToRimColor", Float) = 1 [Enum(Multiply,0, Add,1)] _Is_BlendAddToRimColor("Is_BlendAddToRimColor", Float) = 1
[Toggle(_)] _Is_UseTweakHighColorOnShadow("Is_UseTweakHighColorOnShadow", Float) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow("Is_UseTweakHighColorOnShadow", Float) = 0
_TweakHighColorOnShadow("TweakHighColorOnShadow", Range(0, 1)) = 0 _TweakHighColorOnShadow("TweakHighColorOnShadow", Range(0, 1)) = 0
//HiColorMask
_Set_HighColorMask("Set_HighColorMask", 2D) = "white" {}
_Tweak_HighColorMaskLevel("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0
[Toggle(_)] _RimLight("RimLight", Float) = 0
_RimLightColor("RimLightColor", Color) = (1, 1, 1, 1)
[Toggle(_)] _Is_LightColor_RimLight("Is_LightColor_RimLight", Float) = 1
[Toggle(_)] _Is_NormalMapToRimLight("Is_NormalMapToRimLight", Float) = 0
_RimLight_Strength("RimLight_Strength", Range(0, 10)) = 1
_RimLight_Power("RimLight_Power", Range(0, 1)) = 0.1
_RimLight_InsideMask("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001
[Toggle(_)] _RimLight_FeatherOff("RimLight_FeatherOff", Float) = 0
//RimLight
[Toggle(_)] _LightDirection_MaskOn("LightDirection_MaskOn", Float) = 0
_Tweak_LightDirection_MaskLevel("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0
[Toggle(_)] _Add_Antipodean_RimLight("Add_Antipodean_RimLight", Float) = 0
_Ap_RimLightColor("Ap_RimLightColor", Color) = (1, 1, 1, 1)
[Toggle(_)] _Is_LightColor_Ap_RimLight("Is_LightColor_Ap_RimLight", Float) = 1
_Ap_RimLight_Power("Ap_RimLight_Power", Range(0, 1)) = 0.1
[Toggle(_)] _Ap_RimLight_FeatherOff("Ap_RimLight_FeatherOff", Float) = 0
//RimLightMask
_Set_RimLightMask("Set_RimLightMask", 2D) = "white" {}
_Tweak_RimLightMaskLevel("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0
[Toggle(_)] _MatCap("MatCap", Float) = 0 [Toggle(_)] _MatCap("MatCap", Float) = 0
//v.2.0.6 //v.2.0.6
@@ -519,8 +524,6 @@ Shader "HDRP/Toon"
[Toggle(_)] _ComposerMaskMode("", Float) = 0 [Toggle(_)] _ComposerMaskMode("", Float) = 0
[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0
[HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1)
[KeywordEnum(NONE, SINGLE, FULL)] _Light_Loop_Mode ("Light Loop Mode", Float) = 2 [KeywordEnum(NONE, SINGLE, FULL)] _Light_Loop_Mode ("Light Loop Mode", Float) = 2
// //
// to here parameters for UTS> // to here parameters for UTS>
@@ -675,7 +678,7 @@ Shader "HDRP/Toon"
#pragma shader_feature_local_fragment _ANISOTROPYMAP #pragma shader_feature_local_fragment _ANISOTROPYMAP
#pragma shader_feature_local_fragment _SPECULARCOLORMAP #pragma shader_feature_local_fragment _SPECULARCOLORMAP
#pragma shader_feature_local_fragment _EMISSIVECOLORMAP #pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
#if _PBR_MODE_OFF #if _PBR_MODE_OFF
#undef _MASKMAP #undef _MASKMAP
@@ -1037,7 +1040,7 @@ Shader "HDRP/Toon"
#pragma shader_feature_local_fragment _ANISOTROPYMAP #pragma shader_feature_local_fragment _ANISOTROPYMAP
#pragma shader_feature_local_fragment _SPECULARCOLORMAP #pragma shader_feature_local_fragment _SPECULARCOLORMAP
#pragma shader_feature_local_fragment _EMISSIVECOLORMAP #pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
#pragma shader_feature_local_fragment _OUTLINECOLORMAP #pragma shader_feature_local_fragment _OUTLINECOLORMAP

View File

@@ -24,11 +24,6 @@
#define Uts_ColorSpaceDielectricSpec half4(0.04, 0.04, 0.04, 1.0 - 0.04) #define Uts_ColorSpaceDielectricSpec half4(0.04, 0.04, 0.04, 1.0 - 0.04)
#if 1
struct UTSData
{
};
struct UTSSurfaceData struct UTSSurfaceData
{ {
@@ -185,7 +180,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
#ifdef _SPECULARCOLORMAP #ifdef _SPECULARCOLORMAP
specularColor = SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)).rgb * _SpecularColor; specularColor = SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)).rgb * _SpecularColor;
#endif #endif
specularColor = GetSpecularColor(_MainTex_var.rgb * _BaseColor.rgb, metallic); specularColor = GetSpecularColor(output.baseColor, metallic);
#endif #endif
output.metallic = metallic; output.metallic = metallic;
@@ -198,7 +193,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
output.geomNormalWS = input.tangentToWorld[2]; output.geomNormalWS = input.tangentToWorld[2];
output.tangentWS = Orthonormalize(input.tangentToWorld[0].rgb, normalWS); output.tangentWS = Orthonormalize(input.tangentToWorld[0].rgb, normalWS);
output.subsurfaceColor = SAMPLE_TEXTURE2D(_SSSLutMap, sampler_MainTex, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)) * _SSSIntensity; output.subsurfaceColor = SAMPLE_TEXTURE2D(_SSSLutMap, s_linear_clamp_sampler, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)) * _SSSIntensity;
output.anisotropy = anisotropy; output.anisotropy = anisotropy;
@@ -457,8 +452,6 @@ inline float3 LinearToGammaSpace(float3 linRGB)
#define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,unity_FogColor) #define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,unity_FogColor)
#endif #endif
#endif //#if false
#ifdef DIRECTIONAL #ifdef DIRECTIONAL
#define LIGHTING_COORDS(idx1,idx2) SHADOW_COORDS(idx1) #define LIGHTING_COORDS(idx1,idx2) SHADOW_COORDS(idx1)
#define TRANSFER_VERTEX_TO_FRAGMENT(a) TRANSFER_SHADOW(a) #define TRANSFER_VERTEX_TO_FRAGMENT(a) TRANSFER_SHADOW(a)

View File

@@ -149,7 +149,7 @@ float GetHairShadow(PositionInputs posInput, float3 L)
// Then sample the hair buffer, to see if the fragment lands in shadow. // Then sample the hair buffer, to see if the fragment lands in shadow.
float2 scaledUVs = samplingPoint * _HairShadowRTHandleScale.xy; // We have to including the scaling factor for our shadow map since we are not going to allocate new texture if the rendering resolution changed. float2 scaledUVs = samplingPoint * _HairShadowRTHandleScale.xy; // We have to including the scaling factor for our shadow map since we are not going to allocate new texture if the rendering resolution changed.
float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r; float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_linear_clamp_sampler, scaledUVs).r;
float shadowMask = posInput.deviceDepth <= hairDepth + _HairShadowDepthBias ? 1 : 0; // Hair < Face means Hair are closer to camera float shadowMask = posInput.deviceDepth <= hairDepth + _HairShadowDepthBias ? 1 : 0; // Hair < Face means Hair are closer to camera
// Note that we have LinearEyeDepth in the buffer. A comparison of depth is needed so that we don't project the shadow of hair behind the face. // Note that we have LinearEyeDepth in the buffer. A comparison of depth is needed so that we don't project the shadow of hair behind the face.
shadow = lerp(1, 1.0 - hairShadowOpacity, shadowMask); shadow = lerp(1, 1.0 - hairShadowOpacity, shadowMask);
@@ -226,6 +226,18 @@ DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, Pr
return lighting; return lighting;
} }
float3 UtsEvaluateRimLight(UtsBSDFData bsdfData, PreLightData preLightData, float3 L, float3 lightColor)
{
float clampNdotV = ClampNdotV(preLightData.NdotV);
float rimLightWeight = 1.0 - clampNdotV;
rimLightWeight = pow(rimLightWeight, exp2(lerp(3.0, 0.0, _RimLightLevel)));
float3 rimlightColor = rimLightWeight * _RimLightColor * _RimLightStrength;
float3 outColor = rimlightColor;
return outColor;
}
DirectLighting UtsEvaluateAngelRing(FragInputs input, float3 normalWS, float3 V) DirectLighting UtsEvaluateAngelRing(FragInputs input, float3 normalWS, float3 V)
{ {
DirectLighting lighting; DirectLighting lighting;

View File

@@ -256,6 +256,7 @@ void ApplyAmbientOcclusion(AmbientOcclusionFactor aoFactor, inout BuiltinData bu
void AdjustIndirectLighting(PreLightData preLightData, UtsBSDFData bsdfData, inout BuiltinData builtinData, inout AggregateLighting lighting) void AdjustIndirectLighting(PreLightData preLightData, UtsBSDFData bsdfData, inout BuiltinData builtinData, inout AggregateLighting lighting)
{ {
builtinData.emissiveColor *= GetCurrentExposureMultiplier();
builtinData.bakeDiffuseLighting = ApplyCurrentExposureMultiplier(builtinData.bakeDiffuseLighting * bsdfData.diffuseColor * preLightData.diffuseFGD * _IndirectDiffuseIntensity); builtinData.bakeDiffuseLighting = ApplyCurrentExposureMultiplier(builtinData.bakeDiffuseLighting * bsdfData.diffuseColor * preLightData.diffuseFGD * _IndirectDiffuseIntensity);
lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IndirectSpecularIntensity); lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IndirectSpecularIntensity);
} }

View File

@@ -140,11 +140,6 @@ float _PPDMaxSamples;
float _PPDMinSamples; float _PPDMinSamples;
float _PPDLodThreshold; float _PPDLodThreshold;
float3 _EmissiveColor;
float _AlbedoAffectEmissive;
float _EmissiveExposureWeight;
float _ObjectSpaceUVMappingEmissive;
int _SpecularOcclusionMode; int _SpecularOcclusionMode;
// Transparency // Transparency

View File

@@ -25,6 +25,13 @@ float _SDFHighlightStrength;
float _ShadowDistanceBias; float _ShadowDistanceBias;
float _ShadowNormalBias; float _ShadowNormalBias;
// Emissive
float3 _EmissiveColor;
fixed _AlbedoAffectEmissive;
fixed _EmissiveExposureWeight;
float _ObjectSpaceUVMappingEmissive;
// Ambient // Ambient
float _IndirectDiffuseMatCapLod; float _IndirectDiffuseMatCapLod;
@@ -37,6 +44,11 @@ float _IndirectSpecularMatCapLod;
float _IndirectSpecularIntensity; float _IndirectSpecularIntensity;
float _SSRWeight; float _SSRWeight;
//Rim Light
float4 _RimLightColor;
float _RimLightStrength;
float _RimLightLevel;
// Outline // Outline
float _OutlineWidth; float _OutlineWidth;
float4 _OutlineColor; float4 _OutlineColor;
@@ -85,12 +97,9 @@ fixed _Is_UseTweakHighColorOnShadow;
float _TweakHighColorOnShadow; float _TweakHighColorOnShadow;
float4 _Set_HighColorMask_ST; float4 _Set_HighColorMask_ST;
float _Tweak_HighColorMaskLevel; float _Tweak_HighColorMaskLevel;
fixed _RimLight;
float4 _RimLightColor;
float _RimLight_Strength;
fixed _Is_LightColor_RimLight; fixed _Is_LightColor_RimLight;
fixed _Is_NormalMapToRimLight; fixed _Is_NormalMapToRimLight;
float _RimLight_Power;
float _RimLight_InsideMask; float _RimLight_InsideMask;
fixed _RimLight_FeatherOff; fixed _RimLight_FeatherOff;
fixed _LightDirection_MaskOn; fixed _LightDirection_MaskOn;
@@ -136,7 +145,6 @@ float4 _ViewShift;
float _ColorShift_Speed; float _ColorShift_Speed;
fixed _Is_ColorShift; fixed _Is_ColorShift;
fixed _Is_ViewShift; fixed _Is_ViewShift;
float3 emissive;
// //
float _Unlit_Intensity; float _Unlit_Intensity;

View File

@@ -93,7 +93,6 @@ void Frag(PackedVaryingsToPS packedInput,
#endif #endif
float4 UV0 = input.texCoord0; float4 UV0 = input.texCoord0;
UTSData utsData;
// We need to readapt the SS position as our screen space positions are for a low res buffer, but we try to access a full res buffer. // We need to readapt the SS position as our screen space positions are for a low res buffer, but we try to access a full res buffer.
input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy; input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy;