Updated OutlineScope;

Reorgnize shader code;
This commit is contained in:
2025-02-03 13:46:31 +09:00
parent 281dfbc4f0
commit 886432db7b
24 changed files with 275 additions and 293 deletions

View File

@@ -0,0 +1,40 @@
using UnityEngine;
using static Misaki.HdrpToon.UtsShaderPropertyName;
namespace Misaki.HdrpToon.Editor
{
internal static class MaterialHelpers
{
public static ShadingMode GetShadingMode(this Material material)
{
if (!material.HasProperty(SurfaceOptions.SHADING_MODE))
{
return ShadingMode.Standard;
}
return (ShadingMode)material.GetInteger(SurfaceOptions.SHADING_MODE);
}
public static PBRMode GetPBRMode(this Material material)
{
if (!material.HasProperty(SurfaceOptions.PBR_MODE))
{
return PBRMode.Off;
}
return (PBRMode)material.GetInteger(SurfaceOptions.PBR_MODE);
}
public static bool HasFeature(this Material material, SurfaceFeature feature)
{
if (!material.HasProperty(SurfaceOptions.SURFACE_FEATURE))
{
return false;
}
var value = (SurfaceFeature)material.GetInteger(SurfaceOptions.SURFACE_FEATURE);
return (value & feature) != 0;
}
}
}

View File

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

View File

@@ -12,9 +12,9 @@ namespace Misaki.HdrpToon.Editor
return (PBRMode)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_PBR_Mode").floatValue; return (PBRMode)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_PBR_Mode").floatValue;
} }
public static bool HasFeature(this UTSShaderGUI shaderGUI, SurfaceFeatureFlags feature) public static bool HasFeature(this UTSShaderGUI shaderGUI, SurfaceFeature feature)
{ {
return ((SurfaceFeatureFlags)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_Surface_Features").floatValue & feature) != 0; return ((SurfaceFeature)shaderGUI.GetUIScope<SurfaceOptionsScope>().FindProperty("_Surface_Features").floatValue & feature) != 0;
} }
} }
} }

View File

@@ -77,8 +77,7 @@ namespace Misaki.HdrpToon.Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel); EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
EditorGUI.indentLevel++; 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);
@@ -91,8 +90,6 @@ namespace Misaki.HdrpToon.Editor
{ {
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText); editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
} }
EditorGUI.indentLevel--;
} }
if (indirectSpecularMode != (int)IndirectSpecularMode.Off) if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
@@ -100,8 +97,7 @@ namespace Misaki.HdrpToon.Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel); EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
EditorGUI.indentLevel++; 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);
@@ -109,8 +105,6 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText); editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText); editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
EditorGUI.indentLevel--;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Misaki.ShaderGUI; using Misaki.ShaderGUI;
using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@@ -23,7 +24,7 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent angelRingOffsetVText = new("Angel Ring Offset V", "Specifies the offset of the angel ring in the V direction."); public static readonly GUIContent angelRingOffsetVText = new("Angel Ring Offset V", "Specifies the offset of the angel ring in the V direction.");
} }
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.AngelRing); protected override bool ShowSection => editor.GetMaterials().All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing; protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;

View File

@@ -2,12 +2,16 @@ using Misaki.ShaderGUI;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using static Misaki.HdrpToon.UtsShaderPropertyName.Outline;
namespace Misaki.HdrpToon.Editor namespace Misaki.HdrpToon.Editor
{ {
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable> internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
{ {
private static class Properties private static class Properties
{ {
public static MaterialProperty outlineState;
public static MaterialProperty outlineWidth; public static MaterialProperty outlineWidth;
public static MaterialProperty outlineWidthMap; public static MaterialProperty outlineWidthMap;
@@ -25,6 +29,8 @@ namespace Misaki.HdrpToon.Editor
private static class Styles private static class Styles
{ {
public static readonly GUIContent outlineStateText = new("Outline State", "Enable the outline pass for this material instance.");
public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline."); public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline.");
public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline."); public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline.");
public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color."); public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color.");
@@ -36,37 +42,43 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation."); public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation.");
} }
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.Outline);
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline; protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings"); protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.outlineWidth = FindProperty("_OutlineWidth"); Properties.outlineState = FindProperty(OUTLINE_STATE);
Properties.outlineWidthMap = FindProperty("_OutlineWidthMap");
Properties.outlineColor = FindProperty("_OutlineColor"); Properties.outlineWidth = FindProperty(OUTLINE_WIDTH);
Properties.outlineColorMap = FindProperty("_OutlineColorMap"); Properties.outlineWidthMap = FindProperty(OUTLINE_WIDTH_MAP);
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
Properties.skyColorAffectOutline = FindProperty("_SkyColorAffectOutline");
Properties.skyColorIntensity = FindProperty("_SkyColorIntensity");
Properties.fadeIn = FindProperty("_OutlineFadeIn"); Properties.outlineColor = FindProperty(OUTLINE_COLOR);
Properties.fadeOut = FindProperty("_OutlineFadeOut"); Properties.outlineColorMap = FindProperty(OUTLINE_COLOR_MAP);
Properties.albedoAffectOutline = FindProperty(ALBEDO_AFFECT_OUTLINE);
Properties.skyColorAffectOutline = FindProperty(SKY_COLOR_AFFECT_OUTLINE);
Properties.skyColorIntensity = FindProperty(SKY_COLOR_INTENSITY);
Properties.useSmoothedNormal = FindProperty("_UseSmoothedNormal"); Properties.fadeIn = FindProperty(OUTLINE_FADE_IN);
Properties.fadeOut = FindProperty(OUTLINE_FADE_OUT);
Properties.useSmoothedNormal = FindProperty(USE_SMOOTHED_NORMAL);
} }
protected override void DrawContent() protected override void DrawContent()
{ {
editor.ShaderProperty(Properties.outlineState, Styles.outlineStateText);
using var disabledScope = new EditorGUI.DisabledScope(!Properties.outlineState.GetBooleanValue());
EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth); editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor); editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText); editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
editor.ShaderProperty(Properties.skyColorAffectOutline, Styles.skyColorAffectOutlineText); editor.ShaderProperty(Properties.skyColorAffectOutline, Styles.skyColorAffectOutlineText);
if (Properties.skyColorAffectOutline.GetBooleanValue()) if (Properties.skyColorAffectOutline.GetBooleanValue())
{ {
using var skyColorIndentLevelScope = new EditorGUI.IndentLevelScope();
editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText); editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText);
} }

View File

@@ -1,4 +1,5 @@
using Misaki.ShaderGUI; using Misaki.ShaderGUI;
using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@@ -76,6 +77,10 @@ namespace Misaki.HdrpToon.Editor
"-1 gives 0% for the Rim Light effect, 0 gives 100% for the Rim Light and Mask effect, 1 gives 100% for the Rim Light and 0% for the Mask effect."); "-1 gives 0% for the Rim Light effect, 0 gives 100% for the Rim Light and Mask effect, 1 gives 100% for the Rim Light and 0% for the Mask effect.");
} }
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Rimlight;
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Rim Light Settings");
protected override bool ShowSection => editor.GetMaterials().All(mat => mat.HasFeature(SurfaceFeature.RimLight));
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.rimLightEnabled = FindProperty("_RimLight"); Properties.rimLightEnabled = FindProperty("_RimLight");
@@ -97,46 +102,32 @@ namespace Misaki.HdrpToon.Editor
protected override void DrawContent() protected override void DrawContent()
{ {
editor.ShaderProperty(Properties.rimLightEnabled, Styles.rimLightEnabledText); editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
EditorGUI.BeginDisabledGroup(Properties.rimLightEnabled.floatValue == 0); editor.ShaderProperty(Properties.rimLightStrength, Styles.rimLightStrengthText);
{ editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
EditorGUI.indentLevel++; editor.ShaderProperty(Properties.colorBlendingMode, Styles.colorBlendingModeText);
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText); editor.ShaderProperty(Properties.adjustRimLightArea, Styles.adjustRimLightAreaText);
editor.ShaderProperty(Properties.rimLightStrength, Styles.rimLightStrengthText); editor.ShaderProperty(Properties.rimLightFeatherOff, Styles.rimLightFeatherOffText);
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText); editor.ShaderProperty(Properties.lightDirection, Styles.lightDirectionText);
editor.ShaderProperty(Properties.colorBlendingMode, Styles.colorBlendingModeText);
editor.ShaderProperty(Properties.adjustRimLightArea, Styles.adjustRimLightAreaText);
editor.ShaderProperty(Properties.rimLightFeatherOff, Styles.rimLightFeatherOffText);
editor.ShaderProperty(Properties.lightDirection, Styles.lightDirectionText);
EditorGUI.BeginDisabledGroup(Properties.lightDirection.floatValue == 0);
{
EditorGUI.indentLevel++;
editor.ShaderProperty(Properties.lightDirectionRimLightLevel,
Styles.lightDirectionRimLightLevelText);
editor.ShaderProperty(Properties.invertedDirectionRimLight,
Styles.invertedDirectionRimLightText);
EditorGUI.BeginDisabledGroup(Properties.invertedDirectionRimLight.floatValue == 0);
{
EditorGUI.indentLevel++;
editor.ShaderProperty(Properties.invertedRimLightColor, Styles.invertedRimLightColorText);
editor.ShaderProperty(Properties.inversedRimLightLevel, Styles.inversedRimLightLevelText);
editor.ShaderProperty(Properties.invertedRimLightFeatherOff,
Styles.invertedRimLightFeatherOffText);
}
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel--;
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.Space();
EditorGUI.indentLevel--;
editor.TexturePropertySingleLine(Styles.rimLightMaskMapText, Properties.rimLightMaskMap);
editor.ShaderProperty(Properties.rimLightMaskLevel, Styles.rimLightMaskLevelText);
}
EditorGUI.EndDisabledGroup();
}
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Rimlight; using (var lightDisabledGroup = new EditorGUI.DisabledScope(!Properties.lightDirection.GetBooleanValue()))
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Rim Light Settings"); {
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.RimLight); using var lightIndentLevelScope = new EditorGUI.IndentLevelScope();
editor.ShaderProperty(Properties.lightDirectionRimLightLevel, Styles.lightDirectionRimLightLevelText);
editor.ShaderProperty(Properties.invertedDirectionRimLight, Styles.invertedDirectionRimLightText);
using var invertedDirectionDisabledGroup = new EditorGUI.DisabledScope(!Properties.invertedDirectionRimLight.GetBooleanValue());
using var invertedDirectionIndentLevelScope = new EditorGUI.IndentLevelScope();
editor.ShaderProperty(Properties.invertedRimLightColor, Styles.invertedRimLightColorText);
editor.ShaderProperty(Properties.inversedRimLightLevel, Styles.inversedRimLightLevelText);
editor.ShaderProperty(Properties.invertedRimLightFeatherOff, Styles.invertedRimLightFeatherOffText);
}
EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.rimLightMaskMapText, Properties.rimLightMaskMap);
editor.ShaderProperty(Properties.rimLightMaskLevel, Styles.rimLightMaskLevelText);
}
} }
} }

View File

@@ -1,4 +1,5 @@
using Misaki.ShaderGUI; using Misaki.ShaderGUI;
using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@@ -8,7 +9,7 @@ namespace Misaki.HdrpToon.Editor
{ {
private static class Properties private static class Properties
{ {
public static MaterialProperty useShadingRampMap; public static MaterialProperty shadingRampMapState;
public static MaterialProperty baseColor; public static MaterialProperty baseColor;
public static MaterialProperty baseColorMap; public static MaterialProperty baseColorMap;
@@ -35,7 +36,7 @@ namespace Misaki.HdrpToon.Editor
private static class Styles private static class Styles
{ {
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 shadingRampMapStateText = new("Shading Ramp Map State", "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 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.");
@@ -53,7 +54,7 @@ namespace Misaki.HdrpToon.Editor
public static readonly GUIContent sdfSmoothLevelText = new("SDF Smooth Level", "Control the smoothness of the shadow edge."); 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 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."); public static readonly GUIContent shadingRampMapText = new("Shading Ramp 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;
@@ -78,7 +79,7 @@ namespace Misaki.HdrpToon.Editor
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.useShadingRampMap = FindProperty("_Use_Shading_Ramp_Map"); Properties.shadingRampMapState = FindProperty("_Use_Shading_Ramp_Map");
Properties.baseColor = FindProperty("_BaseColor"); Properties.baseColor = FindProperty("_BaseColor");
Properties.baseColorMap = FindProperty("_BaseColorMap"); Properties.baseColorMap = FindProperty("_BaseColorMap");
@@ -105,17 +106,17 @@ namespace Misaki.HdrpToon.Editor
protected override void DrawContent() protected override void DrawContent()
{ {
editor.ShaderProperty(Properties.useShadingRampMap, Styles.useShadingRampMapText); editor.ShaderProperty(Properties.shadingRampMapState, Styles.shadingRampMapStateText);
editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor); editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor);
if (Properties.useShadingRampMap.GetBooleanValue()) if (Properties.shadingRampMapState.GetBooleanValue())
{ {
editor.TexturePropertySingleLine(Styles.shadingRampMapText, Properties.shadingRampMap, Properties.shadingIndex); editor.TexturePropertySingleLine(Styles.shadingRampMapText, Properties.shadingRampMap, Properties.shadingIndex);
} }
else else
{ {
DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText); DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText);
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.Standard) if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.Standard))
{ {
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText); DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
@@ -127,7 +128,7 @@ namespace Misaki.HdrpToon.Editor
} }
} }
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.SDF) if (editor.GetMaterials().All(material => material.GetShadingMode() == ShadingMode.SDF))
{ {
EditorGUILayout.Space(); EditorGUILayout.Space();
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap); editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);

View File

@@ -1,4 +1,5 @@
using Misaki.ShaderGUI; using Misaki.ShaderGUI;
using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditor.Rendering; using UnityEditor.Rendering;
using UnityEngine; using UnityEngine;
@@ -32,42 +33,21 @@ namespace Misaki.HdrpToon.Editor
private static class Styles private static class Styles
{ {
public static readonly GUIContent NormalMapText = public static readonly GUIContent NormalMapText = new("Normal Map", "A texture that dictates the bumpiness of the material.");
new("Normal Map", "A texture that dictates the bumpiness of the material."); 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 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 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 MaskMapText = new("Mask Map", public static readonly GUIContent AnisotropyMapText = new("Anisotropy Map", "Specifies the anisotropy map of the material.");
"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 KKColorText = new("KK specular Color", "Specifies the color of KK specular.");
public static readonly GUIContent BSDFContributionText = new("BSDF Contribution", "BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation");
public static readonly GUIContent MetallicText = public static readonly GUIContent SpecularColorMapText = new("Specular Color Map", "Specifies the specular color map of the material.");
new("Metallic", "Specifies the metallicness of the material."); public static readonly GUIContent SpecRemap = new("Specular Remap", "Feather and step value of Toon Specular");
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 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 AnisotropyMapText =
new("Anisotropy Map", "Specifies the anisotropy map of the material.");
public static readonly GUIContent KKColorText = new("KK specular Color",
"Specifies the color of KK specular.");
public static readonly GUIContent BSDFContributionText = new("BSDF Contribution",
"BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation");
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");
} }
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs; protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceInputs;
@@ -99,35 +79,18 @@ namespace Misaki.HdrpToon.Editor
protected override void DrawContent() protected override void DrawContent()
{ {
editor.KeywordTexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale); editor.KeywordTexturePropertySingleLine(Styles.NormalMapText, Properties.NormalMap, Properties.NormalMapScale);
//var materials = editor.GetMaterials().ToList();
//foreach (var material in materials)
//{
// material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"),
// Properties.NormalMap.textureValue != null);
//}
var pbrMode = SurfaceOptionsScope.GetPBRMode(); if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.Off))
if (pbrMode != PBRMode.Off)
{ {
if (editor.KeywordTexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap)) if (editor.KeywordTexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap))
{ {
//foreach (var material in materials)
//{
// material.EnableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
//}
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.RoughnessRemapMin, Properties.RoughnessRemapMax, 0, 1, Styles.RoughnessRemap);
} }
else else
{ {
//foreach (var material in materials) if (editor.GetMaterials().All(mat => mat.GetPBRMode() != PBRMode.KKHair))
//{
// material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
//}
if (pbrMode != PBRMode.KKHair)
{ {
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText); editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
} }
@@ -135,72 +98,24 @@ namespace Misaki.HdrpToon.Editor
editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText); editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText);
} }
} }
else
{
editor.SetKeyword("_MASKMAP", false);
editor.SetKeyword("_ANISOTROPY_MAP", false);
editor.SetKeyword("_SPECULAR_COLOR_MAP", false);
//foreach (var material in materials) if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.KKHair))
//{ {
// material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP")); editor.KeywordTexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap, Properties.Anisotropy);
// material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP")); if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.KKHair))
// material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP")); {
//} editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
editor.ShaderProperty(Properties.BSDFContribution, Styles.BSDFContributionText);
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Anisotropy Map only ST");
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
} }
else if (editor.GetMaterials().All(mat => mat.GetPBRMode() == PBRMode.Toon))
switch (pbrMode)
{ {
case PBRMode.Anisotropy or PBRMode.KKHair: editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
{ editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
editor.KeywordTexturePropertySingleLine(Styles.AnisotropyMapText, Properties.AnisotropyMap, Properties.Anisotropy);
if (pbrMode == PBRMode.KKHair)
{
editor.ShaderProperty(Properties.KKColor, Styles.KKColorText);
editor.ShaderProperty(Properties.BSDFContribution, Styles.BSDFContributionText);
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Anisotropy Map only ST");
editor.TextureScaleOffsetProperty(Properties.AnisotropyMap);
//if (Properties.AnisotropyMap.textureValue == null)
//{
// foreach (var material in materials)
// {
// material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
// }
//}
//else
//{
// foreach (var material in materials)
// {
// material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
// }
//}
break;
}
case PBRMode.Toon:
{
editor.KeywordTexturePropertySingleLine(Styles.SpecularColorMapText, Properties.SpecularColorMap, Properties.SpecularColor);
//if (Properties.SpecularColorMap.textureValue == null)
//{
// foreach (var material in materials)
// {
// material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
// }
//}
//else
//{
// foreach (var material in materials)
// {
// material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
// }
//}
editor.MinMaxShaderProperty(Properties.SpecularFeather, Properties.SpecularStep, 0, 1, Styles.SpecRemap);
break;
}
} }
} }
} }

View File

@@ -42,21 +42,6 @@ namespace Misaki.HdrpToon.Editor
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options"); protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
public static ShadingMode GetShadingMode()
{
return (ShadingMode)Properties.shadingMode.floatValue;
}
public static PBRMode GetPBRMode()
{
return (PBRMode)Properties.pbrMode.floatValue;
}
public static bool HasFeature(SurfaceFeatureFlags feature)
{
return ((SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue & feature) != 0;
}
public override void LoadMaterialProperties() public override void LoadMaterialProperties()
{ {
Properties.transparentMode = FindProperty("_TransparentEnabled"); Properties.transparentMode = FindProperty("_TransparentEnabled");
@@ -100,17 +85,7 @@ namespace Misaki.HdrpToon.Editor
} }
} }
var surfaceFeatures = (SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue; editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
EditorGUI.BeginChangeCheck();
surfaceFeatures = (SurfaceFeatureFlags)EditorGUILayout.EnumFlagsField(Styles.surfaceFeaturesText, surfaceFeatures);
if (EditorGUI.EndChangeCheck())
{
Properties.surfaceFeatures.floatValue = (float)surfaceFeatures;
foreach (var material in editor.GetMaterials())
{
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, HasFeature(SurfaceFeatureFlags.Outline));
}
}
} }
} }
} }

View File

@@ -0,0 +1,29 @@
namespace Misaki.HdrpToon
{
internal static class UtsShaderPropertyName
{
public static class SurfaceOptions
{
public const string SHADING_MODE = "_Shading_Mode";
public const string PBR_MODE = "_PBR_Mode";
public const string SURFACE_FEATURE = "_SurfaceFeatures";
}
public static class Outline
{
public const string OUTLINE_STATE = "_OutlineState";
public const string OUTLINE_WIDTH = "_OutlineWidth";
public const string OUTLINE_WIDTH_MAP = "_OutlineWidthMap";
public const string OUTLINE_COLOR = "_OutlineColor";
public const string OUTLINE_COLOR_MAP = "_OutlineColorMap";
public const string ALBEDO_AFFECT_OUTLINE = "_AlbedoAffectOutline";
public const string SKY_COLOR_AFFECT_OUTLINE = "_SkyColorAffectOutline";
public const string SKY_COLOR_INTENSITY = "_SkyColorIntensity";
public const string OUTLINE_FADE_IN = "_OutlineFadeIn";
public const string OUTLINE_FADE_OUT = "_OutlineFadeOut";
public const string USE_SMOOTHED_NORMAL = "_UseSmoothedNormal";
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 723370b3a1613cb43b85b765ebcebee3

View File

@@ -5,12 +5,11 @@ namespace Misaki.HdrpToon
{ {
[Flags] [Flags]
[GenerateHLSL(PackingRules.Exact)] [GenerateHLSL(PackingRules.Exact)]
public enum SurfaceFeatureFlags public enum SurfaceFeature
{ {
None = 0, None = 0,
RimLight = 1 << 0, RimLight = 1 << 0,
Stocking = 1 << 1, Stocking = 1 << 1,
AngelRing = 1 << 2, AngelRing = 1 << 2
Outline = 1 << 3
} }
} }

View File

@@ -0,0 +1,16 @@
//
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
//
#ifndef SURFACEFEATURE_CS_HLSL
#define SURFACEFEATURE_CS_HLSL
//
// Misaki.HdrpToon.SurfaceFeature: static fields
//
#define SURFACEFEATURE_NONE (0)
#define SURFACEFEATURE_RIM_LIGHT (1)
#define SURFACEFEATURE_STOCKING (2)
#define SURFACEFEATURE_ANGEL_RING (4)
#endif

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: ec297400b1508d647a7cdbad2c0edf40 guid: 1ae94e9055342d643a02bd5b4a9fa20b
ShaderIncludeImporter: ShaderIncludeImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 598a7ef5d67c6334ca8f930f37ea989b

View File

@@ -1,16 +0,0 @@
//
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
//
#ifndef SURFACEFEATUREFLAGS_CS_HLSL
#define SURFACEFEATUREFLAGS_CS_HLSL
//
// Misaki.HdrpToon.SurfaceFeatureFlags: static fields
//
#define SURFACEFEATUREFLAGS_RIM_LIGHT (1)
#define SURFACEFEATUREFLAGS_STOCKING (2)
#define SURFACEFEATUREFLAGS_ANGEL_RING (4)
#define SURFACEFEATUREFLAGS_OUTLINE (8)
#endif

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 737ea728a50a7664b90cba3dd3e21249

View File

@@ -157,7 +157,7 @@ Shader "HDRP/Toon"
[HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0
[HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0
[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0
[Enum(Off, 0, Front, 1, Back, 2)] _CullMode("__cullmode", Float) = 2.0 //[Enum(Off, 0, Front, 1, Back, 2)] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent
[HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
@@ -234,15 +234,15 @@ Shader "HDRP/Toon"
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Surface Options // Surface Options
[Enum(Off, 0, On, 1)] _TransparentEnabled("Transparent Mode", int) = 0 [Popup] _TransparentEnabled("Transparent Mode", Integer) = 0
[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", Integer) = 2
[KeywordEnum(Standard, SDF)] _Shading_Mode("Shade Grade mode", Float) = 0 [KeywordEnum(Standard, SDF)] _Shading_Mode("Shading mode", Integer) = 0
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", int) = 0 [KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", Integer) = 0
[KeywordEnum(Off, Standard, Anisotropy, KKHair, Toon)] _PBR_Mode("PBR Mode", int) = 0 [KeywordEnum(Off, Standard, Anisotropy, KKHair, Toon)] _PBR_Mode("PBR Mode", Integer) = 0
[ToggleUI] _HairBlendingTarget("Hair Blending Target", Float) = 0 [ToggleUI] _HairBlendingTarget("Hair Blending Target", Integer) = 0
_SurfaceFeatures("Surface Features", Float) = 0 [EnumFlagsUI(Misaki.HdrpToon.SurfaceFeature, Misaki.HdrpToon)]_SurfaceFeatures("Surface Features", Integer) = 0
// Shading Color // Shading Color
[Popup] _Use_Shading_Ramp_Map("Use Shading Ramp Map", Integer) = 0 [Popup] _Use_Shading_Ramp_Map("Use Shading Ramp Map", Integer) = 0
@@ -325,6 +325,7 @@ Shader "HDRP/Toon"
_AngelRingOffsetV("Angel Ring Offset V", Range(0, 1)) = 0 _AngelRingOffsetV("Angel Ring Offset V", Range(0, 1)) = 0
// Outline // Outline
[PassPopup(Outline)] _OutlineState("Outline State", Integer) = 0
_OutlineWidth("Outline Width", Float) = 0 _OutlineWidth("Outline Width", Float) = 0
_OutlineWidthMap("Outline Tex", 2D) = "white" {} _OutlineWidthMap("Outline Tex", 2D) = "white" {}
_OutlineColor("Outline Color", Color) = (0.5, 0.5, 0.5, 1) _OutlineColor("Outline Color", Color) = (0.5, 0.5, 0.5, 1)
@@ -667,7 +668,20 @@ Shader "HDRP/Toon"
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#pragma multi_compile _ LIGHT_LAYERS #pragma multi_compile _ LIGHT_LAYERS
#pragma shader_feature_local_fragment _PBR_MODE_OFF
#pragma shader_feature_local_fragment _MASKMAP #pragma shader_feature_local_fragment _MASKMAP
#pragma shader_feature_local_fragment _NORMALMAP
#pragma shader_feature_local_fragment _ANISOTROPYMAP
#pragma shader_feature_local_fragment _SPECULARCOLORMAP
#pragma shader_feature_local_fragment _EMISSIVECOLORMAP
#if _PBR_MODE_OFF
#undef _MASKMAP
#undef _ANISOTROPYMAP
#undef _SPECULARCOLORMAP
#endif
#ifndef DEBUG_DISPLAY #ifndef DEBUG_DISPLAY
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer
@@ -676,9 +690,9 @@ Shader "HDRP/Toon"
#endif #endif
#define SHADERPASS SHADERPASS_GBUFFER #define SHADERPASS SHADERPASS_GBUFFER
#ifdef DEBUG_DISPLAY #ifdef DEBUG_DISPLAY
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
#endif #endif
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
// #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
@@ -1019,32 +1033,39 @@ Shader "HDRP/Toon"
#pragma shader_feature_local_fragment _INDIRECT_SPECULAR_MODE_OFF _INDIRECT_SPECULAR_MODE_IBL _INDIRECT_SPECULAR_MODE_MATCAP #pragma shader_feature_local_fragment _INDIRECT_SPECULAR_MODE_OFF _INDIRECT_SPECULAR_MODE_IBL _INDIRECT_SPECULAR_MODE_MATCAP
#pragma shader_feature_local_fragment _MASKMAP #pragma shader_feature_local_fragment _MASKMAP
#pragma shader_feature_local_fragment _NORMAL_MAP #pragma shader_feature_local_fragment _NORMALMAP
#pragma shader_feature_local_fragment _ANISOTROPY_MAP #pragma shader_feature_local_fragment _ANISOTROPYMAP
#pragma shader_feature_local_fragment _SPECULAR_COLOR_MAP #pragma shader_feature_local_fragment _SPECULARCOLORMAP
#pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
#pragma shader_feature_local_fragment _OUTLINE_COLOR_MAP #pragma shader_feature_local_fragment _EMISSIVECOLORMAP
#pragma shader_feature_local_fragment _OUTLINECOLORMAP
#if _PBR_MODE_OFF
#undef _MASKMAP
#undef _ANISOTROPYMAP
#undef _SPECULARCOLORMAP
#endif
#define PUNCTUAL_SHADOW_MEDIUM #define PUNCTUAL_SHADOW_MEDIUM
#define DIRECTIONAL_SHADOW_MEDIUM #define DIRECTIONAL_SHADOW_MEDIUM
#define AREA_SHADOW_MEDIUM #define AREA_SHADOW_MEDIUM
#ifndef SHADER_STAGE_FRAGMENT #ifndef SHADER_STAGE_FRAGMENT
#define SHADOW_LOW #define SHADOW_LOW
#define USE_FPTL_LIGHTLIST #define USE_FPTL_LIGHTLIST
#endif #endif
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
#endif #endif
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
#ifdef DEBUG_DISPLAY #ifdef DEBUG_DISPLAY
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
#endif #endif
// The light loop (or lighting architecture) is in charge to: // The light loop (or lighting architecture) is in charge to:
// - Define light list // - Define light list

View File

@@ -131,7 +131,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
#endif #endif
float4 normalLocal = float4(0, 0, 1.0, 1.0); float4 normalLocal = float4(0, 0, 1.0, 1.0);
#if _NORMAL_MAP #if _NORMALMAP
if (_Use_SSSLut) if (_Use_SSSLut)
{ {
normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap), _SSSIntensity); normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap), _SSSIntensity);
@@ -154,39 +154,39 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
float3 specularColor = 1; float3 specularColor = 1;
float anisotropy = 0; float anisotropy = 0;
#ifdef _MASKMAP #ifdef _MASKMAP
float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)); float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
metallic = _MaskMap_var.x; metallic = _MaskMap_var.x;
metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic); metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic);
ao = _MaskMap_var.y; ao = _MaskMap_var.y;
ao = lerp(_AORemapMin, _AORemapMax, ao); ao = lerp(_AORemapMin, _AORemapMax, ao);
smoothness = _MaskMap_var.w; smoothness = _MaskMap_var.w;
smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness); smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness);
#endif #endif
#ifdef _ANISOTROPY_MAP #ifdef _ANISOTROPYMAP
anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(input.texCoord0, _AnisotropyMap)).r; anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(input.texCoord0, _AnisotropyMap)).r;
#if _PBR_Mode_KK #if _PBR_Mode_KK
anisotropy += _Anisotropy - 0.5; anisotropy += _Anisotropy - 0.5;
#else #else
anisotropy *= _Anisotropy; anisotropy *= _Anisotropy;
#endif #endif
#else #else
anisotropy = 1.0; anisotropy = 1.0;
anisotropy *= _Anisotropy; anisotropy *= _Anisotropy;
#endif #endif
#ifdef _PBR_Mode_KK #ifdef _PBR_Mode_KK
metallic = 0.0; metallic = 0.0;
smoothness *=_BSDFContribution; smoothness *=_BSDFContribution;
#endif #endif
#ifdef _PBR_Mode_TOON #ifdef _PBR_Mode_TOON
#ifdef _SPECULAR_COLOR_MAP #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(_MainTex_var.rgb * _BaseColor.rgb, metallic);
#endif #endif
output.metallic = metallic; output.metallic = metallic;
output.ambientOcclusion = ao; output.ambientOcclusion = ao;

View File

@@ -4,7 +4,7 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/Models/SurfaceFeatureFlags.cs.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Models/SurfaceFeature.cs.hlsl"
// Channel mask enum. // Channel mask enum.
// this must be same to UI cs code // this must be same to UI cs code
@@ -372,7 +372,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
#endif #endif
} }
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATUREFLAGS_ANGEL_RING)) if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_ANGEL_RING))
{ {
DirectLighting lighting = UtsEvaluateAngelRing(fragInputs, bsdfData.normalWS, V); DirectLighting lighting = UtsEvaluateAngelRing(fragInputs, bsdfData.normalWS, V);
AccumulateDirectLighting(lighting, aggregateLighting); AccumulateDirectLighting(lighting, aggregateLighting);

View File

@@ -145,7 +145,7 @@ void Frag(PackedVaryingsToPS packedInput,
float4 outlineColor = _OutlineColor; float4 outlineColor = _OutlineColor;
outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb + ambientSkyColor, _SkyColorAffectOutline); outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb + ambientSkyColor, _SkyColorAffectOutline);
#if _OUTLINE_COLOR_MAP #if _OUTLINECOLORMAP
outlineColor *= SAMPLE_TEXTURE2D(_OutlineColorMap, sampler_OutlineColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb; outlineColor *= SAMPLE_TEXTURE2D(_OutlineColorMap, sampler_OutlineColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb;
#endif #endif
outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb * baseColor, _AlbedoAffectOutline); outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb * baseColor, _AlbedoAffectOutline);