Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d19322b768 | |||
| 961db806e9 | |||
| 10331b93ff | |||
| abdf6196ed | |||
| 410af63578 | |||
| 5a282e0812 | |||
| b205c1523d | |||
| ea3e83157c | |||
| ee0b720b6d | |||
| b2136e1ff4 | |||
| 4ce84572d0 | |||
| eacbbc9b8b | |||
| d44ff7d58c | |||
| de370f845e | |||
| 3d06bb8129 | |||
| 680ebb72e5 | |||
| 74263900ac | |||
| 886432db7b | |||
| 281dfbc4f0 | |||
| ecd0cfdb9f | |||
| 3273812902 | |||
|
|
458afd880f | ||
|
|
a9b989fb19 | ||
|
|
27e743755d | ||
| 780b3f9f13 | |||
| 68870fe818 | |||
| 9822fa61ca | |||
| d92a103be2 | |||
|
|
068e501fad | ||
|
|
e8d1d5923a | ||
| f41c6c9b34 | |||
| 5d23bd906b | |||
|
|
181a53a3b2 | ||
|
|
d8b12a0ca9 | ||
|
|
018300e046 | ||
|
|
1a82022a6f | ||
|
|
fac66d8694 | ||
|
|
476fdc3774 | ||
|
|
6a8095d7e0 | ||
|
|
e6b58cb321 | ||
|
|
12a03e9c3c | ||
|
|
b838223551 | ||
|
|
b1ef8afc8d | ||
| 75a71635a0 | |||
|
|
d47641e5e2 | ||
|
|
9290223624 | ||
|
|
140734dc06 |
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/*
|
||||
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -2,6 +2,20 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [2.1.0] - 09-Jan-2025
|
||||
|
||||
### Added
|
||||
- Added HairBlending shader pass;
|
||||
- Added HairBlendingSetting in UTSRenderPassSetting;
|
||||
- Added MaterialType to UTS;
|
||||
- Added MaterialFeature scope to UTS material editor;
|
||||
|
||||
### Changed
|
||||
- Merged HairBlendingPass and HairShadowPass into UTSPass;
|
||||
|
||||
### Fixed
|
||||
- Fixed the bug that character box light can not update rotation correctly according to bound light source;
|
||||
|
||||
## [2.0.5] - 08-Jan-2025
|
||||
|
||||
### Added
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
SerializedObject m_SerializedObject;
|
||||
|
||||
public static AnimationCurve DefaultAnimationCurve()
|
||||
{
|
||||
return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
@@ -93,7 +98,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
var curve2 = obj.m_AnimationCurve;
|
||||
if (buttonIsPressed)
|
||||
{
|
||||
curve2 = SceneToonEvAdjustment.DefaultAnimationCurve();
|
||||
curve2 = DefaultAnimationCurve();
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<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="Unity.Rendering.HighDefinition.Toon.BoxLightAdjustment, Unity.Toonshader" style="flex-grow: 1;">
|
||||
<engine:VisualElement data-source-type="Misaki.HdrpToon.BoxLightAdjustment, Misaki.HdrpToon" style="flex-grow: 1;">
|
||||
<engine:Label text="Rendering" style="-unity-font-style: bold; margin-top: 4px; margin-bottom: 2px;" />
|
||||
<engine:VisualElement name="renderingGroup" style="padding-left: 8px;">
|
||||
<editor:RenderingLayerMaskField label="Layer Mask" value="DynamicTransform" type="UnityEngine.Rendering.HighDefinition.RenderingLayerMask, Unity.RenderPipelines.HighDefinition.Runtime">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="LayerMask" data-source-type="Unity.Rendering.HighDefinition.Toon.BoxLightAdjustment, Unity.Toonshader" binding-mode="TwoWay" />
|
||||
<engine:DataBinding property="value" data-source-path="LayerMask" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</editor:RenderingLayerMaskField>
|
||||
<editor:ObjectField label="Source Light" type="UnityEngine.Light, UnityEngine.CoreModule">
|
||||
@@ -30,21 +30,11 @@
|
||||
<engine:DataBinding property="index" data-source-path="followGameObjectPosition" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:DropdownField>
|
||||
<engine:DropdownField label="Follow Rotation" choices="Disable,Enable" index="0">
|
||||
<engine:FloatField label="Distance Offset" value="20">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="index" data-source-path="followGameObjectRotation" binding-mode="TwoWay" />
|
||||
<engine:DataBinding property="value" data-source-path="distanceOffset" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:DropdownField>
|
||||
<engine:Vector3Field label="Position Offset">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="positionOffset" binding-mode="TwoWay" />
|
||||
</Bindings>
|
||||
</engine:Vector3Field>
|
||||
<engine:Vector3Field label="Rotation Offset">
|
||||
<Bindings>
|
||||
<engine:DataBinding property="value" data-source-path="rotationOffset" binding-mode="TwoWay" source-to-ui-converters="QuaternionToVector3Converter" ui-to-source-converters="QuaternionToVector3Converter" />
|
||||
</Bindings>
|
||||
</engine:Vector3Field>
|
||||
</engine:FloatField>
|
||||
</engine:VisualElement>
|
||||
</engine:VisualElement>
|
||||
</engine:UXML>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29660dd543a3ad04ea860b6366d28b54
|
||||
guid: bcc6ebf595772354fbb5631c8e4cac04
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -99,16 +99,16 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderProp_Set_RimLightMask = "_Set_RimLightMask";
|
||||
internal const string ShaderProp_HighColor_Tex = "_HighColor_Tex";
|
||||
internal const string ShaderProp_Set_HighColorMask = "_Set_HighColorMask";
|
||||
internal const string ShaderProp_MatCap_Sampler = "_MatCap_Sampler";
|
||||
internal const string ShaderProp_MatCapMap = "_MatCapMap";
|
||||
internal const string ShaderProp_Set_MatcapMask = "_Set_MatcapMask";
|
||||
internal const string ShaderProp_OutlineTex = "_OutlineTex";
|
||||
internal const string ShaderProp_Outline_Sampler = "_Outline_Sampler";
|
||||
|
||||
internal const string ShaderPropCastHairShadow = "_Is_CastHairShadow";
|
||||
internal const string ShaderPropReceiveHairShadow = "_Is_ReceiveHairShadow";
|
||||
internal const string ShaderPropReceiveHairShadow = "_Receive_Hair_Shadow";
|
||||
|
||||
internal const string ShaderPropEyeParallax = "_Is_EyeParallax";
|
||||
internal const string ShaderPropEyebrowSeethrough = "_Is_EyebrowSeethrough";
|
||||
internal const string ShaderPropHairBlendingTarget = "_HairBlendingTarget";
|
||||
|
||||
internal const string ShaderPropSimpleUI = "_simpleUI";
|
||||
internal const string ShaderPropAutoRenderQueue = "_AutoRenderQueue";
|
||||
@@ -128,7 +128,10 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderPropUtsVersionZ = "_utsVersionZ";
|
||||
internal const string ShaderPropIsUnityToonShader = "_isUnityToonshader";
|
||||
internal const string ShaderPropShadowMode = "_Shadow_Mode";
|
||||
internal const string ShaderPropMaterialType = "_Material_Type";
|
||||
internal const string ShaderPropPBR = "_PBR_Mode";
|
||||
internal const string ShaderPropIDMode = "_Indirect_Diffuse_Mode";
|
||||
internal const string ShaderPropISMode = "_Indirect_Specular_Mode";
|
||||
internal const string ShaderPropOutline = "_OUTLINE";
|
||||
internal const string ShaderPropNormalMapToHighColor = "_Is_NormalMapToHighColor";
|
||||
internal const string ShaderPropIsNormalMapToRimLight = "_Is_NormalMapToRimLight";
|
||||
@@ -155,7 +158,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal const string ShaderPropInvert_MatcapMask = "_Inverse_MatcapMask";
|
||||
internal const string ShaderPropUse_BaseAs1st = "_Use_BaseAs1st";
|
||||
internal const string ShaderPropUse_1stAs2nd = "_Use_1stAs2nd";
|
||||
internal const string ShaderPropIs_NormalMapToBase = "_Is_NormalMapToBase";
|
||||
internal const string ShaderPropIs_ColorShift = "_Is_ColorShift";
|
||||
internal const string ShaderPropRimLight = "_RimLight";
|
||||
internal const string ShaderPropRimLight_FeatherOff = "_RimLight_FeatherOff";
|
||||
@@ -211,7 +213,11 @@ namespace UnityEditor.Rendering.Toon
|
||||
protected readonly string[] ClippingModeNames = { "Off", "On", "Clip Transparency" };
|
||||
protected readonly string[] StencilModeNames = { "Off", "Draw If Not Equal to", "Replace Stencil Buffer with" };
|
||||
protected readonly string[] ZTestModeNames = { "Disabled", "Never", "Less", "Equal", "LessEqual", "Greater", "NotEqual", "GreaterEqual", "Always" };
|
||||
protected readonly string[] PbrModeDefines = { "_PBR_Mode_OFF", "_PBR_Mode_ST", "_PBR_Mode_ANISO", "_PBR_Mode_KK", "_PBR_Mode_TOON" };
|
||||
|
||||
protected readonly string[] materialTypeDefines = { "_MATERIAL_TYPE_STANDARD", "_MATERIAL_TYPE_FRONTHAIR", "_MATERIAL_TYPE_FACE", "_MATERIAL_TYPE_EYE" };
|
||||
protected readonly string[] PbrModeDefines = { "_PBR_MODE_OFF", "_PBR_MODE_STANDARD", "_PBR_MODE_ANISOTROPY", "_PBR_MODE_HAIR", "_PBR_MODE_TOON" };
|
||||
protected readonly string[] IndirectDiffuseModeDefines = { "_INDIRECT_DIFFUSE_OFF", "_INDIRECT_DIFFUSE_IBL", "_INDIRECT_DIFFUSE_MATCAP", "_INDIRECT_DIFFUSE_RAMP" };
|
||||
protected readonly string[] IndirectSpecularModeDefines = { "_INDIRECT_SPECULAR_OFF", "_INDIRECT_SPECULAR_IBL", "_INDIRECT_SPECULAR_MATCAP" };
|
||||
|
||||
public enum UTS_ClippingMode
|
||||
{
|
||||
@@ -279,11 +285,30 @@ namespace UnityEditor.Rendering.Toon
|
||||
Normal, SDF
|
||||
}
|
||||
|
||||
public enum MaterialType
|
||||
{
|
||||
Standard,
|
||||
FrontHair,
|
||||
Face,
|
||||
Eye
|
||||
}
|
||||
|
||||
public enum PBRMode
|
||||
{
|
||||
Off, Standard, Anisotropy, KKHair, Toon
|
||||
}
|
||||
|
||||
public enum IndirectDiffuseMode
|
||||
{
|
||||
Off, IBL, Matcap, Ramp
|
||||
}
|
||||
|
||||
public enum IndirectSpecularMode
|
||||
{
|
||||
Off, IBL, Matcap
|
||||
}
|
||||
|
||||
|
||||
public enum OutlineMode
|
||||
{
|
||||
NormalDirection, PositionScaling
|
||||
@@ -309,23 +334,25 @@ namespace UnityEditor.Rendering.Toon
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
[UTS3InspectorHelpURL("instruction")]
|
||||
#endif // UNITY_2021_1_OR_NEWER
|
||||
protected enum Expandable
|
||||
protected enum Expandable : uint
|
||||
{
|
||||
Shader = 1 << 0,
|
||||
Basic = 1 << 1,
|
||||
ShadingStepAndFeather = 1 << 2,
|
||||
NormalMap = 1 << 3,
|
||||
Highlight = 1 << 4,
|
||||
Rimlight = 1 << 5,
|
||||
MatCap = 1 << 6,
|
||||
AngelRing = 1 << 7,
|
||||
Emission = 1 << 8,
|
||||
Outline = 1 << 9,
|
||||
TessellationLegacy = 1 << 10,
|
||||
TessellationHDRP = 1 << 11,
|
||||
SceneLight = 1 << 12,
|
||||
EnvironmentalLightEffectiveness = 1 << 13,
|
||||
MetaverseSettings = 1 << 14,
|
||||
MaterialFeature = 1 << 3,
|
||||
PBR = 1 << 4,
|
||||
AmbientMode = 1 << 5,
|
||||
Highlight = 1 << 6,
|
||||
Rimlight = 1 << 7,
|
||||
MatCap = 1 << 8,
|
||||
AngelRing = 1 << 9,
|
||||
Emission = 1 << 10,
|
||||
Outline = 1 << 11,
|
||||
TessellationLegacy = 1 << 12,
|
||||
TessellationHDRP = 1 << 13,
|
||||
SceneLight = 1 << 14,
|
||||
EnvironmentalLightEffectiveness = 1 << 15,
|
||||
MetaverseSettings = 1 << 16,
|
||||
}
|
||||
|
||||
// variables which must be gotten from shader at the beggning of GUI
|
||||
@@ -333,7 +360,10 @@ namespace UnityEditor.Rendering.Toon
|
||||
internal int m_renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry;
|
||||
// variables which just to be held.
|
||||
internal ShadowMode m_shadowMode;
|
||||
internal MaterialType m_materialType;
|
||||
internal PBRMode m_pbrMode;
|
||||
internal IndirectDiffuseMode m_IndirectDiffuseMode;
|
||||
internal IndirectSpecularMode m_IndirectSpecularMode;
|
||||
internal OutlineMode m_outlineMode;
|
||||
internal CullingMode m_cullingMode;
|
||||
internal EmissionMode m_emissionMode;
|
||||
@@ -397,7 +427,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
protected MaterialProperty set_2nd_ShadePosition = null;
|
||||
protected MaterialProperty shadingGradeMap = null;
|
||||
|
||||
|
||||
protected MaterialProperty hairBlendingMap = null;
|
||||
|
||||
protected MaterialProperty highColor_Tex = null;
|
||||
protected MaterialProperty highColor = null;
|
||||
@@ -409,7 +439,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
protected MaterialProperty ap_RimLight_Power = null;
|
||||
protected MaterialProperty set_RimLightMask = null;
|
||||
|
||||
protected MaterialProperty matCap_Sampler = null;
|
||||
protected MaterialProperty matCapMap = null;
|
||||
protected MaterialProperty matCapColor = null;
|
||||
protected MaterialProperty normalMapForMatCap = null;
|
||||
protected MaterialProperty bumpScaleMatcap = null;
|
||||
@@ -491,6 +521,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
set_2nd_ShadePosition = FindProperty(ShaderProp_Set_2nd_ShadePosition, props, false);
|
||||
shadingGradeMap = FindProperty(ShaderProp_ShadingGradeMap, props, false);
|
||||
|
||||
hairBlendingMap = FindProperty("_HairBlendingMap", props);
|
||||
|
||||
highColor_Tex = FindProperty(ShaderProp_HighColor_Tex, props);
|
||||
highColor = FindProperty("_HighColor", props);
|
||||
@@ -501,7 +532,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
set_RimLightMask = FindProperty(ShaderProp_Set_RimLightMask, props);
|
||||
|
||||
matCap_Sampler = FindProperty(ShaderProp_MatCap_Sampler, props);
|
||||
matCapMap = FindProperty(ShaderProp_MatCapMap, props);
|
||||
matCapColor = FindProperty("_MatCapColor", props);
|
||||
|
||||
normalMapForMatCap = FindProperty("_NormalMapForMatCap", props);
|
||||
@@ -513,8 +544,8 @@ namespace UnityEditor.Rendering.Toon
|
||||
angelRing_Sampler = FindProperty("_AngelRing_Sampler", props, false);
|
||||
angelRing_Color = FindProperty("_AngelRing_Color", props, false);
|
||||
|
||||
emissive_Tex = FindProperty("_Emissive_Tex", props);
|
||||
emissive_Color = FindProperty("_Emissive_Color", props);
|
||||
emissive_Tex = FindProperty("_EmissiveColorMap", props);
|
||||
emissive_Color = FindProperty("_EmissiveColor", props);
|
||||
|
||||
|
||||
outline_Sampler = FindProperty(ShaderProp_Outline_Sampler, props, false);
|
||||
@@ -615,7 +646,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent shaderFoldout = EditorGUIUtility.TrTextContent("Shader Settings", "Shader Settings provides basic settings that are not specific to cel-shading but are needed for general CG.");
|
||||
public static readonly GUIContent basicColorFoldout = EditorGUIUtility.TrTextContent("Shading Color Settings", "Three Color Map and Control Map Settings provide very basic settings for cel-shading in Unity Toon Shader.");
|
||||
public static readonly GUIContent shadingStepAndFeatherFoldout = EditorGUIUtility.TrTextContent("Shading Step and Feather Settings", "Basic 3 color step and feather settings.");
|
||||
public static readonly GUIContent normalMapFoldout = EditorGUIUtility.TrTextContent("PBR Settings", "PBR settings. The settings for PBR effect, such as specular and IBL.");
|
||||
public static readonly GUIContent materialFeatureFoldout = EditorGUIUtility.TrTextContent("Material Feature", "Material Feature Setting. The settings for special material feature like hair shadow, hair blending, etc");
|
||||
public static readonly GUIContent pbrFoldout = EditorGUIUtility.TrTextContent("PBR Settings", "PBR settings. The settings for PBR effect, such as specular and IBL.");
|
||||
public static readonly GUIContent ambientModeFoldout = EditorGUIUtility.TrTextContent("Ambient Settings", "Ambient settings. The settings for ambient lighting like IBL, Matcap, etc.");
|
||||
public static readonly GUIContent highlightFoldout = EditorGUIUtility.TrTextContent("Highlight Settings", "Highlight settings. Such as power, show or hide, light shape and so on.");
|
||||
public static readonly GUIContent rimLightFoldout = EditorGUIUtility.TrTextContent("Rim Light Settings", "Rim Light Settings. Such as color, direction, inverted rim light and so on.");
|
||||
public static readonly GUIContent matCapFoldout = EditorGUIUtility.TrTextContent("Material Capture (MatCap) Settings", "MatCap settings. Sphere maps for metallic or unusual expressions.");
|
||||
@@ -635,10 +668,14 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent SDFShadowText = new GUIContent("SDF Shadow Map", "Specify SDF shadow map");
|
||||
public static readonly GUIContent firstShadeColorText = new GUIContent("1st Shading Map", "The map used for the brighter portions of the shadow.");
|
||||
public static readonly GUIContent secondShadeColorText = new GUIContent("2nd Shading Map", "The map used for the darker portions of the shadow.");
|
||||
public static readonly GUIContent materialTypeText = new GUIContent("Material Type", "Specifies the material type.");
|
||||
public static readonly GUIContent hairBlendingTargetMapText = new GUIContent("Blending Map", "Specifies the texture to blend with hair.");
|
||||
public static readonly GUIContent normalMapText = new GUIContent("Normal Map", "A texture that dictates the bumpiness of the material.");
|
||||
public static readonly GUIContent pbrModeText = new GUIContent("PBR Mode", "Specifies PBR model mode.");
|
||||
public static readonly GUIContent indirectDiffuseModeText = new GUIContent("Indirect Diffuse Mode", "Specifies indirect diffuse mode.");
|
||||
public static readonly GUIContent indirectSpecularText = new GUIContent("Indirect Specular Mode", "Specifies indirect specular mode.");
|
||||
public static readonly GUIContent highColorText = new GUIContent("Highlight", "Highlight : Texture(sRGB) x Color(RGB) Default:White");
|
||||
public static readonly GUIContent highColorMaskText = new GUIContent("Highlight Mask", "A grayscale texture which utilises its brightness to control intensity.");
|
||||
public static readonly GUIContent highColorMaskText = new GUIContent("Highlight Mask", "A grayscale texture which utilizes its brightness to control intensity.");
|
||||
public static readonly GUIContent rimLightMaskText = new GUIContent("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 matCapSamplerText = new GUIContent("MatCap Map", "MatCap Color : Texture(sRGB) x Color(RGB) Default:White");
|
||||
public static readonly GUIContent matCapMaskText = new GUIContent("MatCap Mask", "The MatCap mask is positioned with respect to the UV coordinates of the mesh onto which the MatCap is projected, and the pixels on black areas are hidden.");
|
||||
@@ -650,7 +687,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent outlineSamplerText = new GUIContent("Outline Width Map", "Outline Width Map as Grayscale Texture : Texture(linear). In the case of white, the Outline Width is displayed as it is. In black, the width is 0.");
|
||||
public static readonly GUIContent outlineTexText = new GUIContent("Outline Color Map", "Outline texture : Texture(sRGB) Default:White");
|
||||
public static readonly GUIContent bakedNormalOutlineText = new GUIContent("Baked Normal Map for Outline", "Unpacked Normal Map : Texture(linear) .Note that this is not a standard NORMAL MAP.");
|
||||
public static readonly GUIContent clippingMaskText = new GUIContent("Clipping Mask", "A grayscale texture which utilises its brightness to control transparency.");
|
||||
public static readonly GUIContent clippingMaskText = new GUIContent("Clipping Mask", "A grayscale texture which utilizes its brightness to control transparency.");
|
||||
|
||||
public static readonly GUIContent specularModeText = new GUIContent("Specular Mode", "Specular light mode. Hard or Soft.");
|
||||
public static readonly GUIContent specularBlendModeText = new GUIContent("Color Blending Mode", "Specular color blending mode. Multiply or Add.");
|
||||
@@ -660,7 +697,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
public static readonly GUIContent transparentModeText = new GUIContent("Transparency", "Enable different modes that allow the simulation of a variety of transparent objects. ");
|
||||
public static readonly GUIContent stencilVauleText = new GUIContent("Stencil Value", "Stencil value that is submitted to the stencil buffer for controlling the per-pixel drawing.");
|
||||
public static readonly GUIContent workflowModeText = new GUIContent("Mode", "The UTS mode that controls what settings are exposed in the shader.");
|
||||
public static readonly GUIContent materialTypeText = new GUIContent("Material Type", "The PBR model type of the material");
|
||||
|
||||
// -----------------------------------------------------
|
||||
public static readonly GUIContent clippingmodeModeText = new GUIContent("Trans Clipping", "Select trans clipping mode that fits your purpose. ");
|
||||
@@ -686,6 +722,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
public static readonly GUIContent hairShadowCasterText = new GUIContent("Hair Shadow Caster", "Enable to cast hair shadow");
|
||||
public static readonly GUIContent receiveHairShadowText = new GUIContent("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||
public static readonly GUIContent hairBlendingTargetShadowText = new GUIContent("Hair Blending Target", "Enable to be blended with hair");
|
||||
public static readonly GUIContent eyeParallaxText = new GUIContent("Eye Parallax Correction", "Enables parallax correction for eye material");
|
||||
public static readonly GUIContent eyebrowSeethroughText = new GUIContent("Eyebrow Seethrough", "Enable for eyebrow material to be blended with hair. Must configure HairShadowPass to work.");
|
||||
|
||||
@@ -822,9 +859,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
label: "Eye Parallax Amount", tooltip: "Distance of parallax correction",
|
||||
propName: "_EyeParallaxAmount", defaultValue: 0.1f, min: 0.0f, max: 0.4f);
|
||||
|
||||
public static readonly RangeProperty eyeBrowBlendingFactor = new RangeProperty(
|
||||
label: "Eyebrow Blending Factor", tooltip: "Blend Factor of Eyebrows on Hair",
|
||||
propName: "_EyeBrowBlendingFactor", defaultValue: 0.5f, min: 0.0f, max: 1.0f);
|
||||
public static readonly RangeProperty hairBlendingFactor = new RangeProperty(
|
||||
label: "Hair Blending Factor", tooltip: "Blend Factor of Hair Blending Target on Hair",
|
||||
propName: "_HairBlendingFactor", defaultValue: 0.5f, min: 0.0f, max: 1.0f);
|
||||
|
||||
public static readonly RangeProperty shaderPropStepOffsetText = new RangeProperty(
|
||||
label: "Step Offset", tooltip: "Fine tunes light steps (boundaries) added in the ForwardAdd pass, such as real-time point lights.",
|
||||
@@ -930,12 +967,12 @@ namespace UnityEditor.Rendering.Toon
|
||||
propName: "_RimLight_InsideMask", defaultValue: 0.0001f, min: 0.0001f, max: 1);
|
||||
|
||||
public static readonly RangeProperty SSAOFactorText = new RangeProperty(
|
||||
label: "SSAO Minimum", "The minimum value of SSAO.",
|
||||
propName: "_AOMin", defaultValue: 0.0f, min: 0, max: 1);
|
||||
label: "SSAO Factor", "The weight of SSAO.",
|
||||
propName: "_AO_Factor", defaultValue: 0.0f, min: 0, max: 1);
|
||||
|
||||
public static readonly RangeProperty SSGIFactorText = new RangeProperty(
|
||||
label: "SSGI Factor", "The multiplier of SSGI.",
|
||||
propName: "_GIMultiplier", defaultValue: 1.0f, min: 1, max: 10);
|
||||
label: "SSGI Factor", "The weight of SSGI.",
|
||||
propName: "_GI_Factor", defaultValue: 1.0f, min: 1, max: 10);
|
||||
|
||||
public static readonly RangeProperty BSDFContribution = new RangeProperty(
|
||||
label: "BSDF Contribution", "BSDF smoothness contribution, 1 means KK Hair smoothness will fully contribute bsdf calculation",
|
||||
@@ -1003,7 +1040,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.shaderFoldout, Expandable.Shader, DrawShaderOptions, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.basicColorFoldout, Expandable.Basic, GUI_BasicThreeColors, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.shadingStepAndFeatherFoldout, Expandable.ShadingStepAndFeather, GUI_StepAndFeather, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.normalMapFoldout, Expandable.NormalMap, GUI_PBRSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.materialFeatureFoldout, Expandable.MaterialFeature, GUI_MaterialFeature, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.pbrFoldout, Expandable.PBR, GUI_PBRSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.ambientModeFoldout, Expandable.AmbientMode, GUI_AmbientMode, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.highlightFoldout, Expandable.Highlight, GUI_HighlightSettings, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.rimLightFoldout, Expandable.Rimlight, GUI_RimLight, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
m_MaterialScopeList.RegisterHeaderScope(Styles.matCapFoldout, Expandable.MatCap, GUI_MatCap, (uint)UTS_TransparentMode.Off, isTessellation: 0);
|
||||
@@ -1494,13 +1533,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
{
|
||||
GUI_AdditionalLookdevs(material);
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
GUI_HairShadow(material);
|
||||
|
||||
GUI_EyeParallax(material);
|
||||
|
||||
GUI_EyebrowSeethrough(material);
|
||||
}
|
||||
|
||||
void GUI_SystemShadows(Material material)
|
||||
@@ -1518,71 +1550,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
void GUI_HairShadow(Material material)
|
||||
{
|
||||
var isCastEnable = GUI_Toggle(material, Styles.hairShadowCasterText, ShaderPropCastHairShadow,
|
||||
MaterialGetInt(material, ShaderPropCastHairShadow) != 0);
|
||||
|
||||
var isReceiveEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
MaterialGetInt(material, ShaderPropReceiveHairShadow) != 0);
|
||||
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, isCastEnable);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW"), isReceiveEnabled);
|
||||
}
|
||||
|
||||
void GUI_EyeParallax(Material material)
|
||||
{
|
||||
var isEnabled = GUI_Toggle(material, Styles.eyeParallaxText, ShaderPropEyeParallax,
|
||||
MaterialGetInt(material, ShaderPropEyeParallax) != 0);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!isEnabled);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
GUI_RangeProperty(material, Styles.eyeParallaxAmount);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_EYE_PARALLAX"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_EYE_PARALLAX"));
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_EyebrowSeethrough(Material material)
|
||||
{
|
||||
var isEnabled = GUI_Toggle(material, Styles.eyebrowSeethroughText, ShaderPropEyebrowSeethrough,
|
||||
MaterialGetInt(material, ShaderPropEyebrowSeethrough) != 0);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!isEnabled);
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
GUI_RangeProperty(material, Styles.eyeBrowBlendingFactor);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_EYEBROW_SEETHROUGH"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_EYEBROW_SEETHROUGH"));
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_ShadingStepAndFeatherSettings(Material material)
|
||||
{
|
||||
var shadowMode_Setting = MaterialGetInt(material, ShaderPropShadowMode);
|
||||
@@ -1606,7 +1573,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
case ShadowMode.Normal:
|
||||
{
|
||||
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.Normal);
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SHADOW_MODE_SDF"));
|
||||
|
||||
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_StepText);
|
||||
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_FeatherText);
|
||||
@@ -1624,7 +1591,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
case ShadowMode.SDF:
|
||||
{
|
||||
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.SDF);
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_SDFShadow"));
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_SHADOW_MODE_SDF"));
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.SDFShadowText, SDFShadowMap);
|
||||
GUI_RangeProperty(material, Styles.SDFShadowLevelText);
|
||||
GUI_RangeProperty(material, Styles.SDFSmoothGammaText);
|
||||
@@ -1648,60 +1615,106 @@ namespace UnityEditor.Rendering.Toon
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
void GUI_PBRSettings(Material material)
|
||||
void GUI_MaterialFeature(Material material)
|
||||
{
|
||||
var PBRMode_Setting = MaterialGetInt(material, ShaderPropPBR);
|
||||
//Convert it to Enum format and store it in the offlineMode variable.
|
||||
var materialTypeSetting = MaterialGetInt(material, ShaderPropMaterialType);
|
||||
m_materialType = (MaterialType)materialTypeSetting;
|
||||
|
||||
switch (PBRMode_Setting)
|
||||
m_materialType = (MaterialType)EditorGUILayout.EnumPopup(Styles.materialTypeText, m_materialType);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
switch (m_materialType)
|
||||
{
|
||||
case (int)PBRMode.Off:
|
||||
m_pbrMode = PBRMode.Off;
|
||||
case MaterialType.FrontHair:
|
||||
GUI_FrontHair(material);
|
||||
break;
|
||||
case (int)PBRMode.Standard:
|
||||
m_pbrMode = PBRMode.Standard;
|
||||
case MaterialType.Eye:
|
||||
GUI_EyeParallax(material);
|
||||
break;
|
||||
case (int)PBRMode.Anisotropy:
|
||||
m_pbrMode = PBRMode.Anisotropy;
|
||||
break;
|
||||
case (int)PBRMode.KKHair:
|
||||
m_pbrMode = PBRMode.KKHair;
|
||||
break;
|
||||
case (int)PBRMode.Toon:
|
||||
m_pbrMode = PBRMode.Toon;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//GUI description with EnumPopup.
|
||||
m_pbrMode = (PBRMode)EditorGUILayout.EnumPopup(Styles.pbrModeText, m_pbrMode);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
|
||||
void SwitchPbrMode(string targetMode)
|
||||
var isReceiveHairShadowEnabled = GUI_Toggle(material, Styles.receiveHairShadowText, ShaderPropReceiveHairShadow,
|
||||
MaterialGetInt(material, ShaderPropReceiveHairShadow) != 0);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_RECEIVE_HAIR_SHADOW_ON"), isReceiveHairShadowEnabled);
|
||||
|
||||
var isHairBlendingTargetEnabled = GUI_Toggle(material, Styles.hairBlendingTargetShadowText, ShaderPropHairBlendingTarget,
|
||||
MaterialGetInt(material, ShaderPropHairBlendingTarget) != 0);
|
||||
if (isHairBlendingTargetEnabled)
|
||||
{
|
||||
foreach (var pbrMode in PbrModeDefines)
|
||||
EditorGUI.indentLevel++;
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.hairBlendingTargetMapText, hairBlendingMap);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, isHairBlendingTargetEnabled);
|
||||
|
||||
SwitchKeyword(m_materialType);
|
||||
material.SetFloat(ShaderPropMaterialType, (float)m_materialType);
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, m_materialType == MaterialType.FrontHair);
|
||||
|
||||
void SwitchKeyword(MaterialType target)
|
||||
{
|
||||
for (var i = 0; i < materialTypeDefines.Length; i++)
|
||||
{
|
||||
if (targetMode == pbrMode)
|
||||
var localKeyword = new LocalKeyword(material.shader, materialTypeDefines[i]);
|
||||
if ((int)target == i)
|
||||
{
|
||||
material.EnableKeyword(pbrMode);
|
||||
material.EnableKeyword(localKeyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(pbrMode);
|
||||
material.DisableKeyword(localKeyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_FrontHair(Material material)
|
||||
{
|
||||
GUI_RangeProperty(material, Styles.hairBlendingFactor);
|
||||
}
|
||||
|
||||
void GUI_EyeParallax(Material material)
|
||||
{
|
||||
GUI_RangeProperty(material, Styles.eyeParallaxAmount);
|
||||
}
|
||||
|
||||
void SwitchKeywrod(Material material, string targetKeywrod, string[] sources)
|
||||
{
|
||||
foreach (var keywrod in sources)
|
||||
{
|
||||
if (targetKeywrod == keywrod)
|
||||
{
|
||||
material.EnableKeyword(keywrod);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keywrod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_PBRSettings(Material material)
|
||||
{
|
||||
m_pbrMode = (PBRMode)MaterialGetInt(material, ShaderPropPBR);
|
||||
m_pbrMode = (PBRMode)EditorGUILayout.EnumPopup(Styles.pbrModeText, m_pbrMode);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
material.SetFloat(ShaderPropPBR, (int)m_pbrMode);
|
||||
SwitchPbrMode(PbrModeDefines[(int)m_pbrMode]);
|
||||
SwitchKeywrod(material, PbrModeDefines[(int)m_pbrMode], PbrModeDefines);
|
||||
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"), normalMap.textureValue != null);
|
||||
|
||||
if (m_pbrMode != PBRMode.Off)
|
||||
{
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.MaskMapText, Mask);
|
||||
if (Mask.textureValue == null)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
if (m_pbrMode != PBRMode.KKHair)
|
||||
{
|
||||
GUI_RangeProperty(material, Styles.MetallicText);
|
||||
@@ -1710,7 +1723,7 @@ namespace UnityEditor.Rendering.Toon
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
|
||||
m_MaterialEditor.MinMaxShaderProperty(MetallicRemapMin, MetallicRemapMax, minLimit: 0, 1, Styles.MetallicRemap);
|
||||
m_MaterialEditor.MinMaxShaderProperty(AORemapMin, AORemapMax, 0, 1, Styles.AORemap);
|
||||
m_MaterialEditor.MinMaxShaderProperty(RoughnessRemapMin, RoughnessRemapMax, 0, 1, Styles.RoughnessRemap);
|
||||
@@ -1718,9 +1731,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP"));
|
||||
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"));
|
||||
|
||||
}
|
||||
|
||||
@@ -1739,11 +1752,11 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
if (AnisotropyMap.textureValue == null)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP"));
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1752,11 +1765,11 @@ namespace UnityEditor.Rendering.Toon
|
||||
m_MaterialEditor.TexturePropertySingleLine(new GUIContent("Specular Color Map"), SpecColorMap, SpecColor);
|
||||
if (SpecColorMap.textureValue == null)
|
||||
{
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP"));
|
||||
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP"));
|
||||
material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
|
||||
}
|
||||
m_MaterialEditor.MinMaxShaderProperty(SpecFeather, SpecStep, 0, 1, Styles.SpecRemap);
|
||||
}
|
||||
@@ -1802,6 +1815,22 @@ namespace UnityEditor.Rendering.Toon
|
||||
MaterialSetInt(material, "_Use_SSSLut", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_AmbientMode(Material material)
|
||||
{
|
||||
m_IndirectDiffuseMode = (IndirectDiffuseMode)MaterialGetInt(material, ShaderPropIDMode);
|
||||
m_IndirectDiffuseMode = (IndirectDiffuseMode)EditorGUILayout.EnumPopup(Styles.indirectDiffuseModeText, m_IndirectDiffuseMode);
|
||||
|
||||
material.SetFloat(ShaderPropIDMode, (int)m_IndirectDiffuseMode);
|
||||
SwitchKeywrod(material, IndirectDiffuseModeDefines[(int)m_IndirectDiffuseMode], IndirectDiffuseModeDefines);
|
||||
|
||||
m_IndirectSpecularMode = (IndirectSpecularMode)MaterialGetInt(material, ShaderPropISMode);
|
||||
m_IndirectSpecularMode = (IndirectSpecularMode)EditorGUILayout.EnumPopup(Styles.indirectSpecularText, m_IndirectSpecularMode);
|
||||
|
||||
material.SetFloat(ShaderPropISMode, (int)m_IndirectSpecularMode);
|
||||
SwitchKeywrod(material, IndirectSpecularModeDefines[(int)m_IndirectSpecularMode], IndirectSpecularModeDefines);
|
||||
}
|
||||
|
||||
void GUI_HighlightSettings(Material material)
|
||||
{
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.highColorText, highColor_Tex, highColor);
|
||||
@@ -1880,7 +1909,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
void GUI_RimLight(Material material)
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
var rimLightEnabled = GUI_Toggle(material, Styles.rimlightText, ShaderPropRimLight, MaterialGetInt(material, ShaderPropRimLight) != 0);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
@@ -1960,10 +1988,6 @@ namespace UnityEditor.Rendering.Toon
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GUI_MatCap(Material material)
|
||||
@@ -1973,9 +1997,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.BeginDisabledGroup(!matcapEnabled);
|
||||
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.matCapSamplerText, matCap_Sampler, matCapColor);
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.matCapSamplerText, matCapMap, matCapColor);
|
||||
EditorGUI.indentLevel++;
|
||||
m_MaterialEditor.TextureScaleOffsetProperty(matCap_Sampler);
|
||||
m_MaterialEditor.TextureScaleOffsetProperty(matCapMap);
|
||||
|
||||
if (!_SimpleUI)
|
||||
{
|
||||
@@ -2219,9 +2243,9 @@ namespace UnityEditor.Rendering.Toon
|
||||
|
||||
void GUI_Emissive(Material material)
|
||||
{
|
||||
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveTexText, emissive_Tex, emissive_Color);
|
||||
m_MaterialEditor.TextureScaleOffsetProperty(emissive_Tex);
|
||||
material.SetKeyword(new LocalKeyword(material.shader, "_EMISSIVE_COLOR_MAP"), emissive_Tex.textureValue != null);
|
||||
|
||||
var _EmissiveMode_Setting = MaterialGetInt(material, "_EMISSIVE");
|
||||
if ((int)EmissionMode.SimpleEmissive == _EmissiveMode_Setting)
|
||||
@@ -2389,14 +2413,14 @@ namespace UnityEditor.Rendering.Toon
|
||||
{
|
||||
material.SetFloat(ShaderPropOutline, 0);
|
||||
//The keywords on the UTCS_Outline.cginc side are also toggled around.
|
||||
material.EnableKeyword("_OUTLINE_NML");
|
||||
material.DisableKeyword("_OUTLINE_POS");
|
||||
material.EnableKeyword("_OUTLINE_MODE_NML");
|
||||
material.DisableKeyword("_OUTLINE_MODE_POS");
|
||||
}
|
||||
else if (m_outlineMode == OutlineMode.PositionScaling)
|
||||
{
|
||||
material.SetFloat(ShaderPropOutline, 1);
|
||||
material.EnableKeyword("_OUTLINE_POS");
|
||||
material.DisableKeyword("_OUTLINE_NML");
|
||||
material.EnableKeyword("_OUTLINE_MODE_POS");
|
||||
material.DisableKeyword("_OUTLINE_MODE_NML");
|
||||
}
|
||||
|
||||
GUI_FloatProperty(material, Styles.outlineWidthText);
|
||||
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
|
||||
24
Editor/MeterialEditor/ShaderGUIExpandable.cs
Normal file
24
Editor/MeterialEditor/ShaderGUIExpandable.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public enum ShaderGUIExpandable : uint
|
||||
{
|
||||
SurfaceOptions = 1 << 0,
|
||||
ShadingColor = 1 << 1,
|
||||
Shadow = 1 << 2,
|
||||
MaterialFeature = 1 << 3,
|
||||
SurfaceInputs = 1 << 4,
|
||||
Ambient = 1 << 5,
|
||||
Highlight = 1 << 6,
|
||||
Rimlight = 1 << 7,
|
||||
MatCap = 1 << 8,
|
||||
AngelRing = 1 << 9,
|
||||
Emission = 1 << 10,
|
||||
Outline = 1 << 11,
|
||||
TessellationLegacy = 1 << 12,
|
||||
TessellationHDRP = 1 << 13,
|
||||
SceneLight = 1 << 14,
|
||||
EnvironmentalLightEffectiveness = 1 << 15,
|
||||
MetaverseSettings = 1 << 16,
|
||||
Advance = 1 << 17,
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/ShaderGUIExpandable.cs.meta
Normal file
2
Editor/MeterialEditor/ShaderGUIExpandable.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63067f176ae106c459bcb9cc105f626d
|
||||
8
Editor/MeterialEditor/UIScopes.meta
Normal file
8
Editor/MeterialEditor/UIScopes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc8d991d265341a4598574f90fc0e21c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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
|
||||
55
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
55
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty angelRingColor;
|
||||
public static MaterialProperty angelRingColorMap;
|
||||
public static MaterialProperty angelRingIntensity;
|
||||
public static MaterialProperty angelRingOffsetU;
|
||||
public static MaterialProperty angelRingOffsetV;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent angelRingColorText = new("Angel Ring Color", "Specifies the color of the angel ring.");
|
||||
public static readonly GUIContent angelRingIntensityText = new("Angel Ring Intensity", "Specifies the intensity of the angel ring.");
|
||||
public static readonly GUIContent angelRingOffsetUText = new("Angel Ring Offset U", "Specifies the offset of the angel ring in the U direction.");
|
||||
public static readonly GUIContent angelRingOffsetVText = new("Angel Ring Offset V", "Specifies the offset of the angel ring in the V direction.");
|
||||
}
|
||||
|
||||
protected override bool ShowSection => materials.All(mat => mat.HasFeature(SurfaceFeature.AngelRing));
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Angel Ring Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
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()
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.angelRingColorText, Properties.angelRingColorMap, Properties.angelRingColor);
|
||||
editor.ShaderProperty(Properties.angelRingIntensity, Styles.angelRingIntensityText);
|
||||
editor.ShaderProperty(Properties.angelRingOffsetU, Styles.angelRingOffsetUText);
|
||||
editor.ShaderProperty(Properties.angelRingOffsetV, Styles.angelRingOffsetVText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.TextureScaleOffsetProperty(Properties.angelRingColorMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f21124eb2f73ac14e8cda9a0340191cd
|
||||
92
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
92
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
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;
|
||||
|
||||
public static MaterialProperty useSmoothedNormal;
|
||||
}
|
||||
|
||||
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 ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.outlineState = FindProperty(OUTLINE_STATE);
|
||||
|
||||
Properties.outlineWidth = FindProperty(OUTLINE_WIDTH);
|
||||
Properties.outlineWidthMap = FindProperty(OUTLINE_WIDTH_MAP);
|
||||
|
||||
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.fadeIn = FindProperty(OUTLINE_FADE_IN);
|
||||
Properties.fadeOut = FindProperty(OUTLINE_FADE_OUT);
|
||||
|
||||
Properties.useSmoothedNormal = FindProperty(USE_SMOOTHED_NORMAL);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac42903bc14e05f41a9a06d1e6cf5cd9
|
||||
84
Editor/MeterialEditor/UIScopes/RimLightScope.cs
Normal file
84
Editor/MeterialEditor/UIScopes/RimLightScope.cs
Normal file
@@ -0,0 +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 rimLightColor;
|
||||
public static MaterialProperty rimLightIntensity;
|
||||
|
||||
public static MaterialProperty screenSpaceRimLight;
|
||||
public static MaterialProperty rimLightLevel;
|
||||
public static MaterialProperty rimLightClipping;
|
||||
public static MaterialProperty rimLightClippingLevel;
|
||||
|
||||
public static MaterialProperty lightBaseRimLight;
|
||||
public static MaterialProperty lightDirectionRimLightLevel;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
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 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 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 => 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/MeterialEditor/UIScopes/RimLightScope.cs.meta
Normal file
3
Editor/MeterialEditor/UIScopes/RimLightScope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c18934f763fe4f3cb5e6f02599209764
|
||||
timeCreated: 1738311777
|
||||
163
Editor/MeterialEditor/UIScopes/ShadingColorScope.cs
Normal file
163
Editor/MeterialEditor/UIScopes/ShadingColorScope.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class ShadingColorScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty shadingRampMapState;
|
||||
|
||||
public static MaterialProperty baseColor;
|
||||
public static MaterialProperty baseColorMap;
|
||||
public static MaterialProperty applyTo1stShadingMapEnable;
|
||||
public static MaterialProperty firstShadingColor;
|
||||
public static MaterialProperty firstShadingMap;
|
||||
public static MaterialProperty applyTo2ndShadingMapEnable;
|
||||
public static MaterialProperty secondShadingColor;
|
||||
public static MaterialProperty secondShadingMap;
|
||||
|
||||
public static MaterialProperty firstShadeColorStep;
|
||||
public static MaterialProperty firstShadeColorFeather;
|
||||
public static MaterialProperty secondShadeColorStep;
|
||||
public static MaterialProperty secondShadeColorFeather;
|
||||
|
||||
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 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.");
|
||||
public static readonly GUIContent firstShadingMapText = new("1st Shading Map", "The map used for the brighter portions of the shadow.");
|
||||
public static readonly GUIContent applyTo2ndShadingMapText = new("Apply to 2nd shading map", "Apply Base map or the 1st shading map to the 2st shading map.");
|
||||
public static readonly GUIContent secondShadingMapText = new("2nd Shading Map", "The map used for the darker portions of the shadow.");
|
||||
|
||||
public static readonly GUIContent firstShadeColorStepText = new("1st Shade Color Step", "Sets the step between the Base color and 1st Shade Color, the same as the BaseColor_Step property.");
|
||||
public static readonly GUIContent firstShadeColorFeatherText = new("1st Shade Color Feather", "Sets the feather between the Base color and 1st Shade Color, the same as the BaseColor_Feather property.");
|
||||
public static readonly GUIContent secondShadeColorStepText = new("2nd Shade Color Step", "Sets the step between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorStep property.");
|
||||
public static readonly GUIContent secondShadeColorFeatherText = new("2nd Shade Color Feather", "Sets the feather between the 1st Shade color and 2nd Shade Color, the same as the 1stShadeColorFeather property.");
|
||||
|
||||
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 hairBlendingFactorText = new("Hair Blending Factor", "The blending factor for hair shading.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.ShadingColor;
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Shading Color Settings");
|
||||
|
||||
private void DrawShadingProperties(MaterialProperty inheritProperty, MaterialProperty colorProperty, MaterialProperty colorMapProperty, GUIContent inheritText, GUIContent colorText)
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ShaderProperty(inheritProperty, inheritText);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
if (Mathf.Approximately(inheritProperty.floatValue, 1))
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
editor.ShaderProperty(colorProperty, colorText);
|
||||
EditorGUI.indentLevel -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.TexturePropertySingleLine(colorText, colorMapProperty, colorProperty);
|
||||
}
|
||||
}
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.shadingRampMapState = FindProperty("_Use_Shading_Ramp_Map");
|
||||
|
||||
Properties.baseColor = FindProperty("_BaseColor");
|
||||
Properties.baseColorMap = FindProperty("_BaseColorMap");
|
||||
Properties.applyTo1stShadingMapEnable = FindProperty("_UseBaseAs1st");
|
||||
Properties.firstShadingColor = FindProperty("_1stShadeColor");
|
||||
Properties.firstShadingMap = FindProperty("_1stShadeColorMap");
|
||||
Properties.applyTo2ndShadingMapEnable = FindProperty("_Use1stAs2nd");
|
||||
Properties.secondShadingColor = FindProperty("_2ndShadeColor");
|
||||
Properties.secondShadingMap = FindProperty("_2ndShadeColorMap");
|
||||
|
||||
Properties.firstShadeColorStep = FindProperty("_1stShadeColorStep");
|
||||
Properties.firstShadeColorFeather = FindProperty("_1stShadeColorFeather");
|
||||
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.hairBlendingFactor = FindProperty("_HairBlendingFactor");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.shadingRampMapState, Styles.shadingRampMapStateText);
|
||||
editor.TexturePropertySingleLine(Styles.baseColorText, Properties.baseColorMap, Properties.baseColor);
|
||||
|
||||
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 (materials.All(material => material.GetShadingMode() == ShadingMode.Standard))
|
||||
{
|
||||
DrawShadingProperties(Properties.applyTo2ndShadingMapEnable, Properties.secondShadingColor, Properties.secondShadingMap, Styles.applyTo2ndShadingMapText, Styles.secondShadingMapText);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.firstShadeColorStep, Styles.firstShadeColorStepText);
|
||||
editor.ShaderProperty(Properties.firstShadeColorFeather, Styles.firstShadeColorFeatherText);
|
||||
editor.ShaderProperty(Properties.secondShadeColorStep, Styles.secondShadeColorStepText);
|
||||
editor.ShaderProperty(Properties.secondShadeColorFeather, Styles.secondShadeColorFeatherText);
|
||||
}
|
||||
}
|
||||
|
||||
if (materials.All(material => material.GetShadingMode() == ShadingMode.SDF))
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
editor.TexturePropertySingleLine(Styles.sdfShadingMapText, Properties.sdfShadingMap);
|
||||
editor.ShaderProperty(Properties.sdfShadowLevel, Styles.sdfShadowLevelText);
|
||||
editor.ShaderProperty(Properties.sdfSmoothLevel, Styles.sdfSmoothLevelText);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UIScopes/ShadingColorScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/ShadingColorScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35d7c7fd9279ea64199f1aa61c24fbcd
|
||||
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
|
||||
100
Editor/MeterialEditor/UIScopes/SurfaceOptionsScope.cs
Normal file
100
Editor/MeterialEditor/UIScopes/SurfaceOptionsScope.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
internal class SurfaceOptionsScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty transparentMode;
|
||||
|
||||
public static MaterialProperty alphaClipEnable;
|
||||
public static MaterialProperty alphaClip;
|
||||
|
||||
public static MaterialProperty cullMode;
|
||||
public static MaterialProperty shadingMode;
|
||||
public static MaterialProperty materialType;
|
||||
public static MaterialProperty pbrMode;
|
||||
|
||||
public static MaterialProperty hairBlendingTarget;
|
||||
public static MaterialProperty surfaceFeatures;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent transparentModeText = new("Transparent Mode", "Enable different modes that allow the simulation of a variety of transparent objects.");
|
||||
|
||||
public static readonly GUIContent alphaClipEnableText = new("Alpha Clipping", "Enable alpha clipping.");
|
||||
public static readonly GUIContent alphaClipText = new("Alpha Clipping Threshold", "Threshold for alpha clipping.");
|
||||
|
||||
public static readonly GUIContent cullingModeText = new("Culling Mode", "Controls the sides of polygons that should not be drawn (culled).");
|
||||
public static readonly GUIContent shadingModeText = new("Shading Color Mode", "Specifies the shading grade mode.");
|
||||
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 hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
||||
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
||||
}
|
||||
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
|
||||
|
||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||
|
||||
Properties.alphaClipEnable = FindProperty("_AlphaCutoffEnable");
|
||||
Properties.alphaClip = FindProperty("_AlphaCutoff");
|
||||
|
||||
Properties.cullMode = FindProperty("_CullMode");
|
||||
Properties.shadingMode = FindProperty("_Shading_Mode");
|
||||
Properties.materialType = FindProperty("_Material_Type");
|
||||
Properties.pbrMode = FindProperty("_PBR_Mode");
|
||||
|
||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.transparentMode, Styles.transparentModeText);
|
||||
|
||||
editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText);
|
||||
if (Properties.alphaClipEnable.GetBooleanValue())
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
|
||||
editor.ShaderProperty(Properties.shadingMode, Styles.shadingModeText);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
|
||||
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.pbrMode, Styles.pbrModeText);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.GetBooleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f62b264626a3bbd42a7b45b899084983
|
||||
57
Editor/MeterialEditor/UTSShaderGUI.cs
Normal file
57
Editor/MeterialEditor/UTSShaderGUI.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class UTSShaderGUI : ScopedShaderGUI
|
||||
{
|
||||
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)
|
||||
{
|
||||
OnInitialize(materialEditor, properties);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("HDRP Toon Shader", _headerStyle);
|
||||
EditorGUILayout.Space(20);
|
||||
|
||||
DrawShaderGUI(properties);
|
||||
}
|
||||
|
||||
private void OnInitialize(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
AddUIScope(new SurfaceOptionsScope());
|
||||
AddUIScope(new ShadingColorScope());
|
||||
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,
|
||||
normal =
|
||||
{
|
||||
textColor = GUI.skin.label.normal.textColor
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/MeterialEditor/UTSShaderGUI.cs.meta
Normal file
2
Editor/MeterialEditor/UTSShaderGUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41e8a43d8ee32f04cbf2ac4d1db45948
|
||||
@@ -7,7 +7,9 @@
|
||||
"Unity.RenderPipelines.Core.Editor",
|
||||
"Unity.RenderPipelines.HighDefinition.Runtime",
|
||||
"Unity.RenderPipelines.HighDefinition.Editor",
|
||||
"Unity.Collections"
|
||||
"Unity.Mathematics",
|
||||
"Unity.Collections",
|
||||
"Misaki.ShaderGUI"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
@@ -29,11 +31,6 @@
|
||||
"expression": "",
|
||||
"define": "SRPCORE_IS_INSTALLED_FOR_UTS"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.render-pipelines.universal",
|
||||
"expression": "",
|
||||
"define": "URP_IS_INSTALLED_FOR_UTS"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.render-pipelines.core",
|
||||
"expression": "12.0.0",
|
||||
|
||||
@@ -9,12 +9,17 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
class Styles
|
||||
{
|
||||
public static GUIContent outline = new("Outline Setting");
|
||||
public static GUIContent hairShadow = new("Hair Shadow Setting");
|
||||
public static GUIContent hairShadow = new("Hair Shadow");
|
||||
public static GUIContent hairBlending = new("Hair Blending");
|
||||
public static GUIContent outline = new("Outline");
|
||||
}
|
||||
|
||||
private SerializedObject _customSettings;
|
||||
|
||||
private SerializedProperty _hairShadowSetting;
|
||||
private SerializedProperty _hairBlendingSetting;
|
||||
private SerializedProperty _outlineSetting;
|
||||
|
||||
public UTSRendererSettingProvider(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path, scopes, keywords)
|
||||
{
|
||||
}
|
||||
@@ -22,21 +27,26 @@ namespace Misaki.HdrpToon.Editor
|
||||
public override void OnActivate(string searchContext, VisualElement rootElement)
|
||||
{
|
||||
_customSettings = UTSRenderPassSettings.GetSerializedSettings();
|
||||
|
||||
_hairShadowSetting = _customSettings.FindProperty("hairShadowSetting");
|
||||
_hairBlendingSetting = _customSettings.FindProperty("hairBlendingSetting");
|
||||
_outlineSetting = _customSettings.FindProperty("outlineSetting");
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(_customSettings.FindProperty("outlineSetting"), Styles.outline);
|
||||
EditorGUILayout.PropertyField(_customSettings.FindProperty("hairShadowSetting"), Styles.hairShadow);
|
||||
EditorGUILayout.PropertyField(_hairShadowSetting, Styles.hairShadow);
|
||||
EditorGUILayout.PropertyField(_hairBlendingSetting, Styles.hairBlending);
|
||||
EditorGUILayout.PropertyField(_outlineSetting, Styles.outline);
|
||||
_customSettings.ApplyModifiedPropertiesWithoutUndo();
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
UTSRenderPassRegistrar.NotifyRendererSettingChanged();
|
||||
}
|
||||
|
||||
_customSettings.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
public static bool IsSettingsAvailable()
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) 2024 Enjie Huang
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly: InternalsVisibleTo("Unity.ToonShader.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.VisualCompositor")]
|
||||
[assembly: InternalsVisibleTo("Unity.VisualCompositor.Tests")]
|
||||
[assembly: InternalsVisibleTo("Unity.VisualCompositor.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.VisualCompositor.EditorTests")]
|
||||
|
||||
|
||||
[assembly: InternalsVisibleTo("Misaki.HdrpToon.Editor")]
|
||||
@@ -17,19 +17,21 @@ namespace Misaki.HdrpToon
|
||||
private bool _initialized = false;
|
||||
private bool _srpCallbackInitialized = false;
|
||||
|
||||
[SerializeField]
|
||||
private HDAdditionalLightData _bindingSourceLightData;
|
||||
[SerializeField]
|
||||
private HDAdditionalLightData _targetBoxLightData;
|
||||
|
||||
[SerializeField]
|
||||
private uint _layerMask;
|
||||
[SerializeField]
|
||||
private Light _bindingSourceLight;
|
||||
[SerializeField]
|
||||
private Light _targetBoxLight;
|
||||
|
||||
public Transform trackedTransform;
|
||||
public bool followGameObjectPosition = false;
|
||||
public bool followGameObjectRotation = false;
|
||||
|
||||
public Vector3 positionOffset;
|
||||
public Quaternion rotationOffset;
|
||||
public float distanceOffset = 20.0f;
|
||||
|
||||
[CreateProperty]
|
||||
public Light BindingSourceLight
|
||||
@@ -64,8 +66,8 @@ namespace Misaki.HdrpToon
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateShadowLayer(_bindingSourceLightData, _layerMask, value);
|
||||
UpdateShadowLayer(_targetBoxLightData, _layerMask, value);
|
||||
UpdateShadowLayer(_bindingSourceLightData, value);
|
||||
UpdateShadowLayer(_targetBoxLightData, value);
|
||||
|
||||
_layerMask = value;
|
||||
}
|
||||
@@ -92,13 +94,9 @@ namespace Misaki.HdrpToon
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void LateUpdate()
|
||||
private void Update()
|
||||
{
|
||||
Initialize();
|
||||
|
||||
@@ -125,16 +123,12 @@ namespace Misaki.HdrpToon
|
||||
_targetBoxLight.enabled = _bindingSourceLight.enabled;
|
||||
_targetBoxLight.intensity = _bindingSourceLight.intensity;
|
||||
|
||||
if (trackedTransform != null)
|
||||
if (trackedTransform != null && followGameObjectPosition)
|
||||
{
|
||||
if (followGameObjectPosition)
|
||||
{
|
||||
_targetBoxLight.transform.position = trackedTransform.transform.position + positionOffset;
|
||||
}
|
||||
if (followGameObjectRotation)
|
||||
{
|
||||
_targetBoxLight.transform.rotation = trackedTransform.transform.rotation * rotationOffset;
|
||||
}
|
||||
var desiredPosition = trackedTransform.position - _bindingSourceLight.transform.forward * distanceOffset;
|
||||
|
||||
_targetBoxLight.transform.position = desiredPosition;
|
||||
_targetBoxLight.transform.rotation = _bindingSourceLight.transform.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,11 +164,6 @@ namespace Misaki.HdrpToon
|
||||
Release();
|
||||
}
|
||||
|
||||
private void UpdateObjectLightLayers()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
internal static GameObject CreateBoxLight(Transform transform)
|
||||
{
|
||||
if (transform == null)
|
||||
@@ -187,7 +176,7 @@ namespace Misaki.HdrpToon
|
||||
#if UNITY_EDITOR
|
||||
Undo.RegisterCreatedObjectUndo(lightGameObject, "Created Boxlight adjustment");
|
||||
#endif
|
||||
var hdLightData = lightGameObject.AddHDLight(LightType.Box);
|
||||
var hdLightData = lightGameObject.AddHDLight(UnityEngine.LightType.Box);
|
||||
// light size
|
||||
hdLightData.SetBoxSpotSize(new Vector2(10.0f, 10.0f)); // Size should be culculated with more acculacy?
|
||||
var boxLightAdjustment = lightGameObject.GetComponent<BoxLightAdjustment>();
|
||||
@@ -228,12 +217,11 @@ namespace Misaki.HdrpToon
|
||||
return lightGameObject;
|
||||
}
|
||||
|
||||
private void UpdateShadowLayer(HDAdditionalLightData lightData, uint oldValue, uint newValue)
|
||||
private void UpdateShadowLayer(HDAdditionalLightData lightData, uint newValue)
|
||||
{
|
||||
lightData.linkShadowLayers = false;
|
||||
var oldShadowLayer = lightData.GetShadowLayers();
|
||||
oldShadowLayer &= ~oldValue;
|
||||
var newShadowLayer = oldShadowLayer | newValue;
|
||||
var lightLayer = lightData.GetLightLayers();
|
||||
var newShadowLayer = lightLayer | newValue | UnityEngine.RenderingLayerMask.defaultRenderingLayerMask;
|
||||
lightData.SetShadowLightLayer((UnityEngine.Rendering.HighDefinition.RenderingLayerMask)newShadowLayer);
|
||||
}
|
||||
|
||||
@@ -256,8 +244,7 @@ namespace Misaki.HdrpToon
|
||||
|
||||
if (_targetBoxLight != null)
|
||||
{
|
||||
positionOffset = _targetBoxLight.transform.position - trackedTransform.transform.position;
|
||||
rotationOffset = Quaternion.Inverse(trackedTransform.transform.rotation) * _targetBoxLight.transform.rotation;
|
||||
distanceOffset = Mathf.Abs(Vector3.Distance(_targetBoxLight.transform.position, trackedTransform.transform.position));
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
@@ -6,8 +6,10 @@ namespace Misaki.HdrpToon
|
||||
{
|
||||
public const string OUTLINE_PASS_NAME = "Outline";
|
||||
public const string HAIR_SHADOW_CASTER_PASS_NAME = "HairShadowCaster";
|
||||
public const string HAIR_BLENDING_TARGET_PASS_NAME = "HairBlendingTarget";
|
||||
|
||||
public static readonly ShaderTagId outlinePassId = new(OUTLINE_PASS_NAME);
|
||||
public static readonly ShaderTagId hairShadowCasterPassId = new(HAIR_SHADOW_CASTER_PASS_NAME);
|
||||
public static readonly ShaderTagId hairBlendingTargetPassId = new(HAIR_BLENDING_TARGET_PASS_NAME);
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -1,272 +0,0 @@
|
||||
#ifndef UNITY_DEBUG_DISPLAY_INCLUDED
|
||||
#define UNITY_DEBUG_DISPLAY_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MaterialDebug.cs.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MipMapDebug.cs.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/ColorPickerDebug.cs.hlsl"
|
||||
|
||||
CBUFFER_START(UnityDebugDisplay)
|
||||
// Set of parameters available when switching to debug shader mode
|
||||
int _DebugLightingMode; // Match enum DebugLightingMode
|
||||
int _DebugShadowMapMode;
|
||||
float _DebugViewMaterialArray[11]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
|
||||
int _DebugMipMapMode; // Match enum DebugMipMapMode
|
||||
int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
|
||||
int _ColorPickerMode; // Match enum ColorPickerDebugMode
|
||||
int _DebugStep;
|
||||
int _DebugDepthPyramidMip;
|
||||
int _DebugFullScreenMode;
|
||||
float _DebugTransparencyOverdrawWeight;
|
||||
float4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
|
||||
float4 _DebugLightingSmoothness; // x == bool override, y == override value
|
||||
float4 _DebugLightingNormal; // x == bool override
|
||||
float4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
|
||||
float4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
|
||||
float4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
|
||||
float4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
|
||||
float4 _DebugLightingMaterialValidateLowColor;
|
||||
float4 _DebugLightingMaterialValidatePureMetalColor;
|
||||
float4 _MousePixelCoord; // xy unorm, zw norm
|
||||
float4 _MouseClickPixelCoord; // xy unorm, zw norm
|
||||
int _MatcapMixAlbedo;
|
||||
int _MatcapViewScale;
|
||||
uint _DebugContactShadowLightIndex;
|
||||
CBUFFER_END
|
||||
|
||||
// Local shader variables
|
||||
static DirectionalShadowType g_DebugShadowAttenuation = 0;
|
||||
|
||||
StructuredBuffer<int2> _DebugDepthPyramidOffsets;
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/PBRValidator.hlsl"
|
||||
|
||||
// When displaying lux meter we compress the light in order to be able to display value higher than 65504
|
||||
// The sun is between 100 000 and 150 000, so we use 4 to be able to cover such a range (4 * 65504)
|
||||
#define LUXMETER_COMPRESSION_RATIO 4
|
||||
|
||||
TEXTURE2D(_DebugFont); // Debug font to write string in shader
|
||||
TEXTURE2D(_DebugMatCapTexture);
|
||||
|
||||
void GetPropertiesDataDebug(uint paramId, inout float3 result, inout bool needLinearToSRGB)
|
||||
{
|
||||
switch (paramId)
|
||||
{
|
||||
case DEBUGVIEWPROPERTIES_TESSELLATION:
|
||||
#ifdef TESSELLATION_ON
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_PIXEL_DISPLACEMENT:
|
||||
#ifdef _PIXEL_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_VERTEX_DISPLACEMENT:
|
||||
#ifdef _VERTEX_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_TESSELLATION_DISPLACEMENT:
|
||||
#ifdef _TESSELLATION_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_DEPTH_OFFSET:
|
||||
#ifdef _DEPTHOFFSET_ON // Caution: This define is related to a shader features (But it may become a standard features for HD)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_LIGHTMAP:
|
||||
#if defined(LIGHTMAP_ON) || defined (DIRLIGHTMAP_COMBINED) || defined(DYNAMICLIGHTMAP_ON)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DEBUGVIEWPROPERTIES_INSTANCING:
|
||||
#if defined(UNITY_INSTANCING_ENABLED)
|
||||
result = float3(1.0, 0.0, 0.0);
|
||||
#else
|
||||
result = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor)
|
||||
{
|
||||
float3 outColor = originalColor;
|
||||
|
||||
switch (paramId)
|
||||
{
|
||||
case DEBUGMIPMAPMODE_MIP_RATIO:
|
||||
outColor = GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo);
|
||||
break;
|
||||
case DEBUGMIPMAPMODE_MIP_COUNT:
|
||||
outColor = GetDebugMipCountColor(originalColor, tex);
|
||||
break;
|
||||
case DEBUGMIPMAPMODE_MIP_COUNT_REDUCTION:
|
||||
outColor = GetDebugMipReductionColor(tex, mipInfo);
|
||||
break;
|
||||
case DEBUGMIPMAPMODE_STREAMING_MIP_BUDGET:
|
||||
outColor = GetDebugStreamingMipColor(tex, mipInfo);
|
||||
break;
|
||||
case DEBUGMIPMAPMODE_STREAMING_MIP:
|
||||
outColor = GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
// DebugFont code assume black and white font with texture size 256x128 with bloc of 16x16
|
||||
#define DEBUG_FONT_TEXT_WIDTH 16
|
||||
#define DEBUG_FONT_TEXT_HEIGHT 16
|
||||
#define DEBUG_FONT_TEXT_COUNT_X 16
|
||||
#define DEBUG_FONT_TEXT_COUNT_Y 8
|
||||
#define DEBUG_FONT_TEXT_ASCII_START 32
|
||||
|
||||
#define DEBUG_FONT_TEXT_SCALE_WIDTH 10 // This control the spacing between characters (if a character fill the text block it will overlap).
|
||||
|
||||
// Only support ASCII symbol from DEBUG_FONT_TEXT_ASCII_START to 126
|
||||
// return black or white depends if we hit font character or not
|
||||
// currentUnormCoord is current unormalized screen position
|
||||
// fixedUnormCoord is the position where we want to draw something, this will be incremented by block font size in provided direction
|
||||
// color is current screen color
|
||||
// color of the font to use
|
||||
// direction is 1 or -1 and indicate fixedUnormCoord block shift
|
||||
void DrawCharacter(uint asciiValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color, int direction)
|
||||
{
|
||||
// Are we inside a font display block on the screen ?
|
||||
uint2 localCharCoord = currentUnormCoord - fixedUnormCoord;
|
||||
if (localCharCoord.x >= 0 && localCharCoord.x < DEBUG_FONT_TEXT_WIDTH && localCharCoord.y >= 0 && localCharCoord.y < DEBUG_FONT_TEXT_HEIGHT)
|
||||
{
|
||||
localCharCoord.y = DEBUG_FONT_TEXT_HEIGHT - localCharCoord.y;
|
||||
|
||||
asciiValue -= DEBUG_FONT_TEXT_ASCII_START; // Our font start at ASCII table 32;
|
||||
uint2 asciiCoord = uint2(asciiValue % DEBUG_FONT_TEXT_COUNT_X, asciiValue / DEBUG_FONT_TEXT_COUNT_X);
|
||||
// Unorm coordinate inside the font texture
|
||||
uint2 unormTexCoord = asciiCoord * uint2(DEBUG_FONT_TEXT_WIDTH, DEBUG_FONT_TEXT_HEIGHT) + localCharCoord;
|
||||
// normalized coordinate
|
||||
float2 normTexCoord = float2(unormTexCoord) / float2(DEBUG_FONT_TEXT_WIDTH * DEBUG_FONT_TEXT_COUNT_X, DEBUG_FONT_TEXT_HEIGHT * DEBUG_FONT_TEXT_COUNT_Y);
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
normTexCoord.y = 1.0 - normTexCoord.y;
|
||||
#endif
|
||||
|
||||
float charColor = SAMPLE_TEXTURE2D_LOD(_DebugFont, s_point_clamp_sampler, normTexCoord, 0).r;
|
||||
color = color * (1.0 - charColor) + charColor * fontColor;
|
||||
}
|
||||
|
||||
fixedUnormCoord.x += DEBUG_FONT_TEXT_SCALE_WIDTH * direction;
|
||||
}
|
||||
|
||||
// Shortcut to not have to file direction
|
||||
void DrawCharacter(uint asciiValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color)
|
||||
{
|
||||
DrawCharacter(asciiValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 1);
|
||||
}
|
||||
|
||||
// Draw a signed integer
|
||||
// Can't display more than 16 digit
|
||||
// The two following parameter are for float representation
|
||||
// leading0 is used when drawing frac part of a float to draw the leading 0 (call is in charge of it)
|
||||
// forceNegativeSign is used to force to display a negative sign as -0 is not recognize
|
||||
void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color, int leading0, bool forceNegativeSign)
|
||||
{
|
||||
const uint maxStringSize = 16;
|
||||
|
||||
uint absIntValue = abs(intValue);
|
||||
|
||||
// 1. Get size of the number of display
|
||||
int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + ((intValue < 0 || forceNegativeSign) ? 1 : 0) + leading0, maxStringSize);
|
||||
|
||||
// 2. Shift curseur to last location as we will go reverse
|
||||
fixedUnormCoord.x += numEntries * DEBUG_FONT_TEXT_SCALE_WIDTH;
|
||||
|
||||
// 3. Display the number
|
||||
for (uint j = 0; j < maxStringSize; ++j)
|
||||
{
|
||||
// Numeric value incurrent font start on the second row at 0
|
||||
DrawCharacter((absIntValue % 10) + '0', fontColor, currentUnormCoord, fixedUnormCoord, color, -1);
|
||||
if (absIntValue < 10)
|
||||
break;
|
||||
absIntValue /= 10;
|
||||
}
|
||||
|
||||
// 4. Display leading 0
|
||||
if (leading0 > 0)
|
||||
{
|
||||
for (int i = 0; i < leading0; ++i)
|
||||
{
|
||||
DrawCharacter('0', fontColor, currentUnormCoord, fixedUnormCoord, color, -1);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Display sign
|
||||
if (intValue < 0 || forceNegativeSign)
|
||||
{
|
||||
DrawCharacter('-', fontColor, currentUnormCoord, fixedUnormCoord, color, -1);
|
||||
}
|
||||
|
||||
// 6. Reset cursor at end location
|
||||
fixedUnormCoord.x += (numEntries + 2) * DEBUG_FONT_TEXT_SCALE_WIDTH;
|
||||
}
|
||||
|
||||
void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color)
|
||||
{
|
||||
DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, false);
|
||||
}
|
||||
|
||||
void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color)
|
||||
{
|
||||
if (IsNaN(floatValue))
|
||||
{
|
||||
DrawCharacter('N', fontColor, currentUnormCoord, fixedUnormCoord, color);
|
||||
DrawCharacter('a', fontColor, currentUnormCoord, fixedUnormCoord, color);
|
||||
DrawCharacter('N', fontColor, currentUnormCoord, fixedUnormCoord, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
int intValue = int(floatValue);
|
||||
bool forceNegativeSign = floatValue >= 0.0f ? false : true;
|
||||
DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, forceNegativeSign);
|
||||
DrawCharacter('.', fontColor, currentUnormCoord, fixedUnormCoord, color);
|
||||
int fracValue = int(frac(abs(floatValue)) * 1e6); // 6 digit
|
||||
int leading0 = 6 - (int(log10(fracValue)) + 1); // Counting leading0 to add in front of the float
|
||||
DrawInteger(fracValue, fontColor, currentUnormCoord, fixedUnormCoord, color, leading0, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Debug rendering is performed at the end of the frame (after post-processing).
|
||||
// Debug textures are never flipped upside-down automatically. Therefore, we must always flip manually.
|
||||
bool ShouldFlipDebugTexture()
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
return (_ProjectionParams.x > 0);
|
||||
#else
|
||||
return (_ProjectionParams.x < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
//#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
|
||||
|
||||
#ifndef DECODEDEPTHNORMALS_INCLUDED
|
||||
#define DECODEDEPTHNORMALS_INCLUDED
|
||||
|
||||
|
||||
inline float DecodeFloatRG(float2 enc) {
|
||||
float2 kDecodeDot = float2(1.0, 1 / 255.0);
|
||||
return dot(enc, kDecodeDot);
|
||||
}
|
||||
|
||||
inline float3 DecodeViewNormalStereo(float4 enc4) {
|
||||
float kScale = 1.7777;
|
||||
float3 nn = enc4.xyz * float3(2 * kScale, 2 * kScale, 0) + float3(-kScale, -kScale, 1);
|
||||
float g = 2.0 / dot(nn.xyz, nn.xyz);
|
||||
float3 n;
|
||||
n.xy = g * nn.xy;
|
||||
n.z = g - 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
inline void DecodeDepthNormal(float4 enc, out float depth, out float3 normal) {
|
||||
depth = DecodeFloatRG(enc.zw);
|
||||
normal = DecodeViewNormalStereo(enc);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,298 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
float3 UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, float3 mainLihgtDirection, float3 mainLightColor, out float inverseClipping, out float channelOutAlpha, out UTSData utsData)
|
||||
{
|
||||
channelOutAlpha = 1.0f;
|
||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||
inverseClipping = 0;
|
||||
// input.positionSS is SV_Position
|
||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
||||
|
||||
|
||||
#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;
|
||||
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
|
||||
|
||||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
|
||||
|
||||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
||||
/* todo. these should be put int a struct */
|
||||
float4 Set_UV0 = input.texCoord0;
|
||||
float3x3 tangentTransform = input.tangentToWorld;
|
||||
//UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords))
|
||||
float4 n = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, Set_UV0.xy);
|
||||
// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale);
|
||||
float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale);
|
||||
float3 normalLocal = _NormalMap_var.rgb;
|
||||
utsData.normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals
|
||||
|
||||
float4 _BaseColorMap_var = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _BaseColorMap));
|
||||
float3 i_normalDir = surfaceData.normalWS;
|
||||
utsData.viewDirection = V;
|
||||
/* to here todo. these should be put int a struct */
|
||||
|
||||
//v.2.0.4
|
||||
#if defined(_IS_CLIPPING_MODE)
|
||||
//DoubleShadeWithFeather_Clipping
|
||||
float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _ClippingMask));
|
||||
float Set_Clipping = saturate((lerp(_ClippingMask_var.r, (1.0 - _ClippingMask_var.r), _Inverse_Clipping) + _Clipping_Level));
|
||||
clip(Set_Clipping - 0.5);
|
||||
#elif defined(_IS_CLIPPING_TRANSMODE) || defined(_IS_TRANSCLIPPING_ON)
|
||||
//DoubleShadeWithFeather_TransClipping
|
||||
float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _ClippingMask));
|
||||
float Set_BaseColorMapAlpha = _BaseColorMap_var.a;
|
||||
float _IsBaseMapAlphaAsClippingMask_var = lerp(_ClippingMask_var.r, Set_BaseColorMapAlpha, _IsBaseMapAlphaAsClippingMask);
|
||||
float _Inverse_Clipping_var = lerp(_IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping);
|
||||
float Set_Clipping = saturate((_Inverse_Clipping_var + _Clipping_Level));
|
||||
clip(Set_Clipping - 0.5);
|
||||
inverseClipping = _Inverse_Clipping_var;
|
||||
#elif defined(_IS_CLIPPING_OFF) || defined(_IS_TRANSCLIPPING_OFF)
|
||||
//DoubleShadeWithFeather
|
||||
#endif
|
||||
|
||||
float shadowAttenuation = (float)lightLoopContext.shadowValue;
|
||||
|
||||
|
||||
|
||||
// float4 tmpColor = EvaluateLight_Directional(context, posInput, _DirectionalLightDatas[mainLightIndex]);
|
||||
// float3 mainLightColor = tmpColor.xyz;
|
||||
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, mainLihgtDirection.xyz, any(mainLihgtDirection.xyz)));
|
||||
lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD);
|
||||
float3 originalLightColor = mainLightColor;
|
||||
|
||||
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));
|
||||
|
||||
|
||||
////// Lighting:
|
||||
float3 halfDirection = normalize(utsData.viewDirection + lightDirection);
|
||||
//v.2.0.5
|
||||
_Color = _BaseColor;
|
||||
float3 Set_LightColor = lightColor.rgb;
|
||||
float3 Set_BaseColor = lerp((_BaseColorMap_var.rgb * _BaseColor.rgb), ((_BaseColorMap_var.rgb * _BaseColor.rgb) * Set_LightColor), _Is_LightColor_Base);
|
||||
float3 clippingColor = float3(1.0f, 1.0f, 1.0f);
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 5)
|
||||
{
|
||||
clippingColor = float3(0.0f, 0.0f, 0.0f);
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 1)
|
||||
{
|
||||
clippingColor = Set_BaseColor;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode).xyz;
|
||||
float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode);
|
||||
Set_BaseColor = lerp(Set_BaseColor, overridingColor, maskEnabled);
|
||||
Set_BaseColor *= _BaseColorVisible;
|
||||
float Set_BaseColorAlpha = _BaseColorVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
//v.2.0.5
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _1st_ShadeMap)), _BaseColorMap_var, _Use_BaseAs1st);
|
||||
float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb), ((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_1st_Shade);
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 2)
|
||||
{
|
||||
clippingColor = Set_1st_ShadeColor;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode);
|
||||
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.xyz, maskEnabled);
|
||||
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible);
|
||||
}
|
||||
float Set_1st_ShadeAlpha = _FirstShadeVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
//v.2.0.5
|
||||
float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _2nd_ShadeMap)), _1st_ShadeMap_var, _Use_1stAs2nd);
|
||||
float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade);
|
||||
float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5;
|
||||
float4 _Set_2nd_ShadePosition_var = tex2D(_Set_2nd_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition));
|
||||
float4 _Set_1st_ShadePosition_var = tex2D(_Set_1st_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition));
|
||||
|
||||
float _1stColorFeatherForMask = lerp(_BaseShade_Feather, 0.0f, max(_FirstShadeOverridden, _ComposerMaskMode));
|
||||
float _2ndColorFeatherForMask = lerp(_1st2nd_Shades_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode));
|
||||
|
||||
|
||||
//v.2.0.6
|
||||
//Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
|
||||
float _SystemShadowsLevel_var = (shadowAttenuation * 0.5) + 0.5 + _Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation * 0.5) + 0.5 + _Tweak_SystemShadowsLevel : 0.0001;
|
||||
float Set_FinalShadowMask = saturate((1.0 + ((lerp(_HalfLambert_var, _HalfLambert_var * saturate(_SystemShadowsLevel_var), _Set_SystemShadowsToBase) - (_BaseColor_Step - _1stColorFeatherForMask)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0)) / (_BaseColor_Step - (_BaseColor_Step - _1stColorFeatherForMask))));
|
||||
//
|
||||
//Composition: 3 Basic Colors as Set_FinalBaseColor
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 3)
|
||||
{
|
||||
clippingColor = Set_2nd_ShadeColor;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode);
|
||||
Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, overridingColor.xyz, maskEnabled);
|
||||
Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, Set_BaseColor, 1.0f - _SecondShadeVisible);
|
||||
}
|
||||
float Set_2nd_ShadeAlpha = _SecondShadeVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 Set_FinalBaseColor = lerp(Set_BaseColor, lerp(Set_1st_ShadeColor, Set_2nd_ShadeColor, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); // Final Color
|
||||
channelOutAlpha = lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask);
|
||||
float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask));
|
||||
float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular
|
||||
float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(_HighColor_Power, 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor));
|
||||
float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex));
|
||||
float3 _HighColorWithOutTweak_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor);
|
||||
float3 _HighColor_var = _HighColorWithOutTweak_var * _TweakHighColorMask_var;
|
||||
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 4)
|
||||
{
|
||||
clippingColor = _HighColorWithOutTweak_var;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
//Composition: 3 Basic Colors and HighColor as Set_HighColor
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 Set_HighColor;
|
||||
{
|
||||
float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode);
|
||||
|
||||
_HighColor_var *= _HighlightVisible;
|
||||
Set_HighColor =
|
||||
lerp(SATURATE_IF_SDR(Set_FinalBaseColor - _TweakHighColorMask_var), Set_FinalBaseColor,
|
||||
lerp(_Is_BlendAddToHiColor, 1.0
|
||||
, _Is_SpecularToHighColor));
|
||||
float3 addColor =
|
||||
lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow)))
|
||||
, _Is_UseTweakHighColorOnShadow);
|
||||
Set_HighColor += addColor;
|
||||
if (any(addColor))
|
||||
{
|
||||
Set_HighColor = lerp(Set_HighColor, overridingColor.xyz, maskEnabled);
|
||||
channelOutAlpha = _HighlightVisible;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
float3 Set_HighColor = (lerp(SATURATE_IF_SDR((Set_FinalBaseColor - _TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor, 1.0, _Is_SpecularToHighColor)) + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow));
|
||||
#endif
|
||||
float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask, TRANSFORM_TEX(Set_UV0, _Set_RimLightMask));
|
||||
float3 _Is_LightColor_RimLight_var = lerp(_RimLightColor.rgb, (_RimLightColor.rgb * Set_LightColor), _Is_LightColor_RimLight);
|
||||
float _RimArea_var = abs((1.0 - dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToRimLight), utsData.viewDirection)));
|
||||
float _RimLightPower_var = pow(_RimArea_var, exp2(lerp(3, 0, _RimLight_Power)));
|
||||
float _Rimlight_InsideMask_var = saturate(lerp((0.0 + ((_RimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _RimLightPower_var), _RimLight_FeatherOff));
|
||||
float _VertHalfLambert_var = 0.5 * dot(i_normalDir, lightDirection) + 0.5;
|
||||
float3 _LightDirection_MaskOn_var = lerp((_Is_LightColor_RimLight_var * _Rimlight_InsideMask_var), (_Is_LightColor_RimLight_var * saturate((_Rimlight_InsideMask_var - ((1.0 - _VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel)))), _LightDirection_MaskOn);
|
||||
float _ApRimLightPower_var = pow(_RimArea_var, exp2(lerp(3, 0, _Ap_RimLight_Power)));
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float4 overridingRimColor = lerp(_RimLightMaskColor, float4(_RimLightMaskColor.w, _RimLightMaskColor.w, _RimLightMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskRimEnabled = max(_RimLightOverridden, _ComposerMaskMode);
|
||||
float Set_RimLightAlpha = _RimLightVisible;
|
||||
float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight));
|
||||
Set_RimLight *= _RimLightVisible;
|
||||
float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight);
|
||||
if (any(Set_RimLight) * maskRimEnabled)
|
||||
{
|
||||
_RimLight_var = overridingRimColor.xyz;
|
||||
channelOutAlpha = Set_RimLightAlpha;
|
||||
}
|
||||
#else
|
||||
float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight));
|
||||
//Composition: HighColor and RimLight as _RimLight_var
|
||||
float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight);
|
||||
#endif
|
||||
//Matcap
|
||||
//v.2.0.6 : CameraRolling Stabilizer
|
||||
//Mirror Script Determination: if sign_Mirror = -1, determine "Inside the mirror".
|
||||
//v.2.0.7
|
||||
utsData.signMirror = 0.0; // i.mirrorFlag; todo.
|
||||
float3 _Camera_Right = UNITY_MATRIX_V[0].xyz;
|
||||
float3 _Camera_Front = UNITY_MATRIX_V[2].xyz;
|
||||
float3 _Up_Unit = float3(0, 1, 0);
|
||||
float3 _Right_Axis = cross(_Camera_Front, _Up_Unit);
|
||||
|
||||
//Invert if it's "inside the mirror".
|
||||
if (utsData.signMirror < 0) {
|
||||
_Right_Axis = -1 * _Right_Axis;
|
||||
_Rotate_MatCapUV = -1 * _Rotate_MatCapUV;
|
||||
}
|
||||
else {
|
||||
_Right_Axis = _Right_Axis;
|
||||
}
|
||||
float _Camera_Right_Magnitude = sqrt(_Camera_Right.x * _Camera_Right.x + _Camera_Right.y * _Camera_Right.y + _Camera_Right.z * _Camera_Right.z);
|
||||
float _Right_Axis_Magnitude = sqrt(_Right_Axis.x * _Right_Axis.x + _Right_Axis.y * _Right_Axis.y + _Right_Axis.z * _Right_Axis.z);
|
||||
float _Camera_Roll_Cos = dot(_Right_Axis, _Camera_Right) / (_Right_Axis_Magnitude * _Camera_Right_Magnitude);
|
||||
utsData.cameraRoll = acos(clamp(_Camera_Roll_Cos, -1, 1));
|
||||
utsData.cameraDir = _Camera_Right.y < 0 ? -1 : 1;
|
||||
float _Rot_MatCapUV_var_ang = (_Rotate_MatCapUV * 3.141592654) - utsData.cameraDir * utsData.cameraRoll * _CameraRolling_Stabilizer;
|
||||
//v.2.0.7
|
||||
float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0.xy, (_Rotate_NormalMapForMatCapUV * 3.141592654f), float2(0.5, 0.5), 1.0);
|
||||
//V.2.0.6
|
||||
float3 _NormalMapForMatCap_var = UnpackNormalScale(tex2D(_NormalMapForMatCap, TRANSFORM_TEX(_Rot_MatCapNmUV_var, _NormalMapForMatCap)), _BumpScaleMatcap);
|
||||
//v.2.0.5: MatCap with camera skew correction
|
||||
float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp(i_normalDir, mul(_NormalMapForMatCap_var.rgb, tangentTransform).rgb, _Is_NormalMapForMatCap), 0))).rgb;
|
||||
float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1, -1, 1);
|
||||
float3 NormalBlend_MatcapUV_Base = (mul(UNITY_MATRIX_V, float4(utsData.viewDirection, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1);
|
||||
float3 noSknewViewNormal = NormalBlend_MatcapUV_Base * dot(NormalBlend_MatcapUV_Base, NormalBlend_MatcapUV_Detail) / NormalBlend_MatcapUV_Base.b - NormalBlend_MatcapUV_Detail;
|
||||
float2 _ViewNormalAsMatCapUV = (lerp(noSknewViewNormal, viewNormal, _Is_Ortho).rg * 0.5) + 0.5;
|
||||
//v.2.0.7
|
||||
float2 _Rot_MatCapUV_var = RotateUV((0.0 + ((_ViewNormalAsMatCapUV - (0.0 + _Tweak_MatCapUV)) * (1.0 - 0.0)) / ((1.0 - _Tweak_MatCapUV) - (0.0 + _Tweak_MatCapUV))), _Rot_MatCapUV_var_ang, float2(0.5, 0.5), 1.0);
|
||||
//Invert if it's "inside the mirror".
|
||||
if (utsData.signMirror < 0) {
|
||||
_Rot_MatCapUV_var.x = 1 - _Rot_MatCapUV_var.x;
|
||||
}
|
||||
else {
|
||||
_Rot_MatCapUV_var = _Rot_MatCapUV_var;
|
||||
}
|
||||
//v.2.0.6 : LOD of Matcap
|
||||
//
|
||||
//MatcapMask
|
||||
float4 _MatCap_Sampler_var = tex2Dlod(_MatCap_Sampler, float4(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), 0.0, _BlurLevelMatcap));
|
||||
float4 _Set_MatcapMask_var = tex2D(_Set_MatcapMask, TRANSFORM_TEX(Set_UV0, _Set_MatcapMask));
|
||||
float _Tweak_MatcapMaskLevel_var = saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel);
|
||||
//
|
||||
float3 _Is_LightColor_MatCap_var = lerp((_MatCap_Sampler_var.rgb * _MatCapColor.rgb), ((_MatCap_Sampler_var.rgb * _MatCapColor.rgb) * Set_LightColor), _Is_LightColor_MatCap);
|
||||
//v.2.0.6 : ShadowMask on Matcap in Blend mode : multiply
|
||||
float3 Set_MatCap = lerp(_Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakMatCapOnShadow)) + lerp(Set_HighColor * Set_FinalShadowMask * (1.0 - _TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow);
|
||||
|
||||
//
|
||||
//Composition: RimLight and MatCap as finalColor
|
||||
//Broke down finalColor composition
|
||||
float3 matCapColorOnAddMode = _RimLight_var + Set_MatCap * _Tweak_MatcapMaskLevel_var;
|
||||
float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp(1.0, (1.0 - (Set_FinalShadowMask) * (1.0 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow);
|
||||
float3 matCapColorOnMultiplyMode = Set_HighColor * (1 - _Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor * Set_MatCap * _Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0, 0, 0), Set_RimLight, _RimLight);
|
||||
float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap);
|
||||
float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive
|
||||
//
|
||||
//v.2.0.6: GI_Intensity with Intensity Multiplier Filter
|
||||
float3 envLightColor = DecodeLightProbe(utsData.normalDirection) < float3(1, 1, 1) ? DecodeLightProbe(utsData.normalDirection) : float3(1, 1, 1);
|
||||
float envLightIntensity = 0.299 * envLightColor.r + 0.587 * envLightColor.g + 0.114 * envLightColor.b < 1 ? (0.299 * envLightColor.r + 0.587 * envLightColor.g + 0.114 * envLightColor.b) : 1;
|
||||
|
||||
finalColor = SATURATE_IF_SDR(finalColor) + (envLightColor * envLightIntensity * _GI_Intensity * smoothstep(1, 0, envLightIntensity / 2)) + emissive;
|
||||
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f3d7136d29e4e94694ab0df05f6a94c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,143 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
float3 UTS_OtherLights(FragInputs input, float3 i_normalDir,
|
||||
float3 additionalLightColor, float3 lightDirection, float notDirectional, out float channelOutAlpha)
|
||||
{
|
||||
channelOutAlpha = 1.0f;
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode != 0)
|
||||
{
|
||||
|
||||
return float3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
/* todo. these should be put into struct */
|
||||
#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
|
||||
|
||||
float4 Set_UV0 = input.texCoord0;
|
||||
float3x3 tangentTransform = input.tangentToWorld;
|
||||
//UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords))
|
||||
float4 n = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, Set_UV0.xy, 0);
|
||||
// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale);
|
||||
float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale);
|
||||
float3 normalLocal = _NormalMap_var.rgb;
|
||||
float3 normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals
|
||||
// float3 i_normalDir = surfaceData.normalWS;
|
||||
float3 viewDirection = V;
|
||||
float4 _MainTex_var = SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex), 0.0f);
|
||||
/* end of todo.*/
|
||||
|
||||
|
||||
|
||||
//v.2.0.5:
|
||||
float3 addPassLightColor = (0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5) * additionalLightColor.rgb;
|
||||
float pureIntencity = max(0.001, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b));
|
||||
float3 lightColor = max(0, lerp(addPassLightColor, lerp(0, min(addPassLightColor, addPassLightColor / pureIntencity), notDirectional), _Is_Filter_LightColor));
|
||||
float3 halfDirection = normalize(viewDirection + lightDirection); // has to be recalced here.
|
||||
//v.2.0.5:
|
||||
_BaseColor_Step = saturate(_BaseColor_Step + _StepOffset);
|
||||
_ShadeColor_Step = saturate(_ShadeColor_Step + _StepOffset);
|
||||
//
|
||||
//v.2.0.5: If Added lights is directional, set 0 as _LightIntensity
|
||||
float _LightIntensity = lerp(0, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b), notDirectional);
|
||||
//v.2.0.5: Filtering the high intensity zone of PointLights
|
||||
float3 Set_LightColor = lightColor;
|
||||
//
|
||||
float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb * _LightIntensity), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base);
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode);
|
||||
Set_BaseColor = lerp(Set_BaseColor, overridingColor.xyz, maskEnabled);
|
||||
Set_BaseColor *= _BaseColorVisible;
|
||||
float Set_BaseColorAlpha = _BaseColorVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D_LOD(_1st_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _1st_ShadeMap),0.0f), _MainTex_var, _Use_BaseAs1st);
|
||||
float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb * _LightIntensity), ((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_1st_Shade);
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode);
|
||||
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.xyz, maskEnabled);
|
||||
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible);
|
||||
}
|
||||
float Set_1st_ShadeAlpha = _FirstShadeVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5
|
||||
float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D_LOD(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _2nd_ShadeMap), 0.0), _1st_ShadeMap_var, _Use_1stAs2nd);
|
||||
float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb * _LightIntensity), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade);
|
||||
float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5;
|
||||
float4 _Set_2nd_ShadePosition_var = tex2Dlod(_Set_2nd_ShadePosition, float4(TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition),0.0f,0.0f));
|
||||
float4 _Set_1st_ShadePosition_var = tex2Dlod(_Set_1st_ShadePosition, float4(TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition),0.0f, 0.0f));
|
||||
//v.2.0.5:
|
||||
float _1stColorFeatherForMask = lerp(_BaseShade_Feather, 0.0f, max(_FirstShadeOverridden, _ComposerMaskMode));
|
||||
float _2ndColorFeatherForMask = lerp(_1st2nd_Shades_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode));
|
||||
float Set_FinalShadowMask = saturate((1.0 + ((lerp(_HalfLambert_var, (_HalfLambert_var * saturate(1.0 + _Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase) - (_BaseColor_Step - _1stColorFeatherForMask)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0)) / (_BaseColor_Step - (_BaseColor_Step - _1stColorFeatherForMask))));
|
||||
|
||||
|
||||
|
||||
|
||||
//Composition: 3 Basic Colors as finalColor
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode);
|
||||
Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, overridingColor.xyz, maskEnabled);
|
||||
Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, Set_BaseColor, 1.0f - _SecondShadeVisible);
|
||||
}
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 finalColor = lerp(Set_BaseColor, lerp(Set_1st_ShadeColor, Set_2nd_ShadeColor, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); // Final Color
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float Set_2nd_ShadeAlpha = _SecondShadeVisible;
|
||||
channelOutAlpha = lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask);
|
||||
#endif
|
||||
//v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False
|
||||
|
||||
float4 _Set_HighColorMask_var = tex2Dlod(_Set_HighColorMask, float4(TRANSFORM_TEX(Set_UV0, _Set_HighColorMask),0.0f,0.0f));
|
||||
float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular
|
||||
float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(abs(_HighColor_Power), 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor));
|
||||
float4 _HighColor_Tex_var = tex2Dlod(_HighColor_Tex, float4( TRANSFORM_TEX(Set_UV0, _HighColor_Tex),0.0f,0.0f));
|
||||
|
||||
float3 _HighColor_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor);
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode);
|
||||
_HighColor_var *= _TweakHighColorMask_var;
|
||||
_HighColor_var *= _HighlightVisible;
|
||||
finalColor =
|
||||
lerp(saturate(finalColor - _TweakHighColorMask_var), finalColor,
|
||||
lerp(_Is_BlendAddToHiColor, 1.0
|
||||
, _Is_SpecularToHighColor));
|
||||
float3 addColor =
|
||||
lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow)))
|
||||
, _Is_UseTweakHighColorOnShadow);
|
||||
finalColor += addColor;
|
||||
if (any(addColor))
|
||||
{
|
||||
finalColor = lerp(finalColor, overridingColor.xyz, maskEnabled);
|
||||
channelOutAlpha = _HighlightVisible;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
_HighColor_var *= _TweakHighColorMask_var;
|
||||
finalColor = finalColor + lerp(lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow), float3(0, 0, 0), _Is_Filter_HiCutPointLightColor);
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
//
|
||||
|
||||
finalColor = SATURATE_IF_SDR(finalColor);
|
||||
|
||||
// pointLightColor += finalColor;
|
||||
|
||||
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
// _preIntegratedFGD and _CubemapLD are unique for each BRDF
|
||||
IndirectLighting EvaluateBSDF_Env(LightLoopContext lightLoopContext,
|
||||
float3 V, PositionInputs posInput,
|
||||
PreLightData preLightData, EnvLightData lightData, BSDFData bsdfData,
|
||||
int influenceShapeType,
|
||||
inout float hierarchyWeight)
|
||||
{
|
||||
IndirectLighting lighting;
|
||||
ZERO_INITIALIZE(IndirectLighting, lighting);
|
||||
|
||||
float3 envLighting;
|
||||
float weight = 1.0;
|
||||
|
||||
float3 R = reflect(-V, bsdfData.normalWS);
|
||||
|
||||
EvaluateLight_EnvIntersection(posInput.positionWS, bsdfData.normalWS, lightData, influenceShapeType, R, weight);
|
||||
|
||||
// 31 bit index, 1 bit cache type
|
||||
uint cacheType = IsEnvIndexCubemap(lightData.envIndex) ? ENVCACHETYPE_CUBEMAP : ENVCACHETYPE_TEXTURE2D;
|
||||
// Index start at 1, because -0 == 0, so we can't known which cache to sample for that index. Thus it is invalid.
|
||||
int index = abs(lightData.envIndex) - 1;
|
||||
|
||||
float lod = PerceptualRoughnessToMipmapLevel(preLightData.iblPerceptualRoughness) * lightData.roughReflections;
|
||||
float2 atlasCoords = GetReflectionAtlasCoordsCube(CUBE_SCALE_OFFSET[index], R, lod);
|
||||
|
||||
// No distance based roughness for simple lit
|
||||
float4 preLD = SampleEnv(lightLoopContext, lightData.envIndex, R, PerceptualRoughnessToMipmapLevel(preLightData.iblPerceptualRoughness) * lightData.roughReflections, lightData.rangeCompressionFactorCompensation, posInput.positionNDC);
|
||||
weight *= preLD.a; // Used by planar reflection to discard pixel
|
||||
|
||||
//envLighting = F_Schlick(bsdfData.fresnel0, dot(bsdfData.normalWS, V)) * preLD.rgb;
|
||||
envLighting = preLD.rgb;
|
||||
|
||||
UpdateLightingHierarchyWeights(hierarchyWeight, weight);
|
||||
envLighting *= weight * lightData.multiplier;
|
||||
|
||||
lighting.specularReflected = envLighting;
|
||||
|
||||
return lighting;
|
||||
}
|
||||
|
||||
float4 ComputeReflection(LightLoopContext context, PositionInputs posInput, PreLightData preLightData, BuiltinData builtinData, float3 V, float lod, BSDFData bsdfData)
|
||||
{
|
||||
float3 refcolor = 0;
|
||||
float reflectionHierarchyWeight = 0.0; // Max: 1.0
|
||||
|
||||
uint envLightStart, envLightCount;
|
||||
|
||||
// Fetch first env light to provide the scene proxy for screen space computation
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
GetCountAndStart(posInput, LIGHTCATEGORY_ENV, envLightStart, envLightCount);
|
||||
#else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
envLightCount = _EnvLightCount;
|
||||
envLightStart = 0;
|
||||
#endif
|
||||
|
||||
bool fastPath = false;
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
uint envStartFirstLane;
|
||||
fastPath = IsFastPath(envLightStart, envStartFirstLane);
|
||||
#endif
|
||||
|
||||
context.sampleReflection = SINGLE_PASS_CONTEXT_SAMPLE_REFLECTION_PROBES;
|
||||
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
if (fastPath)
|
||||
{
|
||||
envLightStart = envStartFirstLane;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Scalarized loop, same rationale of the punctual light version
|
||||
uint v_envLightListOffset = 0;
|
||||
uint v_envLightIdx = envLightStart;
|
||||
#if NEED_TO_CHECK_HELPER_LANE
|
||||
// On some platform helper lanes don't behave as we'd expect, therefore we prevent them from entering the loop altogether.
|
||||
// IMPORTANT! This has implications if ddx/ddy is used on results derived from lighting, however given Lightloop is called in compute we should be
|
||||
// sure it will not happen.
|
||||
bool isHelperLane = WaveIsHelperLane();
|
||||
while (!isHelperLane && v_envLightListOffset < envLightCount)
|
||||
#else
|
||||
while (v_envLightListOffset < envLightCount)
|
||||
#endif
|
||||
{
|
||||
v_envLightIdx = FetchIndex(envLightStart, v_envLightListOffset);
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
uint s_envLightIdx = ScalarizeElementIndex(v_envLightIdx, fastPath);
|
||||
#else
|
||||
uint s_envLightIdx = v_envLightIdx;
|
||||
#endif
|
||||
if (s_envLightIdx == -1)
|
||||
break;
|
||||
|
||||
EnvLightData s_envLightData = FetchEnvLight(s_envLightIdx); // Scalar load.
|
||||
|
||||
// If current scalar and vector light index match, we process the light. The v_envLightListOffset for current thread is increased.
|
||||
// Note that the following should really be ==, however, since helper lanes are not considered by WaveActiveMin, such helper lanes could
|
||||
// end up with a unique v_envLightIdx value that is smaller than s_envLightIdx hence being stuck in a loop. All the active lanes will not have this problem.
|
||||
if (s_envLightIdx >= v_envLightIdx)
|
||||
{
|
||||
v_envLightListOffset++;
|
||||
if (reflectionHierarchyWeight < 1.0)
|
||||
{
|
||||
if (IsMatchingLightLayer(s_envLightData.lightLayers, builtinData.renderingLayers))
|
||||
{
|
||||
IndirectLighting lighting = EvaluateBSDF_Env(context, V, posInput, preLightData, s_envLightData, bsdfData, s_envLightData.influenceShapeType, reflectionHierarchyWeight);
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
float3 lightInReflDir = float3(-1, -1, -1);
|
||||
if (s_envLightData.normalizeWithAPV > 0 && all(lightInReflDir >= 0))
|
||||
{
|
||||
float factor = GetReflectionProbeNormalizationFactor(lightInReflDir, bsdfData.normalWS, s_envLightData.L0L1, s_envLightData.L2_1, s_envLightData.L2_2);
|
||||
lighting.specularReflected *= factor;
|
||||
}
|
||||
#endif
|
||||
refcolor += lighting.specularReflected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return float4(refcolor.r, refcolor.g, refcolor.b, reflectionHierarchyWeight);
|
||||
}
|
||||
|
||||
float3 ComputeFresnelLerp(float3 c0, float3 c1, float cosA)
|
||||
{
|
||||
float t = pow(1 - cosA, 5);
|
||||
return lerp(c0, c1, t);
|
||||
}
|
||||
|
||||
float3 ComputeIndirectDiffuse(PositionInputs posInput, BSDFData bsdfData, float3 V)
|
||||
{
|
||||
float3 indirectDiffuse = 0.0;
|
||||
|
||||
if(_ID_Intensity > 0)
|
||||
{
|
||||
#ifdef _PBR_Mode_ANISO
|
||||
GetGGXAnisotropicModifiedNormalAndRoughness(bsdfData.bitangentWS, bsdfData.tangentWS , bsdfData.normalWS, V, bsdfData.anisotropy, bsdfData.perceptualRoughness, bsdfData.normalWS, bsdfData.perceptualRoughness);
|
||||
#endif
|
||||
|
||||
float NdotV = saturate(dot(bsdfData.normalWS, V));
|
||||
|
||||
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
|
||||
BuiltinData apvBuiltinData;
|
||||
ZERO_INITIALIZE(BuiltinData, apvBuiltinData);
|
||||
|
||||
#if defined(_PBR_Mode_OFF) || defined(_PBR_Mode_TOON)
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(posInput.positionWS), 0.0, 0.0, V, posInput.positionSS, apvBuiltinData.bakeDiffuseLighting, apvBuiltinData.backBakeDiffuseLighting);
|
||||
#else
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(posInput.positionWS), bsdfData.normalWS, -bsdfData.normalWS, V, posInput.positionSS, apvBuiltinData.bakeDiffuseLighting, apvBuiltinData.backBakeDiffuseLighting);
|
||||
#endif
|
||||
|
||||
float3 probeDiffuse = apvBuiltinData.bakeDiffuseLighting * GetCurrentExposureMultiplier();
|
||||
|
||||
indirectDiffuse = probeDiffuse;
|
||||
#else
|
||||
#if defined(_PBR_Mode_OFF) || defined(_PBR_Mode_TOON)
|
||||
indirectDiffuse = EvaluateAmbientProbe(0.0) * GetCurrentExposureMultiplier();
|
||||
#else
|
||||
indirectDiffuse = EvaluateAmbientProbe(bsdfData.normalWS) * GetCurrentExposureMultiplier();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//SSGI
|
||||
if(_ReceivesSSGI == 1)
|
||||
{
|
||||
float4 ssgiLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS);
|
||||
ssgiLighting *= _GIMultiplier;
|
||||
indirectDiffuse = lerp(indirectDiffuse, ssgiLighting.rgb, ssgiLighting.a);
|
||||
}
|
||||
|
||||
//Compelete the indirect lighting
|
||||
indirectDiffuse = indirectDiffuse * bsdfData.diffuseColor.rgb * _BaseColor.rgb;
|
||||
|
||||
//SSAO
|
||||
if(_ReceivesSSAO == 1)
|
||||
{
|
||||
AmbientOcclusionFactor aoFactor;
|
||||
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
|
||||
indirectDiffuse *= lerp(_AOMin, 1, aoFactor.indirectAmbientOcclusion);
|
||||
}
|
||||
indirectDiffuse = indirectDiffuse * bsdfData.ambientOcclusion;
|
||||
}
|
||||
|
||||
return indirectDiffuse;
|
||||
}
|
||||
|
||||
float3 ComputeIndirectSpecular(LightLoopContext lightLoopContext, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, SurfaceData surfaceData, BuiltinData builtinData, float3 V)
|
||||
{
|
||||
#if defined(_PBR_Mode_OFF) || defined(_PBR_Mode_TOON)
|
||||
return 0;
|
||||
#else
|
||||
float3 indirectSpecular = 0;
|
||||
|
||||
if(_IR_Intensity > 0)
|
||||
{
|
||||
#ifdef _PBR_Mode_ANISO
|
||||
GetGGXAnisotropicModifiedNormalAndRoughness(bsdfData.bitangentWS, bsdfData.tangentWS , bsdfData.normalWS, V, bsdfData.anisotropy, bsdfData.perceptualRoughness, bsdfData.normalWS, bsdfData.perceptualRoughness);
|
||||
#endif
|
||||
|
||||
float3 albedo = _BaseColor.rgb * surfaceData.baseColor;
|
||||
float mip = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness);
|
||||
float NdotV = saturate(dot(bsdfData.normalWS, V));
|
||||
|
||||
indirectSpecular = SampleSkyTexture(reflect(-V, bsdfData.normalWS), mip, 0).rgb;
|
||||
float3 specColor = lerp(ColorSpaceDielectricSpec.rgb, albedo, surfaceData.metallic);
|
||||
float oneMinusReflectivity = ColorSpaceDielectricSpec.a * (1 - surfaceData.metallic);
|
||||
float grazingTerm = saturate((1 - bsdfData.perceptualRoughness) + (1 - oneMinusReflectivity));
|
||||
|
||||
//Reflection Probe
|
||||
float4 refProbe = ComputeReflection(lightLoopContext, posInput, preLightData, builtinData, V, mip, bsdfData);
|
||||
indirectSpecular = lerp(indirectSpecular, refProbe.rgb, refProbe.a);
|
||||
|
||||
//SSR
|
||||
if(_ReceivesSSR == 1)
|
||||
{
|
||||
float4 ssrLighting = LOAD_TEXTURE2D_X(_SsrLightingTexture, posInput.positionSS);
|
||||
InversePreExposeSsrLighting(ssrLighting);
|
||||
ApplyScreenSpaceReflectionWeight(ssrLighting);
|
||||
indirectSpecular = lerp(indirectSpecular, ssrLighting.rgb, ssrLighting.a);
|
||||
}
|
||||
|
||||
//Compelete the indirect lighting
|
||||
indirectSpecular = indirectSpecular * ComputeFresnelLerp(specColor, grazingTerm, NdotV) * GetCurrentExposureMultiplier();
|
||||
|
||||
// Occlusion
|
||||
if(_ReceivesSSAO == 1)
|
||||
{
|
||||
AmbientOcclusionFactor aoFactor;
|
||||
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
|
||||
|
||||
indirectSpecular *= lerp(_AOMin, 1, aoFactor.indirectSpecularOcclusion);
|
||||
}
|
||||
indirectSpecular = indirectSpecular * bsdfData.specularOcclusion;
|
||||
}
|
||||
return indirectSpecular;
|
||||
#endif
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
float StepAntiAliasing(float x, float y)
|
||||
{
|
||||
float v = x - y;
|
||||
return saturate(v / (fwidth(v)+HALF_MIN));//fwidth(x) = abs(ddx(x) + ddy(x))
|
||||
}
|
||||
|
||||
float Remap(float In, float2 InMinMax, float2 OutMinMax)
|
||||
{
|
||||
return OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x);
|
||||
}
|
||||
|
||||
float3 ToonMaping(float3 x)
|
||||
{
|
||||
x = x * (2.51 * x + 0.03) / (x * (2.43 * x + 0.59) + 0.14);
|
||||
return x;
|
||||
}
|
||||
|
||||
float3 GetSmoothedWorldNormal(float2 uv, float3x3 t_tbn)
|
||||
{
|
||||
float3 normal = float3(uv, 0);
|
||||
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
|
||||
return mul(normal, t_tbn);
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
#ifndef UCTS_HDRP_INCLUDED
|
||||
#define UCTS_HDRP_INCLUDED
|
||||
|
||||
#define UCTS_HDRP 1
|
||||
|
||||
#define UTS_LAYER_VISIBILITY
|
||||
|
||||
|
||||
|
||||
#ifndef DIRECTIONAL
|
||||
# define DIRECTIONAL
|
||||
#endif
|
||||
|
||||
#define FP_BUFFER 1
|
||||
#if FP_BUFFER
|
||||
#define SATURATE_IF_SDR(x) (x)
|
||||
#define SATURATE_BASE_COLOR_IF_SDR(x) (x)
|
||||
#else
|
||||
#define SATURATE_IF_SDR(x) saturate(x)
|
||||
#define SATURATE_BASE_COLOR_IF_SDR(x) saturate(x)
|
||||
#endif
|
||||
|
||||
struct UTSData
|
||||
{
|
||||
float3 viewDirection;
|
||||
float3 normalDirection;
|
||||
fixed cameraDir;
|
||||
float cameraRoll;
|
||||
fixed signMirror;
|
||||
};
|
||||
|
||||
//#define UTSDATA_ZERO_INITIALIZE (UTSData)
|
||||
|
||||
struct UTSLightData
|
||||
{
|
||||
float3 lightDirection;
|
||||
float3 lightColor;
|
||||
float diffuseDimmer;
|
||||
float specularDimmer;
|
||||
float3 shadowTint;
|
||||
float penumbraTint;
|
||||
float shadowValue;
|
||||
};
|
||||
|
||||
struct UTSAggregateLighting
|
||||
{
|
||||
float3 directDiffuse;
|
||||
float3 directSpecular;
|
||||
float3 indirectDiffuse;
|
||||
float3 indirectSpecular;
|
||||
};
|
||||
|
||||
float3 AccumulateAggregateLighting(UTSAggregateLighting aggregateLighting)
|
||||
{
|
||||
return SATURATE_IF_SDR(aggregateLighting.directDiffuse + aggregateLighting.directSpecular) + aggregateLighting.indirectDiffuse + aggregateLighting.indirectSpecular;
|
||||
}
|
||||
|
||||
#if defined(UNITY_PASS_PREPASSBASE) || defined(UNITY_PASS_DEFERRED) || defined(UNITY_PASS_SHADOWCASTER)
|
||||
#undef FOG_LINEAR
|
||||
#undef FOG_EXP
|
||||
#undef FOG_EXP2
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
// Legacy for compatibility with existing shaders
|
||||
inline bool IsGammaSpace()
|
||||
{
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// normal should be normalized, w=1.0
|
||||
half3 SHEvalLinearL0L1(half4 normal)
|
||||
{
|
||||
half3 x;
|
||||
|
||||
// Linear (L1) + constant (L0) polynomial terms
|
||||
x.r = dot(unity_SHAr, normal);
|
||||
x.g = dot(unity_SHAg, normal);
|
||||
x.b = dot(unity_SHAb, normal);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
// normal should be normalized, w=1.0
|
||||
half3 SHEvalLinearL2(half4 normal)
|
||||
{
|
||||
half3 x1, x2;
|
||||
// 4 of the quadratic (L2) polynomials
|
||||
half4 vB = normal.xyzz * normal.yzzx;
|
||||
x1.r = dot(unity_SHBr, vB);
|
||||
x1.g = dot(unity_SHBg, vB);
|
||||
x1.b = dot(unity_SHBb, vB);
|
||||
|
||||
// Final (5th) quadratic (L2) polynomial
|
||||
half vC = normal.x * normal.x - normal.y * normal.y;
|
||||
x2 = unity_SHC.rgb * vC;
|
||||
|
||||
return x1 + x2;
|
||||
}
|
||||
|
||||
// normal should be normalized, w=1.0
|
||||
// output in active color space
|
||||
half3 ShadeSH9(half4 normal)
|
||||
{
|
||||
// Linear + constant polynomial terms
|
||||
half3 res = SHEvalLinearL0L1(normal);
|
||||
|
||||
// Quadratic polynomials
|
||||
res += SHEvalLinearL2(normal);
|
||||
|
||||
# ifdef UNITY_COLORSPACE_GAMMA
|
||||
res = LinearToGammaSpace(res);
|
||||
# endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
float3 DecodeLightProbe(float3 N) {
|
||||
return ShadeSH9(float4(N, 1));
|
||||
}
|
||||
|
||||
|
||||
inline float GammaToLinearSpaceExact(float value)
|
||||
{
|
||||
if (value <= 0.04045F)
|
||||
return value / 12.92F;
|
||||
else if (value < 1.0F)
|
||||
return pow((value + 0.055F) / 1.055F, 2.4F);
|
||||
else
|
||||
return pow(value, 2.2F);
|
||||
}
|
||||
|
||||
inline float3 GammaToLinearSpace(float3 sRGB)
|
||||
{
|
||||
// Approximate version from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011h + 0.682171111h) + 0.012522878h);
|
||||
|
||||
// Precise version, useful for debugging.
|
||||
//return half3(GammaToLinearSpaceExact(sRGB.r), GammaToLinearSpaceExact(sRGB.g), GammaToLinearSpaceExact(sRGB.b));
|
||||
}
|
||||
|
||||
inline float LinearToGammaSpaceExact(float value)
|
||||
{
|
||||
if (value <= 0.0F)
|
||||
return 0.0F;
|
||||
else if (value <= 0.0031308F)
|
||||
return 12.92F * value;
|
||||
else if (value < 1.0F)
|
||||
return 1.055F * pow(value, 0.4166667F) - 0.055F;
|
||||
else
|
||||
return pow(value, 0.45454545F);
|
||||
}
|
||||
|
||||
inline float3 LinearToGammaSpace(float3 linRGB)
|
||||
{
|
||||
linRGB = max(linRGB, float3(0.h, 0.h, 0.h));
|
||||
// An almost-perfect approximation from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1
|
||||
return max(1.055h * pow(linRGB, 0.416666667h) - 0.055h, 0.h);
|
||||
|
||||
// Exact version, useful for debugging.
|
||||
//return half3(LinearToGammaSpaceExact(linRGB.r), LinearToGammaSpaceExact(linRGB.g), LinearToGammaSpaceExact(linRGB.b));
|
||||
}
|
||||
|
||||
|
||||
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
|
||||
#define UNITY_FOG_COORDS(idx) UNITY_FOG_COORDS_PACKED(idx, float1)
|
||||
|
||||
#if (SHADER_TARGET < 30) || defined(SHADER_API_MOBILE)
|
||||
// mobile or SM2.0: calculate fog factor per-vertex
|
||||
#define UNITY_TRANSFER_FOG(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.fogCoord.x = unityFogFactor
|
||||
#else
|
||||
// SM3.0 and PC/console: calculate fog distance per-vertex, and fog factor per-pixel
|
||||
#define UNITY_TRANSFER_FOG(o,outpos) o.fogCoord.x = (outpos).z
|
||||
#endif
|
||||
#else
|
||||
#define UNITY_FOG_COORDS(idx)
|
||||
#define UNITY_TRANSFER_FOG(o,outpos)
|
||||
#endif
|
||||
|
||||
#define UNITY_FOG_LERP_COLOR(col,fogCol,fogFac) col.rgb = lerp((fogCol).rgb, (col).rgb, saturate(fogFac))
|
||||
|
||||
|
||||
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
|
||||
#if (SHADER_TARGET < 30) || defined(SHADER_API_MOBILE)
|
||||
// mobile or SM2.0: fog factor was already calculated per-vertex, so just lerp the color
|
||||
#define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) UNITY_FOG_LERP_COLOR(col,fogCol,(coord).x)
|
||||
#else
|
||||
// SM3.0 and PC/console: calculate fog factor and lerp fog color
|
||||
#define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) UNITY_CALC_FOG_FACTOR((coord).x); UNITY_FOG_LERP_COLOR(col,fogCol,unityFogFactor)
|
||||
#endif
|
||||
#else
|
||||
#define UNITY_APPLY_FOG_COLOR(coord,col,fogCol)
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
#define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,fixed4(0,0,0,0))
|
||||
#else
|
||||
#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)
|
||||
#define LIGHT_ATTENUATION(a) SHADOW_ATTENUATION(a)
|
||||
#endif
|
||||
|
||||
// Transforms 2D UV by scale/bias property
|
||||
//#define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
|
||||
#define UCTS_TEXTURE2D(tex,name) SAMPLE_TEXTURE2D(tex,sampler##tex,TRANSFORM_TEX(name, tex));
|
||||
|
||||
|
||||
inline float4 UnityObjectToClipPosInstanced(in float3 pos)
|
||||
{
|
||||
// return mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorldArray[unity_InstanceID], float4(pos, 1.0)));
|
||||
// todo. right?
|
||||
return mul(UNITY_MATRIX_VP, mul(UNITY_MATRIX_M, float4(pos, 1.0)));
|
||||
}
|
||||
inline float4 UnityObjectToClipPosInstanced(float4 pos)
|
||||
{
|
||||
return UnityObjectToClipPosInstanced(pos.xyz);
|
||||
}
|
||||
#define UnityObjectToClipPos UnityObjectToClipPosInstanced
|
||||
|
||||
inline float3 UnityObjectToWorldNormal( in float3 norm )
|
||||
{
|
||||
#ifdef UNITY_ASSUME_UNIFORM_SCALING
|
||||
return UnityObjectToWorldDir(norm);
|
||||
#else
|
||||
// mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)}
|
||||
return normalize(mul(norm, (float3x3)UNITY_MATRIX_M));
|
||||
#endif
|
||||
}
|
||||
// normal should be normalized, w=1.0
|
||||
float3 SHEvalLinearL0L1 (float4 normal)
|
||||
{
|
||||
float3 x;
|
||||
|
||||
// Linear (L1) + constant (L0) polynomial terms
|
||||
x.r = dot(unity_SHAr,normal);
|
||||
x.g = dot(unity_SHAg,normal);
|
||||
x.b = dot(unity_SHAb,normal);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
// normal should be normalized, w=1.0
|
||||
float3 SHEvalLinearL2 (float4 normal)
|
||||
{
|
||||
float3 x1, x2;
|
||||
// 4 of the quadratic (L2) polynomials
|
||||
float4 vB = normal.xyzz * normal.yzzx;
|
||||
x1.r = dot(unity_SHBr,vB);
|
||||
x1.g = dot(unity_SHBg,vB);
|
||||
x1.b = dot(unity_SHBb,vB);
|
||||
|
||||
// Final (5th) quadratic (L2) polynomial
|
||||
half vC = normal.x*normal.x - normal.y*normal.y;
|
||||
x2 = unity_SHC.rgb * vC;
|
||||
|
||||
return x1 + x2;
|
||||
}
|
||||
|
||||
// normal should be normalized, w=1.0
|
||||
// output in active color space
|
||||
float3 ShadeSH9 (float4 normal)
|
||||
{
|
||||
// Linear + constant polynomial terms
|
||||
float3 res = SHEvalLinearL0L1 (normal);
|
||||
|
||||
// Quadratic polynomials
|
||||
res += SHEvalLinearL2 (normal);
|
||||
|
||||
# ifdef UNITY_COLORSPACE_GAMMA
|
||||
res = LinearToGammaSpace (res);
|
||||
# endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
float rateR = 0.299;
|
||||
float rateG = 0.587;
|
||||
float rateB = 0.114;
|
||||
|
||||
float3 SampleBakedGI_UTS(float3 positionRWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool needToIncludeAPV = false)
|
||||
{
|
||||
float3 bakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backBakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backNormalWS = float3(0, 0, 0);
|
||||
|
||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && (SHADERPASS != SHADERPASS_RAYTRACING_INDIRECT) && (SHADERPASS != SHADERPASS_RAYTRACING_GBUFFER)
|
||||
if (_IndirectDiffuseMode != INDIRECTDIFFUSEMODE_OFF
|
||||
#if (SHADERPASS == SHADERPASS_GBUFER)
|
||||
&& _IndirectDiffuseMode != INDIRECTDIFFUSEMODE_MIXED && _ReflectionsMode != REFLECTIONSMODE_MIXED
|
||||
#endif
|
||||
)
|
||||
return bakeDiffuseLighting;
|
||||
#endif
|
||||
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
EvaluateLightmap(positionRWS, normalWS, backNormalWS, uvStaticLightmap, uvDynamicLightmap, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#elif (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
if (needToIncludeAPV)
|
||||
{
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(positionRWS), normalWS, backNormalWS, GetWorldSpaceNormalizeViewDir(positionRWS), 0.0, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
}
|
||||
#else
|
||||
EvaluateLightProbeBuiltin(positionRWS, normalWS, backNormalWS, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#if defined(SHADER_STAGE_RAY_TRACING)
|
||||
bakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
backBakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return bakeDiffuseLighting;
|
||||
}
|
||||
|
||||
float3 SampleBakedGI_UTS_OutLine(float3 positionRWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap)
|
||||
{
|
||||
float3 bakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backBakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backNormalWS = float3(0, 0, 0);
|
||||
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
EvaluateLightmap(positionRWS, normalWS, backNormalWS, uvStaticLightmap, uvDynamicLightmap, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#elif (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(positionRWS), normalWS, backNormalWS, GetWorldSpaceNormalizeViewDir(positionRWS), 0.0, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#else
|
||||
EvaluateLightProbeBuiltin(positionRWS, normalWS, backNormalWS, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#if defined(SHADER_STAGE_RAY_TRACING)
|
||||
bakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
backBakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return bakeDiffuseLighting;
|
||||
}
|
||||
|
||||
|
||||
#endif //#ifndef UCTS_HDRP_INCLUDED
|
||||
@@ -1,224 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
#undef unity_ObjectToWorld
|
||||
#undef unity_WorldToObject
|
||||
|
||||
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 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"
|
||||
|
||||
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
|
||||
|
||||
#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"
|
||||
|
||||
return PackVaryingsType(varyingsType);
|
||||
}
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
|
||||
PackedVaryingsToPS VertTesselation(VaryingsToDS input)
|
||||
{
|
||||
VaryingsToPS output;
|
||||
output.vmesh = VertMeshTesselation(input.vmesh);
|
||||
|
||||
return PackVaryingsToPS(output);
|
||||
}
|
||||
|
||||
|
||||
#endif // TESSELLATION_ON
|
||||
|
||||
#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
|
||||
#else
|
||||
#define EXTRA_BUFFER_TARGET SV_Target1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void Frag(PackedVaryingsToPS packedInput,
|
||||
#ifdef OUTPUT_SPLIT_LIGHTING
|
||||
out float4 outColor : SV_Target0, // outSpecularLighting
|
||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
||||
out float4 outVTFeedback : VT_BUFFER_TARGET,
|
||||
#endif
|
||||
out float4 outDiffuseLighting : EXTRA_BUFFER_TARGET,
|
||||
OUTPUT_SSSBUFFER(outSSSBuffer)
|
||||
#else
|
||||
out float4 outColor : SV_Target0
|
||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
||||
, out float4 outVTFeedback : VT_BUFFER_TARGET
|
||||
#endif
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
, out float4 outMotionVec : EXTRA_BUFFER_TARGET
|
||||
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
#endif // OUTPUT_SPLIT_LIGHTING
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
, out float outputDepth : SV_Depth
|
||||
#endif
|
||||
)
|
||||
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
||||
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
||||
#ifdef _IS_CLIPPING_MASK
|
||||
if (_ClippingMaskMode != 0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode != 0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#if defined(UTS_DEBUG_SHADOWMAP_NO_OUTLINE)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//v.2.0.5
|
||||
if (_ZOverDrawMode > 0.99f)
|
||||
{
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
||||
|
||||
outVTFeedback = builtinData.vtPackedFeedback;
|
||||
#endif
|
||||
outColor = float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0
|
||||
return;
|
||||
}
|
||||
_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(
|
||||
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)
|
||||
).rgb;
|
||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||
ambientSkyColor *= GetCurrentExposureMultiplier() * 5.0f;
|
||||
|
||||
float4 _MainTex_var = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _MainTex));
|
||||
float3 Set_BaseColor = _BaseColor.rgb*_MainTex_var.rgb;
|
||||
float3 _Is_BlendBaseColor_var = lerp(_Outline_Color.rgb * ambientSkyColor, (_Outline_Color.rgb * ambientSkyColor * Set_BaseColor * Set_BaseColor), _Is_BlendBaseColor);
|
||||
//
|
||||
float3 _OutlineTex_var = tex2D(_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)).xyz;
|
||||
|
||||
float4 overridingColor = lerp(_OutlineMaskColor, float4(_OutlineMaskColor.w, _OutlineMaskColor.w, _OutlineMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_OutlineOverridden, _ComposerMaskMode);
|
||||
|
||||
//v.2.0.7.5
|
||||
#ifdef _IS_OUTLINE_CLIPPING_NO
|
||||
float3 Set_Outline_Color = lerp(_Is_BlendBaseColor_var, _OutlineTex_var.rgb*_Outline_Color.rgb * ambientSkyColor, _Is_OutlineTex );
|
||||
if (_OutlineVisible < 0.1)
|
||||
{
|
||||
// Todo.
|
||||
// without this, something is drawn even if _OutlineVisible = 0, in AngelRing(HDRP)
|
||||
discard;
|
||||
}
|
||||
Set_Outline_Color = lerp(Set_Outline_Color, overridingColor.xyz, maskEnabled);
|
||||
float3 volColor, volOpacity;
|
||||
|
||||
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);
|
||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||
|
||||
EvaluateAtmosphericScattering(posInput, V, volColor, volOpacity); // Premultiplied alpha
|
||||
Set_Outline_Color.xyz = Set_Outline_Color.xyz * (1 - volOpacity) + volColor * _OutlineVisible;
|
||||
outColor =float4(Set_Outline_Color, _OutlineVisible );
|
||||
|
||||
|
||||
#elif _IS_OUTLINE_CLIPPING_YES
|
||||
float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _ClippingMask));
|
||||
float Set_MainTexAlpha = _MainTex_var.a;
|
||||
float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask );
|
||||
float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping );
|
||||
float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level));
|
||||
clip(Set_Clipping - 0.5);
|
||||
float4 Set_Outline_Color = lerp( float4(_Is_BlendBaseColor_var, Set_Clipping), float4((_OutlineTex_var.rgb * _Outline_Color.rgb * ambientSkyColor),Set_Clipping), _Is_OutlineTex );
|
||||
Set_Outline_Color = lerp(Set_Outline_Color, overridingColor, maskEnabled);
|
||||
Set_Outline_Color.w *= _OutlineVisible;
|
||||
|
||||
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);
|
||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||
|
||||
float3 volColor, volOpacity;
|
||||
EvaluateAtmosphericScattering(posInput, V, volColor, volOpacity); // Premultiplied alpha
|
||||
Set_Outline_Color.xyz = Set_Outline_Color.xyz * (1 - volOpacity.x) + volColor * Set_Outline_Color.w;
|
||||
outColor = Set_Outline_Color;
|
||||
#endif
|
||||
//outColor.rgb = ambientSkyColor;
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
||||
outVTFeedback = builtinData.vtPackedFeedback;
|
||||
#endif
|
||||
}
|
||||
// End of File
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
|
||||
#if 1
|
||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||
float2 Set_UV0 = inputMesh.uv0;
|
||||
float4 _Outline_Sampler_var = tex2Dlod(_Outline_Sampler, float4(TRANSFORM_TEX(Set_UV0, _Outline_Sampler), 0.0, 0));
|
||||
//v.2.0.4.3 baked Normal Texture for Outline
|
||||
float3 normalDir = UnityObjectToWorldNormal(inputMesh.normalOS);
|
||||
float3 tangentDir = normalize(mul(unity_ObjectToWorld, float4(inputMesh.tangentOS.xyz, 0.0)).xyz);
|
||||
float3 bitangentDir = normalize(cross(normalDir, tangentDir) * inputMesh.tangentOS.w);
|
||||
float3x3 tangentTransform = float3x3(tangentDir, bitangentDir, normalDir);
|
||||
//UnpackNormal() can't be used, and so as follows. Do not specify a bump for the texture to be used.
|
||||
float4 _BakedNormal_var = (tex2Dlod(_BakedNormal, float4(TRANSFORM_TEX(Set_UV0, _BakedNormal), 0.0, 0)) * 2 - 1);
|
||||
float3 _BakedNormalDir = normalize(mul(_BakedNormal_var.rgb, tangentTransform));
|
||||
//end
|
||||
float Set_Outline_Width = (_Outline_Width * 0.01 * smoothstep(_Farthest_Distance, _Nearest_Distance, distance(objPos.rgb, _WorldSpaceCameraPos)) * _Outline_Sampler_var.rgb).r;
|
||||
Set_Outline_Width *= (1.0f - _ZOverDrawMode);
|
||||
//v.2.0.7.5
|
||||
float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1));
|
||||
//v.2.0.7
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
//v.2.0.4.2 (DX)
|
||||
_Offset_Z = _Offset_Z * -0.01;
|
||||
#else
|
||||
//OpenGL
|
||||
_Offset_Z = _Offset_Z * 0.01;
|
||||
#endif
|
||||
float3 FinalNormal;
|
||||
if(_UseSmoothedNormal == 1)
|
||||
{
|
||||
float3 normal = float3(inputMesh.uv1, 0);
|
||||
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
|
||||
FinalNormal = mul(normal, tangentTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
FinalNormal = lerp(inputMesh.normalOS, _BakedNormalDir, _Is_BakedNormal);
|
||||
}
|
||||
|
||||
//v2.0.4
|
||||
#ifdef _OUTLINE_NML
|
||||
//v.2.0.4.3 baked Normal Texture for Outline
|
||||
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), FinalNormal);
|
||||
#elif _OUTLINE_POS
|
||||
Set_Outline_Width = Set_Outline_Width * 2;
|
||||
float signVar = dot(normalize(inputMesh.positionOS), normalize(inputMesh.normalOS)) < 0 ? -1 : 1;
|
||||
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), signVar * normalize(inputMesh.positionOS));
|
||||
#endif
|
||||
// screen space width
|
||||
float2 extendDir = normalize(TransformWViewToHClip(normal).xy);
|
||||
float4 clipPos = UnityObjectToClipPos(inputMesh.positionOS);
|
||||
clipPos.xy += extendDir * min(_Outline_MaxWidth, (clipPos.w * Set_Outline_Width));
|
||||
clipPos.z = clipPos.z + _Offset_Z * _ClipCameraPos.z;
|
||||
|
||||
float4 rws = mul(UNITY_MATRIX_I_P, clipPos); // use UNITY_MATRIX_I_P instead of unity_CameraInvProjection.
|
||||
rws = mul(UNITY_MATRIX_I_V, rws); // use UNITY_MATRIX_I_V instead of unity_cameraToWorld.
|
||||
#ifndef TESSELLATION_ON
|
||||
varyingsType.vmesh.positionCS = clipPos;
|
||||
#endif // TESSELLATION_ON
|
||||
varyingsType.vmesh.positionRWS = rws.xyz;
|
||||
|
||||
#endif // #if 1
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6499b7b5ccaae6944ae5fe89b016c50b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,189 +0,0 @@
|
||||
#define ColorSpaceDielectricSpec half4(0.22, 0.22, 0.22, 0.779)
|
||||
|
||||
float3 schlick(float f0, float hl) {
|
||||
real x = 1.0 - hl;
|
||||
real x2 = x * x;
|
||||
real x5 = x * x2 * x2;
|
||||
return (1.0 - f0) * x5 + f0;
|
||||
}
|
||||
|
||||
float3 SpecularColor(float3 albedo, float metalic)
|
||||
{
|
||||
float3 specColor = lerp(ColorSpaceDielectricSpec.rgb, albedo, metalic);
|
||||
return specColor;
|
||||
}
|
||||
|
||||
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(float3 V, float3 L, BSDFData bsdfData)
|
||||
{
|
||||
float3 specTerm;
|
||||
#ifdef _PBR_Mode_OFF
|
||||
return 0;
|
||||
#else
|
||||
float3 N = bsdfData.normalWS;
|
||||
float3 H = normalize(L + V);
|
||||
|
||||
float NdotL = dot(N, L);
|
||||
float NdotV = dot(N, V);
|
||||
float clampedNdotV = ClampNdotV(NdotV);
|
||||
float clampedNdotL = saturate(NdotL);
|
||||
float flippedNdotL = ComputeWrappedDiffuseLighting(-NdotL, TRANSMISSION_WRAP_LIGHT);
|
||||
float diffuseNdotL = clampedNdotL;
|
||||
float LdotV = dot(L, V);
|
||||
float NdotH = saturate(dot(N, H));
|
||||
float HdotL = saturate(dot(H, L));
|
||||
|
||||
float3 F = schlick(bsdfData.fresnel0.x, HdotL);
|
||||
|
||||
float partLambdaV;
|
||||
float3 DV = 0;
|
||||
#ifdef _PBR_Mode_ST
|
||||
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughness, 0, bsdfData.roughnessT, bsdfData.roughnessB);
|
||||
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_ANISO
|
||||
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_KK
|
||||
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));
|
||||
specTerm = pow(NdotH, 5.0 * specularExponent);
|
||||
specTerm = StepFeatherToon(specTerm, _ToonSpecularStep, _ToonSpecularFeather);
|
||||
return specTerm * ColorSpaceDielectricSpec.rgb * clampedNdotL;
|
||||
#endif
|
||||
|
||||
specTerm = DV * F;
|
||||
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));
|
||||
}
|
||||
|
||||
// Todo: SDF nose high light
|
||||
// #if define(_SDFShadow) || define(_SDFNoiseHelight)
|
||||
#ifdef _SDFShadow
|
||||
|
||||
// Use main light XZ direction & world Left/Forward Vector to sample character face SDF
|
||||
void SDFSample(out float4 lSDF_Tex, out float4 rSDF_Tex, out float2 leftVector, out float2 forwardVector, float2 UV)
|
||||
{
|
||||
lSDF_Tex = SAMPLE_TEXTURE2D(_SDFShadowTex, sampler_SDFShadowTex, UV);
|
||||
float2 right_uv = float2(1 - UV.x, UV.y);
|
||||
rSDF_Tex = SAMPLE_TEXTURE2D(_SDFShadowTex, sampler_SDFShadowTex, right_uv);
|
||||
|
||||
leftVector = normalize(mul(UNITY_MATRIX_M, float4(1, 0, 0, 0)).xz);
|
||||
forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0, 0, 1, 0)).xz);
|
||||
}
|
||||
|
||||
// Return 1 -> right side
|
||||
bool SDFPickSide(out float angle, float2 Left, float2 Front, float2 lightDir)
|
||||
{
|
||||
// Remap [-1,1] tp [0,1] | 0 <- Face Toward Light ---- Back Toward Light -> 1
|
||||
angle = 1- clamp(0 , 1, dot(Front, lightDir) * 0.5 + 0.5);
|
||||
// Pick side
|
||||
return dot(lightDir,Left) > 0;
|
||||
}
|
||||
|
||||
// Output: readjusted angle between light and pixel facing direction (Represented by a projection length) [Out Param, angle]
|
||||
// Output: SDF Texel Color [Return Value]
|
||||
float4 SDFResult(inout bool rightside, out float angle, float3 L, float2 UV)
|
||||
{
|
||||
|
||||
float4 left_SDFTex;
|
||||
float4 right_SDFTex;
|
||||
float2 Left;
|
||||
float2 Front;
|
||||
|
||||
SDFSample(left_SDFTex, right_SDFTex, Left, Front, UV);
|
||||
|
||||
float2 light_Dir = normalize(L.xz);
|
||||
rightside = SDFPickSide(angle, Left, Front, light_Dir);
|
||||
|
||||
return rightside ? right_SDFTex : left_SDFTex;
|
||||
}
|
||||
|
||||
float SDFMask(float angle, float tex_direct)
|
||||
{
|
||||
float smoothGamma = _SDFSmoothGamma / 10.0f;
|
||||
float shadowLevel = _SDFShadowLevel / 10.0f;
|
||||
|
||||
float SDFMask = smoothstep(tex_direct - smoothGamma, tex_direct + smoothGamma, angle - shadowLevel);
|
||||
return SDFMask;
|
||||
}
|
||||
|
||||
float SDFNoseHighlight(float angle,float tex_value, bool rightside, float2 UV)
|
||||
{
|
||||
// REF: https://zhuanlan.zhihu.com/p/411188212 3.2.1
|
||||
float highlightValue = 0;
|
||||
|
||||
//float cutU = step(0.5, UV.x);
|
||||
float cutU = UV.x;
|
||||
|
||||
float uvMask=lerp(cutU, 1 - cutU, rightside);//discard half of the sdf we sampled (Only one side of highlight wanted)
|
||||
float lightAtten = pow(max(0, angle - (_SDFShadowLevel / 10.0f)), 0.8);
|
||||
|
||||
return smoothstep(lightAtten-_SDFNoseHighlightSmoothRange,lightAtten+_SDFNoseHighlightSmoothRange , uvMask * tex_value) * tex_value; // Safeguard, return 0 when tex_value = 0
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
#if SHADERPASS != SHADERPASS_FORWARD
|
||||
#error SHADERPASS_is_not_correctly_define
|
||||
#endif
|
||||
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl"
|
||||
|
||||
PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass)
|
||||
{
|
||||
VaryingsType varyingsType;
|
||||
varyingsType.vmesh = VertMesh(inputMesh);
|
||||
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
|
||||
|
||||
#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);
|
||||
|
||||
return PackVaryingsType(varyingsType);
|
||||
}
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
|
||||
PackedVaryingsToPS VertTesselation(VaryingsToDS input)
|
||||
{
|
||||
VaryingsToPS output;
|
||||
output.vmesh = VertMeshTesselation(input.vmesh);
|
||||
|
||||
return PackVaryingsToPS(output);
|
||||
}
|
||||
|
||||
|
||||
#endif // TESSELLATION_ON
|
||||
|
||||
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl"
|
||||
#endif
|
||||
|
||||
void Frag(PackedVaryingsToPS packedInput,
|
||||
#ifdef OUTPUT_SPLIT_LIGHTING
|
||||
out float4 outColor : SV_Target0, // outSpecularLighting
|
||||
out float4 outDiffuseLighting : SV_Target1,
|
||||
OUTPUT_SSSBUFFER(outSSSBuffer)
|
||||
#else
|
||||
out float4 outColor : SV_Target0
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
, out float4 outMotionVec : SV_Target1
|
||||
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
#endif // OUTPUT_SPLIT_LIGHTING
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
, out float outputDepth : SV_Depth
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
// Init outMotionVector here to solve compiler warning (potentially unitialized variable)
|
||||
// It is init to the value of forceNoMotion (with 2.0)
|
||||
outMotionVec = float4(2.0, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
||||
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
||||
|
||||
// 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);
|
||||
|
||||
#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;
|
||||
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
|
||||
|
||||
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
|
||||
|
||||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
||||
|
||||
outColor = float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
// We need to skip lighting when doing debug pass because the debug pass is done before lighting so some buffers may not be properly initialized potentially causing crashes on PS4.
|
||||
|
||||
#ifdef DEBUG_DISPLAY
|
||||
// Init in debug display mode to quiet warning
|
||||
#ifdef OUTPUT_SPLIT_LIGHTING
|
||||
outDiffuseLighting = 0;
|
||||
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));
|
||||
|
||||
surfaceData.baseColor = _MainTex_var.xyz;
|
||||
|
||||
|
||||
// Same code in ShaderPassForwardUnlit.shader
|
||||
// Reminder: _DebugViewMaterialArray[i]
|
||||
// i==0 -> the size used in the buffer
|
||||
// i>0 -> the index used (0 value means nothing)
|
||||
// The index stored in this buffer could either be
|
||||
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
|
||||
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
|
||||
bool viewMaterial = false;
|
||||
int bufferSize = int(_DebugViewMaterialArray[0]);
|
||||
if (bufferSize != 0)
|
||||
{
|
||||
bool needLinearToSRGB = false;
|
||||
float3 result = float3(1.0, 0.0, 1.0);
|
||||
|
||||
// Loop through the whole buffer
|
||||
// Works because GetSurfaceDataDebug will do nothing if the index is not a known one
|
||||
for (int index = 1; index <= bufferSize; index++)
|
||||
{
|
||||
int indexMaterialProperty = int(_DebugViewMaterialArray[index]);
|
||||
|
||||
// skip if not really in use
|
||||
if (indexMaterialProperty != 0)
|
||||
{
|
||||
viewMaterial = true;
|
||||
|
||||
GetPropertiesDataDebug(indexMaterialProperty, result, needLinearToSRGB);
|
||||
GetVaryingsDataDebug(indexMaterialProperty, input, result, needLinearToSRGB);
|
||||
GetBuiltinDataDebug(indexMaterialProperty, builtinData, result, needLinearToSRGB);
|
||||
GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB);
|
||||
GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB);
|
||||
}
|
||||
}
|
||||
|
||||
// TEMP!
|
||||
// For now, the final blit in the backbuffer performs an sRGB write
|
||||
// So in the meantime we apply the inverse transform to linear data to compensate.
|
||||
if (!needLinearToSRGB)
|
||||
result = SRGBToLinear(max(0, result));
|
||||
|
||||
outColor = float4(result, 1.0);
|
||||
}
|
||||
|
||||
if (!viewMaterial)
|
||||
{
|
||||
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR || _DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR)
|
||||
{
|
||||
float3 result = float3(0.0, 0.0, 0.0);
|
||||
|
||||
GetPBRValidatorDebug(surfaceData, result);
|
||||
|
||||
outColor = float4(result, 1.0f);
|
||||
}
|
||||
else if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW)
|
||||
{
|
||||
float4 result = _DebugTransparencyOverdrawWeight * float4(TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_A);
|
||||
outColor = result;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef _SURFACE_TYPE_TRANSPARENT
|
||||
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT;
|
||||
#else
|
||||
uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE;
|
||||
#endif
|
||||
float3 diffuseLighting;
|
||||
float3 specularLighting;
|
||||
|
||||
LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
|
||||
|
||||
diffuseLighting *= GetCurrentExposureMultiplier();
|
||||
specularLighting *= GetCurrentExposureMultiplier();
|
||||
|
||||
#ifdef OUTPUT_SPLIT_LIGHTING
|
||||
if (_EnableSubsurfaceScattering != 0 && ShouldOutputSplitLighting(bsdfData))
|
||||
{
|
||||
outColor = float4(specularLighting, 1.0);
|
||||
outDiffuseLighting = float4(TagLightingForSSS(diffuseLighting), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
outColor = float4(diffuseLighting + specularLighting, 1.0);
|
||||
outDiffuseLighting = 0;
|
||||
}
|
||||
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
|
||||
#else
|
||||
outColor = ApplyBlendMode(diffuseLighting, specularLighting, builtinData.opacity);
|
||||
outColor = EvaluateAtmosphericScattering(posInput, V, outColor);
|
||||
#endif
|
||||
|
||||
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
||||
VaryingsPassToPS inputPass = UnpackVaryingsPassToPS(packedInput.vpass);
|
||||
bool forceNoMotion = any(unity_MotionVectorsParams.yw == 0.0);
|
||||
// outMotionVec is already initialize at the value of forceNoMotion (see above)
|
||||
if (!forceNoMotion)
|
||||
{
|
||||
float2 motionVec = CalculateMotionVector(inputPass.positionCS, inputPass.previousPositionCS);
|
||||
EncodeMotionVector(motionVec * 0.5, outMotionVec);
|
||||
outMotionVec.zw = 1.0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISPLAY
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
#endif
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b4f1c7876302e04a81e6bd06cb9dd39
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,353 +0,0 @@
|
||||
// ===========================================================================
|
||||
// WARNING:
|
||||
// On PS4, texture/sampler declarations need to be outside of CBuffers
|
||||
// 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;
|
||||
float4 unity_MipmapStreaming_DebugTex_MipInfo;
|
||||
float4 unity_MipmapStreaming_DebugTex_StreamInfo;
|
||||
|
||||
// Unity Toon Shader
|
||||
#include "UtsTextures.hlsl"
|
||||
|
||||
// Lit
|
||||
TEXTURE2D(_DistortionVectorMap);
|
||||
SAMPLER(sampler_DistortionVectorMap);
|
||||
|
||||
TEXTURE2D(_EmissiveColorMap);
|
||||
SAMPLER(sampler_EmissiveColorMap);
|
||||
|
||||
#ifndef LAYERED_LIT_SHADER
|
||||
|
||||
TEXTURE2D(_DiffuseLightingMap);
|
||||
SAMPLER(sampler_DiffuseLightingMap);
|
||||
|
||||
TEXTURE2D(_BaseColorMap);
|
||||
SAMPLER(sampler_BaseColorMap);
|
||||
|
||||
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(_SDFShadowTex);
|
||||
SAMPLER(sampler_SDFShadowTex);
|
||||
|
||||
TEXTURE2D(_HairShadowTex);
|
||||
//SAMPLER(sampler_HairShadowTex); //registered number of this sampler is more than 16, so we can't use this sampler, use s_trilinear_clamp_sampler instead
|
||||
|
||||
#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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
#ifndef LAYERED_LIT_SHADER
|
||||
|
||||
// Set of users variables
|
||||
float4 _BaseColor;
|
||||
float4 _BaseColorMap_ST;
|
||||
float4 _BaseColorMap_TexelSize;
|
||||
float4 _BaseColorMap_MipInfo;
|
||||
|
||||
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 _AOMin;
|
||||
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
|
||||
|
||||
|
||||
|
||||
// Tessellation specific
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessellationFactor;
|
||||
float _TessellationFactorMinDistance;
|
||||
float _TessellationFactorMaxDistance;
|
||||
float _TessellationFactorTriangleSize;
|
||||
float _TessellationShapeFactor;
|
||||
float _TessellationBackFaceCullEpsilon;
|
||||
float _TessellationObjectScale;
|
||||
float _TessellationTilingScale;
|
||||
#endif
|
||||
|
||||
// Following two variables are feeded by the C++ Editor for Scene selection
|
||||
int _ObjectId;
|
||||
int _PassValue;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
float _Outline_MaxWidth;
|
||||
|
||||
float4 _HairShadowRTHandleScale;
|
||||
|
||||
float _HairShadowDistance;
|
||||
float _HairShadowDistanceScaleFactor;
|
||||
float _HairShadowDepthBias;
|
||||
float _HairShadowFadeInDistance;
|
||||
float _HairShadowFadeOutDistance;
|
||||
@@ -1,275 +0,0 @@
|
||||
//Unity Toon Shader/HDRP
|
||||
//nobuyuki@unity3d.com
|
||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl"
|
||||
#include "HDRPToonHead.hlsl"
|
||||
|
||||
// Channel mask enum.
|
||||
// this must be same to UI cs code
|
||||
// HDRPToonGUI._ChannelEnum
|
||||
int eBaseColor = 0;
|
||||
int eFirstShade = 1;
|
||||
int eSecondShade = 2;
|
||||
int eHighlight = 3;
|
||||
int eAngelRing = 4;
|
||||
int eRimLight = 5;
|
||||
int eOutline = 6;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// not in materials
|
||||
int _ToonLightHiCutFilter;
|
||||
int _ToonEvAdjustmentCurve;
|
||||
float _ToonEvAdjustmentValueArray[128];
|
||||
float _ToonEvAdjustmentValueMin;
|
||||
float _ToonEvAdjustmentValueMax;
|
||||
float _ToonEvAdjustmentCompensation;
|
||||
float _ToonIgnoreExposureMultiplier;
|
||||
|
||||
|
||||
// function to rotate the UV: RotateUV()
|
||||
//float2 rotatedUV = RotateUV(i.uv0, (_angular_Verocity*3.141592654), float2(0.5, 0.5), _Time.g);
|
||||
float2 RotateUV(float2 _uv, float _radian, float2 _piv, float _time)
|
||||
{
|
||||
float RotateUV_ang = _radian;
|
||||
float RotateUV_cos = cos(_time*RotateUV_ang);
|
||||
float RotateUV_sin = sin(_time*RotateUV_ang);
|
||||
return (mul(_uv - _piv, float2x2(RotateUV_cos, -RotateUV_sin, RotateUV_sin, RotateUV_cos)) + _piv);
|
||||
}
|
||||
|
||||
float3 ConvertFromEV100(float3 EV100)
|
||||
{
|
||||
#if 1
|
||||
float3 value = pow(2, EV100) * 2.5f;
|
||||
return value;
|
||||
#else
|
||||
float3 maxLuminance = 1.2f * pow(2.0f, EV100);
|
||||
return 1.0f / maxLuminance;
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 ConvertToEV100(float3 value)
|
||||
{
|
||||
#if 1
|
||||
return log2(value*0.4f);
|
||||
#else
|
||||
return log2(1.0f / (1.2f * value));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
float WeightSample(PositionInputs positionInput)
|
||||
{
|
||||
// Center-weighted
|
||||
const float2 kCenter = _ScreenParams.xy * 0.5;
|
||||
const float weight = pow(length((kCenter.xy - positionInput.positionSS.xy) / _ScreenParams.xy),1.0) ;
|
||||
return 1.0 - saturate(weight);
|
||||
}
|
||||
|
||||
float3 ApplyCompensation(float3 originalColor)
|
||||
{
|
||||
float3 ev100_Color = ConvertToEV100(originalColor) +_ToonEvAdjustmentCompensation * 0.5f;
|
||||
|
||||
|
||||
float3 resultColor = max(0, ConvertFromEV100(ev100_Color));
|
||||
return resultColor;
|
||||
}
|
||||
|
||||
float3 ApplyCurrentExposureMultiplier(float3 color)
|
||||
{
|
||||
return color * lerp(GetCurrentExposureMultiplier(), 1, _ToonIgnoreExposureMultiplier);
|
||||
}
|
||||
|
||||
|
||||
float3 GetExposureAdjustedColor(float3 originalColor)
|
||||
{
|
||||
if (_ToonEvAdjustmentCurve != 0)
|
||||
{
|
||||
|
||||
float3 ev100_Color = ConvertToEV100(originalColor);
|
||||
ev100_Color = clamp(ev100_Color, _ToonEvAdjustmentValueMin, _ToonEvAdjustmentValueMax);
|
||||
float3 ev100_remap = (ev100_Color - _ToonEvAdjustmentValueMin) * (128-1) / (_ToonEvAdjustmentValueMax - _ToonEvAdjustmentValueMin);
|
||||
ev100_remap = clamp(ev100_remap, 0.0, 127.0);
|
||||
int3 ev100_idx = (int3)ev100_remap;
|
||||
float3 ev100_lerp = ev100_remap - ev100_idx;
|
||||
float3 ev100_remapped;
|
||||
|
||||
ev100_remapped.r = _ToonEvAdjustmentValueArray[ev100_idx.r] +(_ToonEvAdjustmentValueArray[ev100_idx.r + 1] - _ToonEvAdjustmentValueArray[ev100_idx.r]) * ev100_lerp.r;
|
||||
ev100_remapped.g = _ToonEvAdjustmentValueArray[ev100_idx.g] +(_ToonEvAdjustmentValueArray[ev100_idx.g + 1] - _ToonEvAdjustmentValueArray[ev100_idx.g]) * ev100_lerp.g;
|
||||
ev100_remapped.b = _ToonEvAdjustmentValueArray[ev100_idx.b] +(_ToonEvAdjustmentValueArray[ev100_idx.b + 1] - _ToonEvAdjustmentValueArray[ev100_idx.b]) * ev100_lerp.b;
|
||||
|
||||
|
||||
float3 resultColor = ConvertFromEV100(ev100_remapped);
|
||||
|
||||
|
||||
return resultColor;
|
||||
}
|
||||
else // else is neccessary to avoid warrnings.
|
||||
{
|
||||
return originalColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float GetLightAttenuation(float3 lightColor)
|
||||
{
|
||||
float lightAttenuation = rateR *lightColor.r + rateG *lightColor.g + rateB *lightColor.b;
|
||||
return lightAttenuation;
|
||||
}
|
||||
|
||||
|
||||
int GetNextDirectionalLightIndex(BuiltinData builtinData, int currentIndex, int mainLightIndex)
|
||||
{
|
||||
int i = 0; // Declare once to avoid the D3D11 compiler warning.
|
||||
for (i = 0; i < (int)_DirectionalLightCount; ++i)
|
||||
{
|
||||
if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, builtinData.renderingLayers))
|
||||
{
|
||||
if (mainLightIndex != i)
|
||||
{
|
||||
if (currentIndex < i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 = GetLightAttenuation(currentLightColor);
|
||||
|
||||
if (mainLightIndex == -1 || (currentLightAttenuation > lightAttenuation))
|
||||
{
|
||||
mainLightIndex = i;
|
||||
lightAttenuation = currentLightAttenuation;
|
||||
|
||||
lightColor = currentLightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mainLightIndex;
|
||||
}
|
||||
|
||||
// UTSLightData GetUTSMainPunctualLightData(BuiltinData builtinData, PositionInputs posInput)
|
||||
// {
|
||||
// UTSLightData mainPunctualLight;
|
||||
|
||||
// uint lightCount, lightStart;
|
||||
|
||||
// #ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
// GetCountAndStart(posInput, LIGHTCATEGORY_PUNCTUAL, lightStart, lightCount);
|
||||
// #else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
// lightCount = _PunctualLightCount;
|
||||
// lightStart = 0;
|
||||
// #endif
|
||||
// bool fastPath = false;
|
||||
// #if SCALARIZE_LIGHT_LOOP
|
||||
// uint lightStartLane0;
|
||||
// fastPath = IsFastPath(lightStart, lightStartLane0);
|
||||
|
||||
// if (fastPath)
|
||||
// {
|
||||
// lightStart = lightStartLane0;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// uint v_lightListOffset = 0;
|
||||
// uint v_lightIdx = lightStart;
|
||||
// float channelAlpha = 0.0f;
|
||||
// [loop] // vulkan shader compiler can not unroll.
|
||||
// while (v_lightListOffset < lightCount)
|
||||
// {
|
||||
// v_lightIdx = FetchIndex(lightStart, v_lightListOffset);
|
||||
// #if SCALARIZE_LIGHT_LOOP
|
||||
// uint s_lightIdx = ScalarizeElementIndex(v_lightIdx, fastPath);
|
||||
// #else
|
||||
// uint s_lightIdx = v_lightIdx;
|
||||
// #endif
|
||||
// if (s_lightIdx == -1)
|
||||
// break;
|
||||
|
||||
// LightData s_lightData = FetchLight(s_lightIdx);
|
||||
|
||||
// // If current scalar and vector light index match, we process the light. The v_lightListOffset for current thread is increased.
|
||||
// // Note that the following should really be ==, however, since helper lanes are not considered by WaveActiveMin, such helper lanes could
|
||||
// // end up with a unique v_lightIdx value that is smaller than s_lightIdx hence being stuck in a loop. All the active lanes will not have this problem.
|
||||
// if (s_lightIdx >= v_lightIdx)
|
||||
// {
|
||||
// v_lightListOffset++;
|
||||
// if (IsMatchingLightLayer(s_lightData.lightLayers, builtinData.renderingLayers))
|
||||
// {
|
||||
// float3 lightDirection;
|
||||
// float4 distances; // {d, d^2, 1/d, d_proj}
|
||||
// GetPunctualLightVectors(posInput.positionWS, s_lightData, lightDirection, distances);
|
||||
// float4 lightColor = EvaluateLight_Punctual(context, posInput, s_lightData, lightDirection, distances);
|
||||
// float3 additionalLightColor = ApplyCurrentExposureMultiplier(lightColor.rgb) * lightColor.a;
|
||||
// const float notDirectional = 1.0f;
|
||||
|
||||
// UTSLightData utsLightData;
|
||||
// utsLightData.lightColor = additionalLightColor;
|
||||
// utsLightData.lightDirection = lightDirection;
|
||||
// utsLightData.diffuseDimmer = s_lightData.diffuseDimmer;
|
||||
// utsLightData.specularDimmer = s_lightData.specularDimmer;
|
||||
// utsLightData.shadowTint = s_lightData.shadowTint;
|
||||
// utsLightData.penumbraTint = s_lightData.penumbraTint;
|
||||
|
||||
// if(length(additionalLightColor) >= length(mainPunctualLight.lightColor))
|
||||
// {
|
||||
// mainPunctualLight = utsLightData;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
# include "ShadingOtherLight.hlsl"
|
||||
# include "UtsSelfShadowMainLight.hlsl"
|
||||
# include "ShadingMainLight.hlsl"
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
// Unity Toon Shader
|
||||
// sampler2D _MainTex;
|
||||
// sampler2D _1st_ShadeMap;
|
||||
// sampler2D _2nd_ShadeMap;
|
||||
|
||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_1st_ShadeMap);
|
||||
TEXTURE2D(_2nd_ShadeMap);
|
||||
|
||||
|
||||
sampler _Set_1st_ShadePosition;
|
||||
sampler _Set_2nd_ShadePosition;
|
||||
sampler _ShadingGradeMap;
|
||||
sampler _HighColor_Tex;
|
||||
sampler _Set_HighColorMask;
|
||||
sampler _Set_RimLightMask;
|
||||
sampler _MatCap_Sampler;
|
||||
sampler _NormalMapForMatCap;
|
||||
sampler _Set_MatcapMask;
|
||||
sampler _Emissive_Tex;
|
||||
// sampler2D _ClippingMask;
|
||||
TEXTURE2D(_ClippingMask);
|
||||
sampler _AngelRing_Sampler;
|
||||
sampler _Outline_Sampler;
|
||||
sampler _OutlineTex;
|
||||
sampler _BakedNormal;
|
||||
@@ -1,205 +0,0 @@
|
||||
|
||||
// cosntant in Unity Toon Shader
|
||||
float _utsTechnique;
|
||||
float4 _Color;
|
||||
fixed _Use_BaseAs1st;
|
||||
fixed _Use_1stAs2nd;
|
||||
fixed _Is_LightColor_Base;
|
||||
float4 _MainTex_ST;
|
||||
float4 _1st_ShadeMap_ST;
|
||||
float4 _1st_ShadeColor;
|
||||
fixed _Is_LightColor_1st_Shade;
|
||||
float4 _2nd_ShadeMap_ST;
|
||||
float4 _2nd_ShadeColor;
|
||||
fixed _Is_LightColor_2nd_Shade;
|
||||
fixed _Is_NormalMapToBase;
|
||||
fixed _Set_SystemShadowsToBase;
|
||||
|
||||
float _Tweak_SystemShadowsLevel;
|
||||
float _ShadowBias;
|
||||
float _SDFShadowLevel;
|
||||
float _SDFSmoothGamma;
|
||||
float _SDFNoseHighlightCoef;
|
||||
float _SDFNoseHighlightSmoothRange;
|
||||
|
||||
float _EyeParallaxAmount;
|
||||
float _EyeBrowBlendingFactor;
|
||||
|
||||
float _BaseColor_Step;
|
||||
float _BaseShade_Feather;
|
||||
float4 _Set_1st_ShadePosition_ST;
|
||||
|
||||
float _ShadeColor_Step;
|
||||
float _1st2nd_Shades_Feather;
|
||||
float4 _Set_2nd_ShadePosition_ST;
|
||||
float4 _ShadingGradeMap_ST;
|
||||
|
||||
float _Tweak_ShadingGradeMapLevel;
|
||||
fixed _BlurLevelSGM;
|
||||
//
|
||||
float _1st_ShadeColor_Step;
|
||||
float _1st_ShadeColor_Feather;
|
||||
float _2nd_ShadeColor_Step;
|
||||
float _2nd_ShadeColor_Feather;
|
||||
|
||||
float4 _HighColor;
|
||||
float4 _HighColor_Tex_ST;
|
||||
fixed _Is_LightColor_HighColor;
|
||||
|
||||
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;
|
||||
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;
|
||||
float4 _AngelRing_Sampler_ST;
|
||||
|
||||
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 _OutlineVisible;
|
||||
float _OutlineOverridden;
|
||||
float4 _OutlineMaskColor;
|
||||
|
||||
float _ComposerMaskMode;
|
||||
int _ClippingMatteMode;
|
||||
|
||||
float _GI_Intensity;
|
||||
float _Light_Intensity_Multiplier;
|
||||
|
||||
|
||||
float4 _AngelRing_Color;
|
||||
fixed _Is_LightColor_AR;
|
||||
float _AR_Intensity;
|
||||
float _AR_ShadowIntensity;
|
||||
float _AR_OffsetU;
|
||||
float _AR_OffsetV;
|
||||
fixed _ARSampler_AlphaOn;
|
||||
|
||||
// Unity Toon Shader Outline
|
||||
|
||||
float _Outline_Width;
|
||||
float _Farthest_Distance;
|
||||
float _Nearest_Distance;
|
||||
float4 _Outline_Sampler_ST;
|
||||
float4 _Outline_Color;
|
||||
fixed _Is_BlendBaseColor;
|
||||
float _Offset_Z;
|
||||
float4 _OutlineTex_ST;
|
||||
fixed _Is_OutlineTex;
|
||||
float4 _BakedNormal_ST;
|
||||
fixed _Is_BakedNormal;
|
||||
fixed _UseSmoothedNormal;
|
||||
|
||||
float _ZOverDrawMode;
|
||||
//
|
||||
|
||||
#if defined(_UTS_TOON_EV_PER_MODEL)
|
||||
// not in materials
|
||||
int _ToonLightHiCutFilter;
|
||||
int _ToonEvAdjustmentCurve;
|
||||
float _ToonEvAdjustmentValueArray[128];
|
||||
float _ToonEvAdjustmentValueMin;
|
||||
float _ToonEvAdjustmentValueMax;
|
||||
float _ToonEvAdjustmentCompensation;
|
||||
#endif //#if !defined(_UTS_TOON_EV_PER_MODEL)
|
||||
|
||||
|
||||
float _BlendMode;
|
||||
|
||||
float3 _ObjectCenterPositionWS;
|
||||
@@ -1,145 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
using UnityEngine.Rendering.RendererUtils;
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
[HideInInspector]
|
||||
internal class UTSHairShadowPass : DrawRenderersCustomPass
|
||||
{
|
||||
public enum ShadowQuality
|
||||
{
|
||||
Low,
|
||||
High
|
||||
}
|
||||
|
||||
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 Output_RT_Name = "_HairShadowTex";
|
||||
|
||||
private RTHandle _outputRTHandle;
|
||||
private bool _needReallocate;
|
||||
|
||||
private ShadowQuality _shadowQuality = ShadowQuality.High;
|
||||
internal ShadowQuality CurrentShadowQuality
|
||||
{
|
||||
get => _shadowQuality;
|
||||
set
|
||||
{
|
||||
if (_shadowQuality == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_shadowQuality = value;
|
||||
_needReallocate = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldReallocateBuffer()
|
||||
{
|
||||
return _outputRTHandle == null || _outputRTHandle.rt == null || !_outputRTHandle.rt.IsCreated() || _needReallocate;
|
||||
}
|
||||
|
||||
private void ReallocateBuffer()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorApplication.isCompiling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
var scale = _shadowQuality switch
|
||||
{
|
||||
ShadowQuality.Low => new Vector2(0.5f, 0.5f),
|
||||
ShadowQuality.High => Vector2.one,
|
||||
_ => Vector2.zero
|
||||
};
|
||||
|
||||
var format = _shadowQuality switch
|
||||
{
|
||||
ShadowQuality.Low => GraphicsFormat.D16_UNorm,
|
||||
ShadowQuality.High => GraphicsFormat.D32_SFloat,
|
||||
_ => GraphicsFormat.D16_UNorm
|
||||
};
|
||||
|
||||
_outputRTHandle?.Release();
|
||||
_outputRTHandle = RTHandles.Alloc(scale, colorFormat: format, filterMode: FilterMode.Bilinear, wrapMode: TextureWrapMode.Clamp, isShadowMap: true, name: Output_RT_Name);
|
||||
Shader.SetGlobalTexture(Output_RT_Name, _outputRTHandle);
|
||||
|
||||
_needReallocate = false;
|
||||
}
|
||||
|
||||
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
|
||||
{
|
||||
ReallocateBuffer();
|
||||
}
|
||||
|
||||
protected override void Execute(CustomPassContext ctx)
|
||||
{
|
||||
if (ShouldReallocateBuffer())
|
||||
{
|
||||
ReallocateBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
CoreUtils.SetRenderTarget(ctx.cmd, _outputRTHandle, ClearFlag.DepthStencil);
|
||||
|
||||
var utsRenderer = ctx.hdCamera.volumeStack.GetComponent<UTSRenderer>();
|
||||
var shouldRender = utsRenderer != null && utsRenderer.enableHairShadow.value && utsRenderer.state.value;
|
||||
if (!shouldRender)
|
||||
{
|
||||
CoreUtils.ClearRenderTarget(ctx.cmd, ClearFlag.DepthStencil, Color.black);
|
||||
return;
|
||||
}
|
||||
|
||||
var mask = RenderStateMask.Nothing;
|
||||
var stateBlock = new RenderStateBlock(mask)
|
||||
{
|
||||
depthState = new DepthState(true, CompareFunction.LessEqual),
|
||||
};
|
||||
|
||||
var result = new RendererListDesc(UtsShaderPassName.hairShadowCasterPassId, ctx.cullingResults, ctx.hdCamera.camera)
|
||||
{
|
||||
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
|
||||
sortingCriteria = SortingCriteria.CommonOpaque,
|
||||
excludeObjectMotionVectors = false,
|
||||
stateBlock = stateBlock,
|
||||
};
|
||||
|
||||
CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, ctx.renderContext.CreateRendererList(result));
|
||||
|
||||
Shader.SetGlobalVector(Hair_Shadow_RTHandle_Scale_Prop_Name, _outputRTHandle.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);
|
||||
}
|
||||
|
||||
protected override void Cleanup()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorApplication.isCompiling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_outputRTHandle?.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7157c6dc91cee0d4aae565d1c8d66807
|
||||
@@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
internal class UTSPass : CustomPass
|
||||
{
|
||||
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 float _max;
|
||||
private float _min;
|
||||
private float[] _exposureArray;
|
||||
|
||||
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
|
||||
{
|
||||
_exposureArray = new float[Adjustment_Curve_Precision];
|
||||
}
|
||||
|
||||
protected override void Execute(CustomPassContext ctx)
|
||||
{
|
||||
var utsRenderer = ctx.hdCamera.volumeStack.GetComponent<UTSRenderer>();
|
||||
if (utsRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var toonEVAdjustment = utsRenderer.toonEVAdjustment.value ? 1 : 0;
|
||||
var lightIntensityLimiter = utsRenderer.lightIntensityLimiter.value ? 1 : 0;
|
||||
var ignoreVolumeExposure = utsRenderer.ignoreVolumeExposure.value ? 1 : 0;
|
||||
var compensation = utsRenderer.compensation.value;
|
||||
|
||||
if (!utsRenderer.state.value)
|
||||
{
|
||||
_min = 0;
|
||||
_max = 0;
|
||||
_exposureArray.AsSpan().Fill(0);
|
||||
|
||||
toonEVAdjustment = 0;
|
||||
lightIntensityLimiter = 0;
|
||||
ignoreVolumeExposure = 0;
|
||||
compensation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fail safe in case the curve is deleted / has 0 point
|
||||
var curve = utsRenderer.adjustmentCurve.value;
|
||||
|
||||
if (curve == null || curve.length == 0)
|
||||
{
|
||||
_min = 0f;
|
||||
_max = 0f;
|
||||
_exposureArray.AsSpan().Fill(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_min = curve[0].time;
|
||||
_max = curve[curve.length - 1].time;
|
||||
var step = (_max - _min) / (Adjustment_Curve_Precision - 1f);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected override void Cleanup()
|
||||
{
|
||||
_exposureArray = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class UTSMeshRenderer : MonoBehaviour
|
||||
{
|
||||
private const string Shader_Prop_Object_Center_Name = "_ObjectCenterPositionWS";
|
||||
|
||||
public Material material;
|
||||
|
||||
public Transform objectCenter;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (material == null)
|
||||
return;
|
||||
|
||||
if (objectCenter != null)
|
||||
{
|
||||
material.SetVector(Shader_Prop_Object_Center_Name, objectCenter.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee7513f8cc93a9d4f981fd4b10f8dfc1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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
|
||||
}
|
||||
}
|
||||
2
Runtime/Models/ShaderEnum.cs.meta
Normal file
2
Runtime/Models/ShaderEnum.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5065e386905cb248bdf1ded804260b4
|
||||
15
Runtime/Models/SurfaceFeature.cs
Normal file
15
Runtime/Models/SurfaceFeature.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
[Flags]
|
||||
[GenerateHLSL(PackingRules.Exact)]
|
||||
public enum SurfaceFeature
|
||||
{
|
||||
None = 0,
|
||||
RimLight = 1 << 0,
|
||||
Stocking = 1 << 1,
|
||||
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: a37603210e947e945be7817ada46bff5
|
||||
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
|
||||
@@ -5,17 +5,30 @@ using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
[Serializable]
|
||||
internal struct UTSOutlineSetting
|
||||
internal enum BufferQuality
|
||||
{
|
||||
public bool enable;
|
||||
Low,
|
||||
High
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal struct UtsHairShadowSetting
|
||||
{
|
||||
public bool enable;
|
||||
public UTSHairShadowPass.ShadowQuality shadowQuality;
|
||||
public BufferQuality quality;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal struct UtsHairBlendingSetting
|
||||
{
|
||||
public bool enable;
|
||||
public BufferQuality quality;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal struct UTSOutlineSetting
|
||||
{
|
||||
public bool enable;
|
||||
}
|
||||
|
||||
[CreateAssetMenu(fileName = "UTSRenderSetting", menuName = "UTS/RenderSetting")]
|
||||
@@ -25,10 +38,12 @@ namespace Misaki.HdrpToon
|
||||
public const string UTS_RENDERING_SETTINGS_PATH = "Assets/Resources/Settings/UTSRenderSettings.asset";
|
||||
public const string UTS_RENDERING_SETTINGS_RESOURCES_PATH = "Settings/UTSRenderSettings";
|
||||
|
||||
[SerializeField]
|
||||
internal UTSOutlineSetting outlineSetting;
|
||||
[SerializeField]
|
||||
internal UtsHairShadowSetting hairShadowSetting;
|
||||
[SerializeField]
|
||||
internal UtsHairBlendingSetting hairBlendingSetting;
|
||||
[SerializeField]
|
||||
internal UTSOutlineSetting outlineSetting;
|
||||
|
||||
internal static UTSRenderPassSettings GetOrCreateSettings()
|
||||
{
|
||||
@@ -1,205 +0,0 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[DisallowMultipleComponent]
|
||||
[UTSHelpURL("ToonEVAdjustment")]
|
||||
|
||||
public class SceneToonEvAdjustment : MonoBehaviour
|
||||
{
|
||||
// flags
|
||||
bool m_initialized = false;
|
||||
bool m_srpCallbackInitialized = false;
|
||||
|
||||
const int kAdjustmentCurvePrecision = 128;
|
||||
|
||||
const string kCompensationPorpName = "_ToonEvAdjustmentCompensation";
|
||||
const string kExposureAdjustmentPropName = "_ToonEvAdjustmentCurve";
|
||||
const string kExposureArrayPropName = "_ToonEvAdjustmentValueArray";
|
||||
const string kExposureMinPropName = "_ToonEvAdjustmentValueMin";
|
||||
const string kExposureMaxPropName = "_ToonEvAdjustmentValueMax";
|
||||
const string kToonLightFilterPropName = "_ToonLightHiCutFilter";
|
||||
const string kIgonoreVolumeExposurePropName = "_ToonIgnoreExposureMultiplier";
|
||||
|
||||
internal bool m_ToonLightHiCutFilter = false;
|
||||
internal bool m_ExposureAdjustmnt = false;
|
||||
internal bool m_IgnorVolumeExposure = false;
|
||||
internal AnimationCurve m_AnimationCurve = DefaultAnimationCurve();
|
||||
internal float[] m_ExposureArray;
|
||||
internal float m_Max, m_Min;
|
||||
internal float m_Compensation;
|
||||
|
||||
|
||||
private static SceneToonEvAdjustment instance;
|
||||
#if UNITY_EDITOR
|
||||
#pragma warning restore CS0414
|
||||
bool m_isCompiling = false;
|
||||
#endif
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this as SceneToonEvAdjustment;
|
||||
return;
|
||||
}
|
||||
else if (instance == this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Debug.LogError("There is ToonEvAdjustmentCurve instance in hierarchy.");
|
||||
#if UNITY_EDITOR
|
||||
DestroyImmediate(this);
|
||||
Selection.activeGameObject = instance.gameObject;
|
||||
#else
|
||||
Destroy(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
OnDisable();
|
||||
OnEnable();
|
||||
DefaultAnimationCurve();
|
||||
}
|
||||
|
||||
public static AnimationCurve DefaultAnimationCurve()
|
||||
{
|
||||
return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
Initialize();
|
||||
|
||||
GetValues();
|
||||
|
||||
|
||||
// Fail safe in case the curve is deleted / has 0 point
|
||||
var curve = m_AnimationCurve;
|
||||
|
||||
|
||||
if (curve == null || curve.length == 0)
|
||||
{
|
||||
m_Min = 0f;
|
||||
m_Max = 0f;
|
||||
|
||||
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
|
||||
m_ExposureArray[i] = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Min = curve[0].time;
|
||||
m_Max = curve[curve.length - 1].time;
|
||||
var step = (m_Max - m_Min) / (kAdjustmentCurvePrecision - 1f);
|
||||
|
||||
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
|
||||
m_ExposureArray[i] = curve.Evaluate(m_Min + step * i);
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// handle script recompile
|
||||
if (EditorApplication.isCompiling && !m_isCompiling)
|
||||
{
|
||||
// on compile begin
|
||||
m_isCompiling = true;
|
||||
// Release(); no need
|
||||
return; //
|
||||
}
|
||||
else if (!EditorApplication.isCompiling && m_isCompiling)
|
||||
{
|
||||
// on compile end
|
||||
m_isCompiling = false;
|
||||
}
|
||||
#endif
|
||||
Shader.SetGlobalFloatArray(kExposureArrayPropName, m_ExposureArray);
|
||||
Shader.SetGlobalFloat(kExposureMinPropName, m_Min);
|
||||
Shader.SetGlobalFloat(kExposureMaxPropName, m_Max);
|
||||
Shader.SetGlobalInt(kExposureAdjustmentPropName, m_ExposureAdjustmnt ? 1 : 0);
|
||||
Shader.SetGlobalInt(kToonLightFilterPropName, m_ToonLightHiCutFilter ? 1 : 0);
|
||||
Shader.SetGlobalInt(kIgonoreVolumeExposurePropName, m_IgnorVolumeExposure ? 1 : 0);
|
||||
Shader.SetGlobalFloat(kCompensationPorpName, m_Compensation);
|
||||
}
|
||||
|
||||
private void GetValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EnableSrpCallbacks()
|
||||
{
|
||||
|
||||
if (!m_srpCallbackInitialized)
|
||||
{
|
||||
m_srpCallbackInitialized = true;
|
||||
}
|
||||
}
|
||||
void DisableSrpCallbacks()
|
||||
{
|
||||
if (m_srpCallbackInitialized)
|
||||
{
|
||||
m_srpCallbackInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
Initialize();
|
||||
|
||||
EnableSrpCallbacks();
|
||||
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
DisableSrpCallbacks();
|
||||
|
||||
Release();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
if (m_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
// initializing renderer can interfere GI baking. so wait until it is completed.
|
||||
|
||||
if (EditorApplication.isCompiling)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (m_ExposureArray == null || m_ExposureArray.Length != kAdjustmentCurvePrecision)
|
||||
{
|
||||
m_ExposureArray = new float[kAdjustmentCurvePrecision];
|
||||
}
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
void Release()
|
||||
{
|
||||
if (m_initialized)
|
||||
{
|
||||
m_ExposureArray = null;
|
||||
Shader.SetGlobalInt(kExposureAdjustmentPropName, 0);
|
||||
Shader.SetGlobalInt(kToonLightFilterPropName, 0);
|
||||
}
|
||||
|
||||
m_initialized = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db8edd5c572b6e648974dac4815d5619
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
8
Runtime/Shaders/Includes.meta
Normal file
8
Runtime/Shaders/Includes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98998b9942068044ab680ee5e6485837
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Shaders/Includes/Common.meta
Normal file
8
Runtime/Shaders/Includes/Common.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3642d3111f8bccb4180d12b99fa6de71
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user