Compare commits
21 Commits
458afd880f
...
3.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
| d19322b768 | |||
| 961db806e9 | |||
| 10331b93ff | |||
| abdf6196ed | |||
| 410af63578 | |||
| 5a282e0812 | |||
| b205c1523d | |||
| ea3e83157c | |||
| ee0b720b6d | |||
| b2136e1ff4 | |||
| 4ce84572d0 | |||
| eacbbc9b8b | |||
| d44ff7d58c | |||
| de370f845e | |||
| 3d06bb8129 | |||
| 680ebb72e5 | |||
| 74263900ac | |||
| 886432db7b | |||
| 281dfbc4f0 | |||
| ecd0cfdb9f | |||
| 3273812902 |
74
.gitignore
vendored
74
.gitignore
vendored
@@ -1,74 +0,0 @@
|
||||
# ---> Unity
|
||||
# This .gitignore file should be placed at the root of your Unity project directory
|
||||
#
|
||||
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
|
||||
#
|
||||
/[Ll]ibrary/
|
||||
/[Tt]emp/
|
||||
/[Oo]bj/
|
||||
/[Bb]uild/
|
||||
/[Bb]uilds/
|
||||
/[Ll]ogs/
|
||||
/[Uu]ser[Ss]ettings/
|
||||
|
||||
# MemoryCaptures can get excessive in size.
|
||||
# They also could contain extremely sensitive data
|
||||
/[Mm]emoryCaptures/
|
||||
|
||||
# Recordings can get excessive in size
|
||||
/[Rr]ecordings/
|
||||
|
||||
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||
# /[Aa]ssets/AssetStoreTools*
|
||||
|
||||
# Autogenerated Jetbrains Rider plugin
|
||||
/[Aa]ssets/Plugins/Editor/JetBrains*
|
||||
|
||||
# Visual Studio cache directory
|
||||
.vs/
|
||||
|
||||
# Gradle cache directory
|
||||
.gradle/
|
||||
|
||||
# Autogenerated VS/MD/Consulo solution and project files
|
||||
ExportedObj/
|
||||
.consulo/
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
*.svd
|
||||
*.pdb
|
||||
*.mdb
|
||||
*.opendb
|
||||
*.VC.db
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
*.pdb.meta
|
||||
*.mdb.meta
|
||||
|
||||
# Unity3D generated file on crash reports
|
||||
sysinfo.txt
|
||||
|
||||
# Builds
|
||||
*.apk
|
||||
*.aab
|
||||
*.unitypackage
|
||||
*.app
|
||||
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
# Packed Addressables
|
||||
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
|
||||
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
||||
|
||||
8
Editor/MeterialEditor/Deprecated.meta
Normal file
8
Editor/MeterialEditor/Deprecated.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcc6ebf595772354fbb5631c8e4cac04
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/MeterialEditor/Helpers.meta
Normal file
8
Editor/MeterialEditor/Helpers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f00671385fbbb674495b9f0b3d6dbe07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Editor/MeterialEditor/Helpers/MaterialHelpers.cs
Normal file
55
Editor/MeterialEditor/Helpers/MaterialHelpers.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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 MaterialType GetMaterialType(this Material material)
|
||||
{
|
||||
if (!material.HasProperty(SurfaceOptions.MATERIAL_TYPE))
|
||||
{
|
||||
return MaterialType.Standard;
|
||||
}
|
||||
|
||||
return (MaterialType)material.GetInteger(SurfaceOptions.MATERIAL_TYPE);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static bool IsHairBlendingTarget(this Material material)
|
||||
{
|
||||
return material.GetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/Helpers/MaterialHelpers.cs.meta
Normal file
2
Editor/MeterialEditor/Helpers/MaterialHelpers.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b32ea10056de246488796e50f7160a4a
|
||||
@@ -4,10 +4,10 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
SurfaceOptions = 1 << 0,
|
||||
ShadingColor = 1 << 1,
|
||||
ShadingGrade = 1 << 2,
|
||||
Shadow = 1 << 2,
|
||||
MaterialFeature = 1 << 3,
|
||||
PBR = 1 << 4,
|
||||
AmbientMode = 1 << 5,
|
||||
SurfaceInputs = 1 << 4,
|
||||
Ambient = 1 << 5,
|
||||
Highlight = 1 << 6,
|
||||
Rimlight = 1 << 7,
|
||||
MatCap = 1 << 8,
|
||||
@@ -19,5 +19,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
SceneLight = 1 << 14,
|
||||
EnvironmentalLightEffectiveness = 1 << 15,
|
||||
MetaverseSettings = 1 << 16,
|
||||
Advance = 1 << 17,
|
||||
}
|
||||
}
|
||||
|
||||
55
Editor/MeterialEditor/UIScopes/AdvanceScope.cs
Normal file
55
Editor/MeterialEditor/UIScopes/AdvanceScope.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.Advance;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class AdvanceScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty diffuseMin;
|
||||
|
||||
public static MaterialProperty lightIntensityMultiplier;
|
||||
public static MaterialProperty clampLightColor;
|
||||
|
||||
public static MaterialProperty lightLoopMode;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent diffuseMinText = new("Minimal diffuse contribution", "Specifies the minimum contribution of the base color to the diffuse light. Keep it 0 to make sure energy conservation.");
|
||||
|
||||
public static readonly GUIContent lightIntensityMultiplierText = new("Light Intensity Multiplier", "Specifies the intensity multiplier of the light.");
|
||||
public static readonly GUIContent clampLightColorText = new("Clamp Light Color", "Specifies whether to clamp the light color.");
|
||||
|
||||
public static readonly GUIContent lightLoopModeText = new("Light Loop Mode", "Specifies the light loop mode.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Advance;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Advance Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.diffuseMin = FindProperty(MINIMAL_DIFFUSE_CONTRIBUTION);
|
||||
|
||||
Properties.lightIntensityMultiplier = FindProperty(LIGHT_INTENSITY_MULTIPLIER);
|
||||
Properties.clampLightColor = FindProperty(CLAMP_LIGHT_COLOR);
|
||||
|
||||
Properties.lightLoopMode = FindProperty(LIGHT_LOOP_MODE);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.diffuseMin, Styles.diffuseMinText);
|
||||
|
||||
editor.ShaderProperty(Properties.lightIntensityMultiplier, Styles.lightIntensityMultiplierText);
|
||||
editor.ShaderProperty(Properties.clampLightColor, Styles.clampLightColorText);
|
||||
|
||||
editor.ShaderProperty(Properties.lightLoopMode, Styles.lightLoopModeText);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/AdvanceScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/AdvanceScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3acfee7f0a1007e4bb2a3b42a6282d52
|
||||
158
Editor/MeterialEditor/UIScopes/AmbientScope.cs
Normal file
158
Editor/MeterialEditor/UIScopes/AmbientScope.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class AmbientScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Ambient;
|
||||
protected override GUIContent Header => new("Ambient Settings");
|
||||
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty indirectDiffuseMode;
|
||||
public static MaterialProperty indirectSpecularMode;
|
||||
|
||||
public static MaterialProperty indirectDiffuseMatCapMap;
|
||||
public static MaterialProperty indirectDiffuseMatCapLod;
|
||||
|
||||
public static MaterialProperty indirectDiffuseRampMap;
|
||||
public static MaterialProperty indirectDiffuseRampIndex;
|
||||
public static MaterialProperty indirectDiffuseRampPosition;
|
||||
|
||||
public static MaterialProperty indirectDiffuseIntensity;
|
||||
public static MaterialProperty ssaoWeight;
|
||||
public static MaterialProperty ssgiWeight;
|
||||
|
||||
public static MaterialProperty indirectSpecularMatCapMap;
|
||||
public static MaterialProperty indirectSpecularMatCapLod;
|
||||
|
||||
public static MaterialProperty indirectReflectionIntensity;
|
||||
public static MaterialProperty ssrWeight;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent indirectDiffuseModeText = new("Indirect Diffuse Mode", "Specifies indirect diffuse mode.");
|
||||
public static readonly GUIContent indirectSpecularModeText = new("Indirect Specular Mode", "Specifies indirect specular mode.");
|
||||
|
||||
public static readonly GUIContent indirectDiffuseMatCapMapText = new("MatCap Map", "The material capture map for indirect diffuse evaluation, with the additional setting for controlling the LOD offset when sampling the indirect diffuse material capture map.");
|
||||
|
||||
public static readonly GUIContent indirectDiffuseRampMapText = new("Ramp Map", "The ramp map for indirect diffuse evaluation, with the additional setting for controlling the sampling index of the ramp map.");
|
||||
public static readonly GUIContent indirectDiffuseRampPositionText = new("Ramp Position", "The ramp position for indirect diffuse evaluation.");
|
||||
|
||||
public static readonly GUIContent indirectDiffuseIntensityText = new("Intensity", "The indirect diffuse color is added to the material color according to the intensity value.");
|
||||
public static readonly GUIContent ssaoWeightText = new("SSAO Weight", "The weight of SSAO.");
|
||||
public static readonly GUIContent ssgiWeightText = new("SSGI Weight", "The weight of SSGI.");
|
||||
|
||||
public static readonly GUIContent indirectSpecularMatCapMapText = new("MatCap Map", "The material capture map for indirect specular evaluation, with the additional setting for controlling the LOD offset when sampling the indirect specular material capture map.");
|
||||
|
||||
public static readonly GUIContent indirectReflectionIntensityText = new("Intensity", "The indirect reflection color is added to the material color according to the intensity value.");
|
||||
public static readonly GUIContent ssrWeightText = new("SSR Weight", "SSR Weight");
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.indirectDiffuseMode = FindProperty("_Indirect_Diffuse_Mode");
|
||||
Properties.indirectSpecularMode = FindProperty("_Indirect_Specular_Mode");
|
||||
|
||||
Properties.indirectDiffuseMatCapMap = FindProperty("_IndirectDiffuseMatCapMap");
|
||||
Properties.indirectDiffuseMatCapLod = FindProperty("_IndirectDiffuseMatCapLod");
|
||||
|
||||
Properties.indirectDiffuseRampMap = FindProperty("_IndirectDiffuseRampMap");
|
||||
Properties.indirectDiffuseRampIndex = FindProperty("_IndirectDiffuseRampIndex");
|
||||
Properties.indirectDiffuseRampPosition = FindProperty("_IndirectDiffuseRampPosition");
|
||||
|
||||
Properties.indirectDiffuseIntensity = FindProperty("_IndirectDiffuseIntensity");
|
||||
Properties.ssaoWeight = FindProperty("_SSAOWeight");
|
||||
Properties.ssgiWeight = FindProperty("_SSGIWeight");
|
||||
|
||||
Properties.indirectSpecularMatCapMap = FindProperty("_IndirectSpecularMatCapMap");
|
||||
Properties.indirectSpecularMatCapLod = FindProperty("_IndirectSpecularMatCapLod");
|
||||
|
||||
Properties.indirectReflectionIntensity = FindProperty("_IndirectSpecularIntensity");
|
||||
Properties.ssrWeight = FindProperty("_SSRWeight");
|
||||
}
|
||||
|
||||
private static void DrawIndirectDiffuseHeader()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
using var indentLevelScope = new EditorGUI.IndentLevelScope(-1);
|
||||
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
private void DrawIndirectDiffuseProperties()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.indirectDiffuseIntensity, Styles.indirectDiffuseIntensityText);
|
||||
editor.ShaderProperty(Properties.ssaoWeight, Styles.ssaoWeightText);
|
||||
}
|
||||
|
||||
private void DrawIndirectSpecularProperties()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
||||
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
||||
}
|
||||
|
||||
private static void DrawIndirectSpecularHeader()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
||||
{
|
||||
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.indirectDiffuseMode, Styles.indirectDiffuseModeText);
|
||||
editor.ShaderProperty(Properties.indirectSpecularMode, Styles.indirectSpecularModeText);
|
||||
|
||||
var indirectDiffuseMode = Properties.indirectDiffuseMode.GetEnumValue<IndirectDiffuseMode>();
|
||||
var indirectSpecularMode = Properties.indirectSpecularMode.GetEnumValue<IndirectSpecularMode>();
|
||||
|
||||
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
|
||||
{
|
||||
DrawIndirectDiffuseHeader();
|
||||
|
||||
switch (indirectDiffuseMode)
|
||||
{
|
||||
case IndirectDiffuseMode.IBL:
|
||||
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
||||
break;
|
||||
case IndirectDiffuseMode.Matcap:
|
||||
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
||||
break;
|
||||
case IndirectDiffuseMode.Ramp:
|
||||
editor.TexturePropertySingleLine(Styles.indirectDiffuseRampMapText, Properties.indirectDiffuseRampMap, Properties.indirectDiffuseRampIndex);
|
||||
editor.ShaderProperty(Properties.indirectDiffuseRampPosition, Styles.indirectDiffuseRampPositionText);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DrawIndirectDiffuseProperties();
|
||||
}
|
||||
|
||||
if (indirectSpecularMode != IndirectSpecularMode.Off)
|
||||
{
|
||||
DrawIndirectSpecularHeader();
|
||||
|
||||
switch (indirectSpecularMode)
|
||||
{
|
||||
case IndirectSpecularMode.IBL:
|
||||
break;
|
||||
case IndirectSpecularMode.Matcap:
|
||||
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DrawIndirectSpecularProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/MeterialEditor/UIScopes/AmbientScope.cs.meta
Normal file
3
Editor/MeterialEditor/UIScopes/AmbientScope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f3997bcef824e5a9bd3728830006bd1
|
||||
timeCreated: 1738419718
|
||||
@@ -1,7 +1,10 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.AngelRing;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class AngelRingScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
@@ -23,7 +26,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.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.AngelRing);
|
||||
protected override bool ShowSection => materials.All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
|
||||
|
||||
@@ -31,11 +34,11 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.angelRingColor = FindProperty("_AngelRingColor");
|
||||
Properties.angelRingColorMap = FindProperty("_AngelRingColorMap");
|
||||
Properties.angelRingIntensity = FindProperty("_AngelRingIntensity");
|
||||
Properties.angelRingOffsetU = FindProperty("_AngelRingOffsetU");
|
||||
Properties.angelRingOffsetV = FindProperty("_AngelRingOffsetV");
|
||||
Properties.angelRingColor = FindProperty(ANGEL_RING_COLOR);
|
||||
Properties.angelRingColorMap = FindProperty(ANGEL_RING_COLOR_MAP);
|
||||
Properties.angelRingIntensity = FindProperty(ANGEL_RING_INTENSITY);
|
||||
Properties.angelRingOffsetU = FindProperty(ANGEL_RING_OFFSET_U);
|
||||
Properties.angelRingOffsetV = FindProperty(ANGEL_RING_OFFSET_V);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
|
||||
@@ -2,18 +2,24 @@ using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.Outline;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty outlineState;
|
||||
|
||||
public static MaterialProperty outlineWidth;
|
||||
public static MaterialProperty outlineWidthMap;
|
||||
|
||||
public static MaterialProperty outlineColor;
|
||||
public static MaterialProperty outlineColorMap;
|
||||
public static MaterialProperty albedoAffectOutline;
|
||||
public static MaterialProperty skyColorAffectOutline;
|
||||
public static MaterialProperty skyColorIntensity;
|
||||
|
||||
public static MaterialProperty fadeIn;
|
||||
public static MaterialProperty fadeOut;
|
||||
@@ -23,43 +29,64 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
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 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 skyColorAffectOutlineText = new("Sky Color Affect Outline", "Enable to affect the outline color with the sky color.");
|
||||
public static readonly GUIContent skyColorIntensityText = new("Sky Color Intensity", "The intensity of the sky color when add to the outline color.");
|
||||
|
||||
public static readonly GUIContent fadeInText = new("Fade In Distance", "Specify the nearest distance, where the outline width changes with the distance between the camera and the object. The outline will be the maximum width at this distance.");
|
||||
public static readonly GUIContent fadeOutText = new("Fade Out Distance", "Specify the furthest distance, where the outline width changes with the distance between the camera and the object. The outline will be zero at this distance.");
|
||||
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 GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.outlineWidth = FindProperty("_OutlineWidth");
|
||||
Properties.outlineWidthMap = FindProperty("_OutlineWidthMap");
|
||||
Properties.outlineState = FindProperty(OUTLINE_STATE);
|
||||
|
||||
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||
Properties.outlineWidth = FindProperty(OUTLINE_WIDTH);
|
||||
Properties.outlineWidthMap = FindProperty(OUTLINE_WIDTH_MAP);
|
||||
|
||||
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||
Properties.outlineColor = FindProperty(OUTLINE_COLOR);
|
||||
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()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||
editor.ShaderProperty(Properties.fadeIn, Styles.fadeInText);
|
||||
editor.ShaderProperty(Properties.fadeOut, Styles.fadeOutText);
|
||||
editor.ShaderProperty(Properties.useSmoothedNormal, Styles.useSmoothedNormalText);
|
||||
editor.ShaderProperty(Properties.outlineState, Styles.outlineStateText);
|
||||
|
||||
if (Properties.outlineState.GetBooleanValue())
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||
editor.ShaderProperty(Properties.skyColorAffectOutline, Styles.skyColorAffectOutlineText);
|
||||
if (Properties.skyColorAffectOutline.GetBooleanValue())
|
||||
{
|
||||
using var skyColorIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.fadeIn, Styles.fadeInText);
|
||||
editor.ShaderProperty(Properties.fadeOut, Styles.fadeOutText);
|
||||
editor.ShaderProperty(Properties.useSmoothedNormal, Styles.useSmoothedNormalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class PBRScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty PbrMode;
|
||||
public static MaterialProperty NormalMap;
|
||||
public static MaterialProperty NormalMapScale;
|
||||
public static MaterialProperty MaskMap;
|
||||
public static MaterialProperty Metallic;
|
||||
public static MaterialProperty MetallicRemapMin;
|
||||
public static MaterialProperty MetallicRemapMax;
|
||||
public static MaterialProperty AORemapMin;
|
||||
public static MaterialProperty AORemapMax;
|
||||
public static MaterialProperty RoughnessRemapMin;
|
||||
public static MaterialProperty RoughnessRemapMax;
|
||||
public static MaterialProperty Smoothness;
|
||||
public static MaterialProperty AnisotropyMap;
|
||||
public static MaterialProperty Anisotropy;
|
||||
public static MaterialProperty KKColor;
|
||||
public static MaterialProperty BSDFContribution;
|
||||
public static MaterialProperty SpecularColorMap;
|
||||
public static MaterialProperty SpecularColor;
|
||||
public static MaterialProperty SpecularFeather;
|
||||
public static MaterialProperty SpecularStep;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent PbrModeText = new("PBR Mode", "PBR Mode");
|
||||
|
||||
public static readonly GUIContent NormalMapText =
|
||||
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: Metallic, G: Occlusion, A: Smoothness");
|
||||
|
||||
|
||||
public static readonly GUIContent MetallicText =
|
||||
new("Metallic", "Specifies the metallicness 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 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");
|
||||
}
|
||||
|
||||
private enum PBRMode
|
||||
{
|
||||
Off,
|
||||
Standard,
|
||||
Anisotropy,
|
||||
KKHair,
|
||||
Toon
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.PBR;
|
||||
protected override GUIContent Header => new("PBR Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.PbrMode = FindProperty("_PBR_Mode");
|
||||
Properties.NormalMap = FindProperty("_NormalMap");
|
||||
Properties.NormalMapScale = FindProperty("_NormalScale");
|
||||
Properties.MaskMap = FindProperty("_MaskMap");
|
||||
Properties.Metallic = FindProperty("_Metallic");
|
||||
Properties.MetallicRemapMin = FindProperty("_MetallicRemapMin");
|
||||
Properties.MetallicRemapMax = FindProperty("_MetallicRemapMax");
|
||||
Properties.AORemapMin = FindProperty("_AORemapMin");
|
||||
Properties.AORemapMax = FindProperty("_AORemapMax");
|
||||
Properties.RoughnessRemapMin = FindProperty("_SmoothnessRemapMin");
|
||||
Properties.RoughnessRemapMax = FindProperty("_SmoothnessRemapMax");
|
||||
Properties.Smoothness = FindProperty("_Smoothness");
|
||||
Properties.AnisotropyMap = FindProperty("_AnisotropyMap");
|
||||
Properties.Anisotropy = FindProperty("_Anisotropy");
|
||||
Properties.KKColor = FindProperty("_KKColor");
|
||||
Properties.BSDFContribution = FindProperty("_BSDFContribution");
|
||||
Properties.SpecularColorMap = FindProperty("_SpecularColorMap");
|
||||
Properties.SpecularColor = FindProperty("_SpecularColor");
|
||||
Properties.SpecularFeather = FindProperty("_ToonSpecularFeather");
|
||||
Properties.SpecularStep = FindProperty("_ToonSpecularStep");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.PbrMode, Styles.PbrModeText);
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(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 = (PBRMode)Properties.PbrMode.floatValue;
|
||||
if (pbrMode != PBRMode.Off)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.MaskMapText, Properties.MaskMap);
|
||||
|
||||
if (Properties.MaskMap.textureValue == null)
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
}
|
||||
|
||||
if (pbrMode != PBRMode.KKHair)
|
||||
editor.ShaderProperty(Properties.Metallic, Styles.MetallicText);
|
||||
editor.ShaderProperty(Properties.Smoothness, Styles.SmoothnessText);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
}
|
||||
|
||||
editor.MinMaxShaderProperty(Properties.MetallicRemapMin, Properties.MetallicRemapMax, 0, 1,
|
||||
Styles.MetallicRemap);
|
||||
editor.MinMaxShaderProperty(Properties.AORemapMin, Properties.AORemapMax, 0, 1, Styles.AORemap);
|
||||
editor.MinMaxShaderProperty(Properties.RoughnessRemapMin, Properties.RoughnessRemapMax, 0, 1,
|
||||
Styles.RoughnessRemap);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
}
|
||||
|
||||
switch (pbrMode)
|
||||
{
|
||||
case PBRMode.Anisotropy or PBRMode.KKHair:
|
||||
{
|
||||
editor.TexturePropertySingleLine(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.TexturePropertySingleLine(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f611f3d462b5414f9241ed80e4f1d0bb
|
||||
timeCreated: 1738325165
|
||||
@@ -1,142 +1,84 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.RimLight;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class RimLightScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty rimLightEnabled;
|
||||
public static MaterialProperty rimLightColor;
|
||||
public static MaterialProperty rimLightStrength;
|
||||
public static MaterialProperty rimLightIntensity;
|
||||
|
||||
public static MaterialProperty screenSpaceRimLight;
|
||||
public static MaterialProperty rimLightLevel;
|
||||
public static MaterialProperty colorBlendingMode;
|
||||
public static MaterialProperty adjustRimLightArea;
|
||||
public static MaterialProperty rimLightFeatherOff;
|
||||
public static MaterialProperty lightDirection;
|
||||
public static MaterialProperty rimLightClipping;
|
||||
public static MaterialProperty rimLightClippingLevel;
|
||||
|
||||
public static MaterialProperty lightBaseRimLight;
|
||||
public static MaterialProperty lightDirectionRimLightLevel;
|
||||
public static MaterialProperty invertedDirectionRimLight;
|
||||
public static MaterialProperty invertedRimLightColor;
|
||||
public static MaterialProperty inversedRimLightLevel;
|
||||
public static MaterialProperty invertedRimLightFeatherOff;
|
||||
public static MaterialProperty rimLightMaskMap;
|
||||
public static MaterialProperty rimLightMaskLevel;
|
||||
}
|
||||
|
||||
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 = new("Rim Light Color", "Specifies the color of rim light.");
|
||||
public static readonly GUIContent rimLightIntensityText = new("Rim Light Strength", "Specifies Rim Light strength.");
|
||||
|
||||
public static readonly GUIContent rimLightColorText =
|
||||
new("Rim Light Color", "Specifies the color of rim light.");
|
||||
public static readonly GUIContent screenSpaceRimLightText = new("Screen Space Rim Light", "Enable to make the rim light width constant in screen space.");
|
||||
public static readonly GUIContent rimLightLevelText = new("Rim Light Level", "Specifies Rim Light power intensity.");
|
||||
public static readonly GUIContent rimLightClippingText = new("Rim Light Clipping", "Enable to Clip the rim light at specific level");
|
||||
public static readonly GUIContent rimLightClippingLevelText = new("Clipping Level", "The Clipping value of the rim light.");
|
||||
|
||||
public static readonly GUIContent rimLightStrengthText =
|
||||
new("Rim Light Strength", "Specifies Rim Light strength.");
|
||||
|
||||
public static readonly GUIContent rimLightLevelText =
|
||||
new("Rim Light Level", "Specifies Rim Light power intensity.");
|
||||
|
||||
public static readonly GUIContent colorBlendingModeText =
|
||||
new("Color Blending Mode", "Rim light color blending mode. Multiply or Add.");
|
||||
|
||||
public static readonly GUIContent adjustRimLightAreaText =
|
||||
new("Adjust Rim Light Area", "Increasing this value narrows the area of influence of Rim Light.");
|
||||
|
||||
public static readonly GUIContent rimLightFeatherOffText =
|
||||
new("Rim Light Feather Off", "Disable Rim light feather.");
|
||||
|
||||
public static readonly GUIContent lightDirectionText =
|
||||
new("Light Direction",
|
||||
"When Enabled, rim light is generated only in the direction of the light source.");
|
||||
|
||||
public static readonly GUIContent lightDirectionRimLightLevelText =
|
||||
new("Light Direction Rim Light Level",
|
||||
"Specifies intensity of Rim Light in the light source direction,");
|
||||
|
||||
public static readonly GUIContent invertedDirectionRimLightText =
|
||||
new("Inverted Direction Rim Light", "Rim light from inverted/antipodean direction.");
|
||||
|
||||
public static readonly GUIContent invertedRimLightColorText =
|
||||
new("Inverted Rim Light Color", "Specifies the color of inverted/antipodean rim light.");
|
||||
|
||||
public static readonly GUIContent inversedRimLightLevelText =
|
||||
new("Inversed Rim Light Level", "Specifies Inverted/Antipodean Rim Light Level.");
|
||||
|
||||
public static readonly GUIContent invertedRimLightFeatherOffText =
|
||||
new("Inverted Rim Light Feather Off", "Disable Inverted Rim light feather.");
|
||||
|
||||
public static readonly GUIContent rimLightMaskMapText = new("Rim Light Mask",
|
||||
"Rim Light Mask : Texture(linear). The white part of the texture is displayed as Rim Light, and the black part is masked and not displayed.");
|
||||
|
||||
public static readonly GUIContent rimLightMaskLevelText =
|
||||
new("Rim Light Mask Level",
|
||||
"-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.");
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.rimLightEnabled = FindProperty("_RimLight");
|
||||
Properties.rimLightColor = FindProperty("_RimLightColor");
|
||||
Properties.rimLightStrength = FindProperty("_RimLight_Strength");
|
||||
Properties.rimLightLevel = FindProperty("_RimLight_Power");
|
||||
Properties.colorBlendingMode = FindProperty("_Is_BlendAddToRimColor");
|
||||
Properties.adjustRimLightArea = FindProperty("_RimLight_InsideMask");
|
||||
Properties.rimLightFeatherOff = FindProperty("_RimLight_FeatherOff");
|
||||
Properties.lightDirection = FindProperty("_LightDirection_MaskOn");
|
||||
Properties.lightDirectionRimLightLevel = FindProperty("_Tweak_LightDirection_MaskLevel");
|
||||
Properties.invertedDirectionRimLight = FindProperty("_Add_Antipodean_RimLight");
|
||||
Properties.invertedRimLightColor = FindProperty("_Ap_RimLightColor");
|
||||
Properties.inversedRimLightLevel = FindProperty("_Ap_RimLight_Power");
|
||||
Properties.invertedRimLightFeatherOff = FindProperty("_Ap_RimLight_FeatherOff");
|
||||
Properties.rimLightMaskMap = FindProperty("_Set_RimLightMask");
|
||||
Properties.rimLightMaskLevel = FindProperty("_Tweak_RimLightMaskLevel");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.rimLightEnabled, Styles.rimLightEnabledText);
|
||||
EditorGUI.BeginDisabledGroup(Properties.rimLightEnabled.floatValue == 0);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
||||
editor.ShaderProperty(Properties.rimLightStrength, Styles.rimLightStrengthText);
|
||||
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
||||
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();
|
||||
public static readonly GUIContent lightBaseRimLightText = new("Light Base Rim Light", "Enable to let rim light calculate per light.");
|
||||
public static readonly GUIContent lightDirectionRimLightLevelText = new("Light Direction Level", "Specifies intensity of Rim Light in the light source direction,");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Rimlight;
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Rim Light Settings");
|
||||
protected override bool ShowSection => SurfaceOptionsScope.HasFeature(SurfaceFeatureFlags.RimLight);
|
||||
protected override bool ShowSection => materials.All(mat => mat.HasFeature(SurfaceFeature.RimLight));
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.rimLightColor = FindProperty(RIM_LIGHT_COLOR);
|
||||
Properties.rimLightIntensity = FindProperty(RIM_LIGHT_INTENSITY);
|
||||
|
||||
Properties.screenSpaceRimLight = FindProperty(SCREEN_SPACE_RIM_LIGHT);
|
||||
Properties.rimLightLevel = FindProperty(RIM_LIGHT_LEVEL);
|
||||
Properties.rimLightClipping = FindProperty(RIM_LIGHT_CLIPPING);
|
||||
Properties.rimLightClippingLevel = FindProperty(RIM_LIGHT_CLIPPING_LEVEL);
|
||||
|
||||
Properties.lightBaseRimLight = FindProperty(LIGHT_BASE_RIM_LIGHT);
|
||||
Properties.lightDirectionRimLightLevel = FindProperty(LIGHT_DIRECTION_RIM_LIGHT_LEVEL);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
||||
editor.ShaderProperty(Properties.rimLightIntensity, Styles.rimLightIntensityText);
|
||||
|
||||
editor.ShaderProperty(Properties.screenSpaceRimLight, Styles.screenSpaceRimLightText);
|
||||
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
||||
|
||||
if (!Properties.screenSpaceRimLight.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.rimLightClipping, Styles.rimLightClippingText);
|
||||
if (Properties.rimLightClipping.GetBooleanValue())
|
||||
{
|
||||
using var clippingLevelIndentLevelScope = new EditorGUI.IndentLevelScope();
|
||||
editor.ShaderProperty(Properties.rimLightClippingLevel, Styles.rimLightClippingLevelText);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.lightBaseRimLight, Styles.lightBaseRimLightText);
|
||||
if (Properties.lightBaseRimLight.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.lightDirectionRimLightLevel, Styles.lightDirectionRimLightLevelText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -8,7 +9,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty useShadingRampMap;
|
||||
public static MaterialProperty shadingRampMapState;
|
||||
|
||||
public static MaterialProperty baseColor;
|
||||
public static MaterialProperty baseColorMap;
|
||||
@@ -26,16 +27,20 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public static MaterialProperty shadingRampMap;
|
||||
public static MaterialProperty shadingIndex;
|
||||
public static MaterialProperty shadingRampMaskMap;
|
||||
public static MaterialProperty shadingRampMask;
|
||||
|
||||
public static MaterialProperty sdfShadingMap;
|
||||
public static MaterialProperty sdfShadowLevel;
|
||||
public static MaterialProperty sdfSmoothLevel;
|
||||
public static MaterialProperty sdfHighlightStrength;
|
||||
|
||||
public static MaterialProperty hairBlendingFactor;
|
||||
}
|
||||
|
||||
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 applyTo1stShadingMapText = new("Apply to 1st shading map", "Apply Base map to the 1st shading map.");
|
||||
@@ -51,9 +56,13 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static readonly GUIContent sdfShadingMapText = new("SDF Shading Map", "The map used for the SDF shading. R channel for SDF shadow, G channel for highlight, B channel for fixed shadow.");
|
||||
public static readonly GUIContent sdfShadowLevelText = new("SDF Shadow Level", "Control the sampling position of the shadow in the SDF shading map.");
|
||||
public static readonly GUIContent sdfSmoothLevelText = new("SDF Smooth Level", "Control the smoothness of the shadow edge.");
|
||||
|
||||
public static readonly GUIContent 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.");
|
||||
public static readonly GUIContent shadingRampMaskMapText = new("Shading Ramp Mask Map", "A texture that contains the mask for the shading ramp 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 hairBlendingFactorText = new("Hair Blending Factor", "The blending factor for hair shading.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor;
|
||||
@@ -78,7 +87,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.useShadingRampMap = FindProperty("_Use_Shading_Ramp_Map");
|
||||
Properties.shadingRampMapState = FindProperty("_Use_Shading_Ramp_Map");
|
||||
|
||||
Properties.baseColor = FindProperty("_BaseColor");
|
||||
Properties.baseColorMap = FindProperty("_BaseColorMap");
|
||||
@@ -94,28 +103,33 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.secondShadeColorStep = FindProperty("_2ndShadeColorStep");
|
||||
Properties.secondShadeColorFeather = FindProperty("_2ndShadeColorFeather");
|
||||
|
||||
Properties.shadingRampMap = FindProperty("_ShadingRampMap");
|
||||
Properties.shadingIndex = FindProperty("_ShadingIndex");
|
||||
Properties.shadingRampMaskMap = FindProperty("_ShadingRampMaskMap");
|
||||
Properties.shadingRampMask = FindProperty("_ShadingRampMask");
|
||||
|
||||
Properties.sdfShadingMap = FindProperty("_SDFShadingMap");
|
||||
Properties.sdfShadowLevel = FindProperty("_SDFShadowLevel");
|
||||
Properties.sdfSmoothLevel = FindProperty("_SDFShadowSmoothLevel");
|
||||
Properties.sdfHighlightStrength = FindProperty("_SDFHighlightStrength");
|
||||
|
||||
Properties.shadingRampMap = FindProperty("_ShadingRampMap");
|
||||
Properties.shadingIndex = FindProperty("_ShadingIndex");
|
||||
Properties.hairBlendingFactor = FindProperty("_HairBlendingFactor");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.useShadingRampMap, Styles.useShadingRampMapText);
|
||||
editor.ShaderProperty(Properties.shadingRampMapState, Styles.shadingRampMapStateText);
|
||||
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.KeywordTexturePropertySingleLine(Styles.shadingRampMaskMapText, Properties.shadingRampMaskMap, Properties.shadingRampMask, "_SHADING_RAMP_MASK_MAP");
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo1stShadingMapEnable, Properties.firstShadingColor, Properties.firstShadingMap, Styles.applyTo1stShadingMapText, Styles.firstShadingMapText);
|
||||
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.Standard)
|
||||
if (materials.All(material => material.GetShadingMode() == ShadingMode.Standard))
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
|
||||
|
||||
@@ -127,7 +141,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
}
|
||||
}
|
||||
|
||||
if (SurfaceOptionsScope.GetShadingMode() == ShadingMode.SDF)
|
||||
if (materials.All(material => material.GetShadingMode() == ShadingMode.SDF))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);
|
||||
@@ -136,6 +150,12 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.ShaderProperty(Properties.sdfHighlightStrength, Styles.sdfHighlightStrengthText);
|
||||
}
|
||||
|
||||
if (materials.All(material => material.GetMaterialType() == MaterialType.FrontHair))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.hairBlendingFactor, Styles.hairBlendingFactorText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.TextureScaleOffsetProperty(Properties.baseColorMap);
|
||||
}
|
||||
|
||||
57
Editor/MeterialEditor/UIScopes/ShadowScope.cs
Normal file
57
Editor/MeterialEditor/UIScopes/ShadowScope.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class ShadowScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty receiveLightShadow;
|
||||
public static MaterialProperty receiveScreenSpaceShadow;
|
||||
public static MaterialProperty receiveHairShadow;
|
||||
|
||||
public static MaterialProperty shadowDistanceBias;
|
||||
public static MaterialProperty shadowNormalBias;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent receiveLightShadowText = new("Receive Light Shadow", "Enable to receive shadow from light.");
|
||||
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
|
||||
public static readonly GUIContent receiveScreenSpaceShadowText = new("Receive Screen Space Shadow", "Enable to receive screen space shadow.");
|
||||
public static readonly GUIContent lightShadowBiasText = new("Light Shadow Bias", "Specifies the bias of the light shadow.");
|
||||
public static readonly GUIContent lightShadowNormalBiasText = new("Light Shadow Normal Bias", "Specifies the normal bias of the light shadow.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Shadow;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shadow Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.receiveLightShadow = FindProperty("_Receive_Light_Shadow");
|
||||
Properties.receiveScreenSpaceShadow = FindProperty("_Receive_Screen_Space_Shadow");
|
||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||
|
||||
Properties.shadowDistanceBias = FindProperty("_ShadowDistanceBias");
|
||||
Properties.shadowNormalBias = FindProperty("_ShadowNormalBias");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.receiveLightShadow, Styles.receiveLightShadowText);
|
||||
if (Properties.receiveLightShadow.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.receiveScreenSpaceShadow, Styles.receiveScreenSpaceShadowText);
|
||||
}
|
||||
editor.ShaderProperty(Properties.receiveHairShadow, Styles.receiveHairShadowText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.shadowDistanceBias, Styles.lightShadowBiasText);
|
||||
editor.ShaderProperty(Properties.shadowNormalBias, Styles.lightShadowNormalBiasText);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/ShadowScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/ShadowScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f9bb5393aec4e648a1c3b2ba0d566c3
|
||||
195
Editor/MeterialEditor/UIScopes/SurfaceInputsScope.cs
Normal file
195
Editor/MeterialEditor/UIScopes/SurfaceInputsScope.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
|
||||
using static Misaki.HdrpToon.UtsShaderPropertyName.SurfaceInputs;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class SurfaceInputsScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty normalMap;
|
||||
public static MaterialProperty normalMapScale;
|
||||
|
||||
public static MaterialProperty maskMap;
|
||||
public static MaterialProperty metallic;
|
||||
public static MaterialProperty metallicRemapMin;
|
||||
public static MaterialProperty metallicRemapMax;
|
||||
public static MaterialProperty aoRemapMin;
|
||||
public static MaterialProperty aoRemapMax;
|
||||
public static MaterialProperty smoothness;
|
||||
public static MaterialProperty smoothnessRemapMin;
|
||||
public static MaterialProperty smoothnessRemapMax;
|
||||
|
||||
public static MaterialProperty anisotropyMap;
|
||||
public static MaterialProperty anisotropy;
|
||||
public static MaterialProperty kkColor;
|
||||
public static MaterialProperty bsdfContribution;
|
||||
|
||||
public static MaterialProperty specularColorMap;
|
||||
public static MaterialProperty specularColor;
|
||||
public static MaterialProperty specularFeather;
|
||||
public static MaterialProperty specularStep;
|
||||
|
||||
public static MaterialProperty hairBlendingMap;
|
||||
|
||||
public static MaterialProperty emissiveColorLDR;
|
||||
public static MaterialProperty emissiveColorMap;
|
||||
public static MaterialProperty emissiveIntensity;
|
||||
|
||||
public static MaterialProperty albedoAffectEmissive;
|
||||
public static MaterialProperty emissiveExposureWeight;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent normalMapText = 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("AO Remap", "Remap the max and min value of ambient occlusion");
|
||||
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 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");
|
||||
|
||||
public static readonly GUIContent hairBlenderMapText = new("Hair Blending Map", "Specifies the hair blending map of the material.");
|
||||
|
||||
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 GUIContent Header => new("Surface Inputs");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.normalMap = FindProperty("_NormalMap");
|
||||
Properties.normalMapScale = FindProperty("_NormalScale");
|
||||
|
||||
Properties.maskMap = FindProperty("_MaskMap");
|
||||
Properties.metallic = FindProperty("_Metallic");
|
||||
Properties.metallicRemapMin = FindProperty("_MetallicRemapMin");
|
||||
Properties.metallicRemapMax = FindProperty("_MetallicRemapMax");
|
||||
Properties.aoRemapMin = FindProperty("_AORemapMin");
|
||||
Properties.aoRemapMax = FindProperty("_AORemapMax");
|
||||
Properties.smoothnessRemapMin = FindProperty("_SmoothnessRemapMin");
|
||||
Properties.smoothnessRemapMax = FindProperty("_SmoothnessRemapMax");
|
||||
Properties.smoothness = FindProperty("_Smoothness");
|
||||
|
||||
Properties.anisotropyMap = FindProperty("_AnisotropyMap");
|
||||
Properties.anisotropy = FindProperty("_Anisotropy");
|
||||
Properties.kkColor = FindProperty("_KKColor");
|
||||
Properties.bsdfContribution = FindProperty("_BSDFContribution");
|
||||
|
||||
Properties.specularColorMap = FindProperty("_SpecularColorMap");
|
||||
Properties.specularColor = FindProperty("_SpecularColor");
|
||||
Properties.specularFeather = FindProperty("_ToonSpecularFeather");
|
||||
Properties.specularStep = FindProperty("_ToonSpecularStep");
|
||||
|
||||
Properties.hairBlendingMap = FindProperty("_HairBlendingMap");
|
||||
|
||||
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()
|
||||
{
|
||||
editor.KeywordTexturePropertySingleLine(Styles.normalMapText, Properties.normalMap, Properties.normalMapScale);
|
||||
|
||||
if (materials.All(mat => mat.GetPBRMode() != PBRMode.Off))
|
||||
{
|
||||
if (editor.KeywordTexturePropertySingleLine(Styles.maskMapText, Properties.maskMap))
|
||||
{
|
||||
editor.MinMaxShaderProperty(Properties.metallicRemapMin, Properties.metallicRemapMax, 0, 1, Styles.metallicRemap);
|
||||
editor.MinMaxShaderProperty(Properties.aoRemapMin, Properties.aoRemapMax, 0, 1, Styles.aoRemap);
|
||||
editor.MinMaxShaderProperty(Properties.smoothnessRemapMin, Properties.smoothnessRemapMax, 0, 1, Styles.smoothnessRemapText);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (materials.All(mat =>
|
||||
{
|
||||
var pbrMode = mat.GetPBRMode();
|
||||
return pbrMode != PBRMode.KKHair && pbrMode != PBRMode.Toon;
|
||||
}))
|
||||
{
|
||||
editor.ShaderProperty(Properties.metallic, Styles.metallicText);
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.smoothness, Styles.smoothnessText);
|
||||
}
|
||||
}
|
||||
|
||||
if (materials.All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.KKHair))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.KeywordTexturePropertySingleLine(Styles.anisotropyMapText, Properties.anisotropyMap, Properties.anisotropy);
|
||||
if (materials.All(mat => mat.GetPBRMode() == 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);
|
||||
}
|
||||
else if (materials.All(mat => mat.GetPBRMode() == PBRMode.Toon))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.KeywordTexturePropertySingleLine(Styles.specularColorMapText, Properties.specularColorMap, Properties.specularColor);
|
||||
editor.MinMaxShaderProperty(Properties.specularFeather, Properties.specularStep, 0, 1, Styles.specRemap);
|
||||
}
|
||||
|
||||
if (materials.All(mat => mat.IsHairBlendingTarget()))
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.hairBlenderMapText, Properties.hairBlendingMap);
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 184fb730617fcf24592d8e6c49e2029a
|
||||
@@ -18,7 +18,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static MaterialProperty materialType;
|
||||
public static MaterialProperty pbrMode;
|
||||
|
||||
public static MaterialProperty receiveHairShadow;
|
||||
public static MaterialProperty hairBlendingTarget;
|
||||
public static MaterialProperty surfaceFeatures;
|
||||
}
|
||||
@@ -35,7 +34,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static readonly GUIContent materialTypeText = new("Material Type", "Specifies the material type.");
|
||||
public static readonly GUIContent pbrModeText = new("PBR Mode", "Specifies PBR model mode.");
|
||||
|
||||
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
||||
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
||||
}
|
||||
@@ -44,16 +42,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
||||
|
||||
public static ShadingMode GetShadingMode()
|
||||
{
|
||||
return (ShadingMode)Properties.shadingMode.floatValue;
|
||||
}
|
||||
|
||||
public static bool HasFeature(SurfaceFeatureFlags feature)
|
||||
{
|
||||
return ((SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue & feature) != 0;
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||
@@ -66,7 +54,6 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.materialType = FindProperty("_Material_Type");
|
||||
Properties.pbrMode = FindProperty("_PBR_Mode");
|
||||
|
||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||
}
|
||||
@@ -76,7 +63,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.ShaderProperty(Properties.transparentMode, Styles.transparentModeText);
|
||||
|
||||
editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText);
|
||||
if (Properties.alphaClipEnable.floatValue == 1.0f)
|
||||
if (Properties.alphaClipEnable.GetBooleanValue())
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
|
||||
@@ -85,32 +72,29 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
|
||||
editor.ShaderProperty(Properties.shadingMode, Styles.shadingModeText);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
|
||||
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, Properties.materialType.GetEnumValue<MaterialType>() == MaterialType.FrontHair);
|
||||
}
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.receiveHairShadow, Styles.receiveHairShadowText);
|
||||
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var material in editor.GetMaterials())
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.GetBooleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
var surfaceFeatures = (SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue;
|
||||
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));
|
||||
}
|
||||
}
|
||||
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,12 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
private GUIStyle _headerStyle;
|
||||
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, (MaterialType)material.GetInteger("_Material_Type") == MaterialType.FrontHair);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, material.GetInteger("_HairBlendingTarget") == 1);
|
||||
}
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
if (!initialized)
|
||||
@@ -26,15 +32,26 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
AddUIScope(new SurfaceOptionsScope());
|
||||
AddUIScope(new ShadingColorScope());
|
||||
AddUIScope(new PBRScope());
|
||||
AddUIScope(new ShadowScope());
|
||||
AddUIScope(new SurfaceInputsScope());
|
||||
AddUIScope(new AmbientScope());
|
||||
AddUIScope(new RimLightScope());
|
||||
AddUIScope(new AngelRingScope());
|
||||
AddUIScope(new OutlineScope());
|
||||
AddUIScope(new AdvanceScope());
|
||||
|
||||
Initialize(materialEditor, properties);
|
||||
|
||||
_headerStyle = new GUIStyle() { fontSize = 25, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter };
|
||||
_headerStyle.normal.textColor = GUI.skin.label.normal.textColor;
|
||||
_headerStyle = new GUIStyle()
|
||||
{
|
||||
fontSize = 25,
|
||||
fontStyle = FontStyle.Bold,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
normal =
|
||||
{
|
||||
textColor = GUI.skin.label.normal.textColor
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"Unity.RenderPipelines.Core.Editor",
|
||||
"Unity.RenderPipelines.HighDefinition.Runtime",
|
||||
"Unity.RenderPipelines.HighDefinition.Editor",
|
||||
"Unity.Mathematics",
|
||||
"Unity.Collections",
|
||||
"Misaki.ShaderGUI"
|
||||
],
|
||||
|
||||
162
Editor/SSS/SSSLutBaker.compute
Normal file
162
Editor/SSS/SSSLutBaker.compute
Normal file
@@ -0,0 +1,162 @@
|
||||
#pragma kernel SkinLut
|
||||
#pragma kernel ShadowLut
|
||||
|
||||
#pragma multi_compile_local _ _PRODUCTION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
|
||||
#define _PROFILE_WIDTH 8.166
|
||||
|
||||
float _ScatterRadius;
|
||||
float _PositionShift;
|
||||
float _Intensity;
|
||||
int _SampleCount;
|
||||
int _ApplyTonemap;
|
||||
|
||||
uint _TextureSize;
|
||||
|
||||
RWTexture2D<float4> _SSSLut;
|
||||
|
||||
static const float VARIANCE[6] =
|
||||
{
|
||||
0.0064,
|
||||
0.0484,
|
||||
0.1870,
|
||||
0.5670,
|
||||
1.9900,
|
||||
7.4100
|
||||
};
|
||||
|
||||
static const float3 WEIGHTS[6] =
|
||||
{
|
||||
float3(0.233, 0.455, 0.649),
|
||||
float3(0.100, 0.336, 0.344),
|
||||
float3(0.118, 0.198, 0.000),
|
||||
float3(0.113, 0.007, 0.007),
|
||||
float3(0.358, 0.004, 0.000),
|
||||
float3(0.078, 0.000, 0.000)
|
||||
};
|
||||
|
||||
float Gaussian(float v, float r)
|
||||
{
|
||||
return rcp(2.0 * PI * v) * exp((-r * r) / (2.0 * v));
|
||||
}
|
||||
|
||||
float3 RadianceScatter(float r)
|
||||
{
|
||||
float3 result = 0.0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
result += WEIGHTS[i] * Gaussian(VARIANCE[i], r);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float3 IntegrateDiffuseScattering_Ring(float theta, float r)
|
||||
{
|
||||
float3 totalScatter = 0;
|
||||
float3 totalWeight = 0;
|
||||
float increment = PI / _SampleCount;
|
||||
|
||||
float x = -HALF_PI;
|
||||
while (x < HALF_PI)
|
||||
{
|
||||
float diffuse = saturate(cos(theta + x));
|
||||
float distance = abs(2.0 * r * sin(x / 2.0));
|
||||
float3 radiance = RadianceScatter(distance);
|
||||
|
||||
totalScatter += radiance * diffuse;
|
||||
totalWeight += radiance;
|
||||
|
||||
x += increment;
|
||||
}
|
||||
|
||||
return totalScatter / totalWeight;
|
||||
}
|
||||
|
||||
float newPenumbra(float pos, float penumbraWidth)
|
||||
{
|
||||
return saturate((pos * penumbraWidth - _PROFILE_WIDTH) / (penumbraWidth - _PROFILE_WIDTH));
|
||||
}
|
||||
|
||||
float3 IntegrateShadowScattering(float penumbraLocation, float penumbraWidth)
|
||||
{
|
||||
float3 totalScatter = 0;
|
||||
float3 totalWeights = 0;
|
||||
float increment = (_PROFILE_WIDTH * 2) / _SampleCount;
|
||||
|
||||
penumbraWidth = max(penumbraWidth, _PROFILE_WIDTH + 1e-5);
|
||||
|
||||
float x = -_PROFILE_WIDTH;
|
||||
while (x <= _PROFILE_WIDTH)
|
||||
{
|
||||
float light = newPenumbra(penumbraLocation + x / penumbraWidth, penumbraWidth);
|
||||
float distance = abs(x);
|
||||
float3 weights = RadianceScatter(distance);
|
||||
|
||||
totalWeights += weights;
|
||||
totalScatter += light * weights;
|
||||
|
||||
x += increment;
|
||||
}
|
||||
|
||||
return totalScatter / totalWeights;
|
||||
}
|
||||
|
||||
float3 FilmicTonemap(float3 color)
|
||||
{
|
||||
return (color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06);
|
||||
}
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void SkinLut (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x > _TextureSize || id.y > _TextureSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float2 uv = id.xy / float2(_TextureSize, _TextureSize);
|
||||
#if UNITY_UV_STARTS_AT_TOP && _PRODUCTION
|
||||
uv.y = 1.0 - uv.y;
|
||||
#endif
|
||||
|
||||
float theta = acos((uv.x * 2.0 - 1.0)) + _PositionShift;
|
||||
float r = rcp(max(uv.y, 0.001) * _ScatterRadius);
|
||||
|
||||
float3 scatter = IntegrateDiffuseScattering_Ring(theta, r) * _Intensity;
|
||||
if (_ApplyTonemap == 1)
|
||||
{
|
||||
scatter = FilmicTonemap(scatter);
|
||||
}
|
||||
|
||||
_SSSLut[id.xy] = float4(scatter, 1.0);
|
||||
//_SSSLut[id.xy] = theta;
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void ShadowLut(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x > _TextureSize || id.y > _TextureSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float2 uv = id.xy / float2(_TextureSize, _TextureSize);
|
||||
#if UNITY_UV_STARTS_AT_TOP && _PRODUCTION
|
||||
uv.y = 1.0 - uv.y;
|
||||
#endif
|
||||
|
||||
float penumbraLocation = uv.x + _PositionShift;
|
||||
float penumbraWidth = rcp(max(uv.y, 0.001) * _ScatterRadius);
|
||||
|
||||
float3 scatter = IntegrateShadowScattering(penumbraLocation, penumbraWidth) * _Intensity;
|
||||
if (_ApplyTonemap == 1)
|
||||
{
|
||||
scatter = FilmicTonemap(scatter);
|
||||
}
|
||||
|
||||
_SSSLut[id.xy] = float4(scatter, 1.0);
|
||||
}
|
||||
7
Editor/SSS/SSSLutBaker.compute.meta
Normal file
7
Editor/SSS/SSSLutBaker.compute.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bf3d5f03d1a012489a8f673afe8a6b3
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
175
Editor/SSS/SSSLutBakerView.cs
Normal file
175
Editor/SSS/SSSLutBakerView.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class SSSLutBakerView : UnityEditor.EditorWindow
|
||||
{
|
||||
public enum Quality
|
||||
{
|
||||
[InspectorName("64")]
|
||||
UltraLow = 64,
|
||||
[InspectorName("128")]
|
||||
VeryLow = 128,
|
||||
[InspectorName("256")]
|
||||
Low = 256,
|
||||
[InspectorName("512")]
|
||||
Medium = 512,
|
||||
[InspectorName("1024")]
|
||||
High = 1024,
|
||||
[InspectorName("2048")]
|
||||
VeryHigh = 2048,
|
||||
[InspectorName("4096")]
|
||||
UltraHigh = 4096,
|
||||
}
|
||||
|
||||
private const int _PREVIEW_SIZE = 128;
|
||||
|
||||
[SerializeField]
|
||||
private VisualTreeAsset _visualAsset;
|
||||
[SerializeField]
|
||||
private ComputeShader _bakerShader;
|
||||
|
||||
private RenderTexture _previewTexture;
|
||||
private RenderTextureDescriptor _previewDescriptor;
|
||||
|
||||
public bool isShadowLut;
|
||||
public float scatterRadius = 1.0f;
|
||||
public float positionShift = 0.0f;
|
||||
public float intensity = 1.0f;
|
||||
public Quality sampleCount = Quality.Low;
|
||||
public bool applyTonemap = true;
|
||||
public Quality outputResolution = Quality.Medium;
|
||||
public int outputQuality = 100;
|
||||
|
||||
[MenuItem("Tools/UTS/SSS LUT Baker")]
|
||||
private static void ShowWindow()
|
||||
{
|
||||
var window = GetWindow<SSSLutBakerView>(true, "SSS LUT Baker");
|
||||
window.minSize = new Vector2(400, 650);
|
||||
window.ShowUtility();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_previewDescriptor = new RenderTextureDescriptor
|
||||
{
|
||||
width = _PREVIEW_SIZE,
|
||||
height = _PREVIEW_SIZE,
|
||||
volumeDepth = 1,
|
||||
dimension = TextureDimension.Tex2D,
|
||||
depthBufferBits = 0,
|
||||
msaaSamples = 1,
|
||||
graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm,
|
||||
enableRandomWrite = true,
|
||||
sRGB = false,
|
||||
useMipMap = false,
|
||||
};
|
||||
|
||||
_previewTexture = RenderTexture.GetTemporary(_previewDescriptor);
|
||||
}
|
||||
|
||||
private bool GenerateSSSLut(RenderTexture texture, int textureSize, bool production)
|
||||
{
|
||||
if (_bakerShader == null || !texture.enableRandomWrite)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var kernelIndex = isShadowLut ? 1 : 0;
|
||||
|
||||
_bakerShader.SetFloat("_ScatterRadius", scatterRadius);
|
||||
_bakerShader.SetFloat("_PositionShift", positionShift);
|
||||
_bakerShader.SetFloat("_Intensity", intensity);
|
||||
_bakerShader.SetInt("_SampleCount", (int)sampleCount);
|
||||
_bakerShader.SetInt("_ApplyTonemap", applyTonemap ? 1 : 0);
|
||||
_bakerShader.SetInt("_TextureSize", textureSize);
|
||||
|
||||
_bakerShader.SetKeyword(new LocalKeyword(_bakerShader, "_PRODUCTION"), production);
|
||||
|
||||
_bakerShader.SetTexture(kernelIndex, "_SSSLut", texture);
|
||||
|
||||
const int groupSizeX = 8;
|
||||
const int groupSizeY = 8;
|
||||
var threadGroupX = (textureSize + (groupSizeX - 1)) / groupSizeX;
|
||||
var threadGroupY = (textureSize + (groupSizeY - 1)) / groupSizeY;
|
||||
_bakerShader.Dispatch(kernelIndex, threadGroupX, threadGroupY, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void BakePreview()
|
||||
{
|
||||
GenerateSSSLut(_previewTexture, _PREVIEW_SIZE, false);
|
||||
}
|
||||
|
||||
private void Bake()
|
||||
{
|
||||
var outputPath = EditorUtility.SaveFilePanel("Export Texture", Application.dataPath, "SSS Lut", "jpg");
|
||||
if (string.IsNullOrEmpty(outputPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var outputDescriptor = _previewDescriptor;
|
||||
outputDescriptor.width = (int)outputResolution;
|
||||
outputDescriptor.height = (int)outputResolution;
|
||||
|
||||
var tempTexture = RenderTexture.GetTemporary(outputDescriptor);
|
||||
var tempTexture2D = new Texture2D(outputDescriptor.width, outputDescriptor.height, TextureFormat.RGB24, false, true);
|
||||
|
||||
try
|
||||
{
|
||||
if (!GenerateSSSLut(tempTexture, (int)outputResolution, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RenderTexture.active = tempTexture;
|
||||
tempTexture2D.ReadPixels(new Rect(0, 0, outputDescriptor.width, outputDescriptor.height), 0, 0);
|
||||
tempTexture2D.Apply();
|
||||
RenderTexture.active = null;
|
||||
|
||||
File.WriteAllBytes(outputPath, tempTexture2D.EncodeToJPG(outputQuality));
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
finally
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(tempTexture);
|
||||
DestroyImmediate(tempTexture2D);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateGUI()
|
||||
{
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var visualTree = _visualAsset.Instantiate();
|
||||
visualTree.StretchToParentSize();
|
||||
visualTree.dataSource = this;
|
||||
|
||||
var previewImage = visualTree.Q<Image>("preview-image");
|
||||
previewImage.image = _previewTexture;
|
||||
|
||||
var previewButton = visualTree.Q<Button>("preview-button");
|
||||
previewButton.clickable.clicked += BakePreview;
|
||||
|
||||
var bakeButton = visualTree.Q<Button>("bake-button");
|
||||
bakeButton.clickable.clicked += Bake;
|
||||
|
||||
rootVisualElement.Add(visualTree);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(_previewTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2a5c3542255fad4b803f96cc141e84d
|
||||
guid: 46ee5c2bb652c6942a58aa97f3a8473b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_ViewDataDictionary: {instanceID: 0}
|
||||
- IntegratorShader: {fileID: 7200000, guid: 0aa27def3e695d34d9e06b6015d57142, type: 3}
|
||||
- _visualAsset: {fileID: 9197481963319205126, guid: 36e5f9eef212a0547b97e2643cd514de,
|
||||
type: 3}
|
||||
- _bakerShader: {fileID: 7200000, guid: 7bf3d5f03d1a012489a8f673afe8a6b3, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
54
Editor/SSS/SSSLutBakerView.uxml
Normal file
54
Editor/SSS/SSSLutBakerView.uxml
Normal file
@@ -0,0 +1,54 @@
|
||||
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<engine:VisualElement data-source-type="Misaki.HdrpToon.Editor.SSSLutBakerView, Misaki.HdrpToon.Editor" style="flex-grow: 1; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px;">
|
||||
<engine:Label text="SSS Lut Baker" style="font-size: 18px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 12px; margin-bottom: 8px; margin-left: 4px; margin-right: 6px; -unity-font-style: bold;" />
|
||||
<engine:Label text="Parameters:" style="-unity-font-style: bold; margin-top: 12px; margin-bottom: 4px; margin-right: 2px; margin-left: 2px;" />
|
||||
<engine:DropdownField label="Lut Type" choices="Skin,Shadow" index="0">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="index" data-source-path="isShadowLut" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:DropdownField>
|
||||
<engine:FloatField label="Scatter Radius" value="1">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="scatterRadius" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:FloatField>
|
||||
<engine:Slider label="Position Shift" value="0.0" low-value="-1" high-value="1" page-size="0.1" show-input-field="true">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="positionShift" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:Slider>
|
||||
<engine:Slider label="Intensity" value="1" high-value="10" show-input-field="true" page-size="0.1">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="intensity" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:Slider>
|
||||
<engine:EnumField label="Sample Count" value="Center" type="Misaki.HdrpToon.Editor.SSSLutBakerView+Quality, Misaki.HdrpToon.Editor">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" binding-mode="TwoWay" data-source-path="sampleCount" />
|
||||
</Bindings>
|
||||
</engine:EnumField>
|
||||
<engine:DropdownField label="Apply Tonemap" choices="Disable,Enable" index="0">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="index" data-source-path="applyTonemap" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:DropdownField>
|
||||
<engine:EnumField label="Output Resolution" value="Center" type="Misaki.HdrpToon.Editor.SSSLutBakerView+Quality, Misaki.HdrpToon.Editor">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" binding-mode="TwoWay" data-source-path="outputResolution" />
|
||||
</Bindings>
|
||||
</engine:EnumField>
|
||||
<engine:SliderInt label="Output Quality" value="75" show-input-field="true" high-value="100" low-value="50">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="outputQuality" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:SliderInt>
|
||||
<engine:Label text="Preview:" style="-unity-font-style: bold; margin-top: 12px; margin-bottom: 4px; margin-right: 2px; margin-left: 2px;" />
|
||||
<engine:VisualElement style="flex-grow: 1; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-top: 4px; margin-right: 4px; margin-bottom: 4px; margin-left: 4px;">
|
||||
<engine:Image name="preview-image" style="flex-grow: 1;" />
|
||||
</engine:VisualElement>
|
||||
<engine:VisualElement style="flex-direction: row; margin-top: 4px;">
|
||||
<engine:Button text="Preview" name="preview-button" style="flex-grow: 1; flex-basis: 0;" />
|
||||
<engine:Button text="Bake" name="bake-button" style="flex-basis: 0; flex-grow: 1; background-color: rgb(70, 96, 124);" />
|
||||
</engine:VisualElement>
|
||||
</engine:VisualElement>
|
||||
</engine:UXML>
|
||||
10
Editor/SSS/SSSLutBakerView.uxml.meta
Normal file
10
Editor/SSS/SSSLutBakerView.uxml.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36e5f9eef212a0547b97e2643cd514de
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,119 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EditorTools
|
||||
{
|
||||
|
||||
public class SubsurfaceLookupTextureIntegratorWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("Tools/Subsurface LUT Integrator", false, 1000)]
|
||||
static void ShowIntegratorWindow()
|
||||
{
|
||||
GetWindow(typeof(SubsurfaceLookupTextureIntegratorWindow), false, "Subsurface LUT Integrator");
|
||||
}
|
||||
|
||||
private Color FalloffColor = new Color(1.0f, 0.3f, 0.2f);
|
||||
private float Radius = 4;
|
||||
private bool KeepDirectBounce = false;
|
||||
[SerializeField]
|
||||
private ComputeShader IntegratorShader;
|
||||
private RenderTexture IntegratedLUT = null;
|
||||
private int resolution = 512;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
//IntegratorShader = AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/Scripts/Tools/Editor/SSS/SubsurfaceLookupTextureIntegrator.compute");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (IntegratedLUT != null)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(IntegratedLUT);
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Base Settings", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
FalloffColor = EditorGUILayout.ColorField("Fallof Color", FalloffColor);
|
||||
Radius = EditorGUILayout.Slider("Radius", Radius, 0, 20);
|
||||
KeepDirectBounce = EditorGUILayout.Toggle("Keep Direct Bounce", KeepDirectBounce);
|
||||
resolution = EditorGUILayout.IntField("Resolution", resolution);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Bake();
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Bake") && IntegratorShader != null)
|
||||
{
|
||||
Bake();
|
||||
}
|
||||
if (GUILayout.Button("Save") && IntegratedLUT != null)
|
||||
{
|
||||
IntegratorShader.SetFloat("_Resoultion", (float)resolution);
|
||||
|
||||
RenderTexture rt = RenderTexture.GetTemporary(resolution, resolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
|
||||
Graphics.Blit(IntegratedLUT, rt);
|
||||
|
||||
RenderTexture.active = rt;
|
||||
Texture2D tex = new Texture2D(resolution, resolution, TextureFormat.ARGB32, false, true);
|
||||
tex.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
|
||||
RenderTexture.active = null;
|
||||
|
||||
RenderTexture.ReleaseTemporary(rt);
|
||||
|
||||
string path = EditorUtility.SaveFilePanel("Export Texture", Application.dataPath, "SSS_Lut", "png");
|
||||
if (path == null) return;
|
||||
System.IO.File.WriteAllBytes(path, tex.EncodeToPNG());
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
IntegratorShader.SetFloat("_Resoultion", (float)resolution);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
float width = position.width - 100;
|
||||
float height = position.height - 189;
|
||||
|
||||
float sacle = width > height ? height / resolution : width / resolution;
|
||||
Rect rect = new Rect(50, 150, resolution * sacle, resolution * sacle);
|
||||
if (IntegratedLUT != null)
|
||||
{
|
||||
EditorGUI.DrawPreviewTexture(rect, IntegratedLUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.DrawRect(rect, Color.black);
|
||||
}
|
||||
}
|
||||
|
||||
private void Bake()
|
||||
{
|
||||
if (IntegratedLUT != null)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(IntegratedLUT);
|
||||
}
|
||||
IntegratedLUT = RenderTexture.GetTemporary(resolution, resolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
|
||||
IntegratedLUT.enableRandomWrite = true;
|
||||
if (KeepDirectBounce)
|
||||
{
|
||||
IntegratorShader.EnableKeyword("KEEP_DIRECT_BOUNCE");
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegratorShader.DisableKeyword("KEEP_DIRECT_BOUNCE");
|
||||
}
|
||||
IntegratorShader.SetTexture(0, "_IntegratedLUT", IntegratedLUT);
|
||||
IntegratorShader.SetVector("_FalloffColor", FalloffColor);
|
||||
IntegratorShader.SetFloat("_Radius", Radius);
|
||||
IntegratorShader.SetFloat("_Resoultion", (float)resolution);
|
||||
IntegratorShader.Dispatch(0, resolution / 8, resolution / 8, 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,11 +38,10 @@ The HDRP Toon Shader is designed to provide a high-quality toon shading effect f
|
||||
3. Apply the material to your 3D models.
|
||||
4. Adjust the shader parameters in the material inspector to achieve the desired look.
|
||||
|
||||
## Examples
|
||||
|
||||
## Example
|
||||
Here are some examples of the HDRP Toon Shader in action:
|
||||
|
||||

|
||||

|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -55,4 +54,4 @@ If you would like to contribute to the development of the HDRP Toon Shader, plea
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
84
Runtime/Constants/UtsShaderPropertyName.cs
Normal file
84
Runtime/Constants/UtsShaderPropertyName.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
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 const string MATERIAL_TYPE = "_Material_Type";
|
||||
}
|
||||
|
||||
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 RimLight
|
||||
{
|
||||
public const string RIM_LIGHT_COLOR = "_RimLightColor";
|
||||
public const string RIM_LIGHT_INTENSITY = "_RimLightIntensity";
|
||||
public const string RIM_LIGHT_LEVEL = "_RimLightLevel";
|
||||
public const string SCREEN_SPACE_RIM_LIGHT = "_Screen_Space_Rim_Light";
|
||||
|
||||
public const string LIGHT_BASE_RIM_LIGHT = "_Light_Base_Rim_Light";
|
||||
public const string LIGHT_DIRECTION_RIM_LIGHT_LEVEL = "_LightDirectionRimLightLevel";
|
||||
|
||||
public const string COLOR_BLENDING_MODE = "_Is_BlendAddToRimColor";
|
||||
public const string RIM_LIGHT_CLIPPING = "_RimLightClipping";
|
||||
public const string RIM_LIGHT_CLIPPING_LEVEL = "_RimLightClippingLevel";
|
||||
|
||||
public const string LIGHT_DIRECTION = "_LightDirection_MaskOn";
|
||||
public const string INVERTED_DIRECTION_RIM_LIGHT = "_Add_Antipodean_RimLight";
|
||||
public const string INVERTED_RIM_LIGHT_COLOR = "_Ap_RimLightColor";
|
||||
public const string INVERSED_RIM_LIGHT_LEVEL = "_Ap_RimLight_Power";
|
||||
public const string INVERTED_RIM_LIGHT_FEATHER_OFF = "_Ap_RimLight_FeatherOff";
|
||||
public const string RIM_LIGHT_MASK_MAP = "_Set_RimLightMask";
|
||||
public const string RIM_LIGHT_MASK_LEVEL = "_Tweak_RimLightMaskLevel";
|
||||
}
|
||||
|
||||
public static class AngelRing
|
||||
{
|
||||
public const string ANGEL_RING_COLOR = "_AngelRingColor";
|
||||
public const string ANGEL_RING_COLOR_MAP = "_AngelRingColorMap";
|
||||
public const string ANGEL_RING_INTENSITY = "_AngelRingIntensity";
|
||||
public const string ANGEL_RING_OFFSET_U = "_AngelRingOffsetU";
|
||||
public const string ANGEL_RING_OFFSET_V = "_AngelRingOffsetV";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
public static class Advance
|
||||
{
|
||||
public const string MINIMAL_DIFFUSE_CONTRIBUTION = "_Minimal_Diffuse_Contribution";
|
||||
|
||||
public const string LIGHT_INTENSITY_MULTIPLIER = "_LightIntensityMultiplier";
|
||||
public const string CLAMP_LIGHT_COLOR = "_ClampLightColor";
|
||||
|
||||
public const string LIGHT_LOOP_MODE = "_Light_Loop_Mode";
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Constants/UtsShaderPropertyName.cs.meta
Normal file
2
Runtime/Constants/UtsShaderPropertyName.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 723370b3a1613cb43b85b765ebcebee3
|
||||
40
Runtime/Models/ShaderEnum.cs
Normal file
40
Runtime/Models/ShaderEnum.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
internal enum ShadingMode
|
||||
{
|
||||
Standard,
|
||||
SDF,
|
||||
}
|
||||
|
||||
internal enum MaterialType
|
||||
{
|
||||
Standard,
|
||||
FrontHair,
|
||||
Face,
|
||||
Eye
|
||||
}
|
||||
|
||||
internal enum PBRMode
|
||||
{
|
||||
Off,
|
||||
Standard,
|
||||
Anisotropy,
|
||||
KKHair,
|
||||
Toon
|
||||
}
|
||||
|
||||
internal enum IndirectDiffuseMode
|
||||
{
|
||||
Off,
|
||||
IBL,
|
||||
Matcap,
|
||||
Ramp
|
||||
}
|
||||
|
||||
internal enum IndirectSpecularMode
|
||||
{
|
||||
Off,
|
||||
IBL,
|
||||
Matcap
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
internal enum ShadingMode
|
||||
{
|
||||
Standard,
|
||||
SDF,
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,11 @@ namespace Misaki.HdrpToon
|
||||
{
|
||||
[Flags]
|
||||
[GenerateHLSL(PackingRules.Exact)]
|
||||
public enum SurfaceFeatureFlags : uint
|
||||
public enum SurfaceFeature
|
||||
{
|
||||
None = 0,
|
||||
RimLight = 1 << 0,
|
||||
Stocking = 1 << 1,
|
||||
AngelRing = 1 << 2,
|
||||
Outline = 1 << 3,
|
||||
AngelRing = 1 << 2
|
||||
}
|
||||
}
|
||||
16
Runtime/Models/SurfaceFeature.cs.hlsl
Normal file
16
Runtime/Models/SurfaceFeature.cs.hlsl
Normal 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
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec297400b1508d647a7cdbad2c0edf40
|
||||
guid: 1ae94e9055342d643a02bd5b4a9fa20b
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
2
Runtime/Models/SurfaceFeature.cs.meta
Normal file
2
Runtime/Models/SurfaceFeature.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 598a7ef5d67c6334ca8f930f37ea989b
|
||||
@@ -1,17 +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_NONE (0)
|
||||
#define SURFACEFEATUREFLAGS_RIM_LIGHT (1)
|
||||
#define SURFACEFEATUREFLAGS_STOCKING (2)
|
||||
#define SURFACEFEATUREFLAGS_ANGEL_RING (4)
|
||||
#define SURFACEFEATUREFLAGS_OUTLINE (8)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 737ea728a50a7664b90cba3dd3e21249
|
||||
@@ -1,139 +1,9 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
Shader "HDRP/Toon"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// -----------------------------------------------------------------------------
|
||||
// parameters for UTS
|
||||
// -----------------------------------------------------------------------------
|
||||
[HideInInspector] _simpleUI("SimpleUI", Int) = 0
|
||||
// Versioning of material to help for upgrading
|
||||
[HideInInspector] [Enum(Off, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1
|
||||
[HideInInspector] _utsVersionX("VersionX", Float) = 0
|
||||
[HideInInspector] _utsVersionY("VersionY", Float) = 7
|
||||
[HideInInspector] _utsVersionZ("VersionZ", Float) = 6
|
||||
|
||||
_HairBlendingMap("HairBlendingMap", 2D) = "black" {}
|
||||
|
||||
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_MaskMap("MaskMap", 2D) = "white" {}
|
||||
//[ToggleUI, HideInInspector] _Use_MaskMap("Use MaskMap", Int) = 0
|
||||
_MetallicRemapMin("MetalicRemapMin", Float) = 0.0
|
||||
_MetallicRemapMax("MetalicRemapMax", Float) = 1.0
|
||||
_SmoothnessRemapMin("RoughnessRemapMin", Float) = 0.0
|
||||
_SmoothnessRemapMax("RoughnessRemapMax", Float) = 1.0
|
||||
_AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14
|
||||
_AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14
|
||||
_AORemapMin("AORemapMin", Float) = 0.0
|
||||
_AORemapMax("AORemapMax", Float) = 1.0
|
||||
_SSSLutMap("SSSLutMap", 2D) = "white" {}
|
||||
[ToggleUI, HideInInspector] _Use_SSSLut("Use SSSLut", Int) = 0
|
||||
_SSSIntensity("SSSIntensity", Range(0.0, 3.0)) = 1.0
|
||||
|
||||
_NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
|
||||
_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value
|
||||
_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1
|
||||
|
||||
_BentNormalMap("_BentNormalMap", 2D) = "bump" {}
|
||||
_BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {}
|
||||
|
||||
_HeightMap("HeightMap", 2D) = "black" {}
|
||||
// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01
|
||||
// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change.
|
||||
[HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI.
|
||||
[HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space
|
||||
|
||||
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0
|
||||
// These parameters are for vertex displacement/Tessellation
|
||||
_HeightOffset("Height Offset", Float) = 0
|
||||
// MinMax mode
|
||||
_HeightMin("Heightmap Min", Float) = -1
|
||||
_HeightMax("Heightmap Max", Float) = 1
|
||||
// Amplitude mode
|
||||
_HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters
|
||||
_HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space
|
||||
|
||||
// These parameters are for pixel displacement
|
||||
_HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters
|
||||
|
||||
_DetailMap("DetailMap", 2D) = "linearGrey" {}
|
||||
_DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1
|
||||
_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1
|
||||
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1
|
||||
|
||||
_TangentMap("TangentMap", 2D) = "bump" {}
|
||||
_TangentMapOS("TangentMapOS", 2D) = "white" {}
|
||||
_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0
|
||||
_AnisotropyMap("AnisotropyMap", 2D) = "white" {}
|
||||
[ToggleUI] _Use_Anisotropy("Use Anisotropy", int) = 0
|
||||
_KKColor("BaseColor", Color) = (1,1,1,1)
|
||||
_BSDFContribution("_BSDFContribution", Range(0.0,1.0)) = 0
|
||||
|
||||
[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0
|
||||
[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0
|
||||
_SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0
|
||||
_SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {}
|
||||
_TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0
|
||||
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
|
||||
_ThicknessMap("Thickness Map", 2D) = "white" {}
|
||||
_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0)
|
||||
|
||||
_IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0
|
||||
_IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {}
|
||||
_IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0)
|
||||
_IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0
|
||||
_IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {}
|
||||
|
||||
_CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0
|
||||
_CoatMaskMap("CoatMaskMap", 2D) = "white" {}
|
||||
|
||||
[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0
|
||||
_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
|
||||
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}
|
||||
_ToonSpecularStep("Toon Specular Step", Range(0.0, 1.0)) = 0.5
|
||||
_ToonSpecularFeather("Toon Specular Feather", Range(0.0, 1.0)) = 0.0
|
||||
|
||||
// Following options are for the GUI inspector and different from the input parameters above
|
||||
// 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
|
||||
|
||||
[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" {}
|
||||
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0
|
||||
[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0
|
||||
[Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0
|
||||
[HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0
|
||||
[HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0
|
||||
[HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0
|
||||
[HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0
|
||||
[HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0
|
||||
_DistortionScale("Distortion Scale", Float) = 1
|
||||
_DistortionVectorScale("Distortion Vector Scale", Float) = 2
|
||||
_DistortionVectorBias("Distortion Vector Bias", Float) = -1
|
||||
_DistortionBlurScale("Distortion Blur Scale", Float) = 1
|
||||
_DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0
|
||||
_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0
|
||||
|
||||
//TODO: Use custom rendering data.
|
||||
[ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0
|
||||
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
|
||||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
_AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5
|
||||
_AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5
|
||||
_AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5
|
||||
@@ -152,8 +22,6 @@ Shader "HDRP/Toon"
|
||||
_ATDistance("Transmittance Absorption Distance", Float) = 1.0
|
||||
[ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0
|
||||
|
||||
// Stencil state
|
||||
|
||||
// Forward
|
||||
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
|
||||
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting
|
||||
@@ -179,7 +47,6 @@ Shader "HDRP/Toon"
|
||||
[HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0
|
||||
[HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.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] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default
|
||||
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
|
||||
@@ -195,82 +62,34 @@ Shader "HDRP/Toon"
|
||||
[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1
|
||||
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
|
||||
|
||||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0
|
||||
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0
|
||||
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
|
||||
[HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1
|
||||
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
|
||||
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
|
||||
|
||||
// Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other
|
||||
// so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature
|
||||
// The only material feature flag that can be added in all cases is clear coat
|
||||
[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard
|
||||
[ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0
|
||||
|
||||
[Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0
|
||||
[ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0
|
||||
[ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0
|
||||
[ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
|
||||
|
||||
[ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0
|
||||
_SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1
|
||||
_SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2
|
||||
|
||||
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
|
||||
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
|
||||
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
|
||||
_PPDPrimitiveLength("Primitive length for POM", Float) = 1
|
||||
_PPDPrimitiveWidth("Primitive width for POM", Float) = 1
|
||||
[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0)
|
||||
|
||||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
|
||||
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)
|
||||
[ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0
|
||||
|
||||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
|
||||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0
|
||||
_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0
|
||||
[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0)
|
||||
|
||||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
|
||||
// value that exist to identify if the GI emission need to be enabled.
|
||||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
|
||||
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
|
||||
_EmissionColor("Color", Color) = (1, 1, 1)
|
||||
|
||||
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
|
||||
_MainTex("Base Map", 2D) = "white" {}
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
|
||||
[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 0.0
|
||||
[ToggleUI] _ReceivesSSAO("Receives SSAO", Float) = 1.0
|
||||
_AO_Factor("_AO_Factor", Range(0.0, 1.0)) = 1
|
||||
[ToggleUI] _ReceivesSSGI("Receives SSGI", Float) = 1.0
|
||||
_GI_Factor("_GI_Factor", Range(0.0, 1.0)) = 1
|
||||
[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
//NOTE: UTS properties
|
||||
//TODO: Move more properties here for better organization
|
||||
|
||||
// Surface Options
|
||||
[Enum(Off, 0, On, 1)] _TransparentEnabled("Transparent Mode", int) = 0
|
||||
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
|
||||
[Popup] _TransparentEnabled("Transparent Mode", Integer) = 0
|
||||
[Popup(_ALPHATEST_ON)] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
|
||||
_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
|
||||
[KeywordEnum(Standard, SDF)] _Shading_Mode("Shade Grade mode", Float) = 0
|
||||
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", int) = 0
|
||||
[KeywordEnum(Off, Standard, Anisotropy, KKHair, Toon)] _PBR_Mode("PBR Mode", int) = 0
|
||||
[Toggle] _Receive_Hair_Shadow("Receive HairS hadow", Float) = 0
|
||||
[ToggleUI] _HairBlendingTarget("Hair Blending Target", Float) = 0
|
||||
_SurfaceFeatures("Surface Features", Float) = 0
|
||||
[Enum(Off, 0, Front, 1, Back, 2)] _CullMode("Cull Mode", Integer) = 2
|
||||
[KeywordEnum(Standard, SDF)] _Shading_Mode("Shading mode", Integer) = 0
|
||||
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", Integer) = 0
|
||||
[KeywordEnum(Off, Standard, Anisotropy, Hair, Toon)] _PBR_Mode("PBR Mode", Integer) = 0
|
||||
[PassPopup(HairBlendingTarget)] _HairBlendingTarget("Hair Blending Target", Integer) = 0
|
||||
[EnumFlagsUI(Misaki.HdrpToon.SurfaceFeature, Misaki.HdrpToon)]_SurfaceFeatures("Surface Features", Integer) = 0
|
||||
|
||||
// Shading Color
|
||||
[Popup] _Use_Shading_Ramp_Map("Use Shading Ramp Map", Integer) = 0
|
||||
@@ -292,12 +111,110 @@ Shader "HDRP/Toon"
|
||||
|
||||
_ShadingRampMap("ShadingRampMap", 2DArray) = "white" {}
|
||||
_ShadingIndex("ShadingIndex", Integer) = 0
|
||||
_ShadingRampMaskMap("ShadingRampMaskMap", 2D) = "white" {}
|
||||
_ShadingRampMask("ShadingRampMask", Range(0, 1)) = 1
|
||||
|
||||
_SDFShadingMap("SDFShadingMap", 2D) = "white" {}
|
||||
_SDFShadowLevel("SDFShadowLevel", Range(0.0, 1.0)) = 0.25
|
||||
_SDFShadowSmoothLevel("SDFShadowSmoothLevel", Range(0.0, 0.1)) = 0.02
|
||||
_SDFHighlightStrength("SDFHighlightStrength", Range(0.0, 1.0)) = 0.75
|
||||
|
||||
_HairBlendingFactor("HairBlendingFactor", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
// Shadow
|
||||
[Popup] _Receive_Light_Shadow("Receive Light Shadow", Integer) = 0
|
||||
[Popup] _Receive_Screen_Space_Shadow("Receive Screen Space Shadow", Integer) = 0
|
||||
[Popup] _Receive_Hair_Shadow("Receive Hair Shadow", Integer) = 0
|
||||
|
||||
_ShadowDistanceBias("ShadowBias", Range(0.0, 5.0)) = 0.0
|
||||
_ShadowNormalBias("ShadowNormalBias", Range(0.0, 5.0)) = 0.0
|
||||
//_Tweak_SystemShadowsLevel("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0
|
||||
|
||||
// Surface Inputs
|
||||
_NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
|
||||
_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1
|
||||
|
||||
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.0
|
||||
_MaskMap("MaskMap", 2D) = "white" {}
|
||||
_MetallicRemapMin("MetalicRemapMin", Float) = 0.0
|
||||
_MetallicRemapMax("MetalicRemapMax", Float) = 1.0
|
||||
_SmoothnessRemapMin("RoughnessRemapMin", Float) = 0.0
|
||||
_SmoothnessRemapMax("RoughnessRemapMax", Float) = 1.0
|
||||
_AlphaRemapMin("AlphaRemapMin", Float) = 0.0
|
||||
_AlphaRemapMax("AlphaRemapMax", Float) = 1.0
|
||||
_AORemapMin("AORemapMin", Float) = 0.0
|
||||
_AORemapMax("AORemapMax", Float) = 1.0
|
||||
|
||||
_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0
|
||||
_AnisotropyMap("AnisotropyMap", 2D) = "white" {}
|
||||
|
||||
_KKColor("BaseColor", Color) = (1,1,1,1)
|
||||
_BSDFContribution("_BSDFContribution", Range(0.0,1.0)) = 0
|
||||
|
||||
[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0
|
||||
_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
|
||||
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}
|
||||
_ToonSpecularStep("Toon Specular Step", Range(0.0, 1.0)) = 0.5
|
||||
_ToonSpecularFeather("Toon Specular Feather", Range(0.0, 1.0)) = 0.0
|
||||
|
||||
_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
|
||||
|
||||
// Ambient
|
||||
[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
|
||||
|
||||
_IndirectDiffuseMatCapMap("IndirectDiffuseMatCapMap", 2D) = "black" {}
|
||||
_IndirectDiffuseMatCapLod("IndirectDiffuseMatCapMapLOD", Range(-5, 5)) = 0.0
|
||||
|
||||
_IndirectDiffuseIntensity("Indirect Diffuse Intensity", Range(0, 5)) = 1.0
|
||||
_SSAOWeight("SSAO Weight", Range(0.0, 1.0)) = 1.0
|
||||
_SSGIWeight("SSGI Weight", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
_IndirectSpecularMatCapMap("IndirectSpecularMatCapMap", 2D) = "black" {}
|
||||
_IndirectSpecularMatCapLod("IndirectSpecularMatCapMapLOD", Range(-5, 5)) = 0.0
|
||||
|
||||
_IndirectDiffuseRampMap("_IndirectDiffuseRampMap", 2DArray) = "black" {}
|
||||
_IndirectDiffuseRampIndex("IndirectDiffuseRampIndex", Integer) = 0
|
||||
_IndirectDiffuseRampPosition("IndirectDiffuseRampPosition", Range(0, 1)) = 0.5
|
||||
|
||||
_IndirectSpecularIntensity("Indirect Specular Intensity", Range(0, 5)) = 1.0
|
||||
_SSRWeight("SSR Weight", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
// Rim Light
|
||||
_RimLightColor("Rim Light Color", Color) = (1, 1, 1, 1)
|
||||
_RimLightIntensity("Rim Light Intensity", Range(0, 10)) = 1
|
||||
[Popup] _Screen_Space_Rim_Light ("Screen Space Rim Light", Integer) = 0
|
||||
_RimLightLevel("RimLight Level", Range(0, 1)) = 0.1
|
||||
[ToggleUI] _RimLightClipping("Rim Light Clipping", Float) = 0.25
|
||||
_RimLightClippingLevel("Rim Light Clipping Level", Range(0.0001, 1)) = 0.0001
|
||||
|
||||
[Popup] _Light_Base_Rim_Light ("Light Base Rim Light", Integer) = 0
|
||||
_LightDirectionRimLightLevel("Light Direction Rim Light Level", Range(0, 0.5)) = 0
|
||||
|
||||
[ToggleUI] _Is_LightColor_RimLight("Is_LightColor_RimLight", Float) = 1
|
||||
[ToggleUI] _Is_NormalMapToRimLight("Is_NormalMapToRimLight", Float) = 0
|
||||
|
||||
[ToggleUI] _LightDirection_MaskOn("LightDirection_MaskOn", Float) = 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
|
||||
_AngelRingColor("Angel Ring Color", Color) = (1, 1, 1, 1)
|
||||
@@ -307,214 +224,40 @@ Shader "HDRP/Toon"
|
||||
_AngelRingOffsetV("Angel Ring Offset V", Range(0, 1)) = 0
|
||||
|
||||
// Outline
|
||||
_OutlineWidth("Outline Width", Float) = 0
|
||||
[PassPopup(Outline)] _OutlineState("Outline State", Integer) = 1
|
||||
_OutlineWidth("Outline Width", Float) = 0.25
|
||||
_OutlineWidthMap("Outline Tex", 2D) = "white" {}
|
||||
_OutlineColor("Outline Color", Color) = (0.5, 0.5, 0.5, 1)
|
||||
_OutlineColorMap("Outline Color Map", 2D) = "white" {}
|
||||
[Toggle(_)] _AlbedoAffectOutline("AlbedoAffectOutline", Float) = 0
|
||||
[ToggleUI] _AlbedoAffectOutline("Albedo Affect Outline", Float) = 1
|
||||
[ToggleUI] _SkyColorAffectOutline("Sky Color Affect Outline", Float) = 1
|
||||
_SkyColorIntensity("Sky Color Intensity", Range(0, 5)) = 1
|
||||
|
||||
_OutlineFadeIn("Outline Fade In", Float) = 50
|
||||
_OutlineFadeOut("Outline Fade Out", Float) = 100
|
||||
[Toggle(_)] _UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
||||
//[HideInInspector]_Cutoff("Alpha cutoff", Range(0, 1)) = 0.5
|
||||
_BakedNormal("Baked Normal for Outline", 2D) = "white" {}
|
||||
[ToggleUI] _UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
||||
|
||||
// Advance
|
||||
_LightIntensityMultiplier("Light_Intensity_Multiplier" , Range(0, 1)) = 0.5
|
||||
[ToggleUI] _ClampLightColor("VRChat : SceneLights HiCut_Filter", Float) = 0
|
||||
_Minimal_Diffuse_Contribution("Minimal_Diffuse_Contribution", Range(0, 1)) = 0.05
|
||||
[KeywordEnum(Single, Full, Custom)] _Light_Loop_Mode ("Light Loop Mode", Float) = 1
|
||||
|
||||
|
||||
//TODO: Clear hdrp default properties
|
||||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
|
||||
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)
|
||||
[ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0
|
||||
|
||||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
|
||||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5, Same as Base, 6)] _UVEmissive("UV Set for emissive", Float) = 0
|
||||
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMappingEmissive("Mapping space", Float) = 0.0
|
||||
_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0
|
||||
[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0)
|
||||
|
||||
[HideInInspector] _utsTechnique("Technique", int) = 0 //DWF
|
||||
[HideInInspector] _AutoRenderQueue("Automatic Render Queue ", int) = 1
|
||||
[Enum(Off, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0
|
||||
// these are set in UniversalToonGUI.cs in accordance with _StencilMode
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_StencilNo("Stencil No", Float) = 1
|
||||
_StencilOpPass("Stencil Operation", Float) = 0
|
||||
_StencilOpFail("Stencil Operation", Float) = 0
|
||||
|
||||
// DoubleShadeWithFeather
|
||||
// 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE
|
||||
// ShadingGradeMap
|
||||
// 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON
|
||||
[Enum(Off, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0
|
||||
|
||||
[Enum(Off, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON
|
||||
[Enum(Off, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON
|
||||
_SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15
|
||||
[Enum(Off, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK
|
||||
// ClippingMask paramaters from Here.
|
||||
_ClippingMask("ClippingMask", 2D) = "white" {}
|
||||
//v.2.0.4
|
||||
[HideInInspector] _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0
|
||||
//
|
||||
[Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0
|
||||
_Clipping_Level("Clipping_Level", Range(0, 1)) = 0
|
||||
_Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0
|
||||
// ClippingMask paramaters to Here.
|
||||
|
||||
// _MainTex("BaseMap", 2D) = "white" {}
|
||||
[HideInInspector] _BaseMap("BaseMap", 2D) = "white" {}
|
||||
_BaseColor("BaseColor", Color) = (1, 1, 1, 1)
|
||||
//v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack.
|
||||
//If you want to go back the former SSAO results, comment out the below line.
|
||||
[HideInInspector] _Color("Color", Color) = (1, 1, 1, 1)
|
||||
|
||||
// _NormalMap("NormalMap", 2D) = "bump" {}
|
||||
_BumpScale("Normal Scale", Range(0, 1)) = 1
|
||||
[Toggle(_)] _Is_NormalMapToBase("Is_NormalMapToBase", Float) = 0
|
||||
|
||||
// Hair Shadow
|
||||
[Toggle(_)] _Cast_Hair_Shadow("CastHairShadow", Float) = 0
|
||||
|
||||
_ShadowBias("ShadowBias", Range(0.0, 5.0)) = 0.0
|
||||
|
||||
[Toggle(_)] _Set_SystemShadowsToBase("Set_SystemShadowsToBase", Float) = 1
|
||||
_Tweak_SystemShadowsLevel("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0
|
||||
|
||||
// Eye Parallax
|
||||
[Toggle(_)] _Is_EyeParallax("_Is_EyeParallax", Float) = 0
|
||||
_EyeParallaxAmount("EyeParallaxAmount", Float) = 0.1
|
||||
|
||||
// Eyebrow Seethrough
|
||||
_HairBlendingFactor("EyeBrowBlendingFactor", Float) = 0.5
|
||||
|
||||
//v.2.0.6
|
||||
_BaseColor_Step("BaseColor_Step", Range(0, 1)) = 0.5
|
||||
_BaseShade_Feather("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001
|
||||
_ShadeColor_Step("ShadeColor_Step", Range(0, 1)) = 0
|
||||
_1st2nd_Shades_Feather("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001
|
||||
|
||||
//v.2.0.5
|
||||
_StepOffset("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0
|
||||
[Toggle(_)] _Is_Filter_HiCutPointLightColor("PointLights HiCut_Filter (ForwardAdd Only)", Float) = 1
|
||||
//
|
||||
_Set_1st_ShadePosition("Set_1st_ShadePosition", 2D) = "white" {}
|
||||
_Set_2nd_ShadePosition("Set_2nd_ShadePosition", 2D) = "white" {}
|
||||
//v.2.0.6
|
||||
_Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0
|
||||
_BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0
|
||||
|
||||
//
|
||||
_HighColor("HighColor", Color) = (0, 0, 0, 1)
|
||||
//v.2.0.4 HighColor_Tex
|
||||
_HighColor_Tex("HighColor_Tex", 2D) = "white" {}
|
||||
[Toggle(_)] _Is_LightColor_HighColor("Is_LightColor_HighColor", Float) = 1
|
||||
[Toggle(_)] _Is_NormalMapToHighColor("Is_NormalMapToHighColor", Float) = 0
|
||||
_HighColor_Power("HighColor_Power", Range(0, 1)) = 0
|
||||
[Toggle(_)] _Is_SpecularToHighColor("Is_SpecularToHighColor", Float) = 0
|
||||
[Toggle(_)] _Is_BlendAddToHiColor("Is_BlendAddToHiColor", Float) = 0
|
||||
[Enum(Multiply,0, Add,1)] _Is_BlendAddToRimColor("Is_BlendAddToRimColor", Float) = 1
|
||||
[Toggle(_)] _Is_UseTweakHighColorOnShadow("Is_UseTweakHighColorOnShadow", Float) = 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
|
||||
//
|
||||
_Indirect_Diffuse_Mode("_Indirect_Diffuse_Mode", Float) = 0
|
||||
_Indirect_Specular_Mode("_Indirect_Specular_Mode", Float) = 0
|
||||
|
||||
[Toggle(_)] _MatCap("MatCap", Float) = 0
|
||||
_MatCapMap("MatCapMap", 2D) = "black" {}
|
||||
//v.2.0.6
|
||||
_BlurLevelMatcap("Blur Level of MatCap_Sampler", Range(0, 10)) = 0
|
||||
_MatCapColor("MatCapColor", Color) = (1, 1, 1, 1)
|
||||
[Toggle(_)] _Is_LightColor_MatCap("Is_LightColor_MatCap", Float) = 1
|
||||
[Toggle(_)] _Is_BlendAddToMatCap("Is_BlendAddToMatCap", Float) = 1
|
||||
_Tweak_MatCapUV("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0
|
||||
_Rotate_MatCapUV("Rotate_MatCapUV", Range(-1, 1)) = 0
|
||||
//v.2.0.6
|
||||
[Toggle(_)] _CameraRolling_Stabilizer("Activate CameraRolling_Stabilizer", Float) = 0
|
||||
[Toggle(_)] _Is_NormalMapForMatCap("Is_NormalMapForMatCap", Float) = 0
|
||||
_NormalMapForMatCap("NormalMapForMatCap", 2D) = "bump" {}
|
||||
_BumpScaleMatcap("Scale for NormalMapforMatCap", Range(0, 1)) = 1
|
||||
_Rotate_NormalMapForMatCapUV("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0
|
||||
[Toggle(_)] _Is_UseTweakMatCapOnShadow("Is_UseTweakMatCapOnShadow", Float) = 0
|
||||
_TweakMatCapOnShadow("TweakMatCapOnShadow", Range(0, 1)) = 0
|
||||
//MatcapMask
|
||||
_Set_MatcapMask("Set_MatcapMask", 2D) = "white" {}
|
||||
_Tweak_MatcapMaskLevel("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0
|
||||
[Toggle(_)] _Inverse_MatcapMask("Inverse_MatcapMask", Float) = 0
|
||||
//v.2.0.5
|
||||
[Toggle(_)] _Is_Ortho("Orthographic Projection for MatCap", Float) = 0
|
||||
|
||||
//
|
||||
//v.2.0.7 Emissive
|
||||
[KeywordEnum(SIMPLE, ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0
|
||||
_Base_Speed("Base_Speed", Float) = 0
|
||||
_Scroll_EmissiveU("Scroll_EmissiveU", Range(-1, 1)) = 0
|
||||
_Scroll_EmissiveV("Scroll_EmissiveV", Range(-1, 1)) = 0
|
||||
_Rotate_EmissiveUV("Rotate_EmissiveUV", Float) = 0
|
||||
[Toggle(_)] _Is_PingPong_Base("Is_PingPong_Base", Float) = 0
|
||||
[Toggle(_)] _Is_ColorShift("Activate ColorShift", Float) = 0
|
||||
[HDR]_ColorShift("ColorSift", Color) = (0, 0, 0, 1)
|
||||
_ColorShift_Speed("ColorShift_Speed", Float) = 0
|
||||
[Toggle(_)] _Is_ViewShift("Activate ViewShift", Float) = 0
|
||||
[HDR]_ViewShift("ViewSift", Color) = (0, 0, 0, 1)
|
||||
[Toggle(_)] _Is_ViewCoord_Scroll("Is_ViewCoord_Scroll", Float) = 0
|
||||
//
|
||||
//GI Intensity
|
||||
_ID_Intensity("GI_Intensity", Range(0, 1)) = 1
|
||||
_IR_Intensity("GI_Intensity", Range(0, 1)) = 1
|
||||
_Light_Intensity_Multiplier("Light_Intensity_Multiplier" , Range(0, 1)) = 0.25
|
||||
//For VR Chat under No effective light objects
|
||||
_Unlit_Intensity("Unlit_Intensity", Range(0, 4)) = 0
|
||||
//v.2.0.5
|
||||
[Toggle(_)] _Is_Filter_LightColor("VRChat : SceneLights HiCut_Filter", Float) = 0
|
||||
//Built-in Light Direction
|
||||
[Toggle(_)] _Is_BLD("Advanced : Activate Built-in Light Direction", Float) = 0
|
||||
_Offset_X_Axis_BLD(" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05
|
||||
_Offset_Y_Axis_BLD(" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09
|
||||
[Toggle(_)] _Inverse_Z_Axis_BLD(" Inverse Z-Axis (Built-in Light Direction)", Float) = 1
|
||||
|
||||
[Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0
|
||||
_BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1)
|
||||
|
||||
[Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0
|
||||
_FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1)
|
||||
|
||||
[Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0
|
||||
_SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1)
|
||||
|
||||
[Toggle(_)] _HighlightVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0
|
||||
_HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1)
|
||||
|
||||
[Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0
|
||||
_AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1)
|
||||
|
||||
[Toggle(_)] _RimLightVisible("Channel mask", Float) = 1
|
||||
[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0
|
||||
_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1)
|
||||
|
||||
[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
|
||||
|
||||
[HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1)
|
||||
|
||||
[KeywordEnum(NONE, SINGLE, FULL)] _Light_Loop_Mode ("Light Loop Mode", Float) = 2
|
||||
//
|
||||
// to here parameters for UTS>
|
||||
[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0
|
||||
[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
@@ -525,15 +268,7 @@ Shader "HDRP/Toon"
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Variant
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
#pragma shader_feature_local _DEPTHOFFSET_ON
|
||||
#pragma shader_feature_local _DOUBLESIDED_ON
|
||||
#pragma shader_feature_local _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT
|
||||
#pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE
|
||||
#pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE
|
||||
#pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE
|
||||
#pragma shader_feature_local _TESSELLATION_PHONG
|
||||
|
||||
#pragma shader_feature_local _NORMALMAP_TANGENT_SPACE
|
||||
#pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3
|
||||
@@ -547,10 +282,6 @@ Shader "HDRP/Toon"
|
||||
//enable GPU instancing support
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
// enable debug shado
|
||||
// #pragma multi_compile _ UTS_DEBUG_SELFSHADOW
|
||||
// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP
|
||||
// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Define
|
||||
@@ -607,6 +338,7 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
// Note: Require _ObjectId and _PassValue variables
|
||||
|
||||
// We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation
|
||||
@@ -659,6 +391,21 @@ Shader "HDRP/Toon"
|
||||
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
|
||||
#pragma multi_compile _ LIGHT_LAYERS
|
||||
|
||||
#pragma shader_feature_local_fragment _PBR_MODE_OFF
|
||||
|
||||
#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 _EMISSIVE_COLOR_MAP
|
||||
|
||||
#if _PBR_MODE_OFF
|
||||
#undef _MASKMAP
|
||||
#undef _ANISOTROPYMAP
|
||||
#undef _SPECULARCOLORMAP
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG_DISPLAY
|
||||
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer
|
||||
// Don't do it with debug display mode as it is possible there is no depth prepass in this case
|
||||
@@ -666,9 +413,9 @@ Shader "HDRP/Toon"
|
||||
#endif
|
||||
|
||||
#define SHADERPASS SHADERPASS_GBUFFER
|
||||
#ifdef DEBUG_DISPLAY
|
||||
#ifdef DEBUG_DISPLAY
|
||||
#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 "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
||||
@@ -676,7 +423,7 @@ Shader "HDRP/Toon"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl"
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/UtsShaderPassGBuffer.hlsl"
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
|
||||
@@ -695,6 +442,7 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
// Lightmap memo
|
||||
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
|
||||
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
|
||||
@@ -727,6 +475,8 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
#define SHADERPASS SHADERPASS_SHADOWS
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
||||
@@ -746,7 +496,7 @@ Shader "HDRP/Toon"
|
||||
Tags{ "LightMode" = "DepthForwardOnly" }
|
||||
|
||||
Cull[_CullMode]
|
||||
|
||||
AlphaToMask [_AlphaCutoffEnable]
|
||||
// To be able to tag stencil with disableSSR information for forward
|
||||
Stencil
|
||||
{
|
||||
@@ -760,6 +510,8 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
// In deferred, depth only pass don't output anything.
|
||||
// In forward it output the normal buffer
|
||||
#pragma multi_compile _ WRITE_NORMAL_BUFFER
|
||||
@@ -799,6 +551,7 @@ Shader "HDRP/Toon"
|
||||
}
|
||||
|
||||
Cull[_CullMode]
|
||||
AlphaToMask [_AlphaCutoffEnable]
|
||||
|
||||
ZWrite On
|
||||
|
||||
@@ -806,6 +559,9 @@ Shader "HDRP/Toon"
|
||||
#pragma multi_compile _ WRITE_NORMAL_BUFFER
|
||||
#pragma multi_compile _ WRITE_MSAA_DEPTH
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
|
||||
#define SHADERPASS SHADERPASS_MOTION_VECTORS
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
|
||||
@@ -868,6 +624,9 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
|
||||
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
||||
#define CUTOFF_TRANSPARENT_DEPTH_PREPASS
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
@@ -895,6 +654,9 @@ Shader "HDRP/Toon"
|
||||
ZTest [_ZTestTransparent]
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
@@ -904,11 +666,11 @@ Shader "HDRP/Toon"
|
||||
// Setup DECALS_OFF so the shader stripper can remove variants
|
||||
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
|
||||
|
||||
// Supported shadow modes per light type
|
||||
#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
|
||||
#define PUNCTUAL_SHADOW_MEDIUM
|
||||
#define DIRECTIONAL_SHADOW_MEDIUM
|
||||
#define AREA_SHADOW_MEDIUM
|
||||
|
||||
#define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent
|
||||
#define AREA_SHADOW_LOW
|
||||
#define SHADERPASS SHADERPASS_FORWARD
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
||||
@@ -941,14 +703,13 @@ Shader "HDRP/Toon"
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Name "ForwardOnly"
|
||||
Tags { "LightMode" = "ForwardOnly" }
|
||||
Tags { "LightMode" = "ForwardOnly" }
|
||||
|
||||
ZWrite[_ZWriteMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [_ZTestMode]
|
||||
Cull[_CullMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull [_CullMode]
|
||||
Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend]
|
||||
Stencil {
|
||||
|
||||
Ref[_StencilNo]
|
||||
@@ -959,10 +720,7 @@ Shader "HDRP/Toon"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HLSLPROGRAM
|
||||
//#pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION
|
||||
#pragma multi_compile _ DEBUG_DISPLAY
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
@@ -973,66 +731,74 @@ Shader "HDRP/Toon"
|
||||
#pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
|
||||
|
||||
#pragma multi_compile_fragment USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
|
||||
//#pragma multi_compile_fragment PUNCTUAL_SHADOW_LOW PUNCTUAL_SHADOW_MEDIUM PUNCTUAL_SHADOW_HIGH
|
||||
//#pragma multi_compile_fragment DIRECTIONAL_SHADOW_LOW DIRECTIONAL_SHADOW_MEDIUM DIRECTIONAL_SHADOW_HIGH
|
||||
//#pragma multi_compile_fragment AREA_SHADOW_MEDIUM AREA_SHADOW_HIGH
|
||||
#pragma multi_compile PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
|
||||
#define SHADERPASS SHADERPASS_FORWARD
|
||||
// In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI)
|
||||
// Don't do it with debug display mode as it is possible there is no depth prepass in this case
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
|
||||
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
||||
#endif
|
||||
// used in ShadingGradeMap
|
||||
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
|
||||
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
|
||||
// used in Shadow calculation
|
||||
#pragma shader_feature _ UTS_USE_RAYTRACING_SHADOW
|
||||
// used in DoubleShadeWithFeather
|
||||
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
|
||||
// controlling mask rendering
|
||||
#pragma shader_feature _ _IS_CLIPPING_MATTE
|
||||
|
||||
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
|
||||
//Probe volume
|
||||
#pragma multi_compile PROBE_VOLUMES_OFF PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
|
||||
#pragma shader_feature ENABLE_UTS_HAIR_SHAOW
|
||||
#pragma shader_feature ENABLE_UTS_HAIR_BLENDING
|
||||
|
||||
#pragma shader_feature_local_fragment _LIGHT_LOOP_MODE_SINGLE _LIGHT_LOOP_MODE_FULL _LIGHT_LOOP_MODE_CUSTOM
|
||||
|
||||
#pragma shader_feature_local_fragment _SHADING_MODE_STANDARD _SHADING_MODE_SDF
|
||||
#pragma shader_feature_local_fragment _MATERIAL_TYPE_STANDARD _MATERIAL_TYPE_FRONTHAIR _MATERIAL_TYPE_FACE _MATERIAL_TYPE_EYE
|
||||
#pragma shader_feature_local_fragment _PBR_MODE_OFF _PBR_MODE_STANDARD _PBR_MODE_ANISOTROPY _PBR_MODE_HAIR _PBR_MODE_TOON
|
||||
|
||||
#pragma shader_feature_local_fragment _USE_SHADING_RAMP_MAP_ON
|
||||
|
||||
#pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_OFF _INDIRECT_DIFFUSE_IBL _INDIRECT_DIFFUSE_MATCAP _INDIRECT_DIFFUSE_RAMP
|
||||
#pragma shader_feature_local_fragment _INDIRECT_SPECULAR_OFF _INDIRECT_SPECULAR_IBL _INDIRECT_SPECULAR_MATCAP
|
||||
#pragma shader_feature_local_fragment _RECEIVE_LIGHT_SHADOW_ON
|
||||
#pragma shader_feature_local_fragment _RECEIVE_SCREEN_SPACE_SHADOW_ON
|
||||
#pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON
|
||||
|
||||
#pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_MODE_OFF _INDIRECT_DIFFUSE_MODE_IBL _INDIRECT_DIFFUSE_MODE_MATCAP _INDIRECT_DIFFUSE_MODE_RAMP
|
||||
#pragma shader_feature_local_fragment _INDIRECT_SPECULAR_MODE_OFF _INDIRECT_SPECULAR_MODE_IBL _INDIRECT_SPECULAR_MODE_MATCAP
|
||||
|
||||
#pragma shader_feature_local_fragment _SCREEN_SPACE_RIM_LIGHT_ON
|
||||
#pragma shader_feature_local_fragment _LIGHT_BASE_RIM_LIGHT_ON
|
||||
|
||||
#pragma shader_feature_local_fragment _SHADING_RAMP_MASK_MAP
|
||||
|
||||
#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 _MASK_MAP
|
||||
#pragma shader_feature_local_fragment _NORMAL_MAP
|
||||
#pragma shader_feature_local_fragment _ANISOTROPY_MAP
|
||||
#pragma shader_feature_local_fragment _SPECULAR_COLOR_MAP
|
||||
#pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
|
||||
|
||||
#pragma shader_feature_local_fragment _OUTLINE_COLOR_MAP
|
||||
#pragma shader_feature_local_fragment _OUTLINECOLORMAP
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
#pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON
|
||||
|
||||
#define PUNCTUAL_SHADOW_MEDIUM
|
||||
#define DIRECTIONAL_SHADOW_MEDIUM
|
||||
#define AREA_SHADOW_MEDIUM
|
||||
|
||||
#ifndef SHADER_STAGE_FRAGMENT
|
||||
#define SHADOW_LOW
|
||||
#define USE_FPTL_LIGHTLIST
|
||||
#endif
|
||||
#ifndef SHADER_STAGE_FRAGMENT
|
||||
#define SHADOW_LOW
|
||||
#define USE_FPTL_LIGHTLIST
|
||||
#endif
|
||||
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
|
||||
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
||||
#endif
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
|
||||
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
||||
#endif
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
||||
|
||||
#ifdef DEBUG_DISPLAY
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
|
||||
#endif
|
||||
#ifdef DEBUG_DISPLAY
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
|
||||
#endif
|
||||
|
||||
// The light loop (or lighting architecture) is in charge to:
|
||||
// - Define light list
|
||||
@@ -1074,6 +840,9 @@ Shader "HDRP/Toon"
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
||||
#define CUTOFF_TRANSPARENT_DEPTH_POSTPASS
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
@@ -1101,8 +870,6 @@ Shader "HDRP/Toon"
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
||||
// enable dithering LOD crossfade
|
||||
#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
|
||||
#define SHADERPASS SHADERPASS_CONSTANT
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||
@@ -1127,7 +894,6 @@ Shader "HDRP/Toon"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
|
||||
#define AREA_SHADOW_LOW
|
||||
#define SHADERPASS SHADERPASS_FORWARD
|
||||
#define SHADOW_LOW
|
||||
@@ -1141,13 +907,6 @@ Shader "HDRP/Toon"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
|
||||
#endif
|
||||
|
||||
// The light loop (or lighting architecture) is in charge to:
|
||||
// - Define light list
|
||||
// - Define the light loop
|
||||
// - Setup the constant/data
|
||||
// - Do the reflection hierarchy
|
||||
// - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong))
|
||||
|
||||
#define HAS_LIGHTLOOP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
|
||||
@@ -1158,8 +917,6 @@ Shader "HDRP/Toon"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl"
|
||||
|
||||
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsHead.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/HDRPToonOutline.hlsl"
|
||||
|
||||
@@ -1185,6 +942,9 @@ Shader "HDRP/Toon"
|
||||
HLSLPROGRAM
|
||||
|
||||
#define SHADERPASS SHADERPASS_SHADOWS
|
||||
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl"
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
#ifndef UCTS_HDRP_INCLUDED
|
||||
#define UCTS_HDRP_INCLUDED
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
|
||||
|
||||
#define UTS_LAYER_VISIBILITY
|
||||
|
||||
#ifndef DIRECTIONAL
|
||||
# define DIRECTIONAL
|
||||
#endif
|
||||
|
||||
#define FP_BUFFER 1
|
||||
|
||||
#if _PBR_MODE_OFF
|
||||
#undef _MASKMAP
|
||||
#undef _ANISOTROPYMAP
|
||||
#undef _SPECULARCOLORMAP
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(UNITY_PASS_PREPASSBASE) || defined(UNITY_PASS_DEFERRED) || defined(UNITY_PASS_SHADOWCASTER)
|
||||
#undef FOG_LINEAR
|
||||
@@ -24,21 +21,16 @@
|
||||
|
||||
#define Uts_ColorSpaceDielectricSpec half4(0.04, 0.04, 0.04, 1.0 - 0.04)
|
||||
|
||||
#if 1
|
||||
|
||||
struct UTSData
|
||||
{
|
||||
};
|
||||
|
||||
struct UTSSurfaceData
|
||||
{
|
||||
uint surfaceFeatures;
|
||||
|
||||
|
||||
real3 baseColor;
|
||||
real3 firstShadingColor;
|
||||
real3 secondShadingColor;
|
||||
real alpha;
|
||||
|
||||
|
||||
float3 normalWS;
|
||||
real perceptualSmoothness;
|
||||
real metallic;
|
||||
@@ -48,35 +40,35 @@ struct UTSSurfaceData
|
||||
|
||||
float3 geomNormalWS;
|
||||
float3 tangentWS;
|
||||
|
||||
|
||||
real4 subsurfaceColor;
|
||||
|
||||
|
||||
real anisotropy;
|
||||
};
|
||||
|
||||
struct UtsBSDFData
|
||||
{
|
||||
uint surfaceFeatures;
|
||||
|
||||
|
||||
real3 diffuseColor;
|
||||
real3 firstShadingDiffuseColor;
|
||||
real3 secondShadingDiffuseColor;
|
||||
|
||||
|
||||
real3 fresnel0;
|
||||
real fresnel90;
|
||||
real reflectivity;
|
||||
|
||||
|
||||
real ambientOcclusion;
|
||||
real specularOcclusion;
|
||||
real perceptualRoughness;
|
||||
|
||||
|
||||
real3 subsurfaceColor;
|
||||
|
||||
float3 geomNormalWS;
|
||||
float3 normalWS;
|
||||
float3 tangentWS;
|
||||
float3 bitangentWS;
|
||||
|
||||
|
||||
real anisotropy;
|
||||
real roughnessT;
|
||||
real roughnessB;
|
||||
@@ -111,7 +103,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
|
||||
UTSSurfaceData output;
|
||||
|
||||
output.surfaceFeatures = _SurfaceFeatures;
|
||||
|
||||
|
||||
float4 mainTexture = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
|
||||
output.baseColor = mainTexture.rgb * _BaseColor.rgb;
|
||||
output.alpha = mainTexture.a;
|
||||
@@ -131,12 +123,12 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
|
||||
#endif
|
||||
|
||||
float4 normalLocal = float4(0, 0, 1.0, 1.0);
|
||||
#if _NORMAL_MAP
|
||||
if (_Use_SSSLut)
|
||||
{
|
||||
normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap), _SSSIntensity);
|
||||
}
|
||||
else
|
||||
#if _NORMALMAP
|
||||
// if (_Use_SSSLut)
|
||||
// {
|
||||
// normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap), _SSSIntensity);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
normalLocal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
|
||||
normalLocal.rgb = UnpackNormalScale(normalLocal, _NormalScale);
|
||||
@@ -154,54 +146,57 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
|
||||
float3 specularColor = 1;
|
||||
float anisotropy = 0;
|
||||
|
||||
#ifdef _MASK_MAP
|
||||
float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
|
||||
metallic = _MaskMap_var.x;
|
||||
metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic);
|
||||
ao = _MaskMap_var.y;
|
||||
ao = lerp(_AORemapMin, _AORemapMax, ao);
|
||||
smoothness = _MaskMap_var.w;
|
||||
smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness);
|
||||
#endif
|
||||
#ifdef _MASKMAP
|
||||
float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
|
||||
metallic = _MaskMap_var.x;
|
||||
metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic);
|
||||
ao = _MaskMap_var.y;
|
||||
ao = lerp(_AORemapMin, _AORemapMax, ao);
|
||||
smoothness = _MaskMap_var.w;
|
||||
smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness);
|
||||
#endif
|
||||
|
||||
#ifdef _ANISOTROPY_MAP
|
||||
anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(input.texCoord0, _AnisotropyMap)).r;
|
||||
#if _PBR_Mode_KK
|
||||
anisotropy += _Anisotropy - 0.5;
|
||||
#else
|
||||
anisotropy *= _Anisotropy;
|
||||
#endif
|
||||
#else
|
||||
anisotropy = 1.0;
|
||||
anisotropy *= _Anisotropy;
|
||||
#endif
|
||||
#ifdef _ANISOTROPYMAP
|
||||
anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(input.texCoord0, _AnisotropyMap)).r;
|
||||
#if _PBR_Mode_KK
|
||||
anisotropy += _Anisotropy - 0.5;
|
||||
#else
|
||||
anisotropy *= _Anisotropy;
|
||||
#endif
|
||||
#else
|
||||
anisotropy = 1.0;
|
||||
anisotropy *= _Anisotropy;
|
||||
#endif
|
||||
|
||||
#ifdef _PBR_Mode_KK
|
||||
metallic = 0.0;
|
||||
smoothness *=_BSDFContribution;
|
||||
#endif
|
||||
#ifdef _PBR_Mode_KK
|
||||
metallic = 0.0;
|
||||
smoothness *=_BSDFContribution;
|
||||
#endif
|
||||
|
||||
// TODO: Specular color is not handle correctly.
|
||||
#ifdef _PBR_MODE_TOON
|
||||
metallic = 0.0;
|
||||
specularColor = _SpecularColor;
|
||||
#ifdef _SPECULARCOLORMAP
|
||||
specularColor *= SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)).rgb;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _PBR_Mode_TOON
|
||||
#ifdef _SPECULAR_COLOR_MAP
|
||||
specularColor = SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)).rgb * _SpecularColor;
|
||||
#endif
|
||||
specularColor = GetSpecularColor(_MainTex_var.rgb * _BaseColor.rgb, metallic);
|
||||
#endif
|
||||
|
||||
output.metallic = metallic;
|
||||
output.ambientOcclusion = ao;
|
||||
output.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(dot(normalWS, V), ao, PerceptualRoughnessToRoughness(1 - smoothness));
|
||||
output.perceptualSmoothness = smoothness;
|
||||
output.normalWS = normalWS;
|
||||
output.specularColor = specularColor;
|
||||
|
||||
|
||||
output.geomNormalWS = input.tangentToWorld[2];
|
||||
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.subsurfaceColor = 0.0;
|
||||
|
||||
output.anisotropy = anisotropy;
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -210,13 +205,20 @@ UtsBSDFData ConvertUTSSurfaceDataToUTSBSDFData(UTSSurfaceData surfaceData)
|
||||
UtsBSDFData output;
|
||||
|
||||
output.surfaceFeatures = surfaceData.surfaceFeatures;
|
||||
|
||||
output.diffuseColor = UtsComputeDiffuseColor(surfaceData.baseColor, surfaceData.metallic, 0.05);
|
||||
output.firstShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.firstShadingColor, surfaceData.metallic, 0.05);
|
||||
output.secondShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.secondShadingColor, surfaceData.metallic, 0.05);
|
||||
|
||||
#if _PBR_MODE_TOON
|
||||
float m = Max3(surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b);
|
||||
#else
|
||||
float m = surfaceData.metallic;
|
||||
#endif
|
||||
output.diffuseColor = UtsComputeDiffuseColor(surfaceData.baseColor, m, _Minimal_Diffuse_Contribution);
|
||||
output.firstShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.firstShadingColor, m, _Minimal_Diffuse_Contribution);
|
||||
output.secondShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.secondShadingColor, m, _Minimal_Diffuse_Contribution);
|
||||
|
||||
#if _PBR_MODE_OFF
|
||||
output.fresnel0 = surfaceData.baseColor;
|
||||
output.fresnel0 = 0.22;
|
||||
#elif _PBR_MODE_TOON
|
||||
output.fresnel0 = surfaceData.specularColor;
|
||||
#else
|
||||
output.fresnel0 = ComputeFresnel0(surfaceData.baseColor, surfaceData.metallic, 0.22);
|
||||
#endif
|
||||
@@ -236,7 +238,7 @@ UtsBSDFData ConvertUTSSurfaceDataToUTSBSDFData(UTSSurfaceData surfaceData)
|
||||
|
||||
output.anisotropy = surfaceData.anisotropy;
|
||||
ConvertAnisotropyToRoughness(output.perceptualRoughness, surfaceData.anisotropy, output.roughnessT, output.roughnessB);
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -250,7 +252,7 @@ PreLightData GetPreLightData_UTS(float3 V, PositionInputs posInput, inout UtsBSD
|
||||
preLightData.iblPerceptualRoughness = bsdfData.perceptualRoughness;
|
||||
|
||||
float clampedNdotV = ClampNdotV(preLightData.NdotV);
|
||||
|
||||
|
||||
// Handle IBL + area light + multiscattering.
|
||||
// Note: use the not modified by anisotropy iblPerceptualRoughness here.
|
||||
float specularReflectivity = 1.0;
|
||||
@@ -457,8 +459,6 @@ inline float3 LinearToGammaSpace(float3 linRGB)
|
||||
#define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,unity_FogColor)
|
||||
#endif
|
||||
|
||||
#endif //#if false
|
||||
|
||||
#ifdef DIRECTIONAL
|
||||
#define LIGHTING_COORDS(idx1,idx2) SHADOW_COORDS(idx1)
|
||||
#define TRANSFER_VERTEX_TO_FRAGMENT(a) TRANSFER_SHADOW(a)
|
||||
@@ -593,4 +593,4 @@ float3 SampleBakedGI_UTS_OutLine(float3 positionRWS, float3 normalWS, float2 uvS
|
||||
}
|
||||
|
||||
|
||||
#endif //#ifndef UCTS_HDRP_INCLUDED
|
||||
#endif //#ifndef UCTS_HDRP_INCLUDED
|
||||
|
||||
394
Runtime/Shaders/Includes/Common/UtsLitData.hlsl
Normal file
394
Runtime/Shaders/Includes/Common/UtsLitData.hlsl
Normal file
@@ -0,0 +1,394 @@
|
||||
#ifndef UTS_LIT_DATA
|
||||
#define UTS_LIT_DATA
|
||||
|
||||
float UtsGetSurfaceData(FragInputs input, LayerTexCoord layerTexCoord, out SurfaceData surfaceData,
|
||||
out float3 normalTS, out float3 bentNormalTS)
|
||||
{
|
||||
float3 detailNormalTS = float3(0.0, 0.0, 0.0);
|
||||
float detailMask = 0.0;
|
||||
#ifdef _DETAIL_MAP_IDX
|
||||
detailMask = 1.0;
|
||||
#ifdef _MASKMAP_IDX
|
||||
detailMask = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).b;
|
||||
#endif
|
||||
float2 detailAlbedoAndSmoothness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details)).rb;
|
||||
float detailAlbedo = detailAlbedoAndSmoothness.r * 2.0 - 1.0;
|
||||
float detailSmoothness = detailAlbedoAndSmoothness.g * 2.0 - 1.0;
|
||||
// Resample the detail map but this time for the normal map. This call should be optimize by the compiler
|
||||
// We split both call due to trilinear mapping
|
||||
detailNormalTS = SAMPLE_UVMAPPING_NORMALMAP_AG(ADD_IDX(_DetailMap), SAMPLER_DETAILMAP_IDX, ADD_IDX(layerTexCoord.details), ADD_IDX(_DetailNormalScale));
|
||||
#endif
|
||||
|
||||
float4 color = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap),
|
||||
ADD_IDX(layerTexCoord.base)).rgba * ADD_IDX(_BaseColor).rgba;
|
||||
surfaceData.baseColor = color.rgb;
|
||||
|
||||
float alpha = 1.0f;
|
||||
#ifdef DEBUG_DISPLAY
|
||||
if (_DebugMipMapMode == DEBUGMIPMAPMODE_NONE)
|
||||
#endif
|
||||
{
|
||||
alpha = color.a;
|
||||
alpha = lerp(ADD_IDX(_AlphaRemapMin), ADD_IDX(_AlphaRemapMax), alpha);
|
||||
}
|
||||
|
||||
#ifdef _DETAIL_MAP_IDX
|
||||
// Goal: we want the detail albedo map to be able to darken down to black and brighten up to white the surface albedo.
|
||||
// The scale control the speed of the gradient. We simply remap detailAlbedo from [0..1] to [-1..1] then perform a lerp to black or white
|
||||
// with a factor based on speed.
|
||||
// For base color we interpolate in sRGB space (approximate here as square) as it get a nicer perceptual gradient
|
||||
float albedoDetailSpeed = saturate(abs(detailAlbedo) * ADD_IDX(_DetailAlbedoScale));
|
||||
float3 baseColorOverlay = lerp(sqrt(surfaceData.baseColor), (detailAlbedo < 0.0) ? float3(0.0, 0.0, 0.0) : float3(1.0, 1.0, 1.0), albedoDetailSpeed * albedoDetailSpeed);
|
||||
baseColorOverlay *= baseColorOverlay;
|
||||
// Lerp with details mask
|
||||
surfaceData.baseColor = lerp(surfaceData.baseColor, saturate(baseColorOverlay), detailMask);
|
||||
#endif
|
||||
|
||||
surfaceData.specularOcclusion = 1.0; // Will be setup outside of this function
|
||||
|
||||
surfaceData.normalWS = float3(0.0, 0.0, 0.0);
|
||||
// Need to init this to keep quiet the compiler, but this is overriden later (0, 0, 0) so if we forget to override the compiler may comply.
|
||||
surfaceData.geomNormalWS = float3(0.0, 0.0, 0.0); // Not used, just to keep compiler quiet.
|
||||
|
||||
normalTS = ADD_IDX(GetNormalTS)(input, layerTexCoord, detailNormalTS, detailMask);
|
||||
bentNormalTS = ADD_IDX(GetBentNormalTS)(input, layerTexCoord, normalTS, detailNormalTS, detailMask);
|
||||
|
||||
#if _PBR_MODE_OFF
|
||||
surfaceData.perceptualSmoothness = 0.0;
|
||||
#else
|
||||
#if defined(_MASKMAP_IDX)
|
||||
surfaceData.perceptualSmoothness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).a;
|
||||
surfaceData.perceptualSmoothness = lerp(ADD_IDX(_SmoothnessRemapMin), ADD_IDX(_SmoothnessRemapMax), surfaceData.perceptualSmoothness);
|
||||
#else
|
||||
surfaceData.perceptualSmoothness = ADD_IDX(_Smoothness);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _DETAIL_MAP_IDX
|
||||
// See comment for baseColorOverlay
|
||||
float smoothnessDetailSpeed = saturate(abs(detailSmoothness) * ADD_IDX(_DetailSmoothnessScale));
|
||||
float smoothnessOverlay = lerp(surfaceData.perceptualSmoothness, (detailSmoothness < 0.0) ? 0.0 : 1.0, smoothnessDetailSpeed);
|
||||
// Lerp with details mask
|
||||
surfaceData.perceptualSmoothness = lerp(surfaceData.perceptualSmoothness, saturate(smoothnessOverlay), detailMask);
|
||||
#endif
|
||||
|
||||
#if _PBR_MODE_OFF
|
||||
surfaceData.metallic = 0.0;
|
||||
surfaceData.ambientOcclusion = 1.0;
|
||||
#else
|
||||
// MaskMap is RGBA: Metallic, Ambient Occlusion (Optional), detail Mask (Optional), Smoothness
|
||||
#ifdef _MASKMAP_IDX
|
||||
surfaceData.metallic = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
|
||||
surfaceData.metallic = lerp(ADD_IDX(_MetallicRemapMin), ADD_IDX(_MetallicRemapMax), surfaceData.metallic);
|
||||
surfaceData.ambientOcclusion = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).g;
|
||||
surfaceData.ambientOcclusion = lerp(ADD_IDX(_AORemapMin), ADD_IDX(_AORemapMax), surfaceData.ambientOcclusion);
|
||||
#else
|
||||
surfaceData.metallic = ADD_IDX(_Metallic);
|
||||
surfaceData.ambientOcclusion = 1.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
surfaceData.diffusionProfileHash = asuint(ADD_IDX(_DiffusionProfileHash));
|
||||
surfaceData.subsurfaceMask = ADD_IDX(_SubsurfaceMask);
|
||||
surfaceData.transmissionMask = ADD_IDX(_TransmissionMask);
|
||||
|
||||
#ifdef _SUBSURFACE_MASK_MAP_IDX
|
||||
surfaceData.subsurfaceMask *= SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_SubsurfaceMaskMap), SAMPLER_SUBSURFACE_MASK_MAP_IDX, ADD_IDX(layerTexCoord.base)).r;
|
||||
#endif
|
||||
#ifdef _TRANSMISSION_MASK_MAP_IDX
|
||||
surfaceData.transmissionMask *= SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_TransmissionMaskMap), SAMPLER_TRANSMISSION_MASK_MAP_IDX, ADD_IDX(layerTexCoord.base)).r;
|
||||
#endif
|
||||
|
||||
#ifdef _THICKNESSMAP_IDX
|
||||
surfaceData.thickness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_ThicknessMap), SAMPLER_THICKNESSMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
|
||||
surfaceData.thickness = ADD_IDX(_ThicknessRemap).x + ADD_IDX(_ThicknessRemap).y * surfaceData.thickness;
|
||||
#else
|
||||
surfaceData.thickness = ADD_IDX(_Thickness);
|
||||
#endif
|
||||
|
||||
|
||||
// This part of the code is not used in case of layered shader but we keep the same macro system for simplicity
|
||||
#if !defined(LAYERED_LIT_SHADER)
|
||||
|
||||
// These static material feature allow compile time optimization
|
||||
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
|
||||
|
||||
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_TRANSMISSION
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_ANISOTROPY
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
||||
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef _TANGENTMAP
|
||||
#ifdef _NORMALMAP_TANGENT_SPACE_IDX // Normal and tangent use same space
|
||||
// Tangent space vectors always use only 2 channels.
|
||||
float3 tangentTS = UnpackNormalmapRGorAG(SAMPLE_UVMAPPING_TEXTURE2D(_TangentMap, sampler_TangentMap, layerTexCoord.base), 1.0);
|
||||
surfaceData.tangentWS = TransformTangentToWorld(tangentTS, input.tangentToWorld);
|
||||
#else // Object space
|
||||
// Note: There is no such a thing like triplanar with object space normal, so we call directly 2D function
|
||||
float3 tangentOS = UnpackNormalRGB(SAMPLE_TEXTURE2D(_TangentMapOS, sampler_TangentMapOS, layerTexCoord.base.uv), 1.0);
|
||||
surfaceData.tangentWS = TransformObjectToWorldNormal(tangentOS);
|
||||
#endif
|
||||
#else
|
||||
// Note we don't normalize tangentWS either with a tangentmap above or using the interpolated tangent from the TBN frame
|
||||
// as it will be normalized later with a call to Orthonormalize():
|
||||
surfaceData.tangentWS = input.tangentToWorld[0].xyz;
|
||||
// The tangent is not normalize in tangentToWorld for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
|
||||
#endif
|
||||
|
||||
#ifdef _ANISOTROPYMAP
|
||||
surfaceData.anisotropy = SAMPLE_UVMAPPING_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, layerTexCoord.base).r;
|
||||
#else
|
||||
surfaceData.anisotropy = 1.0;
|
||||
#endif
|
||||
surfaceData.anisotropy *= ADD_IDX(_Anisotropy);
|
||||
|
||||
surfaceData.specularColor = _SpecularColor.rgb;
|
||||
#ifdef _SPECULARCOLORMAP
|
||||
surfaceData.specularColor *= SAMPLE_UVMAPPING_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, layerTexCoord.base).rgb;
|
||||
#endif
|
||||
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
|
||||
// Require to have setup baseColor
|
||||
// Reproduce the energy conservation done in legacy Unity. Not ideal but better for compatibility and users can unchek it
|
||||
surfaceData.baseColor *= _EnergyConservingSpecularColor > 0.0 ? (1.0 - Max3(surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b)) : 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
#if HAS_REFRACTION
|
||||
if (_EnableSSRefraction)
|
||||
{
|
||||
surfaceData.ior = _Ior;
|
||||
surfaceData.transmittanceColor = _TransmittanceColor;
|
||||
#ifdef _TRANSMITTANCECOLORMAP
|
||||
surfaceData.transmittanceColor *= SAMPLE_UVMAPPING_TEXTURE2D(_TransmittanceColorMap, sampler_TransmittanceColorMap, ADD_IDX(layerTexCoord.base)).rgb;
|
||||
#endif
|
||||
|
||||
surfaceData.atDistance = _ATDistance;
|
||||
// Rough refraction don't use opacity. Instead we use opacity as a transmittance mask.
|
||||
surfaceData.transmittanceMask = (1.0 - alpha);
|
||||
alpha = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceData.ior = 1.0;
|
||||
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
||||
surfaceData.atDistance = 1.0;
|
||||
surfaceData.transmittanceMask = 0.0;
|
||||
alpha = 1.0;
|
||||
}
|
||||
#else
|
||||
surfaceData.ior = 1.0;
|
||||
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
||||
surfaceData.atDistance = 1.0;
|
||||
surfaceData.transmittanceMask = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
|
||||
surfaceData.coatMask = _CoatMask;
|
||||
// To shader feature for keyword to limit the variant
|
||||
surfaceData.coatMask *= SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_CoatMaskMap), ADD_ZERO_IDX(sampler_CoatMaskMap), ADD_IDX(layerTexCoord.base)).r;
|
||||
#else
|
||||
surfaceData.coatMask = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
|
||||
#ifdef _IRIDESCENCE_THICKNESSMAP
|
||||
surfaceData.iridescenceThickness = SAMPLE_UVMAPPING_TEXTURE2D(_IridescenceThicknessMap, sampler_IridescenceThicknessMap, layerTexCoord.base).r;
|
||||
surfaceData.iridescenceThickness = _IridescenceThicknessRemap.x + _IridescenceThicknessRemap.y * surfaceData.iridescenceThickness;
|
||||
#else
|
||||
surfaceData.iridescenceThickness = _IridescenceThickness;
|
||||
#endif
|
||||
surfaceData.iridescenceMask = _IridescenceMask;
|
||||
surfaceData.iridescenceMask *= SAMPLE_UVMAPPING_TEXTURE2D(_IridescenceMaskMap, sampler_IridescenceMaskMap, layerTexCoord.base).r;
|
||||
#else
|
||||
surfaceData.iridescenceThickness = 0.0;
|
||||
surfaceData.iridescenceMask = 0.0;
|
||||
#endif
|
||||
|
||||
#else // #if !defined(LAYERED_LIT_SHADER)
|
||||
|
||||
// Mandatory to setup value to keep compiler quiet
|
||||
|
||||
// Layered shader material feature are define outside of this call
|
||||
surfaceData.materialFeatures = 0;
|
||||
|
||||
// All these parameters are ignore as they are re-setup outside of the layers function
|
||||
// Note: any parameters set here must also be set in GetSurfaceAndBuiltinData() layer version
|
||||
surfaceData.tangentWS = float3(0.0, 0.0, 0.0);
|
||||
surfaceData.anisotropy = 0.0;
|
||||
surfaceData.specularColor = float3(0.0, 0.0, 0.0);
|
||||
surfaceData.iridescenceThickness = 0.0;
|
||||
surfaceData.iridescenceMask = 0.0;
|
||||
surfaceData.coatMask = 0.0;
|
||||
|
||||
// Transparency
|
||||
surfaceData.ior = 1.0;
|
||||
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
|
||||
surfaceData.atDistance = 1000000.0;
|
||||
surfaceData.transmittanceMask = 0.0;
|
||||
|
||||
#endif // #if !defined(LAYERED_LIT_SHADER)
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
void UtsGetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData,
|
||||
out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS)
|
||||
{
|
||||
// Fix case 1210058. With Lit.shader / LayeredLit.shader we always have UV1. But in the case of some SpeedTree mesh, there is no stream sent
|
||||
// and UV1 is corrupt when we use surface gradient. In case UV1 aren't required we set them to 0, so we ensure there is no garbage.
|
||||
// When using lightmaps, the uv1 is always valid but we don't update _UVMappingMask.y to 1
|
||||
// So when we are using them, we just need to keep the UVs as is.
|
||||
#if !defined(LIGHTMAP_ON) && defined(SURFACE_GRADIENT)
|
||||
input.texCoord1 = (_UVMappingMask.y + _UVDetailsMappingMask.y + _UVMappingMaskEmissive.y) > 0 ? input.texCoord1 : 0;
|
||||
#endif
|
||||
|
||||
// Don't dither if displaced tessellation (we're fading out the displacement instead to match the next LOD)
|
||||
#if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT)
|
||||
#ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group
|
||||
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float3 doubleSidedConstants = GetDoubleSidedConstants();
|
||||
|
||||
ApplyDoubleSidedFlipOrMirror(input, doubleSidedConstants); // Apply double sided flip on the vertex normal
|
||||
|
||||
LayerTexCoord layerTexCoord;
|
||||
ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
|
||||
GetLayerTexCoord(input, layerTexCoord);
|
||||
|
||||
#if !defined(SHADER_STAGE_RAY_TRACING)
|
||||
float depthOffset = ApplyPerPixelDisplacement(input, V, layerTexCoord);
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
ApplyDepthOffsetPositionInput(V, depthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput);
|
||||
#endif
|
||||
#else
|
||||
float depthOffset = 0.0;
|
||||
#endif
|
||||
|
||||
#if defined(_ALPHATEST_ON)
|
||||
float alphaTex = SAMPLE_UVMAPPING_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, layerTexCoord.base).a;
|
||||
alphaTex = lerp(_AlphaRemapMin, _AlphaRemapMax, alphaTex);
|
||||
float alphaValue = alphaTex * _BaseColor.a;
|
||||
|
||||
// Perform alha test very early to save performance (a killed pixel will not sample textures)
|
||||
#if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS
|
||||
float alphaCutoff = _AlphaCutoffPrepass;
|
||||
#elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS
|
||||
float alphaCutoff = _AlphaCutoffPostpass;
|
||||
#elif (SHADERPASS == SHADERPASS_SHADOWS) || (SHADERPASS == SHADERPASS_RAYTRACING_VISIBILITY)
|
||||
float alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : _AlphaCutoff;
|
||||
#else
|
||||
float alphaCutoff = _AlphaCutoff;
|
||||
#endif
|
||||
|
||||
GENERIC_ALPHA_TEST(alphaValue, alphaCutoff);
|
||||
#endif
|
||||
|
||||
// We perform the conversion to world of the normalTS outside of the GetSurfaceData
|
||||
// so it allow us to correctly deal with detail normal map and optimize the code for the layered shaders
|
||||
float3 normalTS;
|
||||
float3 bentNormalTS;
|
||||
float3 bentNormalWS;
|
||||
float alpha = UtsGetSurfaceData(input, layerTexCoord, surfaceData, normalTS, bentNormalTS);
|
||||
|
||||
// This need to be init here to quiet the compiler in case of decal, but can be override later.
|
||||
surfaceData.geomNormalWS = input.tangentToWorld[2];
|
||||
surfaceData.specularOcclusion = 1.0;
|
||||
|
||||
#ifdef DECAL_NORMAL_BLENDING
|
||||
if (_EnableDecals)
|
||||
{
|
||||
#ifndef SURFACE_GRADIENT
|
||||
normalTS = SurfaceGradientFromTangentSpaceNormalAndFromTBN(normalTS,
|
||||
input.tangentToWorld[0], input.tangentToWorld[1]);
|
||||
#endif
|
||||
|
||||
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, input, alpha);
|
||||
ApplyDecalToSurfaceData(decalSurfaceData, input.tangentToWorld[2], surfaceData, normalTS);
|
||||
}
|
||||
|
||||
GetNormalWS_SG(input, normalTS, surfaceData.normalWS, doubleSidedConstants);
|
||||
#else
|
||||
GetNormalWS(input, normalTS, surfaceData.normalWS, doubleSidedConstants);
|
||||
|
||||
#if HAVE_DECALS
|
||||
if (_EnableDecals)
|
||||
{
|
||||
// Both uses and modifies 'surfaceData.normalWS'.
|
||||
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, input, alpha);
|
||||
ApplyDecalToSurfaceData(decalSurfaceData, input.tangentToWorld[2], surfaceData);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Use bent normal to sample GI if available
|
||||
#ifdef _BENTNORMALMAP
|
||||
GetNormalWS(input, bentNormalTS, bentNormalWS, doubleSidedConstants);
|
||||
#else
|
||||
bentNormalWS = surfaceData.normalWS;
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if !defined(SHADER_STAGE_RAY_TRACING)
|
||||
// Mipmap mode debugging isn't supported with ray tracing as it relies on derivatives
|
||||
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
|
||||
{
|
||||
surfaceData.baseColor = GET_TEXTURE_STREAMING_DEBUG(posInput.positionSS, input.texCoord0);
|
||||
surfaceData.metallic = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// We need to call ApplyDebugToSurfaceData after filling the surfaceData and before filling builtinData
|
||||
// as it can modify attribute use for static lighting
|
||||
ApplyDebugToSurfaceData(input.tangentToWorld, surfaceData);
|
||||
#endif
|
||||
|
||||
// By default we use the ambient occlusion with Tri-ace trick (apply outside) for specular occlusion.
|
||||
// If user provide bent normal then we process a better term
|
||||
#if defined(_SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP)
|
||||
// If we have bent normal and ambient occlusion, process a specular occlusion
|
||||
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO(V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
||||
// Don't do spec occ from Ambient if there is no mask mask
|
||||
#elif defined(_MASKMAP) && !defined(_SPECULAR_OCCLUSION_NONE)
|
||||
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(dot(surfaceData.normalWS, V)), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness(surfaceData.perceptualSmoothness));
|
||||
#endif
|
||||
|
||||
// This is use with anisotropic material
|
||||
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
|
||||
|
||||
#if defined(_ENABLE_GEOMETRIC_SPECULAR_AA) && !defined(SHADER_STAGE_RAY_TRACING)
|
||||
// Specular AA
|
||||
#ifdef PROJECTED_SPACE_NDF_FILTERING
|
||||
surfaceData.perceptualSmoothness = ProjectedSpaceGeometricNormalFiltering(surfaceData.perceptualSmoothness, input.tangentToWorld[2], _SpecularAAScreenSpaceVariance, _SpecularAAThreshold);
|
||||
#else
|
||||
surfaceData.perceptualSmoothness = GeometricNormalFiltering(surfaceData.perceptualSmoothness, input.tangentToWorld[2], _SpecularAAScreenSpaceVariance, _SpecularAAThreshold);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Caution: surfaceData must be fully initialize before calling GetBuiltinData
|
||||
GetBuiltinData(input, V, posInput, surfaceData, alpha, bentNormalWS, depthOffset, layerTexCoord.base, builtinData);
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
// Used for sharpening by alpha to mask
|
||||
builtinData.alphaClipTreshold = alphaCutoff;
|
||||
#endif
|
||||
|
||||
RAY_TRACING_OPTIONAL_ALPHA_TEST_PASS
|
||||
}
|
||||
|
||||
#endif
|
||||
3
Runtime/Shaders/Includes/Common/UtsLitData.hlsl.meta
Normal file
3
Runtime/Shaders/Includes/Common/UtsLitData.hlsl.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be7208b19c2b4f53b717af959f293024
|
||||
timeCreated: 1738569488
|
||||
@@ -1,259 +0,0 @@
|
||||
#ifndef UTS_MATERIAL_EVALUATION
|
||||
#define UTS_MATERIAL_EVALUATION
|
||||
|
||||
#define ColorSpaceDielectricSpec half4(0.22, 0.22, 0.22, 0.779)
|
||||
|
||||
struct UtsShadeMask
|
||||
{
|
||||
float baseShadeMask;
|
||||
float firstShadeMask;
|
||||
};
|
||||
|
||||
float RoughnessToBlinnPhongSpecularExponent(float roughness)
|
||||
{
|
||||
return clamp(2 * rcp(roughness * roughness) - 2, FLT_EPS, rcp(FLT_EPS));
|
||||
}
|
||||
|
||||
float StepFeatherToon(float value,float step,float feather)
|
||||
{
|
||||
return saturate((value - step + feather) / feather);
|
||||
}
|
||||
|
||||
float3 ComputeSpecularTerm(UtsBSDFData bsdfData, PreLightData preLightData, float3 V, float3 L)
|
||||
{
|
||||
#ifdef _PBR_MODE_OFF
|
||||
return 0;
|
||||
#else
|
||||
float3 specTerm;
|
||||
float3 N = bsdfData.normalWS;
|
||||
float3 H = normalize(L + V);
|
||||
|
||||
float NdotL = dot(N, L);
|
||||
float NdotH = saturate(dot(N, H));
|
||||
float clampedNdotV = ClampNdotV(preLightData.NdotV);
|
||||
float clampedNdotL = saturate(NdotL);
|
||||
|
||||
float partLambdaV;
|
||||
float3 DV = 0;
|
||||
#ifdef _PBR_MODE_STANDARD
|
||||
partLambdaV = GetSmithJointGGXPartLambdaV(clampedNdotV, bsdfData.roughnessT);
|
||||
// We use abs(NdotL) to handle the none case of double sided
|
||||
DV = DV_SmithJointGGX(NdotH, abs(NdotL), clampedNdotV, bsdfData.roughnessT, partLambdaV);
|
||||
|
||||
#elif _PBR_MODE_ANISOTROPY
|
||||
float TdotV = dot(bsdfData.tangentWS, V);
|
||||
float BdotV = dot(bsdfData.bitangentWS, V);
|
||||
|
||||
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughness, bsdfData.anisotropy, bsdfData.roughnessT, bsdfData.roughnessB);
|
||||
partLambdaV = GetSmithJointGGXAnisoPartLambdaV(TdotV, BdotV, clampedNdotV, bsdfData.roughnessT, bsdfData.roughnessB);
|
||||
|
||||
// For anisotropy we must not saturate these values
|
||||
float TdotH = dot(bsdfData.tangentWS, H);
|
||||
float TdotL = dot(bsdfData.tangentWS, L);
|
||||
float BdotH = dot(bsdfData.bitangentWS, H);
|
||||
float BdotL = dot(bsdfData.bitangentWS, L);
|
||||
|
||||
// We use abs(NdotL) to handle the none case of double sided
|
||||
DV = DV_SmithJointGGXAniso(TdotH, BdotH, NdotH, clampedNdotV, TdotL, BdotL, abs(NdotL), bsdfData.roughnessT, bsdfData.roughnessB, partLambdaV);
|
||||
|
||||
#elif _PBR_MODE_HAIR
|
||||
float3 t = ShiftTangent(bsdfData.bitangentWS, N, bsdfData.anisotropy);
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.coatRoughness));
|
||||
DV = D_KajiyaKay(t, H, specularExponent);
|
||||
|
||||
float normalizeSpec = DV * rcp(specularExponent + 2) * 2 * PI;
|
||||
//DV *= StepFeatherToon(normalizeSpec,specularStep,specularFeather);
|
||||
DV = DV * normalizeSpec * _KKColor.rgb;
|
||||
#elif _PBR_MODE_TOON
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||
DV = pow(NdotH, 5.0 * specularExponent);
|
||||
DV = StepFeatherToon(DV, _ToonSpecularStep, _ToonSpecularFeather);
|
||||
//specTerm = pow(NdotH, 5.0 * specularExponent);
|
||||
//specTerm = StepFeatherToon(specTerm, _ToonSpecularStep, _ToonSpecularFeather);
|
||||
//return specTerm * ColorSpaceDielectricSpec.rgb * clampedNdotL;
|
||||
#endif
|
||||
|
||||
specTerm = DV * preLightData.specularFGD;
|
||||
specTerm = specTerm * clampedNdotL;
|
||||
|
||||
return specTerm;
|
||||
#endif
|
||||
}
|
||||
|
||||
half3 FitWithCurveApprox(half NdotL, half Curvature)
|
||||
{
|
||||
half curva = (1.0 / mad(Curvature, 0.5 - 0.0625, 0.0625) - 2.0) / (16.0 - 2.0);
|
||||
half oneMinusCurva = 1.0 - curva;
|
||||
half3 curve0;
|
||||
{
|
||||
half3 rangeMin = half3(0.0, 0.3, 0.3);
|
||||
half3 rangeMax = half3(1.0, 0.7, 0.7);
|
||||
half3 offset = half3(0.0, 0.06, 0.06);
|
||||
half3 t = saturate(mad(NdotL, 1.0 / (rangeMax - rangeMin), (offset + rangeMin) / (rangeMin - rangeMax)));
|
||||
half3 lowerLine = (t * t) * half3(0.65, 0.5, 0.9);
|
||||
lowerLine.r += 0.045;
|
||||
lowerLine.b *= t.b;
|
||||
half3 m = half3(1.75, 2.0, 1.97);
|
||||
half3 upperLine = mad(NdotL, m, half3(0.99, 0.99, 0.99) - m);
|
||||
upperLine = saturate(upperLine);
|
||||
half3 lerpMin = half3(0.0, 0.35, 0.35);
|
||||
half3 lerpMax = half3(1.0, 0.7, 0.6);
|
||||
half3 lerpT = saturate(mad(NdotL, 1.0 / (lerpMax - lerpMin), lerpMin / (lerpMin - lerpMax)));
|
||||
curve0 = lerp(lowerLine, upperLine, lerpT * lerpT);
|
||||
}
|
||||
half3 curve1;
|
||||
{
|
||||
half3 m = half3(1.95, 2.0, 2.0);
|
||||
half3 upperLine = mad(NdotL, m, half3(0.99, 0.99, 1.0) - m);
|
||||
curve1 = saturate(upperLine);
|
||||
}
|
||||
float oneMinusCurva2 = oneMinusCurva * oneMinusCurva;
|
||||
return lerp(curve0, curve1, mad(oneMinusCurva2, -1.0 * oneMinusCurva2, 1.0));
|
||||
}
|
||||
|
||||
float3 SampleSDFTexture(float3 L, float2 uv, out float angle)
|
||||
{
|
||||
float2 right_uv = float2(1 - uv.x, uv.y);
|
||||
float3 left_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, uv).rgb;
|
||||
float3 right_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, right_uv).rgb;
|
||||
|
||||
float2 leftVector = normalize(mul(UNITY_MATRIX_M, float4(1.0, 0.0, 0.0, 0.0)).xz);
|
||||
float2 forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0.0, 0.0, 1.0, 0.0)).xz);
|
||||
|
||||
float2 lightDirection = normalize(L.xz);
|
||||
angle = saturate(dot(forwardVector, lightDirection) * -1.0 + _SDFShadowLevel);
|
||||
bool isRightSide = dot(lightDirection, leftVector) > 0;
|
||||
|
||||
return isRightSide ? right_SDFTex : left_SDFTex;
|
||||
}
|
||||
|
||||
float GetHairShadow(PositionInputs posInput, float3 L)
|
||||
{
|
||||
float shadow = 1.0;
|
||||
|
||||
// Push the face fragment view space position towards the light for a little bit
|
||||
float hairShadowOpacity = saturate(Remap(length(posInput.positionWS), float2(_HairShadowFadeOutDistance, _HairShadowFadeInDistance), float2(0, 1)));
|
||||
|
||||
if (hairShadowOpacity > 0.0)
|
||||
{
|
||||
float3 viewLightDir = TransformWorldToViewDir(L); // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face.
|
||||
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||
float shadowLengthY = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth;
|
||||
float2 shadowLength = float2(shadowLengthY * 2.0f, shadowLengthY);
|
||||
|
||||
float3 camDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||
float camDirFactor = 1 - smoothstep(0.1, 0.9, camDirOS.y);
|
||||
shadowLength.y *= camDirFactor;
|
||||
|
||||
float2 samplingPoint = (posInput.positionSS + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2(1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
|
||||
|
||||
// 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.
|
||||
float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r;
|
||||
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.
|
||||
shadow = lerp(1, 1.0 - hairShadowOpacity, shadowMask);
|
||||
}
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData, SHADOW_TYPE shadow,
|
||||
float3 lightColor, float3 V, float3 L, float2 uv,
|
||||
float diffuseDimmer, float specularDimmer)
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
if (Max3(lightColor.r, lightColor.g, lightColor.b) > 0.0)
|
||||
{
|
||||
shadow = smoothstep(0.4, 0.6, shadow);
|
||||
#if _RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW
|
||||
shadow *= GetHairShadow(posInput, L);
|
||||
#endif
|
||||
shadow = saturate(lerp(1.0, shadow, _Set_SystemShadowsToBase));
|
||||
|
||||
#if _SHADING_MODE_SDF
|
||||
float angle;
|
||||
float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf highlight, b: fixed shadow
|
||||
float shadowSmoothLevel = _SDFShadowSmoothLevel / 10.0;
|
||||
float sdfShadowMask = smoothstep(angle - shadowSmoothLevel, angle + shadowSmoothLevel, sdfTexture.r);
|
||||
float sdfHighlight = sdfTexture.g * _SDFHighlightStrength;
|
||||
#endif
|
||||
|
||||
float3 diffuseTerm = 0.0;
|
||||
float3 specularTerm = ComputeSpecularTerm(bsdfData, preLightData, V, L);
|
||||
#if _USE_SHADING_RAMP_MAP_ON
|
||||
#if _SHADING_MODE_STANDARD
|
||||
float NdotL = dot(bsdfData.normalWS, L);
|
||||
float halfLambert = 0.5 * NdotL + 0.5;
|
||||
|
||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY_LOD(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, 0.0), _ShadingIndex, 0.0).rgb;
|
||||
|
||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||
specularTerm *= saturate(NdotL) * shadow;
|
||||
#elif _SHADING_MODE_SDF
|
||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY_LOD(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * shadow.x, 0.0), _ShadingIndex, 0.0).rgb;
|
||||
|
||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * shadow;
|
||||
#endif
|
||||
#else
|
||||
#if _SHADING_MODE_STANDARD
|
||||
float NdotL = dot(bsdfData.normalWS, L);
|
||||
float halfLambert = 0.5 * NdotL + 0.5;
|
||||
|
||||
float firstColorFeatherForMask = lerp(_1stShadeColorFeather, 0.0, max(_ComposerMaskMode, _FirstShadeOverridden));
|
||||
float baseShadeMask = saturate((halfLambert - (_1stShadeColorStep - firstColorFeatherForMask)) / (_1stShadeColorStep - (_1stShadeColorStep - firstColorFeatherForMask)));
|
||||
baseShadeMask *= shadow;
|
||||
|
||||
float secondColorFeatherForMask = lerp(_2ndShadeColorFeather, 0.0, max(_SecondShadeOverridden, _ComposerMaskMode));
|
||||
float firstShadeMask = saturate((halfLambert - (_2ndShadeColorStep - secondColorFeatherForMask)) / (_2ndShadeColorStep - (_2ndShadeColorStep - secondColorFeatherForMask)));
|
||||
|
||||
diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, firstShadeMask), bsdfData.diffuseColor, baseShadeMask);
|
||||
specularTerm *= baseShadeMask;
|
||||
#elif _SHADING_MODE_SDF
|
||||
float shadeMask = sdfShadowMask * sdfTexture.b * shadow;
|
||||
|
||||
diffuseTerm = lerp(bsdfData.firstShadingDiffuseColor, bsdfData.diffuseColor, shadeMask);
|
||||
specularTerm = (specularTerm + sdfHighlight) * shadeMask;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
lighting.diffuse += diffuseTerm * lightColor * diffuseDimmer;
|
||||
lighting.specular += specularTerm * lightColor * specularDimmer;
|
||||
}
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
DirectLighting UtsEvaluateAngelRing(FragInputs input, float3 normalWS, float3 V)
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
// Should we scroll the angel ring texture on x?
|
||||
float3 cameraRight = UNITY_MATRIX_V[0].xyz;
|
||||
float3 cameraFront = UNITY_MATRIX_V[2].xyz;
|
||||
float3 upVector = float3(0, 1, 0);
|
||||
float3 rightAxis = cross(cameraFront, upVector);
|
||||
float cameraRightMagnitude = sqrt(cameraRight.x * cameraRight.x + cameraRight.y * cameraRight.y + cameraRight.z * cameraRight.z);
|
||||
float rightAxisMagnitude = sqrt(rightAxis.x * rightAxis.x + rightAxis.y * rightAxis.y + rightAxis.z * rightAxis.z);
|
||||
float cameraRollCos = dot(rightAxis, cameraRight) / (rightAxisMagnitude * cameraRightMagnitude);
|
||||
float3 cameraRoll = acos(clamp(cameraRollCos, -1.0, 1.0));
|
||||
float cameraDir = cameraRight.y < 0 ? -1.0 : 1.0;
|
||||
|
||||
float2 arOffsetU = lerp(mul(UNITY_MATRIX_V, float4(normalWS, 0)).xyz, float3(0, 0, 1), _AngelRingOffsetU).xy;
|
||||
arOffsetU = arOffsetU * 0.5 + 0.5;
|
||||
float2 arvnRotate = RotateUV(arOffsetU, -(cameraDir * cameraRoll), 0.5, 1.0);
|
||||
float2 arOffsetUV = float2(arvnRotate.x, lerp(input.texCoord0.y, arvnRotate.y, _AngelRingOffsetV));
|
||||
float4 angelRingColor = SAMPLE_TEXTURE2D(_AngelRingColorMap, sampler_AngelRingColorMap, TRANSFORM_TEX(arOffsetUV, _AngelRingColorMap)) * _AngelRingColor * _AngelRingIntensity;
|
||||
|
||||
float weight = saturate(dot(normalize(V), normalWS));
|
||||
|
||||
lighting.specular += angelRingColor.r * angelRingColor.a * weight;
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef UTS_SURFACE_FEATURE_EVALUATION
|
||||
#define UTS_SURFACE_FEATURE_EVALUATION
|
||||
|
||||
DirectLighting UtsEvaluateLighting_RimLight(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData
|
||||
#if _LIGHT_BASE_RIM_LIGHT_ON
|
||||
, float3 L, float3 lightColor
|
||||
#endif
|
||||
)
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
float3 rimLightColor = _RimLightColor.rgb * _RimLightIntensity;
|
||||
|
||||
#if _SCREEN_SPACE_RIM_LIGHT_ON
|
||||
float3 normalVS = normalize(mul((float3x3)UNITY_MATRIX_V, bsdfData.geomNormalWS));
|
||||
float2 depthUV = posInput.positionNDC.xy + normalVS.xy * (_RimLightLevel * 0.05 / posInput.linearDepth);
|
||||
float offsetedDepth = SampleCameraDepth(depthUV);
|
||||
float depthDiff = saturate(posInput.deviceDepth - offsetedDepth);
|
||||
|
||||
float rimLightMask = step(0.0025 / posInput.linearDepth, depthDiff);
|
||||
#else
|
||||
float clampNdotV = ClampNdotV(preLightData.NdotV);
|
||||
float rimLightMask = pow(1.0 - clampNdotV, exp2(lerp(3.0, 0.0, _RimLightLevel)));
|
||||
rimLightMask = lerp(rimLightMask, step(_RimLightClippingLevel, rimLightMask), _RimLightClipping);
|
||||
#endif
|
||||
|
||||
#if _LIGHT_BASE_RIM_LIGHT_ON
|
||||
float halfLambert = 0.5 * dot(bsdfData.normalWS, L) + 0.5;
|
||||
float lightBaseMask = saturate(smoothstep(_LightDirectionRimLightLevel, 1.0, halfLambert));
|
||||
|
||||
rimLightMask *= lightBaseMask;
|
||||
rimLightColor *= lightColor;
|
||||
#endif
|
||||
|
||||
lighting.diffuse = rimLightMask * rimLightColor;
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
DirectLighting UtsEvaluateLighting_AngelRing(FragInputs input, float3 normalWS, float3 V)
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
// Should we scroll the angel ring texture on x?
|
||||
float3 cameraRight = UNITY_MATRIX_V[0].xyz;
|
||||
float3 cameraFront = UNITY_MATRIX_V[2].xyz;
|
||||
float3 upVector = float3(0, 1, 0);
|
||||
float3 rightAxis = cross(cameraFront, upVector);
|
||||
float cameraRightMagnitude = sqrt(cameraRight.x * cameraRight.x + cameraRight.y * cameraRight.y + cameraRight.z * cameraRight.z);
|
||||
float rightAxisMagnitude = sqrt(rightAxis.x * rightAxis.x + rightAxis.y * rightAxis.y + rightAxis.z * rightAxis.z);
|
||||
float cameraRollCos = dot(rightAxis, cameraRight) / (rightAxisMagnitude * cameraRightMagnitude);
|
||||
float3 cameraRoll = acos(clamp(cameraRollCos, -1.0, 1.0));
|
||||
float cameraDir = cameraRight.y < 0 ? -1.0 : 1.0;
|
||||
|
||||
float2 arOffsetU = lerp(mul(UNITY_MATRIX_V, float4(normalWS, 0)).xyz, float3(0, 0, 1), _AngelRingOffsetU).xy;
|
||||
arOffsetU = arOffsetU * 0.5 + 0.5;
|
||||
float2 arvnRotate = RotateUV(arOffsetU, -(cameraDir * cameraRoll).x, 0.5, 1.0);
|
||||
float2 arOffsetUV = float2(arvnRotate.x, lerp(input.texCoord0.y, arvnRotate.y, _AngelRingOffsetV));
|
||||
float4 angelRingColor = SAMPLE_TEXTURE2D(_AngelRingColorMap, sampler_AngelRingColorMap, TRANSFORM_TEX(arOffsetUV, _AngelRingColorMap)) * _AngelRingColor * _AngelRingIntensity;
|
||||
|
||||
float weight = saturate(dot(normalize(V), normalWS));
|
||||
|
||||
lighting.specular = angelRingColor.r * angelRingColor.a * weight;
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0719f4875020bca4b8ccebbb1c92041f
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Shaders/Includes/Deprecated.meta
Normal file
8
Runtime/Shaders/Includes/Deprecated.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4b440fa5514bff4089187ae3b07b338
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -679,8 +679,8 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD);
|
||||
float3 originalLightColor = customMainLight.lightColor.rgb;
|
||||
|
||||
originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin ), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve) * _Light_Intensity_Multiplier;
|
||||
float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_Is_Filter_LightColor, _ToonLightHiCutFilter));
|
||||
originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin ), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve) * _LightIntensityMultiplier;
|
||||
float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_ClampLightColor, _ToonLightHiCutFilter));
|
||||
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _1st_ShadeMap)), _MainTex_var, _Use_BaseAs1st);
|
||||
float3 _1st_Shade_var = lerp((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb) * lightColor), _Is_LightColor_1st_Shade);
|
||||
@@ -782,4 +782,4 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
|
||||
//outColor.rgb = customMainLight.shadowValue;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float3 originalLightColor = mainLightColor.rgb;
|
||||
|
||||
originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve);
|
||||
float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_Is_Filter_LightColor, _ToonLightHiCutFilter)) * _Light_Intensity_Multiplier;
|
||||
float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_ClampLightColor, _ToonLightHiCutFilter)) * _LightIntensityMultiplier;
|
||||
|
||||
////// Lighting:
|
||||
float3 halfDirection = normalize(utsData.viewDirection + lightDirection);
|
||||
@@ -337,4 +337,4 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
utsAggregateLighting.directSpecular += specularTerm * utsLightData.specularDimmer;
|
||||
|
||||
#endif // _SDFShadow
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,6 @@ void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLig
|
||||
|
||||
// We dont have to calculate lighting here if we are using sdf shadow
|
||||
#ifndef _SDFShadow
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode != 0)
|
||||
{
|
||||
|
||||
return float3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||
// input.positionSS is SV_Position
|
||||
@@ -32,7 +25,7 @@ void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLig
|
||||
#endif
|
||||
|
||||
float3 lightDirection = utsLightData.lightDirection;
|
||||
float3 additionalLightColor = utsLightData.lightColor * _Light_Intensity_Multiplier;
|
||||
float3 additionalLightColor = utsLightData.lightColor * _LightIntensityMultiplier;
|
||||
|
||||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
||||
|
||||
@@ -70,7 +63,7 @@ void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLig
|
||||
}
|
||||
|
||||
float pureIntensity = max(0.001, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b));
|
||||
float3 lightColor = max(float3(0.0, 0.0, 0.0), lerp(addPassLightColor, lerp(float3(0.0, 0.0, 0.0), min(addPassLightColor, addPassLightColor / pureIntensity), notDirectional), _Is_Filter_LightColor));
|
||||
float3 lightColor = max(float3(0.0, 0.0, 0.0), lerp(addPassLightColor, lerp(float3(0.0, 0.0, 0.0), min(addPassLightColor, addPassLightColor / pureIntensity), notDirectional), _ClampLightColor));
|
||||
float3 halfDirection = normalize(viewDirection + lightDirection); // has to be recalced here.
|
||||
//v.2.0.5:
|
||||
_1st_ShadeColor_Step = saturate(_1st_ShadeColor_Step + _StepOffset);
|
||||
@@ -255,4 +248,4 @@ void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLig
|
||||
utsAggregateLighting.directDiffuse += diffuseTerm * utsLightData.diffuseDimmer;
|
||||
utsAggregateLighting.directSpecular += specularTerm * utsLightData.specularDimmer;
|
||||
#endif // _SDFShadow
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
#define SATURATE_BASE_COLOR_IF_SDR(x) saturate(x)
|
||||
#endif
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsMaterialEvaluation.hlsl"
|
||||
|
||||
const float rateR = 0.299;
|
||||
const float rateG = 0.587;
|
||||
const float rateB = 0.114;
|
||||
@@ -32,8 +34,9 @@ float GetColorAttenuation(float3 lightColor)
|
||||
|
||||
float3 GetLimitedLightColor(float3 lightColor)
|
||||
{
|
||||
lightColor = ApplyCurrentExposureMultiplier(lightColor);
|
||||
float3 result = lerp(lightColor, saturate(lightColor), _Is_Filter_LightColor);
|
||||
// In a hemisphere, The engery of full radiance is L * 2pi, and the engery of lambert is L * pi. We multiply by 0.5 here to apply the energy conservation.
|
||||
lightColor = ApplyCurrentExposureMultiplier(lightColor) * 0.5;
|
||||
float3 result = lerp(lightColor, normalize(lightColor), _ClampLightColor);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -42,17 +45,21 @@ DirectLighting UtsEvaluateBSDF_Directional(LightLoopContext lightLoopContext, Po
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
|
||||
float3 L = -lightData.forward;
|
||||
SHADOW_TYPE shadow = EvaluateShadow_Directional(lightLoopContext, posInput, lightData, builtinData, bsdfData.geomNormalWS);
|
||||
|
||||
|
||||
SHADOW_TYPE shadow = 1.0;
|
||||
#if _RECEIVE_LIGHT_SHADOW_ON
|
||||
shadow = EvaluateShadow_Directional(lightLoopContext, posInput, lightData, builtinData, bsdfData.geomNormalWS);
|
||||
#endif
|
||||
|
||||
if (lightData.lightDimmer > 0.0)
|
||||
{
|
||||
// TODO: Colored shadow will overwrite the first and second shading diffuse color
|
||||
//float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint);
|
||||
float4 lightColor = EvaluateLight_Directional(lightLoopContext, posInput, lightData);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _Light_Intensity_Multiplier);
|
||||
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _LightIntensityMultiplier);
|
||||
|
||||
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
|
||||
|
||||
lighting = UtsShadeSurface(posInput, bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer);
|
||||
@@ -65,28 +72,28 @@ DirectLighting UtsEvaluateBSDF_Punctual(LightLoopContext lightLoopContext, Posit
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
|
||||
float3 L;
|
||||
float4 distances; // {d, d^2, 1/d, d_proj}
|
||||
GetPunctualLightVectors(posInput.positionWS, lightData, L, distances);
|
||||
|
||||
PositionInputs shadowPositionInputs = posInput;
|
||||
shadowPositionInputs.positionWS = posInput.positionWS + L * _ShadowBias;
|
||||
|
||||
SHADOW_TYPE shadow = EvaluateShadow_Punctual(lightLoopContext, shadowPositionInputs, lightData, builtinData, bsdfData.geomNormalWS, L, distances);
|
||||
|
||||
|
||||
SHADOW_TYPE shadow = 1.0;
|
||||
#if _RECEIVE_LIGHT_SHADOW_ON
|
||||
shadow = UtsEvaluateShadow_Punctual(lightLoopContext, posInput, lightData, builtinData, UtsGetShadowNormal(bsdfData), L, distances);
|
||||
#endif
|
||||
|
||||
if (lightData.lightDimmer > 0.0)
|
||||
{
|
||||
// TODO: Colored shadow will overwrite the first and second shading diffuse color
|
||||
//float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint);
|
||||
float4 lightColor = EvaluateLight_Punctual(lightLoopContext, posInput, lightData, L, distances);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _Light_Intensity_Multiplier);
|
||||
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _LightIntensityMultiplier);
|
||||
|
||||
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
|
||||
|
||||
lighting = UtsShadeSurface(posInput, bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer);
|
||||
}
|
||||
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
@@ -95,15 +102,18 @@ IndirectLighting UtsEvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput,
|
||||
IndirectLighting lighting;
|
||||
ZERO_INITIALIZE(IndirectLighting, lighting);
|
||||
|
||||
// TODO: this texture is sparse (mostly black). Can we avoid reading every texel? How about using Hi-S?
|
||||
float4 ssrLighting = LOAD_TEXTURE2D_X(_SsrLightingTexture, posInput.positionSS);
|
||||
InversePreExposeSsrLighting(ssrLighting);
|
||||
if (_SSRWeight > 0.0)
|
||||
{
|
||||
// TODO: this texture is sparse (mostly black). Can we avoid reading every texel? How about using Hi-S?
|
||||
float4 ssrLighting = LOAD_TEXTURE2D_X(_SsrLightingTexture, posInput.positionSS);
|
||||
InversePreExposeSsrLighting(ssrLighting);
|
||||
|
||||
// Apply the weight on the ssr contribution (if required)
|
||||
ApplyScreenSpaceReflectionWeight(ssrLighting);
|
||||
// Apply the weight on the ssr contribution (if required)
|
||||
ApplyScreenSpaceReflectionWeight(ssrLighting);
|
||||
|
||||
reflectionHierarchyWeight = ssrLighting.a;
|
||||
lighting.specularReflected = ssrLighting.rgb * preLightData.specularFGD;
|
||||
reflectionHierarchyWeight = ssrLighting.a;
|
||||
lighting.specularReflected = lerp(lighting.specularReflected, ssrLighting.rgb * preLightData.specularFGD, _SSRWeight);
|
||||
}
|
||||
|
||||
return lighting;
|
||||
}
|
||||
@@ -114,41 +124,40 @@ void UtsEvaluateBSDF_BakeDiffuse(PositionInputs posInput, PreLightData preLightD
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
lightInReflDir = float3(-1, -1, -1); // This variable is used with APV for reflection probe normalization - see code for LIGHTFEATUREFLAGS_ENV
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_PBR_MODE_OFF) || defined(_PBR_MODE_TOON)
|
||||
float3 normalWS = float3(0.0, 0.0, 1.0);
|
||||
#else
|
||||
float3 normalWS = bsdfData.normalWS;
|
||||
#endif
|
||||
float3 backNormalWS = -normalWS;
|
||||
|
||||
// Reflect normal to get lighting for reflection probe tinting
|
||||
float3 R = reflect(-V, normalWS);
|
||||
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(posInput.positionWS),
|
||||
normalWS, -backNormalWS,
|
||||
R, V,
|
||||
posInput.positionSS, builtinData.renderingLayers,
|
||||
builtinData.bakeDiffuseLighting, builtinData.backBakeDiffuseLighting, lightInReflDir);
|
||||
}
|
||||
else // If probe volume is disabled we fallback on the ambient probes
|
||||
{
|
||||
builtinData.bakeDiffuseLighting = EvaluateAmbientProbe(normalWS);
|
||||
builtinData.backBakeDiffuseLighting = EvaluateAmbientProbe(backNormalWS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(SCREEN_SPACE_INDIRECT_DIFFUSE_DISABLED)
|
||||
if (_IndirectDiffuseMode != INDIRECTDIFFUSEMODE_OFF)
|
||||
{
|
||||
builtinData.bakeDiffuseLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS).xyz * GetInverseCurrentExposureMultiplier();
|
||||
float3 ssgiLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS).xyz * GetInverseCurrentExposureMultiplier();
|
||||
builtinData.bakeDiffuseLighting = lerp(builtinData.bakeDiffuseLighting, ssgiLighting.rgb, _SSGIWeight);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
// Reflect normal to get lighting for reflection probe tinting
|
||||
float3 R = reflect(-V, bsdfData.normalWS);
|
||||
|
||||
#if defined(_PBR_Mode_OFF) || defined(_PBR_Mode_TOON)
|
||||
float3 normalWS = 0.0;
|
||||
float3 backNormalWS = 0.0;
|
||||
#else
|
||||
float3 normalWS = bsdfData.normalWS;
|
||||
float3 backNormalWS = -bsdfData.normalWS;
|
||||
#endif
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(posInput.positionWS),
|
||||
bsdfData.normalWS, -bsdfData.normalWS,
|
||||
R, V,
|
||||
posInput.positionSS, builtinData.renderingLayers,
|
||||
builtinData.bakeDiffuseLighting, builtinData.backBakeDiffuseLighting, lightInReflDir);
|
||||
}
|
||||
else // If probe volume is disabled we fallback on the ambient probes
|
||||
{
|
||||
builtinData.bakeDiffuseLighting = EvaluateAmbientProbe(bsdfData.normalWS);
|
||||
builtinData.backBakeDiffuseLighting = EvaluateAmbientProbe(-bsdfData.normalWS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void UtsEvaluateBSDF_MatCapDiffuse(float3 positionWS, float3 normalWS, inout BuiltinData builtinData)
|
||||
@@ -161,14 +170,15 @@ void UtsEvaluateBSDF_MatCapDiffuse(float3 positionWS, float3 normalWS, inout Bui
|
||||
uv.x *= -1;
|
||||
uv = uv * 0.5 + 0.5;
|
||||
|
||||
builtinData.bakeDiffuseLighting = SAMPLE_TEXTURE2D_LOD(_MatCapMap, s_linear_clamp_sampler, uv, UNITY_SPECCUBE_LOD_STEPS).rgb * GetInverseCurrentExposureMultiplier();
|
||||
float lod = clamp(UNITY_SPECCUBE_LOD_STEPS + _IndirectDiffuseMatCapLod, 0.0, 10.0);
|
||||
builtinData.bakeDiffuseLighting = SAMPLE_TEXTURE2D_LOD(_IndirectDiffuseMatCapMap, s_trilinear_clamp_sampler, uv, lod).rgb * GetInverseCurrentExposureMultiplier();
|
||||
}
|
||||
|
||||
IndirectLighting UtsEvaluateBSDF_MatCapSpecular(float3 positionWS, UtsBSDFData bsdfData, PreLightData preLightData)
|
||||
{
|
||||
IndirectLighting lighting;
|
||||
ZERO_INITIALIZE(IndirectLighting, lighting);
|
||||
|
||||
|
||||
float3 positionVS = mul(UNITY_MATRIX_V, float4(positionWS, 1.0)).xyz;
|
||||
float3 normalVS = mul(UNITY_MATRIX_V, float4(bsdfData.normalWS, 1.0)).xyz;
|
||||
float3 pcrossN = cross(normalize(positionVS), normalVS);
|
||||
@@ -177,27 +187,24 @@ IndirectLighting UtsEvaluateBSDF_MatCapSpecular(float3 positionWS, UtsBSDFData b
|
||||
uv.x *= -1;
|
||||
uv = uv * 0.5 + 0.5;
|
||||
|
||||
lighting.specularReflected = SAMPLE_TEXTURE2D_LOD(_MatCapMap, s_linear_clamp_sampler, uv, PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness)).rgb;
|
||||
float lod = clamp(PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness) + _IndirectSpecularMatCapLod, 0.0, 10.0);
|
||||
lighting.specularReflected = SAMPLE_TEXTURE2D_LOD(_IndirectSpecularMatCapMap, s_trilinear_clamp_sampler, uv, lod).rgb;
|
||||
lighting.specularReflected *= preLightData.specularFGD * GetInverseCurrentExposureMultiplier();
|
||||
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
void UtsEvaluateBSDF_Ramp(PositionInputs posInput, UtsBSDFData bsdfData, float3 L, inout BuiltinData builtinData)
|
||||
void UtsEvaluateBSDF_Ramp(PositionInputs posInput, UtsBSDFData bsdfData, inout BuiltinData builtinData)
|
||||
{
|
||||
// TODO
|
||||
float3 lighting = SAMPLE_TEXTURE2D_ARRAY(_IndirectDiffuseRampMap, s_trilinear_clamp_sampler, float2(_IndirectDiffuseRampPosition, 0.0), _IndirectDiffuseRampIndex).rgb;
|
||||
builtinData.bakeDiffuseLighting = lighting * GetInverseCurrentExposureMultiplier();
|
||||
}
|
||||
|
||||
IndirectLighting UtsEvaluateBSDF_Env(LightLoopContext lightLoopContext, PositionInputs posInput, PreLightData preLightData, EnvLightData lightData, UtsBSDFData bsdfData, int influenceShapeType, int GPUImageBasedLightingType, inout float hierarchyWeight)
|
||||
{
|
||||
IndirectLighting lighting;
|
||||
ZERO_INITIALIZE(IndirectLighting, lighting);
|
||||
|
||||
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION)
|
||||
{
|
||||
return lighting;
|
||||
}
|
||||
|
||||
|
||||
float3 envLighting;
|
||||
float3 positionWS = posInput.positionWS;
|
||||
float weight = 1.0;
|
||||
@@ -238,27 +245,38 @@ IndirectLighting UtsEvaluateBSDF_Env(LightLoopContext lightLoopContext, Position
|
||||
return lighting;
|
||||
}
|
||||
|
||||
void ApplyAmbientOcclusion(AmbientOcclusionFactor aoFactor, inout BuiltinData builtinData, inout AggregateLighting lighting)
|
||||
{
|
||||
builtinData.bakeDiffuseLighting = APPLY_WEIGHT(builtinData.bakeDiffuseLighting, aoFactor.indirectAmbientOcclusion, _SSAOWeight);
|
||||
lighting.indirect.specularReflected = APPLY_WEIGHT(lighting.indirect.specularReflected, aoFactor.indirectSpecularOcclusion, _SSAOWeight);
|
||||
lighting.direct.diffuse = APPLY_WEIGHT(lighting.direct.diffuse, aoFactor.directAmbientOcclusion, _SSAOWeight);
|
||||
lighting.direct.specular = APPLY_WEIGHT(lighting.direct.specular, aoFactor.directSpecularOcclusion, _SSAOWeight);
|
||||
}
|
||||
|
||||
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);
|
||||
lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IndirectSpecularIntensity);
|
||||
}
|
||||
|
||||
void UtsPostEvaluateBSDF(PositionInputs posInput, PreLightData preLightData, UtsBSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, out LightLoopOutput lightLoopOutput)
|
||||
{
|
||||
#if !defined(_INDIRECT_DIFFUSE_MODE_OFF) || !defined(_INDIRECT_SPECULAR_MODE_OFF)
|
||||
AmbientOcclusionFactor aoFactor;
|
||||
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
|
||||
builtinData.bakeDiffuseLighting = APPLY_WEIGHT(builtinData.bakeDiffuseLighting, aoFactor.indirectAmbientOcclusion, _AO_Factor);
|
||||
lighting.indirect.specularReflected = APPLY_WEIGHT(lighting.indirect.specularReflected, aoFactor.indirectSpecularOcclusion, _AO_Factor);
|
||||
lighting.direct.diffuse = APPLY_WEIGHT(lighting.direct.diffuse, aoFactor.directAmbientOcclusion, _AO_Factor);
|
||||
lighting.direct.specular = APPLY_WEIGHT(lighting.direct.specular, aoFactor.directSpecularOcclusion, _AO_Factor);
|
||||
ApplyAmbientOcclusion(aoFactor, builtinData, lighting);
|
||||
#endif
|
||||
AdjustIndirectLighting(preLightData, bsdfData, builtinData, lighting);
|
||||
|
||||
builtinData.bakeDiffuseLighting = ApplyCurrentExposureMultiplier(builtinData.bakeDiffuseLighting * bsdfData.diffuseColor * preLightData.diffuseFGD * _ID_Intensity);
|
||||
lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IR_Intensity);
|
||||
|
||||
lightLoopOutput.diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting;
|
||||
// In regular pbr, we need to multiple diffuse color here with direct diffuse lighting. However, in UTS, we have already multiplied it when evaluating the direct diffuse since we need to apply the shading color.
|
||||
lightLoopOutput.diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor;
|
||||
lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
|
||||
// Rescale the GGX to account for the multiple scattering.
|
||||
lightLoopOutput.specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation;
|
||||
|
||||
|
||||
ApplyExposureAdjustment(lightLoopOutput.diffuseLighting);
|
||||
ApplyExposureAdjustment(lightLoopOutput.specularLighting);
|
||||
|
||||
lightLoopOutput.diffuseLighting += builtinData.emissiveColor;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsMaterialEvaluation.hlsl"
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Models/SurfaceFeature.cs.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsSurfaceFeatureEvaluation.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Models/SurfaceFeatureFlags.cs.hlsl"
|
||||
|
||||
// Channel mask enum.
|
||||
// this must be same to UI cs code
|
||||
@@ -37,32 +38,6 @@ int GetNextDirectionalLightIndex(BuiltinData builtinData, int currentIndex, int
|
||||
return -1; // not found
|
||||
}
|
||||
|
||||
int GetUtsMainLightIndex(BuiltinData builtinData)
|
||||
{
|
||||
int mainLightIndex = -1;
|
||||
float3 lightColor = float3(0.0f, 0.0f, 0.0f);
|
||||
float lightAttenuation = 0.0f;
|
||||
uint i = 0; // Declare once to avoid the D3D11 compiler warning.
|
||||
for (i = 0; i < _DirectionalLightCount; ++i)
|
||||
{
|
||||
if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, builtinData.renderingLayers))
|
||||
{
|
||||
float3 currentLightColor = _DirectionalLightDatas[i].color;
|
||||
float currentLightAttenuation = GetColorAttenuation(currentLightColor);
|
||||
|
||||
if (mainLightIndex == -1 || (currentLightAttenuation > lightAttenuation))
|
||||
{
|
||||
mainLightIndex = i;
|
||||
lightAttenuation = currentLightAttenuation;
|
||||
|
||||
lightColor = currentLightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mainLightIndex;
|
||||
}
|
||||
|
||||
bool UtsUseScreenSpaceShadow(DirectionalLightData light, float3 normalWS)
|
||||
{
|
||||
#if defined(RAY_TRACED_SCREEN_SPACE_SHADOW_FLAG)
|
||||
@@ -74,7 +49,7 @@ bool UtsUseScreenSpaceShadow(DirectionalLightData light, float3 normalWS)
|
||||
bool rayTracedShadow = (light.screenSpaceShadowIndex & RAY_TRACED_SCREEN_SPACE_SHADOW_FLAG) != 0.0;
|
||||
return (validScreenSpaceShadow && ((rayTracedShadow && visibleLight) || !rayTracedShadow));
|
||||
#else
|
||||
return ( (light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW);
|
||||
return ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -92,6 +67,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
// Initialize the contactShadow and contactShadowFade fields
|
||||
InitContactShadow(posInput, context);
|
||||
|
||||
#if _RECEIVE_LIGHT_SHADOW_ON
|
||||
// First of all we compute the shadow value of the directional light to reduce the VGPR pressure
|
||||
if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
|
||||
{
|
||||
@@ -100,8 +76,8 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
{
|
||||
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
|
||||
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
||||
if (UseScreenSpaceShadow(light, bsdfData.normalWS))
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && defined(_RECEIVE_SCREEN_SPACE_SHADOW_ON)
|
||||
if (UtsUseScreenSpaceShadow(light, bsdfData.normalWS))
|
||||
{
|
||||
context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE;
|
||||
}
|
||||
@@ -111,22 +87,22 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
float3 L = -light.forward;
|
||||
|
||||
// Is it worth sampling the shadow map?
|
||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0) && // Note: Volumetric can have different dimmer, thus why we test it here
|
||||
dot(bsdfData.normalWS, L) > 0.0)
|
||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0))
|
||||
{
|
||||
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
||||
posInput.positionSS, posInput.positionWS + L * _ShadowBias, bsdfData.normalWS,
|
||||
posInput.positionSS, posInput.positionWS + L * _ShadowDistanceBias, UtsGetShadowNormal(bsdfData),
|
||||
light.shadowIndex, L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PreLightData preLightData = GetPreLightData_UTS(V, posInput, bsdfData);
|
||||
|
||||
|
||||
AggregateLighting aggregateLighting;
|
||||
ZERO_INITIALIZE(AggregateLighting, aggregateLighting);
|
||||
|
||||
|
||||
// Evaluate the punctual lights.
|
||||
if (featureFlags & LIGHTFEATUREFLAGS_PUNCTUAL)
|
||||
{
|
||||
@@ -134,7 +110,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
GetCountAndStart(posInput, LIGHTCATEGORY_PUNCTUAL, lightStart, lightCount);
|
||||
#else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
#else
|
||||
lightCount = _PunctualLightCount;
|
||||
lightStart = 0;
|
||||
#endif
|
||||
@@ -196,7 +172,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Evaluate the directional lights.
|
||||
if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
|
||||
{
|
||||
@@ -246,44 +222,43 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
#endif
|
||||
|
||||
float3 lightInReflDir = 0.0;
|
||||
#ifdef _INDIRECT_DIFFUSE_OFF
|
||||
#ifdef _INDIRECT_DIFFUSE_MODE_OFF
|
||||
|
||||
#elif _INDIRECT_DIFFUSE_IBL
|
||||
#elif _INDIRECT_DIFFUSE_MODE_IBL
|
||||
bool replaceBakeDiffuseLighting = false;
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) // No SSGI/RTGI/Mixed effect on transparent
|
||||
if (_IndirectDiffuseMode != INDIRECTDIFFUSEMODE_OFF)
|
||||
{
|
||||
replaceBakeDiffuseLighting = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
#endif
|
||||
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
if (!builtinData.isLightmap)
|
||||
{
|
||||
replaceBakeDiffuseLighting = true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIGHT_EVALUATION_SKIP_INDIRECT_DIFFUSE)
|
||||
#if defined(LIGHT_EVALUATION_SKIP_INDIRECT_DIFFUSE)
|
||||
replaceBakeDiffuseLighting = false;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (replaceBakeDiffuseLighting)
|
||||
{
|
||||
UtsEvaluateBSDF_BakeDiffuse(posInput, preLightData, bsdfData, V, builtinData, lightInReflDir);
|
||||
}
|
||||
#elif _INDIRECT_DIFFUSE_MATCAP
|
||||
//builtinData.bakeDiffuseLighting = UtsEvaluateColor_MatCap(posInput.positionWS, bsdfData.normalWS, 0.0);
|
||||
#elif _INDIRECT_DIFFUSE_MODE_MATCAP
|
||||
UtsEvaluateBSDF_MatCapDiffuse(posInput.positionWS, bsdfData.normalWS, builtinData);
|
||||
#elif _INDIRECT_DIFFUSE_RAMP
|
||||
#elif _INDIRECT_DIFFUSE_MODE_RAMP
|
||||
UtsEvaluateBSDF_Ramp(posInput, bsdfData, builtinData);
|
||||
#endif
|
||||
|
||||
if (featureFlags & LIGHTFEATUREFLAGS_ENV)
|
||||
{
|
||||
#if _INDIRECT_SPECULAR_OFF
|
||||
|
||||
#elif _INDIRECT_SPECULAR_IBL
|
||||
#if _INDIRECT_SPECULAR_MODE_OFF
|
||||
|
||||
#elif _INDIRECT_SPECULAR_MODE_IBL
|
||||
context.sampleReflection = SINGLE_PASS_CONTEXT_SAMPLE_REFLECTION_PROBES;
|
||||
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
@@ -342,16 +317,15 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
AccumulateIndirectLighting(lighting, aggregateLighting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#elif _INDIRECT_SPECULAR_MATCAP
|
||||
#elif _INDIRECT_SPECULAR_MODE_MATCAP
|
||||
IndirectLighting lighting = UtsEvaluateBSDF_MatCapSpecular(posInput.positionWS, bsdfData, preLightData);
|
||||
AccumulateIndirectLighting(lighting, aggregateLighting);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if _INDIRECT_SPECULAR_IBL
|
||||
#if _INDIRECT_SPECULAR_MODE_IBL
|
||||
// Only apply the sky IBL if the sky texture is available
|
||||
if ((featureFlags & LIGHTFEATUREFLAGS_SKY) && _EnvLightSkyEnabled)
|
||||
{
|
||||
@@ -370,10 +344,18 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATUREFLAGS_ANGEL_RING))
|
||||
|
||||
#ifndef _LIGHT_BASE_RIM_LIGHT_ON
|
||||
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_RIM_LIGHT))
|
||||
{
|
||||
DirectLighting lighting = UtsEvaluateAngelRing(fragInputs, bsdfData.normalWS, V);
|
||||
DirectLighting lighting = UtsEvaluateLighting_RimLight(posInput, bsdfData, preLightData);
|
||||
AccumulateDirectLighting(lighting, aggregateLighting);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_ANGEL_RING))
|
||||
{
|
||||
DirectLighting lighting = UtsEvaluateLighting_AngelRing(fragInputs, bsdfData.normalWS, V);
|
||||
AccumulateDirectLighting(lighting, aggregateLighting);
|
||||
}
|
||||
|
||||
@@ -385,7 +367,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
// UTSLightData mainPunctualLight;
|
||||
|
||||
// uint lightCount, lightStart;
|
||||
|
||||
|
||||
// #ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
// GetCountAndStart(posInput, LIGHTCATEGORY_PUNCTUAL, lightStart, lightCount);
|
||||
// #else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
@@ -454,29 +436,4 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
// return mainPunctualLight;
|
||||
// }
|
||||
|
||||
// Todo: calculate the acutal main lighboth dorectional and punctual)t based on the light attenuation, rather than using the main directional light
|
||||
UTSLightData GetCustomMainLightData(BuiltinData builtinData, UTSLightData mainPunctualLight)
|
||||
{
|
||||
UTSLightData utsLightData;
|
||||
int mainLightIndex;
|
||||
|
||||
mainLightIndex = GetUtsMainLightIndex(builtinData);
|
||||
|
||||
if (mainLightIndex == -1 || length(_DirectionalLightDatas[mainLightIndex].color) < length(mainPunctualLight.lightColor))
|
||||
{
|
||||
utsLightData = mainPunctualLight;
|
||||
}
|
||||
else
|
||||
{
|
||||
utsLightData.lightColor = ApplyCurrentExposureMultiplier(_DirectionalLightDatas[mainLightIndex].color);
|
||||
utsLightData.lightDirection = -_DirectionalLightDatas[mainLightIndex].forward;
|
||||
utsLightData.diffuseDimmer = _DirectionalLightDatas[mainLightIndex].diffuseDimmer;
|
||||
utsLightData.specularDimmer = _DirectionalLightDatas[mainLightIndex].specularDimmer;
|
||||
utsLightData.shadowTint = _DirectionalLightDatas[mainLightIndex].shadowTint;
|
||||
utsLightData.penumbraTint = _DirectionalLightDatas[mainLightIndex].penumbraTint;
|
||||
}
|
||||
|
||||
return utsLightData;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
189
Runtime/Shaders/Includes/Lighting/UtsMaterialEvaluation.hlsl
Normal file
189
Runtime/Shaders/Includes/Lighting/UtsMaterialEvaluation.hlsl
Normal file
@@ -0,0 +1,189 @@
|
||||
#ifndef UTS_MATERIAL_EVALUATION
|
||||
#define UTS_MATERIAL_EVALUATION
|
||||
|
||||
#define ColorSpaceDielectricSpec half4(0.22, 0.22, 0.22, 0.779)
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsShadowEvaluation.hlsl"
|
||||
|
||||
float RoughnessToBlinnPhongSpecularExponent(float roughness)
|
||||
{
|
||||
return clamp(2 * rcp(roughness * roughness) - 2, FLT_EPS, rcp(FLT_EPS));
|
||||
}
|
||||
|
||||
float StepFeatherToon(float value,float step,float feather)
|
||||
{
|
||||
return saturate((value - step + feather) / feather);
|
||||
}
|
||||
|
||||
float3 ComputeSpecularTerm(UtsBSDFData bsdfData, PreLightData preLightData, float3 V, float3 L)
|
||||
{
|
||||
#ifdef _PBR_MODE_OFF
|
||||
return 0;
|
||||
#else
|
||||
float3 specTerm;
|
||||
float3 N = bsdfData.normalWS;
|
||||
float3 H = normalize(L + V);
|
||||
|
||||
float NdotL = dot(N, L);
|
||||
float NdotH = saturate(dot(N, H));
|
||||
float clampedNdotV = ClampNdotV(preLightData.NdotV);
|
||||
float clampedNdotL = saturate(NdotL);
|
||||
|
||||
float partLambdaV;
|
||||
float3 DV = 0;
|
||||
#ifdef _PBR_MODE_STANDARD
|
||||
partLambdaV = GetSmithJointGGXPartLambdaV(clampedNdotV, bsdfData.roughnessT);
|
||||
// We use abs(NdotL) to handle the none case of double sided
|
||||
DV = DV_SmithJointGGX(NdotH, abs(NdotL), clampedNdotV, bsdfData.roughnessT, partLambdaV);
|
||||
|
||||
#elif _PBR_MODE_ANISOTROPY
|
||||
float TdotV = dot(bsdfData.tangentWS, V);
|
||||
float BdotV = dot(bsdfData.bitangentWS, V);
|
||||
|
||||
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughness, bsdfData.anisotropy, bsdfData.roughnessT, bsdfData.roughnessB);
|
||||
partLambdaV = GetSmithJointGGXAnisoPartLambdaV(TdotV, BdotV, clampedNdotV, bsdfData.roughnessT, bsdfData.roughnessB);
|
||||
|
||||
// For anisotropy we must not saturate these values
|
||||
float TdotH = dot(bsdfData.tangentWS, H);
|
||||
float TdotL = dot(bsdfData.tangentWS, L);
|
||||
float BdotH = dot(bsdfData.bitangentWS, H);
|
||||
float BdotL = dot(bsdfData.bitangentWS, L);
|
||||
|
||||
// We use abs(NdotL) to handle the none case of double sided
|
||||
DV = DV_SmithJointGGXAniso(TdotH, BdotH, NdotH, clampedNdotV, TdotL, BdotL, abs(NdotL), bsdfData.roughnessT, bsdfData.roughnessB, partLambdaV);
|
||||
|
||||
#elif _PBR_MODE_HAIR
|
||||
float3 t = ShiftTangent(bsdfData.bitangentWS, N, bsdfData.anisotropy);
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||
DV = D_KajiyaKay(t, H, specularExponent);
|
||||
|
||||
float normalizeSpec = DV * rcp(specularExponent + 2) * 2 * PI;
|
||||
DV = DV * normalizeSpec * _KKColor.rgb;
|
||||
#elif _PBR_MODE_TOON
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||
DV = pow(NdotH, 5.0 * specularExponent);
|
||||
DV = StepFeatherToon(DV, _ToonSpecularStep, _ToonSpecularFeather);
|
||||
#endif
|
||||
|
||||
// We use specularFGD here to approximate F.
|
||||
specTerm = DV * preLightData.specularFGD * clampedNdotL;
|
||||
return specTerm;
|
||||
#endif
|
||||
}
|
||||
|
||||
half3 FitWithCurveApprox(half NdotL, half Curvature)
|
||||
{
|
||||
half curva = (1.0 / mad(Curvature, 0.5 - 0.0625, 0.0625) - 2.0) / (16.0 - 2.0);
|
||||
half oneMinusCurva = 1.0 - curva;
|
||||
half3 curve0;
|
||||
{
|
||||
half3 rangeMin = half3(0.0, 0.3, 0.3);
|
||||
half3 rangeMax = half3(1.0, 0.7, 0.7);
|
||||
half3 offset = half3(0.0, 0.06, 0.06);
|
||||
half3 t = saturate(mad(NdotL, 1.0 / (rangeMax - rangeMin), (offset + rangeMin) / (rangeMin - rangeMax)));
|
||||
half3 lowerLine = (t * t) * half3(0.65, 0.5, 0.9);
|
||||
lowerLine.r += 0.045;
|
||||
lowerLine.b *= t.b;
|
||||
half3 m = half3(1.75, 2.0, 1.97);
|
||||
half3 upperLine = mad(NdotL, m, half3(0.99, 0.99, 0.99) - m);
|
||||
upperLine = saturate(upperLine);
|
||||
half3 lerpMin = half3(0.0, 0.35, 0.35);
|
||||
half3 lerpMax = half3(1.0, 0.7, 0.6);
|
||||
half3 lerpT = saturate(mad(NdotL, 1.0 / (lerpMax - lerpMin), lerpMin / (lerpMin - lerpMax)));
|
||||
curve0 = lerp(lowerLine, upperLine, lerpT * lerpT);
|
||||
}
|
||||
half3 curve1;
|
||||
{
|
||||
half3 m = half3(1.95, 2.0, 2.0);
|
||||
half3 upperLine = mad(NdotL, m, half3(0.99, 0.99, 1.0) - m);
|
||||
curve1 = saturate(upperLine);
|
||||
}
|
||||
float oneMinusCurva2 = oneMinusCurva * oneMinusCurva;
|
||||
return lerp(curve0, curve1, mad(oneMinusCurva2, -1.0 * oneMinusCurva2, 1.0));
|
||||
}
|
||||
|
||||
DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData, SHADOW_TYPE shadow,
|
||||
float3 lightColor, float3 V, float3 L, float2 uv,
|
||||
float diffuseDimmer, float specularDimmer)
|
||||
{
|
||||
DirectLighting lighting;
|
||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||
|
||||
if (Max3(lightColor.r, lightColor.g, lightColor.b) > 0.0)
|
||||
{
|
||||
SHADOW_TYPE sharpShadow = smoothstep(0.4, 0.6, shadow);
|
||||
#if _RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW
|
||||
sharpShadow *= GetHairShadow(posInput, L);
|
||||
#endif
|
||||
|
||||
#if _SHADING_MODE_SDF
|
||||
float angle;
|
||||
float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf highlight, b: halfshadow
|
||||
float shadowSmoothLevel = _SDFShadowSmoothLevel / 10.0;
|
||||
float sdfShadowMask = smoothstep(angle - shadowSmoothLevel, angle + shadowSmoothLevel, sdfTexture.r);
|
||||
float sdfHighlight = sdfTexture.g * _SDFHighlightStrength;
|
||||
#endif
|
||||
|
||||
float3 diffuseTerm = 0.0;
|
||||
float3 specularTerm = ComputeSpecularTerm(bsdfData, preLightData, V, L);
|
||||
|
||||
#if _USE_SHADING_RAMP_MAP_ON
|
||||
float rampMask = _ShadingRampMask;
|
||||
#if _SHADING_RAMP_MASK_MAP
|
||||
rampMask *= SAMPLE_TEXTURE2D(_ShadingRampMaskMap, s_linear_clamp_sampler, uv).r;
|
||||
#endif
|
||||
|
||||
#if _SHADING_MODE_STANDARD
|
||||
float NdotL = dot(bsdfData.normalWS, L);
|
||||
float halfLambert = 0.5 * NdotL + 0.5;
|
||||
|
||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, rampMask), _ShadingIndex).rgb;
|
||||
|
||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||
specularTerm *= saturate(NdotL) * sharpShadow;
|
||||
#elif _SHADING_MODE_SDF
|
||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * sharpShadow.x, rampMask), _ShadingIndex).rgb;
|
||||
|
||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * sharpShadow;
|
||||
#endif
|
||||
#else
|
||||
#if _SHADING_MODE_STANDARD
|
||||
float NdotL = dot(bsdfData.normalWS, L);
|
||||
float halfLambert = 0.5 * NdotL + 0.5;
|
||||
|
||||
// float firstColorFeatherForMask = lerp(_1stShadeColorFeather, 0.0, max(_ComposerMaskMode, _FirstShadeOverridden));
|
||||
float baseShadeMask = saturate((halfLambert - (_1stShadeColorStep - _1stShadeColorFeather)) / (_1stShadeColorStep - (_1stShadeColorStep - _1stShadeColorFeather)));
|
||||
baseShadeMask *= sharpShadow.x;
|
||||
|
||||
// float secondColorFeatherForMask = lerp(_2ndShadeColorFeather, 0.0, max(_SecondShadeOverridden, _ComposerMaskMode));
|
||||
float firstShadeMask = saturate((halfLambert - (_2ndShadeColorStep - _2ndShadeColorFeather)) / (_2ndShadeColorStep - (_2ndShadeColorStep - _2ndShadeColorFeather)));
|
||||
|
||||
diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, firstShadeMask), bsdfData.diffuseColor, baseShadeMask);
|
||||
specularTerm *= baseShadeMask;
|
||||
#elif _SHADING_MODE_SDF
|
||||
float shadeMask = sdfShadowMask * sdfTexture.b * sharpShadow.x;
|
||||
|
||||
diffuseTerm = lerp(bsdfData.firstShadingDiffuseColor, bsdfData.diffuseColor, shadeMask);
|
||||
specularTerm = (specularTerm + sdfHighlight) * shadeMask;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
lighting.diffuse += diffuseTerm * lightColor * diffuseDimmer;
|
||||
lighting.specular += specularTerm * lightColor * specularDimmer;
|
||||
|
||||
#if _LIGHT_BASE_RIM_LIGHT_ON
|
||||
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_RIM_LIGHT))
|
||||
{
|
||||
DirectLighting rimLightLighting = UtsEvaluateLighting_RimLight(posInput, bsdfData, preLightData, L, lightColor);
|
||||
|
||||
lighting.diffuse += rimLightLighting.diffuse;
|
||||
lighting.specular += rimLightLighting.specular;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
#endif
|
||||
122
Runtime/Shaders/Includes/Lighting/UtsShadowEvaluation.hlsl
Normal file
122
Runtime/Shaders/Includes/Lighting/UtsShadowEvaluation.hlsl
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef UTS_SHADOW_EVALUATION
|
||||
#define UTS_SHADOW_EVALUATION
|
||||
|
||||
float3 UtsGetShadowNormal(UtsBSDFData bsdfData)
|
||||
{
|
||||
#if _MATERIAL_TYPE_FACE
|
||||
return normalize(mul(UNITY_MATRIX_M, float4(0.0, 0.0, 1.0, 0.0))).xyz;
|
||||
#else
|
||||
return bsdfData.geomNormalWS * (1.0 + _ShadowNormalBias);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 SampleSDFTexture(float3 L, float2 uv, out float angle)
|
||||
{
|
||||
// TODO: Move sdf sample result to UtsBSDFData to avoid sampleing in a loop
|
||||
float2 right_uv = float2(1 - uv.x, uv.y);
|
||||
float3 left_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, uv).rgb;
|
||||
float3 right_SDFTex = SAMPLE_TEXTURE2D(_SDFShadingMap, sampler_SDFShadingMap, right_uv).rgb;
|
||||
|
||||
float2 leftVector = normalize(mul(UNITY_MATRIX_M, float4(1.0, 0.0, 0.0, 0.0)).xz);
|
||||
float2 forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0.0, 0.0, 1.0, 0.0)).xz);
|
||||
|
||||
float2 lightDirection = normalize(L.xz);
|
||||
angle = saturate(dot(forwardVector, lightDirection) * -1.0 + _SDFShadowLevel);
|
||||
bool isRightSide = dot(lightDirection, leftVector) > 0;
|
||||
|
||||
return isRightSide ? right_SDFTex : left_SDFTex;
|
||||
}
|
||||
|
||||
float GetHairShadow(PositionInputs posInput, float3 L)
|
||||
{
|
||||
float shadow = 1.0;
|
||||
|
||||
// Push the face fragment view space position towards the light for a little bit
|
||||
float hairShadowOpacity = saturate(Remap(length(posInput.positionWS), float2(_HairShadowFadeOutDistance, _HairShadowFadeInDistance), float2(0, 1)));
|
||||
|
||||
if (hairShadowOpacity > 0.0)
|
||||
{
|
||||
float3 viewLightDir = TransformWorldToViewDir(L);
|
||||
float shadowLengthY = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth;
|
||||
float2 shadowLength = float2(shadowLengthY * 2.0f, shadowLengthY);
|
||||
|
||||
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||
float cameraDirFactor = 1 - smoothstep(0.1, 0.9, cameraDirOS.y);
|
||||
shadowLength.y *= cameraDirFactor;
|
||||
|
||||
// TODO: sample point is still shifting when fov change.
|
||||
float2 samplingPoint = (posInput.positionSS + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2(1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
|
||||
|
||||
float2 scaledUVs = samplingPoint * _RTHandleScale.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 hairShadow = SAMPLE_TEXTURE2D_SHADOW(_HairShadowTex, s_linear_clamp_compare_sampler, float3(scaledUVs, posInput.deviceDepth + _HairShadowDepthBias)).r;
|
||||
shadow = lerp(1.0 - hairShadowOpacity, 1.0, hairShadow);
|
||||
}
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
// distances = {d, d^2, 1/d, d_proj}, where d_proj = dot(lightToSample, light.forward).
|
||||
SHADOW_TYPE UtsEvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionInputs posInput, LightData light, BuiltinData builtinData, float3 N, float3 L, float4 distances)
|
||||
{
|
||||
#ifndef LIGHT_EVALUATION_NO_SHADOWS
|
||||
float shadow = 1.0;
|
||||
float shadowMask = 1.0;
|
||||
float NdotL = dot(N, L); // Disable contact shadow and shadow mask when facing away from light (i.e transmission)
|
||||
|
||||
#ifdef SHADOWS_SHADOWMASK
|
||||
// shadowMaskSelector.x is -1 if there is no shadow mask
|
||||
// Note that we override shadow value (in case we don't have any dynamic shadow)
|
||||
shadow = shadowMask = (light.shadowMaskSelector.x >= 0.0 && NdotL > 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, light.shadowMaskSelector) : 1.0;
|
||||
#endif
|
||||
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && defined(_RECEIVE_SCREEN_SPACE_SHADOW_ON)
|
||||
if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW)
|
||||
{
|
||||
shadow = GetScreenSpaceShadow(posInput, light.screenSpaceShadowIndex);
|
||||
shadow = lerp(shadowMask, shadow, light.shadowDimmer);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((light.shadowIndex >= 0) && (light.shadowDimmer > 0))
|
||||
{
|
||||
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS + L * _ShadowDistanceBias, N, light.shadowIndex, L, distances.x, light.lightType == GPULIGHTTYPE_POINT, light.lightType != GPULIGHTTYPE_PROJECTOR_BOX);
|
||||
|
||||
#ifdef SHADOWS_SHADOWMASK
|
||||
// Note: Legacy Unity have two shadow mask mode. ShadowMask (ShadowMask contain static objects shadow and ShadowMap contain only dynamic objects shadow, final result is the minimun of both value)
|
||||
// and ShadowMask_Distance (ShadowMask contain static objects shadow and ShadowMap contain everything and is blend with ShadowMask based on distance (Global distance setup in QualitySettigns)).
|
||||
// HDRenderPipeline change this behavior. Only ShadowMask mode is supported but we support both blend with distance AND minimun of both value. Distance is control by light.
|
||||
// The following code do this.
|
||||
// The min handle the case of having only dynamic objects in the ShadowMap
|
||||
// The second case for blend with distance is handled with ShadowDimmer. ShadowDimmer is define manually and by shadowDistance by light.
|
||||
// With distance, ShadowDimmer become one and only the ShadowMask appear, we get the blend with distance behavior.
|
||||
shadow = light.nonLightMappedOnly ? min(shadowMask, shadow) : shadow;
|
||||
#endif
|
||||
|
||||
shadow = lerp(shadowMask, shadow, light.shadowDimmer);
|
||||
}
|
||||
|
||||
// Transparents have no contact shadow information
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(LIGHT_EVALUATION_NO_CONTACT_SHADOWS)
|
||||
{
|
||||
// In certain cases (like hair) we allow to force the contact shadow sample.
|
||||
#ifdef LIGHT_EVALUATION_CONTACT_SHADOW_DISABLE_NDOTL
|
||||
const bool allowContactShadow = true;
|
||||
#else
|
||||
const bool allowContactShadow = NdotL > 0.0;
|
||||
#endif
|
||||
|
||||
shadow = min(shadow, allowContactShadow ? GetContactShadow(lightLoopContext, light.contactShadowMask, light.isRayTracedContactShadow) : 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_DISPLAY
|
||||
if (_DebugShadowMapMode == SHADOWMAPDEBUGMODE_SINGLE_SHADOW && light.shadowIndex == _DebugSingleShadowIndex)
|
||||
g_DebugShadowAttenuation = shadow;
|
||||
#endif
|
||||
return shadow;
|
||||
#else // LIGHT_EVALUATION_NO_SHADOWS
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58ed9f8b53f6c414991b5223756b2938
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Runtime/Shaders/Includes/Lighting/UtsSingleLightLoop.hlsl
Normal file
59
Runtime/Shaders/Includes/Lighting/UtsSingleLightLoop.hlsl
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef UTS_SINGLE_LIGHT_LOOP
|
||||
#define UTS_SINGLE_LIGHT_LOOP
|
||||
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Models/SurfaceFeature.cs.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsSurfaceFeatureEvaluation.hlsl"
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl"
|
||||
|
||||
struct UtsSingleMainLight
|
||||
{
|
||||
GPULightType lightType;
|
||||
uint lightIndex;
|
||||
};
|
||||
|
||||
int GetMainLightIndex(BuiltinData builtinData)
|
||||
{
|
||||
int mainLightIndex = -1;
|
||||
|
||||
if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
|
||||
{
|
||||
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
|
||||
|
||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0) && IsMatchingLightLayer(light.lightLayers, builtinData.renderingLayers))
|
||||
{
|
||||
SHADOW_TYPE shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
||||
posInput.positionSS, _ObjectCenterPositionWS + L * _ShadowDistanceBias, UtsGetShadowNormal(bsdfData),
|
||||
light.shadowIndex, L);
|
||||
|
||||
if (length(shadowValue) > 0.0)
|
||||
{
|
||||
mainLightIndex = _DirectionalShadowIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mainLightIndex;
|
||||
}
|
||||
|
||||
// TODO: The process of finding main light index should be move to vertex stage
|
||||
void UtsSingleLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bsdfData, BuiltinData builtinData,
|
||||
float3 V, uint featureFlags, out LightLoopOutput lightLoopOutput)
|
||||
{
|
||||
PreLightData preLightData = GetPreLightData_UTS(V, posInput, bsdfData);
|
||||
|
||||
AggregateLighting aggregateLighting;
|
||||
ZERO_INITIALIZE(AggregateLighting, aggregateLighting);
|
||||
|
||||
#if _USER_LIGHT_SOURCE_LOOP_ON
|
||||
|
||||
#else
|
||||
int mainLightIndex = GetMainLightIndex(builtinData);
|
||||
|
||||
if (mainLightIndex != -1 && featureFlags & LIGHTFEATUREFLAGS_PUNCTUAL)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74f20e448cd01914fa3934de999353bc
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,8 +4,6 @@
|
||||
// Otherwise those parameters are not bound correctly at runtime.
|
||||
// ===========================================================================
|
||||
|
||||
#define fixed half
|
||||
|
||||
#define UNITY_TEXTURE_STREAMING_DEBUG_VARS
|
||||
float4 unity_MipmapStreaming_DebugTex_ST;
|
||||
float4 unity_MipmapStreaming_DebugTex_TexelSize;
|
||||
@@ -15,307 +13,36 @@ float4 unity_MipmapStreaming_DebugTex_StreamInfo;
|
||||
// Unity Toon Shader
|
||||
#include "UtsTextures.hlsl"
|
||||
|
||||
// Lit
|
||||
TEXTURE2D(_DistortionVectorMap);
|
||||
SAMPLER(sampler_DistortionVectorMap);
|
||||
|
||||
TEXTURE2D(_EmissiveColorMap);
|
||||
SAMPLER(sampler_EmissiveColorMap);
|
||||
|
||||
// TODO: HDRP properties, clean it in the future
|
||||
#ifndef LAYERED_LIT_SHADER
|
||||
|
||||
TEXTURE2D(_DiffuseLightingMap);
|
||||
SAMPLER(sampler_DiffuseLightingMap);
|
||||
|
||||
TEXTURE2D(_BaseColorMap);
|
||||
SAMPLER(sampler_BaseColorMap);
|
||||
|
||||
TEXTURE2D(_HairBlendingMap);
|
||||
SAMPLER(sampler_HairBlendingMap);
|
||||
|
||||
TEXTURE2D(_MaskMap);
|
||||
SAMPLER(sampler_MaskMap);
|
||||
TEXTURE2D(_BentNormalMap); // Reuse sampler from normal map
|
||||
SAMPLER(sampler_BentNormalMap);
|
||||
|
||||
TEXTURE2D(_NormalMap);
|
||||
SAMPLER(sampler_NormalMap);
|
||||
TEXTURE2D(_NormalMapOS);
|
||||
SAMPLER(sampler_NormalMapOS);
|
||||
|
||||
TEXTURE2D(_DetailMap);
|
||||
SAMPLER(sampler_DetailMap);
|
||||
|
||||
TEXTURE2D(_HeightMap);
|
||||
SAMPLER(sampler_HeightMap);
|
||||
|
||||
TEXTURE2D(_TangentMap);
|
||||
SAMPLER(sampler_TangentMap);
|
||||
TEXTURE2D(_TangentMapOS);
|
||||
SAMPLER(sampler_TangentMapOS);
|
||||
|
||||
TEXTURE2D(_AnisotropyMap);
|
||||
SAMPLER(sampler_AnisotropyMap);
|
||||
|
||||
TEXTURE2D(_SubsurfaceMaskMap);
|
||||
SAMPLER(sampler_SubsurfaceMaskMap);
|
||||
TEXTURE2D(_ThicknessMap);
|
||||
SAMPLER(sampler_ThicknessMap);
|
||||
|
||||
TEXTURE2D(_IridescenceThicknessMap);
|
||||
SAMPLER(sampler_IridescenceThicknessMap);
|
||||
|
||||
TEXTURE2D(_IridescenceMaskMap);
|
||||
SAMPLER(sampler_IridescenceMaskMap);
|
||||
|
||||
TEXTURE2D(_SpecularColorMap);
|
||||
SAMPLER(sampler_SpecularColorMap);
|
||||
|
||||
TEXTURE2D(_TransmittanceColorMap);
|
||||
SAMPLER(sampler_TransmittanceColorMap);
|
||||
|
||||
TEXTURE2D(_CoatMaskMap);
|
||||
SAMPLER(sampler_CoatMaskMap);
|
||||
|
||||
TEXTURE2D(_SSSLutMap);
|
||||
//SAMPLER(sampler_SSSLutMap); //Use s_linear_clamp_sampler instead
|
||||
|
||||
TEXTURE2D(_HairShadowTex);
|
||||
TEXTURE2D(_HairBlendingTex);
|
||||
|
||||
#else
|
||||
|
||||
// Set of users variables
|
||||
#define PROP_DECL(type, name) type name##0, name##1, name##2, name##3
|
||||
// sampler are share by texture type inside a layered material but we need to support that a particualr layer have no texture, so we take the first sampler of available texture as the share one
|
||||
// mean we must declare all sampler
|
||||
#define PROP_DECL_TEX2D(name)\
|
||||
TEXTURE2D(CALL_MERGE_NAME(name, 0)); \
|
||||
SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 0)); \
|
||||
TEXTURE2D(CALL_MERGE_NAME(name, 1)); \
|
||||
SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 1)); \
|
||||
TEXTURE2D(CALL_MERGE_NAME(name, 2)); \
|
||||
SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 2)); \
|
||||
TEXTURE2D(CALL_MERGE_NAME(name, 3)); \
|
||||
SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 3))
|
||||
|
||||
|
||||
PROP_DECL_TEX2D(_BaseColorMap);
|
||||
PROP_DECL_TEX2D(_MaskMap);
|
||||
PROP_DECL_TEX2D(_BentNormalMap);
|
||||
PROP_DECL_TEX2D(_NormalMap);
|
||||
PROP_DECL_TEX2D(_NormalMapOS);
|
||||
PROP_DECL_TEX2D(_DetailMap);
|
||||
PROP_DECL_TEX2D(_HeightMap);
|
||||
|
||||
PROP_DECL_TEX2D(_SubsurfaceMaskMap);
|
||||
PROP_DECL_TEX2D(_ThicknessMap);
|
||||
|
||||
TEXTURE2D(_LayerMaskMap);
|
||||
SAMPLER(sampler_LayerMaskMap);
|
||||
TEXTURE2D(_LayerInfluenceMaskMap);
|
||||
SAMPLER(sampler_LayerInfluenceMaskMap);
|
||||
|
||||
#endif
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
#include "UtsUnityPerMaterial.hlsl"
|
||||
|
||||
// shared constant between lit and layered lit
|
||||
float _AlphaCutoff;
|
||||
float _UseShadowThreshold;
|
||||
float _AlphaCutoffShadow;
|
||||
float _AlphaCutoffPrepass;
|
||||
float _AlphaCutoffPostpass;
|
||||
float4 _DoubleSidedConstants;
|
||||
float _DistortionScale;
|
||||
float _DistortionVectorScale;
|
||||
float _DistortionVectorBias;
|
||||
float _DistortionBlurScale;
|
||||
float _DistortionBlurRemapMin;
|
||||
float _DistortionBlurRemapMax;
|
||||
|
||||
float _PPDMaxSamples;
|
||||
float _PPDMinSamples;
|
||||
float _PPDLodThreshold;
|
||||
|
||||
float3 _EmissiveColor;
|
||||
float _AlbedoAffectEmissive;
|
||||
float _EmissiveExposureWeight;
|
||||
float _ObjectSpaceUVMappingEmissive;
|
||||
|
||||
int _SpecularOcclusionMode;
|
||||
|
||||
// Transparency
|
||||
float3 _TransmittanceColor;
|
||||
float _Ior;
|
||||
float _ATDistance;
|
||||
|
||||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
|
||||
// value that exist to identify if the GI emission need to be enabled.
|
||||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
|
||||
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
|
||||
float3 _EmissionColor;
|
||||
float4 _EmissiveColorMap_ST;
|
||||
float _TexWorldScaleEmissive;
|
||||
// TODO: This is for layered lit only, clean it in the future
|
||||
float4 _UVMappingMaskEmissive;
|
||||
|
||||
float _ID_Intensity;
|
||||
float _IR_Intensity;
|
||||
|
||||
float4 _InvPrimScale; // Only XY are used
|
||||
|
||||
// Wind
|
||||
float _InitialBend;
|
||||
float _Stiffness;
|
||||
float _Drag;
|
||||
float _ShiverDrag;
|
||||
float _ShiverDirectionality;
|
||||
|
||||
// Specular AA
|
||||
float _EnableGeometricSpecularAA;
|
||||
float _SpecularAAScreenSpaceVariance;
|
||||
float _SpecularAAThreshold;
|
||||
|
||||
// TODO: HDRP properties, clean it in the future
|
||||
#ifndef LAYERED_LIT_SHADER
|
||||
|
||||
// Set of users variables
|
||||
|
||||
float _Metallic;
|
||||
float _MetallicRemapMin;
|
||||
float _MetallicRemapMax;
|
||||
float _Smoothness;
|
||||
float _SmoothnessRemapMin;
|
||||
float _SmoothnessRemapMax;
|
||||
float _Roughness;
|
||||
float _RoughnessRemapMin;
|
||||
float _RoughnessRemapMax;
|
||||
float _AlphaRemapMin;
|
||||
float _AlphaRemapMax;
|
||||
float _AORemapMin;
|
||||
float _AORemapMax;
|
||||
float _SSSIntensity;
|
||||
int _Use_SSSLut;
|
||||
|
||||
float4 _SpecularColor;
|
||||
float _ToonSpecularStep;
|
||||
float _ToonSpecularFeather;
|
||||
|
||||
float _ReceivesSSR;
|
||||
float _ReceivesSSAO;
|
||||
float _AO_Factor;
|
||||
float _ReceivesSSGI;
|
||||
float _GIMultiplier;
|
||||
|
||||
float _NormalScale;
|
||||
|
||||
float4 _DetailMap_ST;
|
||||
float _DetailAlbedoScale;
|
||||
float _DetailNormalScale;
|
||||
float _DetailSmoothnessScale;
|
||||
|
||||
float4 _HeightMap_TexelSize; // Unity facility. This will provide the size of the heightmap to the shader
|
||||
|
||||
float _HeightAmplitude;
|
||||
float _HeightCenter;
|
||||
|
||||
float _Anisotropy;
|
||||
float4 _AnisotropyMap_ST;
|
||||
int _Use_Anisotropy;
|
||||
float4 _KKColor;
|
||||
float _BSDFContribution;
|
||||
|
||||
float _DiffusionProfileHash;
|
||||
float _SubsurfaceMask;
|
||||
float _TransmissionMask;
|
||||
float _Thickness;
|
||||
float4 _ThicknessRemap;
|
||||
|
||||
|
||||
float _IridescenceThickness;
|
||||
float4 _IridescenceThicknessRemap;
|
||||
float _IridescenceMask;
|
||||
|
||||
float _CoatMask;
|
||||
|
||||
//float4 _SpecularColor;
|
||||
float _EnergyConservingSpecularColor;
|
||||
|
||||
float _TexWorldScale;
|
||||
float _InvTilingScale;
|
||||
float4 _UVMappingMask;
|
||||
float4 _UVDetailsMappingMask;
|
||||
float _LinkDetailsWithBase;
|
||||
float _ObjectSpaceUVMapping;
|
||||
#else // LAYERED_LIT_SHADER
|
||||
|
||||
// Set of users variables
|
||||
PROP_DECL(float4, _BaseColor);
|
||||
float4 _BaseColorMap0_ST;
|
||||
float4 _BaseColorMap1_ST;
|
||||
float4 _BaseColorMap2_ST;
|
||||
float4 _BaseColorMap3_ST;
|
||||
|
||||
float4 _BaseColorMap0_TexelSize;
|
||||
float4 _BaseColorMap0_MipInfo;
|
||||
|
||||
PROP_DECL(float, _Metallic);
|
||||
PROP_DECL(float, _MetallicRemapMin);
|
||||
PROP_DECL(float, _MetallicRemapMax);
|
||||
PROP_DECL(float, _Smoothness);
|
||||
PROP_DECL(float, _SmoothnessRemapMin);
|
||||
PROP_DECL(float, _SmoothnessRemapMax);
|
||||
PROP_DECL(float, _AORemapMin);
|
||||
PROP_DECL(float, _AORemapMax);
|
||||
|
||||
PROP_DECL(float, _NormalScale);
|
||||
float4 _NormalMap0_TexelSize; // Unity facility. This will provide the size of the base normal to the shader
|
||||
|
||||
float4 _HeightMap0_TexelSize;
|
||||
float4 _HeightMap1_TexelSize;
|
||||
float4 _HeightMap2_TexelSize;
|
||||
float4 _HeightMap3_TexelSize;
|
||||
|
||||
float4 _DetailMap0_ST;
|
||||
float4 _DetailMap1_ST;
|
||||
float4 _DetailMap2_ST;
|
||||
float4 _DetailMap3_ST;
|
||||
PROP_DECL(float, _UVDetail);
|
||||
PROP_DECL(float, _DetailAlbedoScale);
|
||||
PROP_DECL(float, _DetailNormalScale);
|
||||
PROP_DECL(float, _DetailSmoothnessScale);
|
||||
|
||||
PROP_DECL(float, _HeightAmplitude);
|
||||
PROP_DECL(float, _HeightCenter);
|
||||
|
||||
PROP_DECL(float, _DiffusionProfileHash);
|
||||
PROP_DECL(float, _SubsurfaceMask);
|
||||
PROP_DECL(float, _Thickness);
|
||||
PROP_DECL(float4, _ThicknessRemap);
|
||||
|
||||
PROP_DECL(float, _OpacityAsDensity);
|
||||
float _InheritBaseNormal1;
|
||||
float _InheritBaseNormal2;
|
||||
float _InheritBaseNormal3;
|
||||
float _InheritBaseHeight1;
|
||||
float _InheritBaseHeight2;
|
||||
float _InheritBaseHeight3;
|
||||
float _InheritBaseColor1;
|
||||
float _InheritBaseColor2;
|
||||
float _InheritBaseColor3;
|
||||
PROP_DECL(float, _HeightOffset);
|
||||
float _HeightTransition;
|
||||
|
||||
float4 _LayerMaskMap_ST;
|
||||
float _TexWorldScaleBlendMask;
|
||||
PROP_DECL(float, _TexWorldScale);
|
||||
PROP_DECL(float, _InvTilingScale);
|
||||
float4 _UVMappingMaskBlendMask;
|
||||
PROP_DECL(float4, _UVMappingMask);
|
||||
PROP_DECL(float4, _UVDetailsMappingMask);
|
||||
PROP_DECL(float, _LinkDetailsWithBase);
|
||||
|
||||
#endif // LAYERED_LIT_SHADER
|
||||
|
||||
// Following two variables are feeded by the C++ Editor for Scene selection
|
||||
@@ -324,6 +51,7 @@ int _PassValue;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
// Global
|
||||
int _ToonLightHiCutFilter;
|
||||
int _ToonEvAdjustmentCurve;
|
||||
float _ToonEvAdjustmentValueArray[128];
|
||||
@@ -334,11 +62,11 @@ float _ToonIgnoreExposureMultiplier;
|
||||
|
||||
float _Outline_MaxWidth;
|
||||
|
||||
float4 _HairShadowRTHandleScale;
|
||||
float4 _HairBlendingRTHandleScale;
|
||||
|
||||
float _HairShadowDistance;
|
||||
float _HairShadowDistanceScaleFactor;
|
||||
float _HairShadowDepthBias;
|
||||
float _HairShadowFadeInDistance;
|
||||
float _HairShadowFadeOutDistance;
|
||||
float _HairShadowFadeOutDistance;
|
||||
|
||||
// float2 _HairShadowRTHandleScale;
|
||||
// float2 _HairBlendingRTHandleScale;
|
||||
|
||||
@@ -1,23 +1,49 @@
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
// Shading Color
|
||||
TEXTURE2D(_BaseColorMap);
|
||||
SAMPLER(sampler_BaseColorMap);
|
||||
|
||||
TEXTURE2D(_1stShadeColorMap);
|
||||
TEXTURE2D(_2ndShadeColorMap);
|
||||
|
||||
TEXTURE2D_ARRAY(_ShadingRampMap);
|
||||
TEXTURE2D(_ShadingRampMaskMap);
|
||||
|
||||
// Shadow
|
||||
TEXTURE2D(_SDFShadingMap);
|
||||
SAMPLER(sampler_SDFShadingMap);
|
||||
|
||||
TEXTURE2D_ARRAY(_ShadingRampMap);
|
||||
// Surface Inputs
|
||||
TEXTURE2D(_MaskMap);
|
||||
SAMPLER(sampler_MaskMap);
|
||||
|
||||
TEXTURE2D(_MatCapMap);
|
||||
TEXTURE2D(_NormalMap);
|
||||
SAMPLER(sampler_NormalMap);
|
||||
|
||||
TEXTURE2D(_AnisotropyMap);
|
||||
SAMPLER(sampler_AnisotropyMap);
|
||||
|
||||
TEXTURE2D(_SpecularColorMap);
|
||||
SAMPLER(sampler_SpecularColorMap);
|
||||
|
||||
TEXTURE2D(_SSSLutMap);
|
||||
|
||||
TEXTURE2D(_HairBlendingMap);
|
||||
SAMPLER(sampler_HairBlendingMap);
|
||||
|
||||
// Global
|
||||
TEXTURE2D(_HairShadowTex);
|
||||
TEXTURE2D_X(_HairBlendingTex);
|
||||
|
||||
|
||||
|
||||
TEXTURE2D(_IndirectDiffuseMatCapMap);
|
||||
TEXTURE2D(_IndirectSpecularMatCapMap);
|
||||
|
||||
TEXTURE2D_ARRAY(_IndirectDiffuseRampMap);
|
||||
|
||||
sampler _Set_1st_ShadePosition;
|
||||
sampler _Set_2nd_ShadePosition;
|
||||
sampler _HighColor_Tex;
|
||||
sampler _Set_HighColorMask;
|
||||
sampler _Set_RimLightMask;
|
||||
sampler _NormalMapForMatCap;
|
||||
sampler _Set_MatcapMask;
|
||||
TEXTURE2D(_ClippingMask);
|
||||
|
||||
TEXTURE2D(_AngelRingColorMap);
|
||||
@@ -28,6 +54,3 @@ SAMPLER(sampler_OutlineWidthMap);
|
||||
|
||||
TEXTURE2D(_OutlineColorMap);
|
||||
SAMPLER(sampler_OutlineColorMap);
|
||||
|
||||
TEXTURE2D(_BakedNormalMap);
|
||||
SAMPLER(sampler_BakedNormalMap);
|
||||
@@ -1,3 +1,7 @@
|
||||
// Surface Option
|
||||
float _SurfaceFeatures;
|
||||
half _AlphaCutoffEnable;
|
||||
float _AlphaCutoff;
|
||||
|
||||
// Shading Color
|
||||
float4 _BaseColor;
|
||||
@@ -5,12 +9,13 @@ float4 _BaseColorMap_ST;
|
||||
float4 _BaseColorMap_TexelSize;
|
||||
float4 _BaseColorMap_MipInfo;
|
||||
|
||||
float _ShadingIndex;
|
||||
int _ShadingIndex;
|
||||
float _ShadingRampMask;
|
||||
|
||||
float4 _1stShadeColor;
|
||||
float4 _2ndShadeColor;
|
||||
fixed _UseBaseAs1st;
|
||||
fixed _Use1stAs2nd;
|
||||
half _UseBaseAs1st;
|
||||
half _Use1stAs2nd;
|
||||
|
||||
float _1stShadeColorStep;
|
||||
float _1stShadeColorFeather;
|
||||
@@ -21,160 +26,111 @@ float _SDFShadowLevel;
|
||||
float _SDFShadowSmoothLevel;
|
||||
float _SDFHighlightStrength;
|
||||
|
||||
// Shadow
|
||||
float _ShadowDistanceBias;
|
||||
float _ShadowNormalBias;
|
||||
|
||||
float _utsTechnique;
|
||||
float4 _Color;
|
||||
fixed _Set_SystemShadowsToBase;
|
||||
// Surface Inputs
|
||||
float _AlphaRemapMin;
|
||||
float _AlphaRemapMax;
|
||||
|
||||
float _SurfaceFeatures;
|
||||
float _NormalScale;
|
||||
|
||||
float _Tweak_SystemShadowsLevel;
|
||||
float _ShadowBias;
|
||||
float _Metallic;
|
||||
float _MetallicRemapMin;
|
||||
float _MetallicRemapMax;
|
||||
float _Smoothness;
|
||||
float _SmoothnessRemapMin;
|
||||
float _SmoothnessRemapMax;
|
||||
float _Roughness;
|
||||
float _RoughnessRemapMin;
|
||||
float _RoughnessRemapMax;
|
||||
|
||||
float _EyeParallaxAmount;
|
||||
float _HairBlendingFactor;
|
||||
float _AORemapMin;
|
||||
float _AORemapMax;
|
||||
|
||||
float _BaseColor_Step;
|
||||
float _BaseShade_Feather;
|
||||
float4 _Set_1st_ShadePosition_ST;
|
||||
float _Anisotropy;
|
||||
float4 _AnisotropyMap_ST;
|
||||
|
||||
float _ShadeColor_Step;
|
||||
float _1st2nd_Shades_Feather;
|
||||
float4 _Set_2nd_ShadePosition_ST;
|
||||
float4 _ShadingGradeMap_ST;
|
||||
float4 _KKColor;
|
||||
|
||||
float _Tweak_ShadingGradeMapLevel;
|
||||
fixed _BlurLevelSGM;
|
||||
//
|
||||
float4 _SpecularColor;
|
||||
float _ToonSpecularStep;
|
||||
float _ToonSpecularFeather;
|
||||
float _BSDFContribution;
|
||||
float _EnergyConservingSpecularColor;
|
||||
|
||||
float4 _HighColor;
|
||||
float4 _HighColor_Tex_ST;
|
||||
fixed _Is_LightColor_HighColor;
|
||||
// float _SSSIntensity;
|
||||
// int _Use_SSSLut;
|
||||
|
||||
fixed _Is_NormalMapToHighColor;
|
||||
float _HighColor_Power;
|
||||
fixed _Is_SpecularToHighColor;
|
||||
fixed _Is_BlendAddToHiColor;
|
||||
fixed _Is_BlendAddToRimColor;
|
||||
fixed _Is_UseTweakHighColorOnShadow;
|
||||
float _TweakHighColorOnShadow;
|
||||
float4 _Set_HighColorMask_ST;
|
||||
float _Tweak_HighColorMaskLevel;
|
||||
fixed _RimLight;
|
||||
float3 _EmissiveColor;
|
||||
half _AlbedoAffectEmissive;
|
||||
half _EmissiveExposureWeight;
|
||||
|
||||
float _ObjectSpaceUVMappingEmissive;
|
||||
|
||||
// Ambient
|
||||
float _IndirectDiffuseMatCapLod;
|
||||
|
||||
int _IndirectDiffuseRampIndex;
|
||||
float _IndirectDiffuseRampPosition;
|
||||
|
||||
float _IndirectDiffuseIntensity;
|
||||
float _SSAOWeight;
|
||||
float _SSGIWeight;
|
||||
|
||||
float _IndirectSpecularMatCapLod;
|
||||
|
||||
float _IndirectSpecularIntensity;
|
||||
float _SSRWeight;
|
||||
|
||||
//Rim Light
|
||||
float4 _RimLightColor;
|
||||
float _RimLight_Strength;
|
||||
fixed _Is_LightColor_RimLight;
|
||||
fixed _Is_NormalMapToRimLight;
|
||||
float _RimLight_Power;
|
||||
float _RimLight_InsideMask;
|
||||
fixed _RimLight_FeatherOff;
|
||||
fixed _LightDirection_MaskOn;
|
||||
float _Tweak_LightDirection_MaskLevel;
|
||||
fixed _Add_Antipodean_RimLight;
|
||||
float4 _Ap_RimLightColor;
|
||||
fixed _Is_LightColor_Ap_RimLight;
|
||||
float _Ap_RimLight_Power;
|
||||
fixed _Ap_RimLight_FeatherOff;
|
||||
float4 _Set_RimLightMask_ST;
|
||||
float _Tweak_RimLightMaskLevel;
|
||||
fixed _MatCap;
|
||||
float4 _MatCap_Sampler_ST;
|
||||
float4 _MatCapColor;
|
||||
fixed _Is_LightColor_MatCap;
|
||||
fixed _Is_BlendAddToMatCap;
|
||||
float _Tweak_MatCapUV;
|
||||
float _Rotate_MatCapUV;
|
||||
fixed _Is_NormalMapForMatCap;
|
||||
float4 _NormalMapForMatCap_ST;
|
||||
float _Rotate_NormalMapForMatCapUV;
|
||||
fixed _Is_UseTweakMatCapOnShadow;
|
||||
float _TweakMatCapOnShadow;
|
||||
float4 _Set_MatcapMask_ST;
|
||||
float _Tweak_MatcapMaskLevel;
|
||||
fixed _Is_Ortho;
|
||||
float _CameraRolling_Stabilizer;
|
||||
fixed _BlurLevelMatcap;
|
||||
fixed _Inverse_MatcapMask;
|
||||
float _BumpScale;
|
||||
float _BumpScaleMatcap;
|
||||
float4 _Emissive_Tex_ST;
|
||||
float4 _Emissive_Color;
|
||||
|
||||
fixed _Is_ViewCoord_Scroll;
|
||||
float _Rotate_EmissiveUV;
|
||||
float _Base_Speed;
|
||||
float _Scroll_EmissiveU;
|
||||
float _Scroll_EmissiveV;
|
||||
fixed _Is_PingPong_Base;
|
||||
float4 _ColorShift;
|
||||
float4 _ViewShift;
|
||||
float _ColorShift_Speed;
|
||||
fixed _Is_ColorShift;
|
||||
fixed _Is_ViewShift;
|
||||
float3 emissive;
|
||||
//
|
||||
float _Unlit_Intensity;
|
||||
|
||||
fixed _Is_Filter_HiCutPointLightColor;
|
||||
fixed _Is_Filter_LightColor;
|
||||
|
||||
float _StepOffset;
|
||||
fixed _Is_BLD;
|
||||
float _Offset_X_Axis_BLD;
|
||||
float _Offset_Y_Axis_BLD;
|
||||
fixed _Inverse_Z_Axis_BLD;
|
||||
|
||||
float4 _ClippingMask_ST;
|
||||
|
||||
fixed _IsBaseMapAlphaAsClippingMask;
|
||||
float _Clipping_Level;
|
||||
fixed _Inverse_Clipping;
|
||||
float _Tweak_transparency;
|
||||
fixed _AngelRing;
|
||||
|
||||
float _BaseColorVisible;
|
||||
float _BaseColorOverridden;
|
||||
float4 _BaseColorMaskColor;
|
||||
|
||||
float _FirstShadeVisible;
|
||||
float _FirstShadeOverridden;
|
||||
float4 _FirstShadeMaskColor;
|
||||
|
||||
float _SecondShadeVisible;
|
||||
float _SecondShadeOverridden;
|
||||
float4 _SecondShadeMaskColor;
|
||||
|
||||
float _HighlightVisible;
|
||||
float _HighlightOverridden;
|
||||
float4 _HighlightMaskColor;
|
||||
|
||||
float _AngelRingVisible;
|
||||
float _AngelRingOverridden;
|
||||
float4 _AngelRingMaskColor;
|
||||
|
||||
float _RimLightVisible;
|
||||
float _RimLightOverridden;
|
||||
float4 _RimLightMaskColor;
|
||||
|
||||
float _ComposerMaskMode;
|
||||
int _ClippingMatteMode;
|
||||
|
||||
float _GI_Intensity;
|
||||
float _Light_Intensity_Multiplier;
|
||||
float _RimLightIntensity;
|
||||
float _RimLightLevel;
|
||||
half _RimLightClipping;
|
||||
float _RimLightClippingLevel;
|
||||
|
||||
float _LightDirectionRimLightLevel;
|
||||
|
||||
// Angle Ring
|
||||
float4 _AngelRingColor;
|
||||
float4 _AngelRingColorMap_ST;
|
||||
float _AngelRingIntensity;
|
||||
float _AngelRingOffsetU;
|
||||
float _AngelRingOffsetV;
|
||||
|
||||
// Outline
|
||||
float _OutlineWidth;
|
||||
float4 _OutlineColor;
|
||||
fixed _AlbedoAffectOutline;
|
||||
half _AlbedoAffectOutline;
|
||||
half _SkyColorAffectOutline;
|
||||
float _SkyColorIntensity;
|
||||
|
||||
float _OutlineFadeIn;
|
||||
float _OutlineFadeOut;
|
||||
fixed _UseSmoothedNormal;
|
||||
half _UseSmoothedNormal;
|
||||
|
||||
float _Tweak_SystemShadowsLevel;
|
||||
|
||||
float _EyeParallaxAmount;
|
||||
float _HairBlendingFactor;
|
||||
|
||||
// Advance
|
||||
half _ClampLightColor;
|
||||
float _LightIntensityMultiplier;
|
||||
float _Minimal_Diffuse_Contribution;
|
||||
|
||||
// Light Loop
|
||||
float3 _ObjectCenterPositionWS;
|
||||
|
||||
// NOTE: Not sure what these are for
|
||||
// float _FirstShadeOverridden;
|
||||
// float _SecondShadeOverridden;
|
||||
|
||||
float _UseShadowThreshold;
|
||||
float _AlphaCutoffShadow;
|
||||
float _ComposerMaskMode;
|
||||
|
||||
#if defined(_UTS_TOON_EV_PER_MODEL)
|
||||
// not in materials
|
||||
@@ -184,9 +140,4 @@ float _ToonEvAdjustmentValueArray[128];
|
||||
float _ToonEvAdjustmentValueMin;
|
||||
float _ToonEvAdjustmentValueMax;
|
||||
float _ToonEvAdjustmentCompensation;
|
||||
#endif //#if !defined(_UTS_TOON_EV_PER_MODEL)
|
||||
|
||||
|
||||
float _BlendMode;
|
||||
|
||||
float3 _ObjectCenterPositionWS;
|
||||
#endif
|
||||
|
||||
@@ -63,18 +63,16 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
, out float outputDepth : SV_Depth
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
||||
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
||||
|
||||
_Color = _BaseColor;
|
||||
|
||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||
float4 Set_UV0 = input.texCoord0;
|
||||
|
||||
|
||||
// The following temporary definition of unity_AmbientEquator is for HDRP only.
|
||||
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
||||
//v.2.0.9
|
||||
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
||||
float3 envLightSource_GradientEquator = ShadeSH9(float4(0, 1, 0, 0));
|
||||
float3 envLightSource_SkyboxIntensity = max(
|
||||
@@ -84,9 +82,9 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||
ambientSkyColor *= GetCurrentExposureMultiplier();
|
||||
|
||||
float4 _BlendingTex_var = SAMPLE_TEXTURE2D(_HairBlendingMap, sampler_HairBlendingMap, TRANSFORM_TEX(Set_UV0, _BaseColorMap));
|
||||
outColor = float4(_BlendingTex_var.rgb * ambientSkyColor, _BlendingTex_var.a);
|
||||
|
||||
float4 blendingTex = SAMPLE_TEXTURE2D(_HairBlendingMap, sampler_HairBlendingMap, TRANSFORM_TEX(Set_UV0, _BaseColorMap));
|
||||
outColor = float4(blendingTex.rgb + ambientSkyColor, blendingTex.a);
|
||||
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
@@ -94,4 +92,4 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
outVTFeedback = builtinData.vtPackedFeedback;
|
||||
#endif
|
||||
}
|
||||
// End of File
|
||||
// End of File
|
||||
|
||||
@@ -10,75 +10,38 @@ float4 _LightColor0; // not referenced in c# code ??
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl"
|
||||
|
||||
// PackedVaryingsType
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L120
|
||||
// PackedVaryingsType
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L120
|
||||
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass)
|
||||
{
|
||||
// VaryingsType
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L118
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass)
|
||||
{
|
||||
// VaryingsType
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L118
|
||||
|
||||
VaryingsType varyingsType;
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
varyingsType.vmesh.
|
||||
#include "HDRPToonOutlineVertMain.hlsl"
|
||||
VaryingsType varyingsType;
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
varyingsType.vmesh.
|
||||
#include "HDRPToonOutlineVertMain.hlsl"
|
||||
|
||||
return MotionVectorVS(varyingsType, inputMesh, inputPass);
|
||||
}
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
|
||||
PackedVaryingsToPS VertTesselation(VaryingsToDS input)
|
||||
{
|
||||
VaryingsToPS output;
|
||||
output.vmesh = VertMeshTesselation(input.vmesh);
|
||||
MotionVectorPositionZBias(output);
|
||||
|
||||
output.vpass.positionCS = input.vpass.positionCS;
|
||||
output.vpass.previousPositionCS = input.vpass.previousPositionCS;
|
||||
|
||||
return PackVaryingsToPS(output);
|
||||
}
|
||||
|
||||
#endif // TESSELLATION_ON
|
||||
return MotionVectorVS(varyingsType, inputMesh, inputPass);
|
||||
}
|
||||
|
||||
#else // _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl"
|
||||
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
||||
{
|
||||
VaryingsType varyingsType;
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
#include "HDRPToonOutlineVertMain.hlsl"
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
||||
{
|
||||
VaryingsType varyingsType;
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
#include "HDRPToonOutlineVertMain.hlsl"
|
||||
|
||||
return PackVaryingsType(varyingsType);
|
||||
}
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
|
||||
PackedVaryingsToPS VertTesselation(VaryingsToDS input)
|
||||
{
|
||||
VaryingsToPS output;
|
||||
output.vmesh = VertMeshTesselation(input.vmesh);
|
||||
|
||||
return PackVaryingsToPS(output);
|
||||
}
|
||||
|
||||
|
||||
#endif // TESSELLATION_ON
|
||||
return PackVaryingsType(varyingsType);
|
||||
}
|
||||
|
||||
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
||||
#define VT_BUFFER_TARGET SV_Target1
|
||||
#define EXTRA_BUFFER_TARGET SV_Target2
|
||||
@@ -119,12 +82,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode != 0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
#if defined(UTS_DEBUG_SHADOWMAP_NO_OUTLINE)
|
||||
discard;
|
||||
#endif
|
||||
@@ -132,26 +90,23 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||
float4 uv0 = input.texCoord0;
|
||||
|
||||
// The following temporary definition of unity_AmbientEquator is for HDRP only.
|
||||
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
||||
//v.2.0.9
|
||||
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
||||
float3 envLightSource_GradientEquator = ShadeSH9(float4(0, 1, 0, 0));
|
||||
float3 envLightSource_SkyboxIntensity = max(
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy),
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy)
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, 1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy),
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, -1.0, -0.0), input.texCoord1.xy, input.texCoord2.xy)
|
||||
).rgb;
|
||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||
ambientSkyColor *= GetCurrentExposureMultiplier() * 5.0f;
|
||||
ambientSkyColor *= GetCurrentExposureMultiplier() * _SkyColorIntensity;
|
||||
|
||||
float3 baseColor = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb;
|
||||
baseColor *= _BaseColor.rgb;
|
||||
|
||||
float4 outlineColor = _OutlineColor;
|
||||
#if _OUTLINE_COLOR_MAP
|
||||
outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb + ambientSkyColor, _SkyColorAffectOutline);
|
||||
#if _OUTLINECOLORMAP
|
||||
outlineColor *= SAMPLE_TEXTURE2D(_OutlineColorMap, sampler_OutlineColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb;
|
||||
#endif
|
||||
outlineColor.rgb = lerp(outlineColor.rgb * ambientSkyColor, outlineColor.rgb * ambientSkyColor * baseColor, _AlbedoAffectOutline);
|
||||
outlineColor.rgb = lerp(outlineColor.rgb, outlineColor.rgb * baseColor, _AlbedoAffectOutline);
|
||||
|
||||
float3 volColor, volOpacity;
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
|
||||
#endif
|
||||
float4 Set_UV0 = input.texCoord0;
|
||||
float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex));
|
||||
float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _BaseColorMap));
|
||||
|
||||
surfaceData.baseColor = _MainTex_var.xyz;
|
||||
|
||||
|
||||
@@ -91,16 +91,10 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
#if defined(VARYINGS_NEED_CULLFACE) && SHADER_STAGE_FRAGMENT
|
||||
input.isFrontFace = IS_FRONT_VFACE(packedInput.cullFace, true, false);
|
||||
#endif
|
||||
|
||||
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.
|
||||
input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy;
|
||||
|
||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||
|
||||
// input.positionSS is SV_Position
|
||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
||||
|
||||
|
||||
@@ -112,7 +106,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float2 viewT = TransformObjectToTangent(V, input.tangentToWorld);
|
||||
float2 parallaxOffset = viewT;
|
||||
parallaxOffset.y = -parallaxOffset.y;
|
||||
UV0.xy = clamp(UV0.xy -_EyeParallaxAmount * parallaxOffset, 0, 1);
|
||||
input.texCoord0.xy = clamp(input.texCoord0.xy -_EyeParallaxAmount * parallaxOffset, 0, 1);
|
||||
#endif
|
||||
|
||||
#else
|
||||
@@ -152,140 +146,28 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
// Initialize the contactShadow and contactShadowFade fields
|
||||
InitContactShadow(posInput, context);
|
||||
|
||||
float channelAlpha = 0.0f;
|
||||
|
||||
LightLoopOutput lightLoopOutput;
|
||||
ZERO_INITIALIZE(LightLoopOutput, lightLoopOutput);
|
||||
|
||||
UtsLightLoop(input, posInput, bsdfData, builtinData, V, featureFlags, lightLoopOutput);
|
||||
|
||||
/*
|
||||
#ifdef _EMISSIVE_SIMPLE
|
||||
float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(UV0, _Emissive_Tex));
|
||||
float emissiveMask = _Emissive_Tex_var.a;
|
||||
emissive = _Emissive_Tex_var.rgb * _Emissive_Color.rgb * emissiveMask;
|
||||
#elif _EMISSIVE_ANIMATION
|
||||
//v.2.0.7 Calculation View Coord UV for Scroll
|
||||
float3 viewNormal_Emissive = (mul(UNITY_MATRIX_V, float4(i_normalDir, 0))).xyz;
|
||||
float3 NormalBlend_Emissive_Detail = viewNormal_Emissive * float3(-1, -1, 1);
|
||||
float3 NormalBlend_Emissive_Base = (mul(UNITY_MATRIX_V, float4(utsData.viewDirection, 0)).xyz * float3(-1, -1, 1)) + float3(0, 0, 1);
|
||||
float3 noSknewViewNormal_Emissive = NormalBlend_Emissive_Base * dot(NormalBlend_Emissive_Base, NormalBlend_Emissive_Detail) / NormalBlend_Emissive_Base.z - NormalBlend_Emissive_Detail;
|
||||
float2 _ViewNormalAsEmissiveUV = noSknewViewNormal_Emissive.xy * 0.5 + 0.5;
|
||||
float2 _ViewCoord_UV = RotateUV(_ViewNormalAsEmissiveUV, -(utsData.cameraDir * utsData.cameraRoll), float2(0.5, 0.5), 1.0);
|
||||
//Invert if it's "inside the mirror".
|
||||
if (utsData.signMirror < 0) {
|
||||
_ViewCoord_UV.x = 1 - _ViewCoord_UV.x;
|
||||
}
|
||||
else {
|
||||
_ViewCoord_UV = _ViewCoord_UV;
|
||||
}
|
||||
float2 emissive_uv = lerp(UV0, _ViewCoord_UV, _Is_ViewCoord_Scroll);
|
||||
//
|
||||
float4 _time_var = _Time;
|
||||
float _base_Speed_var = (_time_var.g * _Base_Speed);
|
||||
float _Is_PingPong_Base_var = lerp(_base_Speed_var, sin(_base_Speed_var), _Is_PingPong_Base);
|
||||
float2 scrolledUV = emissive_uv + float2(_Scroll_EmissiveU, _Scroll_EmissiveV) * _Is_PingPong_Base_var;
|
||||
float rotateVelocity = _Rotate_EmissiveUV * 3.141592654;
|
||||
float2 _rotate_EmissiveUV_var = RotateUV(scrolledUV, rotateVelocity, float2(0.5, 0.5), _Is_PingPong_Base_var);
|
||||
float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(UV0, _Emissive_Tex));
|
||||
float emissiveMask = _Emissive_Tex_var.a;
|
||||
_Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(_rotate_EmissiveUV_var, _Emissive_Tex));
|
||||
float _colorShift_Speed_var = 1.0 - cos(_time_var.g * _ColorShift_Speed);
|
||||
float viewShift_var = smoothstep(0.0, 1.0, max(0, dot(utsData.normalDirection, utsData.viewDirection)));
|
||||
float4 colorShift_Color = lerp(_Emissive_Color, lerp(_Emissive_Color, _ColorShift, _colorShift_Speed_var), _Is_ColorShift);
|
||||
float4 viewShift_Color = lerp(_ViewShift, colorShift_Color, viewShift_var);
|
||||
float4 emissive_Color = lerp(colorShift_Color, viewShift_Color, _Is_ViewShift);
|
||||
emissive = emissive_Color.rgb * _Emissive_Tex_var.rgb * emissiveMask;
|
||||
|
||||
//
|
||||
//v.2.0.6: GI_Intensity with Intensity Multiplier Filter
|
||||
#endif
|
||||
*/
|
||||
|
||||
// We directly calculate custome main light during the light loop in upper code to avoid extra calculation
|
||||
//customMainLight = GetCustomMainLightData(builtinData, mainPunctualLight);
|
||||
|
||||
/*
|
||||
#if _SHADOW_MODE_SDF || (_RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW)
|
||||
float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz);
|
||||
float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max(ShadeSH9(float4(0.0, 0.0, 0.0, 1.0)), ShadeSH9(float4(0.0, -1.0, 0.0, 1.0)).rgb) * _Unlit_Intensity));
|
||||
|
||||
float3 customLightDirection = normalize(mul(UNITY_MATRIX_M, float4(((float3(1.0, 0.0, 0.0) * _Offset_X_Axis_BLD * 10) + (float3(0.0, 1.0, 0.0) * _Offset_Y_Axis_BLD * 10) + (float3(0.0, 0.0, -1.0) * lerp(-1.0, 1.0, _Inverse_Z_Axis_BLD))), 0)).xyz);
|
||||
float3 lightDirection = normalize(lerp(defaultLightDirection, customMainLight.lightDirection.xyz, any(customMainLight.lightDirection.xyz)));
|
||||
lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD);
|
||||
float3 originalLightColor = customMainLight.lightColor.rgb;
|
||||
|
||||
originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin ), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve) * _Light_Intensity_Multiplier;
|
||||
float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_Is_Filter_LightColor, _ToonLightHiCutFilter));
|
||||
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(UV0, _1st_ShadeMap)), _MainTex_var, _Use_BaseAs1st);
|
||||
float3 _1st_Shade_var = lerp((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb) * lightColor), _Is_LightColor_1st_Shade);
|
||||
|
||||
float systemShadowValue = lerp(1.0f, saturate(customMainLight.shadowValue * 2.0f), _Set_SystemShadowsToBase);
|
||||
#endif
|
||||
|
||||
#if _SHADOW_MODE_SDF
|
||||
// modified by Suomi @ 20230902 - SDFResult is used to sample SDF texture on the correct side
|
||||
|
||||
float angle;
|
||||
bool rightside;
|
||||
float2 SDF_UV = TRANSFORM_TEX(UV0, _BaseColorMap);
|
||||
float4 sdfRes = SDFResult(rightside, angle, customMainLight.lightDirection, SDF_UV);
|
||||
float sdfShadowValue = 1.0f - SDFMask(angle, sdfRes.r);
|
||||
|
||||
utsAggregateLighting.directDiffuse = lerp(_1st_Shade_var, bsdfData.diffuseColor * _BaseColor.rgb * lightColor, sdfShadowValue * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular = lerp(0, utsAggregateLighting.directSpecular, sdfShadowValue * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular += _SDFNoseHighlightCoef * SDFNoseHighlight(angle, sdfRes.g, rightside, SDF_UV) * lightColor;
|
||||
#endif
|
||||
|
||||
#if _RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW
|
||||
// Push the face fragment view space position towards the light for a little bit
|
||||
float hairShadowOpacity = saturate(Remap(length(posInput.positionWS), float2(_HairShadowFadeOutDistance, _HairShadowFadeInDistance), float2(0, 1)));
|
||||
|
||||
float3 viewLightDir = TransformWorldToViewDir(customMainLight.lightDirection); // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face.
|
||||
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||
float shadowLengthY = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth;
|
||||
float2 shadowLength = float2(shadowLengthY * 2.0f, shadowLengthY);
|
||||
|
||||
float3 camDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||
float camDirFactor = 1 - smoothstep(0.1, 0.9, camDirOS.y);
|
||||
shadowLength.y *= camDirFactor;
|
||||
|
||||
float2 samplingPoint = (input.positionSS.xy + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2 (1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
|
||||
|
||||
// Then sample the hair buffer, to see if the fragment lands in shadow.
|
||||
float2 scaledUVs = samplingPoint * _HairShadowRTHandleScale; // 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 depthCorrect = 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.
|
||||
float hairShadow = lerp(0,hairShadowOpacity,depthCorrect);
|
||||
|
||||
utsAggregateLighting.directDiffuse = lerp(utsAggregateLighting.directDiffuse, _1st_Shade_var, hairShadow * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, hairShadow * systemShadowValue);
|
||||
#endif
|
||||
*/
|
||||
//outColor.rgb = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting;
|
||||
//outColor.a = 1.0;
|
||||
//return;
|
||||
|
||||
float3 finalColor = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting;
|
||||
|
||||
#ifdef _IS_TRANSCLIPPING_OFF
|
||||
|
||||
outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha));
|
||||
|
||||
#elif _IS_TRANSCLIPPING_ON
|
||||
|
||||
float Set_Opacity = saturate((inverseClipping + _Tweak_transparency));
|
||||
|
||||
outColor = EvaluateAtmosphericScattering(posInput, V, float4(finalColor, 1));
|
||||
outColor = float4(outColor.rgb, Set_Opacity * ApplyChannelAlpha(channelAlpha));
|
||||
#endif
|
||||
// #if _SURFACE_TYPE_TRANSPARENT
|
||||
// float alpha = channelAlpha;
|
||||
// outColor = EvaluateAtmosphericScattering(posInput, V, float4(finalColor, 1));
|
||||
// #else
|
||||
// float alpha = lerp(1.0, channelAlpha, _AlphaCutoffEnable);
|
||||
// #endif
|
||||
//
|
||||
// alpha = lerp(alpha, step(_AlphaCutoff, alpha), _AlphaCutoffEnable);
|
||||
outColor = float4(finalColor, 1.0);
|
||||
|
||||
#if _MATERIAL_TYPE_FRONTHAIR && ENABLE_UTS_HAIR_BLENDING
|
||||
float2 screenUV = posInput.positionNDC * _HairBlendingRTHandleScale.xy;
|
||||
float4 hairBlendingMap = SAMPLE_TEXTURE2D(_HairBlendingTex, s_trilinear_clamp_sampler, screenUV);
|
||||
outColor.rgb = lerp(outColor.rgb, hairBlendingMap.rgb, hairBlendingMap.a * _HairBlendingFactor);
|
||||
float2 screenUV = posInput.positionSS; // * _HairBlendingRTHandleScale.xy; // Why we don't need to scale? Does unity handle it internally?
|
||||
float4 hairBlendingTex = LOAD_TEXTURE2D_X(_HairBlendingTex, screenUV);
|
||||
outColor.rgb = lerp(outColor.rgb, hairBlendingTex.rgb, hairBlendingTex.a * _HairBlendingFactor);
|
||||
#endif
|
||||
|
||||
#if UTS_DEBUG_SHADOWMAP || UTS_DEBUG_SELFSHADOW
|
||||
@@ -302,7 +184,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
#endif
|
||||
#endif // ifdef UTS_DEBUG_SHADOWMAP
|
||||
#endif // defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
@@ -311,4 +193,4 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
outVTFeedback = builtinData.vtPackedFeedback;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#if SHADERPASS != SHADERPASS_GBUFFER
|
||||
#error SHADERPASS_is_not_correctly_define
|
||||
#endif
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl"
|
||||
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
||||
{
|
||||
VaryingsType varyingsType;
|
||||
|
||||
#if defined(HAVE_RECURSIVE_RENDERING)
|
||||
// If we have a recursive raytrace object, we will not render it.
|
||||
// As we don't want to rely on renderqueue to exclude the object from the list,
|
||||
// we cull it by settings position to NaN value.
|
||||
// TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer
|
||||
if (_EnableRecursiveRayTracing && _RayTracing > 0.0)
|
||||
{
|
||||
ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive.
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
}
|
||||
|
||||
return PackVaryingsType(varyingsType);
|
||||
}
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
|
||||
PackedVaryingsToPS VertTesselation(VaryingsToDS input)
|
||||
{
|
||||
VaryingsToPS output;
|
||||
output.vmesh = VertMeshTesselation(input.vmesh);
|
||||
return PackVaryingsToPS(output);
|
||||
}
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl"
|
||||
|
||||
#endif // TESSELLATION_ON
|
||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsLitData.hlsl"
|
||||
void Frag( PackedVaryingsToPS packedInput,
|
||||
OUTPUT_GBUFFER(outGBuffer)
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
, out float outputDepth : DEPTH_OFFSET_SEMANTIC
|
||||
#endif
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
||||
FragInputs input = UnpackVaryingsToFragInputs(packedInput);
|
||||
|
||||
// input.positionSS is SV_Position
|
||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS);
|
||||
|
||||
#ifdef VARYINGS_NEED_POSITION_WS
|
||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||
#else
|
||||
// Unused
|
||||
float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0
|
||||
#endif
|
||||
|
||||
SurfaceData surfaceData;
|
||||
BuiltinData builtinData;
|
||||
UtsGetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
|
||||
ENCODE_INTO_GBUFFER(surfaceData, builtinData, posInput.positionSS, outGBuffer);
|
||||
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c07059b2d184d9a8a6d8ad658a0f7ab
|
||||
timeCreated: 1738566127
|
||||
@@ -11,27 +11,27 @@ namespace Misaki.HdrpToon
|
||||
[HideInInspector]
|
||||
internal class UTSPass : CustomPass
|
||||
{
|
||||
private const int Adjustment_Curve_Precision = 128;
|
||||
private const int _ADJUSTMENT_CURVE_PRECISION = 128;
|
||||
|
||||
private const string Compensation_Prop_Name = "_ToonEvAdjustmentCompensation";
|
||||
private const string Exposure_Adjustment_Prop_Name = "_ToonEvAdjustmentCurve";
|
||||
private const string Exposure_Array_Prop_Name = "_ToonEvAdjustmentValueArray";
|
||||
private const string Exposure_Min_Prop_Name = "_ToonEvAdjustmentValueMin";
|
||||
private const string Exposure_Max_Prop_Name = "_ToonEvAdjustmentValueMax";
|
||||
private const string Toon_Light_Filter_Prop_Name = "_ToonLightHiCutFilter";
|
||||
private const string Ignore_Volume_Exposure_Prop_Name = "_ToonIgnoreExposureMultiplier";
|
||||
private const string _COMPENSATION_PROP_NAME = "_ToonEvAdjustmentCompensation";
|
||||
private const string _EXPOSURE_ADJUSTMENT_PROP_NAME = "_ToonEvAdjustmentCurve";
|
||||
private const string _EXPOSURE_ARRAY_PROP_NAME = "_ToonEvAdjustmentValueArray";
|
||||
private const string _EXPOSURE_MIN_PROP_NAME = "_ToonEvAdjustmentValueMin";
|
||||
private const string _EXPOSURE_MAX_PROP_NAME = "_ToonEvAdjustmentValueMax";
|
||||
private const string _TOON_LIGHT_FILTER_PROP_NAME = "_ToonLightHiCutFilter";
|
||||
private const string _IGNORE_VOLUME_EXPOSURE_PROP_NAME = "_ToonIgnoreExposureMultiplier";
|
||||
|
||||
private const string Hair_Shadow_RTHandle_Scale_Prop_Name = "_HairShadowRTHandleScale";
|
||||
private const string Hair_Shadow_Distance_Prop_Name = "_HairShadowDistance";
|
||||
private const string Hair_Shadow_Distance_Scale_Prop_Name = "_HairShadowDistanceScaleFactor";
|
||||
private const string Hair_Shadow_Depth_Bias_Prop_Name = "_HairShadowDepthBias";
|
||||
private const string Hair_Shadow_FadeIn_Prop_Name = "_HairShadowFadeInDistance";
|
||||
private const string Hair_Shadow_Fade_Out_Prop_Name = "_HairShadowFadeOutDistance";
|
||||
private const string _HAIR_SHADOW_DISTANCE_PROP_NAME = "_HairShadowDistance";
|
||||
private const string _HAIR_SHADOW_DISTANCE_SCALE_PROP_NAME = "_HairShadowDistanceScaleFactor";
|
||||
private const string _HAIR_SHADOW_DEPTH_BIAS_PROP_NAME = "_HairShadowDepthBias";
|
||||
private const string _HAIR_SHADOW_FADEIN_PROP_NAME = "_HairShadowFadeInDistance";
|
||||
private const string _HAIR_SHADOW_FADE_OUT_PROP_NAME = "_HairShadowFadeOutDistance";
|
||||
|
||||
private const string Hair_Blending_RTHandle_Scale_Prop_Name = "_HairBlendingRTHandleScale";
|
||||
private const string _HAIR_SHADOW_RT_PROP_NAME = "_HairShadowTex";
|
||||
private const string _HAIR_BLENDING_PROP_NAME = "_HairBlendingTex";
|
||||
|
||||
private const string Output_RT_Prop_Name = "_HairShadowTex";
|
||||
private const string Hair_Blending_Prop_Name = "_HairBlendingTex";
|
||||
private static readonly ProfilingSampler _hairShadowProfilingSampler = new("UTS Hair Shadow");
|
||||
private static readonly ProfilingSampler _hairBlendingProfilingSampler = new("UTS Hair Blending Target");
|
||||
|
||||
private float _max;
|
||||
private float _min;
|
||||
@@ -40,7 +40,9 @@ namespace Misaki.HdrpToon
|
||||
private RTHandle _hairShadowRTHandle;
|
||||
private bool _needReallocateHairShadow;
|
||||
|
||||
// TODO: Possible to avoid another RTHandle for depth?
|
||||
private RTHandle _hairBlendingRTHandle;
|
||||
private RTHandle _hairBlendingDepthRTHandle;
|
||||
private bool _needReallocateHairBlending;
|
||||
|
||||
private bool _enableHairShadow;
|
||||
@@ -139,23 +141,17 @@ namespace Misaki.HdrpToon
|
||||
}
|
||||
#endif
|
||||
|
||||
var scale = _hairShadowQuality switch
|
||||
{
|
||||
BufferQuality.Low => new Vector2(0.5f, 0.5f),
|
||||
BufferQuality.High => Vector2.one,
|
||||
_ => Vector2.zero
|
||||
};
|
||||
|
||||
// Use R8 or R16 directly?
|
||||
var format = _hairShadowQuality switch
|
||||
{
|
||||
BufferQuality.Low => GraphicsFormat.D16_UNorm,
|
||||
BufferQuality.High => GraphicsFormat.D32_SFloat,
|
||||
_ => GraphicsFormat.D16_UNorm
|
||||
_ => GraphicsFormat.R16G16B16A16_SFloat
|
||||
};
|
||||
|
||||
_hairShadowRTHandle?.Release();
|
||||
_hairShadowRTHandle = RTHandles.Alloc(scale, colorFormat: format, isShadowMap: true, useDynamicScale: true, name: Output_RT_Prop_Name);
|
||||
Shader.SetGlobalTexture(Output_RT_Prop_Name, _hairShadowRTHandle);
|
||||
_hairShadowRTHandle = RTHandles.Alloc(Vector2.one, useDynamicScale: true, format: format, isShadowMap: true, name: _HAIR_SHADOW_RT_PROP_NAME);
|
||||
Shader.SetGlobalTexture(_HAIR_SHADOW_RT_PROP_NAME, _hairShadowRTHandle);
|
||||
|
||||
_needReallocateHairShadow = false;
|
||||
}
|
||||
@@ -176,97 +172,28 @@ namespace Misaki.HdrpToon
|
||||
|
||||
var format = _hairBlendingQuality switch
|
||||
{
|
||||
BufferQuality.Low => GraphicsFormat.R8G8B8A8_SNorm,
|
||||
BufferQuality.High => GraphicsFormat.R8G8B8A8_SRGB,
|
||||
_ => GraphicsFormat.R8G8B8A8_SRGB
|
||||
BufferQuality.Low => GraphicsFormat.A2B10G10R10_UNormPack32,
|
||||
BufferQuality.High => GraphicsFormat.R16G16B16A16_UNorm,
|
||||
_ => GraphicsFormat.A2B10G10R10_UNormPack32
|
||||
};
|
||||
|
||||
_hairBlendingRTHandle?.Release();
|
||||
_hairBlendingRTHandle = RTHandles.Alloc(Vector2.one, colorFormat: format, useDynamicScale: true, name: Hair_Blending_Prop_Name);
|
||||
Shader.SetGlobalTexture(Hair_Blending_Prop_Name, _hairBlendingRTHandle);
|
||||
_hairBlendingRTHandle = RTHandles.Alloc(Vector2.one, useDynamicScale: true, dimension: TextureXR.dimension, colorFormat: format, name: _HAIR_BLENDING_PROP_NAME);
|
||||
|
||||
if (_hairBlendingDepthRTHandle == null || _hairBlendingDepthRTHandle.rt == null || !_hairBlendingDepthRTHandle.rt.IsCreated())
|
||||
{
|
||||
_hairBlendingDepthRTHandle?.Release();
|
||||
_hairBlendingDepthRTHandle = RTHandles.Alloc(Vector2.one, useDynamicScale: true, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.D16_UNorm, name: _HAIR_BLENDING_PROP_NAME + "_depth");
|
||||
}
|
||||
|
||||
Shader.SetGlobalTexture(_HAIR_BLENDING_PROP_NAME, _hairBlendingRTHandle);
|
||||
|
||||
_needReallocateHairBlending = false;
|
||||
}
|
||||
|
||||
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
|
||||
{
|
||||
_exposureArray = new float[Adjustment_Curve_Precision];
|
||||
|
||||
ReallocateHairShadowBuffer();
|
||||
ReallocateHairBlendingBuffer();
|
||||
}
|
||||
|
||||
protected override void Execute(CustomPassContext ctx)
|
||||
{
|
||||
var utsRenderer = ctx.hdCamera.volumeStack.GetComponent<UTSRenderer>();
|
||||
|
||||
UpdateSceneEV(utsRenderer);
|
||||
RenderHairShadow(ref ctx, utsRenderer);
|
||||
RenderHairBlending(ref ctx);
|
||||
}
|
||||
|
||||
private void RenderHairShadow(ref CustomPassContext ctx, UTSRenderer utsRenderer)
|
||||
{
|
||||
if (!_enableHairShadow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldReallocateHairShadowBuffer())
|
||||
{
|
||||
ReallocateHairShadowBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
CoreUtils.SetRenderTarget(ctx.cmd, _hairShadowRTHandle, ClearFlag.DepthStencil);
|
||||
|
||||
var shouldRender = utsRenderer != null && utsRenderer.enableHairShadow.value && utsRenderer.state.value;
|
||||
if (!shouldRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var result = new RendererListDesc(UtsShaderPassName.hairShadowCasterPassId, ctx.cullingResults, ctx.hdCamera.camera)
|
||||
{
|
||||
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
|
||||
sortingCriteria = SortingCriteria.CommonOpaque,
|
||||
excludeObjectMotionVectors = false,
|
||||
};
|
||||
|
||||
CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, ctx.renderContext.CreateRendererList(result));
|
||||
|
||||
Shader.SetGlobalVector(Hair_Shadow_RTHandle_Scale_Prop_Name, _hairShadowRTHandle.rtHandleProperties.rtHandleScale);
|
||||
Shader.SetGlobalFloat(Hair_Shadow_Distance_Prop_Name, utsRenderer.shadowDistance.value);
|
||||
Shader.SetGlobalFloat(Hair_Shadow_Distance_Scale_Prop_Name, utsRenderer.shadowDistanceScale.value);
|
||||
Shader.SetGlobalFloat(Hair_Shadow_Depth_Bias_Prop_Name, utsRenderer.shadowDepthBias.value);
|
||||
Shader.SetGlobalFloat(Hair_Shadow_FadeIn_Prop_Name, utsRenderer.shadowFadeIn.value);
|
||||
Shader.SetGlobalFloat(Hair_Shadow_Fade_Out_Prop_Name, utsRenderer.shadowFadeOut.value);
|
||||
}
|
||||
|
||||
private void RenderHairBlending(ref CustomPassContext ctx)
|
||||
{
|
||||
if (!_enableHairBlending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldReallocateHairBlendingBuffer())
|
||||
{
|
||||
ReallocateHairBlendingBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
CoreUtils.SetRenderTarget(ctx.cmd, _hairBlendingRTHandle, ctx.cameraDepthBuffer, ClearFlag.Color);
|
||||
|
||||
var result = new RendererListDesc(UtsShaderPassName.hairBlendingTargetPassId, ctx.cullingResults, ctx.hdCamera.camera)
|
||||
{
|
||||
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
|
||||
sortingCriteria = SortingCriteria.CommonOpaque,
|
||||
excludeObjectMotionVectors = false,
|
||||
};
|
||||
|
||||
CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, ctx.renderContext.CreateRendererList(result));
|
||||
Shader.SetGlobalVector(Hair_Blending_RTHandle_Scale_Prop_Name, _hairBlendingRTHandle.rtHandleProperties.rtHandleScale);
|
||||
_exposureArray = new float[_ADJUSTMENT_CURVE_PRECISION];
|
||||
}
|
||||
|
||||
private void UpdateSceneEV(UTSRenderer utsRenderer)
|
||||
@@ -307,22 +234,96 @@ namespace Misaki.HdrpToon
|
||||
{
|
||||
_min = curve[0].time;
|
||||
_max = curve[curve.length - 1].time;
|
||||
var step = (_max - _min) / (Adjustment_Curve_Precision - 1f);
|
||||
var step = (_max - _min) / (_ADJUSTMENT_CURVE_PRECISION - 1f);
|
||||
|
||||
for (var i = 0; i < Adjustment_Curve_Precision; i++)
|
||||
for (var i = 0; i < _ADJUSTMENT_CURVE_PRECISION; i++)
|
||||
{
|
||||
_exposureArray[i] = curve.Evaluate(_min + step * i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Shader.SetGlobalFloatArray(Exposure_Array_Prop_Name, _exposureArray);
|
||||
Shader.SetGlobalFloat(Exposure_Min_Prop_Name, _min);
|
||||
Shader.SetGlobalFloat(Exposure_Max_Prop_Name, _max);
|
||||
Shader.SetGlobalInt(Exposure_Adjustment_Prop_Name, toonEVAdjustment);
|
||||
Shader.SetGlobalInt(Toon_Light_Filter_Prop_Name, lightIntensityLimiter);
|
||||
Shader.SetGlobalInt(Ignore_Volume_Exposure_Prop_Name, ignoreVolumeExposure);
|
||||
Shader.SetGlobalFloat(Compensation_Prop_Name, compensation);
|
||||
Shader.SetGlobalFloatArray(_EXPOSURE_ARRAY_PROP_NAME, _exposureArray);
|
||||
Shader.SetGlobalFloat(_EXPOSURE_MIN_PROP_NAME, _min);
|
||||
Shader.SetGlobalFloat(_EXPOSURE_MAX_PROP_NAME, _max);
|
||||
Shader.SetGlobalInt(_EXPOSURE_ADJUSTMENT_PROP_NAME, toonEVAdjustment);
|
||||
Shader.SetGlobalInt(_TOON_LIGHT_FILTER_PROP_NAME, lightIntensityLimiter);
|
||||
Shader.SetGlobalInt(_IGNORE_VOLUME_EXPOSURE_PROP_NAME, ignoreVolumeExposure);
|
||||
Shader.SetGlobalFloat(_COMPENSATION_PROP_NAME, compensation);
|
||||
}
|
||||
|
||||
private void RenderHairShadow(ref CustomPassContext ctx, UTSRenderer utsRenderer)
|
||||
{
|
||||
if (!_enableHairShadow
|
||||
|| utsRenderer == null
|
||||
|| !utsRenderer.state.value
|
||||
|| !utsRenderer.enableHairShadow.value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldReallocateHairShadowBuffer())
|
||||
{
|
||||
ReallocateHairShadowBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
using (new ProfilingScope(ctx.cmd, _hairShadowProfilingSampler))
|
||||
{
|
||||
CoreUtils.SetRenderTarget(ctx.cmd, _hairShadowRTHandle, ClearFlag.Depth);
|
||||
|
||||
var result = new RendererListDesc(UtsShaderPassName.hairShadowCasterPassId, ctx.cullingResults, ctx.hdCamera.camera)
|
||||
{
|
||||
renderQueueRange = GetRenderQueueRange(RenderQueueType.AllOpaque),
|
||||
sortingCriteria = SortingCriteria.CommonOpaque,
|
||||
excludeObjectMotionVectors = false,
|
||||
};
|
||||
|
||||
CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, ctx.renderContext.CreateRendererList(result));
|
||||
|
||||
Shader.SetGlobalFloat(_HAIR_SHADOW_DISTANCE_PROP_NAME, utsRenderer.shadowDistance.value);
|
||||
Shader.SetGlobalFloat(_HAIR_SHADOW_DISTANCE_SCALE_PROP_NAME, utsRenderer.shadowDistanceScale.value);
|
||||
Shader.SetGlobalFloat(_HAIR_SHADOW_DEPTH_BIAS_PROP_NAME, utsRenderer.shadowDepthBias.value);
|
||||
Shader.SetGlobalFloat(_HAIR_SHADOW_FADEIN_PROP_NAME, utsRenderer.shadowFadeIn.value);
|
||||
Shader.SetGlobalFloat(_HAIR_SHADOW_FADE_OUT_PROP_NAME, utsRenderer.shadowFadeOut.value);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderHairBlending(ref CustomPassContext ctx)
|
||||
{
|
||||
if (!_enableHairBlending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldReallocateHairBlendingBuffer())
|
||||
{
|
||||
ReallocateHairBlendingBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
using (new ProfilingScope(ctx.cmd, _hairBlendingProfilingSampler))
|
||||
{
|
||||
CoreUtils.SetRenderTarget(ctx.cmd, _hairBlendingRTHandle, _hairBlendingDepthRTHandle, ClearFlag.Color | ClearFlag.Depth);
|
||||
|
||||
var result = new RendererListDesc(UtsShaderPassName.hairBlendingTargetPassId, ctx.cullingResults, ctx.hdCamera.camera)
|
||||
{
|
||||
renderQueueRange = GetRenderQueueRange(RenderQueueType.AllOpaque),
|
||||
sortingCriteria = SortingCriteria.CommonOpaque,
|
||||
excludeObjectMotionVectors = false,
|
||||
};
|
||||
|
||||
CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, ctx.renderContext.CreateRendererList(result));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Execute(CustomPassContext ctx)
|
||||
{
|
||||
var utsRenderer = ctx.hdCamera.volumeStack.GetComponent<UTSRenderer>();
|
||||
|
||||
UpdateSceneEV(utsRenderer);
|
||||
RenderHairShadow(ref ctx, utsRenderer);
|
||||
RenderHairBlending(ref ctx);
|
||||
}
|
||||
|
||||
protected override void Cleanup()
|
||||
@@ -330,6 +331,7 @@ namespace Misaki.HdrpToon
|
||||
_exposureArray = null;
|
||||
_hairShadowRTHandle?.Release();
|
||||
_hairBlendingRTHandle?.Release();
|
||||
_hairBlendingDepthRTHandle?.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Misaki.HdrpToon
|
||||
targetDepthBuffer = CustomPass.TargetBuffer.Camera,
|
||||
};
|
||||
|
||||
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.BeforeRendering, _utsPass);
|
||||
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, _utsPass);
|
||||
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.BeforePostProcess, _outlinePass);
|
||||
|
||||
NotifyRendererSettingChanged();
|
||||
|
||||
@@ -13,7 +13,6 @@ public sealed class UTSTonemapping : CustomPostProcessVolumeComponent, IPostProc
|
||||
|
||||
public bool IsActive() => _material != null && state.value;
|
||||
|
||||
// Do not forget to add this post process in the Custom Post Process Orders list (Project Settings > Graphics > HDRP Global Settings).
|
||||
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
|
||||
|
||||
const string Shader_Name = "Hidden/Shader/UTSTonemapping";
|
||||
@@ -38,7 +37,7 @@ public sealed class UTSTonemapping : CustomPostProcessVolumeComponent, IPostProc
|
||||
}
|
||||
|
||||
_material.SetTexture("_MainTex", source);
|
||||
HDUtils.DrawFullScreen(cmd, _material, destination, shaderPassId: 0);
|
||||
HDUtils.DrawFullScreen(cmd, _material, destination);
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"com.unity.render-pipelines.high-definition": "17.0.0",
|
||||
"com.misaki.shader-gui": "1.1.0"
|
||||
"com.misaki.shader-gui": "1.1.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user