From 85a03a3cbeda671d43799d55175fe414327bc26e Mon Sep 17 00:00:00 2001 From: Yamo4490 Date: Thu, 15 May 2025 00:25:26 +0900 Subject: [PATCH] =?UTF-8?q?Modify:=20=EB=8B=90=EB=A1=9C=ED=88=B0=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B5=9C=EC=8B=A0?= =?UTF-8?q?=EB=B2=84=EC=A0=84=EC=9C=BC=EB=A1=9C=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/EditorExtension/MenuItemScript.cs | 40 +- .../Scripts/Editor/Gizmos/GizmoUtility.cs | 183 +- Assets/External/NiloToonURP/CHANGELOG.md | 4 +- ...itor_AutoGeneratePrefabVariantAndAssets.cs | 6 +- .../NiloToonMaterialConvertor.cs | 103 +- .../NiloEditorMotionBlurVideoBaker.cs | 612 +++-- ...erCharacterRenderControllerCustomEditor.cs | 18 +- .../Editor/NiloToonEditorShaderStripping.cs | 51 +- .../Editor/AssetProcessor/ExcludeFromBuild.cs | 17 +- .../ShaderModifyListener.cs | 3 + .../ShaderModifyListener.cs.meta | 0 .../Editor/CustomGUISample/CustomFooter.cs | 3 +- .../Editor/CustomGUISample/CustomHeader.cs | 3 +- .../CustomMaterialAssetFinder.cs | 48 + .../CustomMaterialAssetFinder.cs.meta | 3 + .../LWGUI-main/Editor/Helper/Helper.cs | 202 +- .../Editor/Helper/MetaDataHelper.cs | 36 +- .../LWGUI-main/Editor/Helper/PresetHelper.cs | 11 +- .../LWGUI-main/Editor/Helper/RampHelper.cs | 216 +- .../Editor/Helper/ReflectionHelper.cs | 158 -- .../Editor/Helper/RevertableHelper.cs | 3 +- .../Editor/Helper/VersionControlHelper.cs | 2 +- .../ShaderGUI/LWGUI-main/Editor/LWGUI.asmdef | 5 +- .../ShaderGUI/LWGUI-main/Editor/LWGUI.cs | 31 +- .../Editor/MetaData/PerMaterialData.cs | 23 +- .../Editor/MetaData/PerShaderData.cs | 9 +- .../ScriptableObject/ShaderPropertyPreset.cs | 22 +- .../LWGUI-main/Editor/ShaderDrawer.cs | 683 +++-- .../Editor/ShaderGUI/LWGUI-main/README.md | 4 +- .../image-20220821234658509.png.meta | 49 +- .../image-20240416142736663.png | 4 +- .../image-20240716183800118.png | 3 + .../image-20240716183800118.png.meta | 127 + .../image-20240716184045776.png | 3 + .../image-20240716184045776.png.meta | 127 + .../image-20240717104144821.png | 3 + .../image-20240717104144821.png.meta | 123 + .../image-20240717104206365.png | 3 + .../image-20240717104206365.png.meta | 123 + .../image-20241126105823397.png | 3 + .../image-20241126105823397.png.meta | 153 ++ .../image-20241126110012922.png | 3 + .../image-20241126110012922.png.meta | 153 ++ .../image-20241126112320151.png | 3 + .../image-20241126112320151.png.meta | 153 ++ .../image-20241127180711449.png | 3 + .../image-20241127180711449.png.meta | 127 + .../Editor/ShaderGUI/LWGUI-main/README_CN.md | 4 +- .../Editor/ShaderGUI/LWGUI-main/Runtime.meta} | 3 +- .../LWGUI-main/Runtime/LWGUI.Runtime.asmdef | 3 + .../Runtime/LWGUI.Runtime.asmdef.meta | 7 + .../LWGUI-main/Runtime/LwguiGradient.meta | 3 + .../Runtime/LwguiGradient/LwguiGradient.cs | 500 ++++ .../LwguiGradient/LwguiGradient.cs.meta | 3 + .../LwguiGradient/LwguiGradientHelper.cs | 91 + .../LwguiGradient/LwguiGradientHelper.cs.meta | 3 + ...set.asset => LWGUI_Preset_BlendMode.asset} | 2 +- ...meta => LWGUI_Preset_BlendMode.asset.meta} | 0 .../LWGUI-main/Test/LWGUI_Preset_Toggle.asset | 29 + .../Test/LWGUI_Preset_Toggle.asset.meta | 8 + .../LWGUI-main/Test/LWGUI_SampleDrawer 1.mat | 4 + .../LWGUI-main/Test/RampMap_Linear.png.meta | 12 +- .../LWGUI-main/Test/RampMap_Test.png | 3 + .../LWGUI-main/Test/RampMap_Test.png.meta | 127 + .../LWGUI-main/Test/RampMap_sRGB.png.meta | 2 +- .../LWGUI-main/Test/SampleDrawer 1.shader | 6 +- .../LWGUI-main/Test/SampleDrawer.shader | 2 +- .../LWGUI-main/UnityEditorExtension.meta} | 3 +- .../LwguiGradientEditor.meta | 3 + .../LwguiGradientDrawer.cs | 58 + .../LwguiGradientDrawer.cs.meta | 3 + .../LwguiGradientEditor.cs | 851 +++++++ .../LwguiGradientEditor.cs.meta | 3 + .../LwguiGradientEditorHelper.cs | 195 ++ .../LwguiGradientEditorHelper.cs.meta | 3 + .../LwguiGradientPresetLibrary.cs | 117 + .../LwguiGradientPresetLibrary.cs.meta | 3 + .../LwguiGradientPresetLibraryInspector.cs | 40 + ...wguiGradientPresetLibraryInspector.cs.meta | 3 + .../LwguiGradientWindow.cs | 318 +++ .../LwguiGradientWindow.cs.meta | 3 + .../LWGUI-main/UnityEditorExtension/README.md | 3 + .../UnityEditorExtension/README.md.meta | 7 + .../UnityEditorExtension/ReflectionHelper.cs | 242 ++ .../ReflectionHelper.cs.meta | 0 .../Unity.InternalAPIEditorBridge.020.asmdef | 18 + ...ty.InternalAPIEditorBridge.020.asmdef.meta | 7 + .../UnityEditorExtension.cs | 57 + .../UnityEditorExtension.cs.meta | 3 + .../Editor/ShaderGUI/LWGUI-main/package.json | 4 +- .../Volume/NiloToonBloomVolumeEditor.cs | 8 +- ...iloToonCharRenderingControlVolumeEditor.cs | 2 +- .../NiloToonCinematicRimLightVolumeEditor.cs | 8 +- .../NiloToonEnvironmentControlVolumeEditor.cs | 4 +- .../Volume/NiloToonMotionBlurVolumeEditor.cs | 30 + .../NiloToonMotionBlurVolumeEditor.cs.meta | 11 + ...onScreenSpaceOutlineControlVolumeEditor.cs | 7 +- .../NiloToonShadowControlVolumeEditor.cs | 5 +- .../NiloToonURP/NiloToonURP user document.pdf | 4 +- .../NiloToonURP/RenderPipelineAsset.meta | 2 +- .../NiloToonShaderStrippingSettingSO.cs | 57 +- .../NiloToonPerCharacterRenderController.cs | 136 +- .../NiloToonAllInOneRendererFeature.cs | 28 + .../Passes/NiloToonAnimePostProcessPass.cs | 150 +- .../Passes/NiloToonAverageShadowTestRTPass.cs | 288 ++- .../Passes/NiloToonCharSelfShadowMapRTPass.cs | 121 +- .../NiloToonExtraThickToonOutlinePass.cs | 73 + .../Passes/NiloToonMotionBlurPass.cs | 387 +++ .../Passes/NiloToonMotionBlurPass.cs.meta | 11 + .../Passes/NiloToonPrepassBufferRTPass.cs | 14 + .../Passes/NiloToonScreenSpaceOutlinePass.cs | 346 ++- .../Passes/NiloToonSetToonParamPass.cs | 1144 +++++---- .../Passes/NiloToonToonOutlinePass.cs | 204 +- .../Passes/NiloToonUberPostProcessPass.cs | 16 +- .../Runtime/Utility/AutoEyeBlink.cs | 415 +++ .../Runtime/Utility/AutoEyeBlink.cs.meta | 11 + .../Runtime/Utility/NiloToonUtils.cs | 5 + .../NiloToonURP/Runtime/Utility/UnlockFPS.cs | 5 +- .../Volume/NiloToonCinematicRimLightVolume.cs | 2 +- .../NiloToonEnvironmentControlVolume.cs | 20 +- .../Volume/NiloToonMotionBlurVolume.cs | 18 + .../Volume/NiloToonMotionBlurVolume.cs.meta | 11 + ...NiloToonScreenSpaceOutlineControlVolume.cs | 34 +- .../Volume/NiloToonShadowControlVolume.cs | 20 +- .../Volume/NiloToonTonemappingVolume.cs | 4 +- .../NiloToonVolumePresetPicker.prefab | 4 +- ...rongRim&Shadow(NiloToonVolumePreset).asset | 18 +- ...StyleDark_ACES(NiloToonVolumePreset).asset | 43 +- ...06_StyleBright(NiloToonVolumePreset).asset | 2 +- ...Dir_MotionBlur(NiloToonVolumePreset).asset | 2267 +++++++++++++++++ ...otionBlur(NiloToonVolumePreset).asset.meta | 8 + ...Dir_MotionBlur(NiloToonVolumePreset).asset | 2251 ++++++++++++++++ ...otionBlur(NiloToonVolumePreset).asset.meta | 8 + .../NiloUtilityHLSL/NiloOutlineUtil.hlsl | 46 + .../NiloUtilityHLSL/NiloStrandSpecular.hlsl | 15 +- .../Shaders/NiloToonCharacter.shader | 897 +++++-- .../NiloToonCharacter_LightingEquation.hlsl | 44 +- ...NiloToonCharacter_ObjectMotionVectors.hlsl | 71 +- .../NiloToonCharacter_Shared.hlsl | 161 +- .../Shaders/NiloToonEnvironment.shader | 204 +- .../NiloToonEnvironment_LitForwardPass.hlsl | 57 +- .../NiloToonEnvironment_LitInput.hlsl | 73 +- .../Resources/NiloToonKinoMotion.meta | 8 + .../Resources/NiloToonKinoMotion/LICENSE.txt | 3 + .../NiloToonKinoMotion/LICENSE.txt.meta | 7 + .../NiloToonKinoMotionBlur.hlsl | 319 +++ .../NiloToonKinoMotionBlur.hlsl.meta | 7 + .../NiloToonKinoMotionBlur.shader | 91 + .../NiloToonKinoMotionBlur.shader.meta | 9 + .../Resources/NiloToonMotionBlur.shader | 353 +++ .../Resources/NiloToonMotionBlur.shader.meta | 10 + Assets/External/NiloToonURP/package.json | 4 +- 152 files changed, 14708 insertions(+), 2291 deletions(-) rename Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/{ => AssetProcessor}/ShaderModifyListener.cs (86%) rename Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/{ => AssetProcessor}/ShaderModifyListener.cs.meta (100%) create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs.meta delete mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png.meta rename Assets/External/{UnityMemoryMappedFile/UnityMemoryMappedFile.csproj.meta => NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime.meta} (67%) create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs.meta rename Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/{LWGUI_BlendModePreset.asset => LWGUI_Preset_BlendMode.asset} (98%) rename Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/{LWGUI_BlendModePreset.asset.meta => LWGUI_Preset_BlendMode.asset.meta} (100%) create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png.meta rename Assets/{Plugins/websocket-sharp/websocket-sharp.csproj.meta => External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension.meta} (67%) create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs rename Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/{Editor/Helper => UnityEditorExtension}/ReflectionHelper.cs.meta (100%) create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef.meta create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs create mode 100644 Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs.meta create mode 100644 Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs create mode 100644 Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs.meta create mode 100644 Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs create mode 100644 Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs.meta create mode 100644 Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs create mode 100644 Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs.meta create mode 100644 Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs create mode 100644 Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs.meta create mode 100644 Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset create mode 100644 Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta create mode 100644 Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset create mode 100644 Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion.meta create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt.meta create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl.meta create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader.meta create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader create mode 100644 Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader.meta diff --git a/Assets/External/MagicaCloth2/Scripts/Editor/EditorExtension/MenuItemScript.cs b/Assets/External/MagicaCloth2/Scripts/Editor/EditorExtension/MenuItemScript.cs index cc3bd16..5f76f08 100644 --- a/Assets/External/MagicaCloth2/Scripts/Editor/EditorExtension/MenuItemScript.cs +++ b/Assets/External/MagicaCloth2/Scripts/Editor/EditorExtension/MenuItemScript.cs @@ -96,16 +96,12 @@ namespace MagicaCloth2 //========================================================================================= [MenuItem("Tools/Magica Cloth2/Manager information", false)] - static void DispClothManagerInfo() + static async void DispClothManagerInfo() { - if (MagicaManager.IsPlaying() == false) - { - Debug.Log("This feature is run-time only."); - return; - } - StringBuilder allsb = new StringBuilder(); + await ClothEditorManager.InformationLog(allsb); + var timeManager = MagicaManager.Time; if (timeManager == null) { @@ -186,8 +182,15 @@ namespace MagicaCloth2 renderManager.InformationLog(allsb); } - // clipboard - //GUIUtility.systemCopyBuffer = allsb.ToString(); + var preBuildManager = MagicaManager.PreBuild; + if (preBuildManager == null) + { + Debug.LogWarning("PreBuild Manager is null!"); + } + else + { + preBuildManager.InformationLog(allsb); + } // file DateTime dt = DateTime.Now; @@ -197,5 +200,24 @@ namespace MagicaCloth2 sw.Flush(); sw.Close(); } + + //========================================================================================= + // インスペクターのコンテキストメニュー + [MenuItem("CONTEXT/MagicaCloth/Rebuild InitData")] + private static void SampleMenu(MenuCommand menuCommand) + { + // 初期化データをクリアして再構築する + var cloth = menuCommand.context as MagicaCloth; + if (cloth) + { + cloth.GetSerializeData2().initData.Clear(); + EditorUtility.SetDirty(cloth); + + // 編集用メッシュの再構築 + ClothEditorManager.RegisterComponent(cloth, GizmoType.Active, true); // 強制更新 + + Develop.Log($"[{cloth.name}] Initialization data rebuilt."); + } + } } } diff --git a/Assets/External/MagicaCloth2/Scripts/Editor/Gizmos/GizmoUtility.cs b/Assets/External/MagicaCloth2/Scripts/Editor/Gizmos/GizmoUtility.cs index afece44..b317001 100644 --- a/Assets/External/MagicaCloth2/Scripts/Editor/Gizmos/GizmoUtility.cs +++ b/Assets/External/MagicaCloth2/Scripts/Editor/Gizmos/GizmoUtility.cs @@ -1,6 +1,7 @@ // Magica Cloth 2. // Copyright (c) 2023 MagicaSoft. // https://magicasoft.jp +using Unity.Mathematics; using UnityEditor; using UnityEngine; @@ -10,6 +11,7 @@ namespace MagicaCloth2 { // ギズモカラー定義 public static readonly Color ColorCollider = new Color(0.0f, 1.0f, 0.0f); + public static readonly Color ColorSymmetryCollider = new Color(0.0f, 1.0f, 1.0f); public static readonly Color ColorNonSelectedCollider = new Color(0.5f, 0.3f, 0.0f); public static readonly Color ColorSkinningBone = new Color(1.0f, 0.5f, 0.0f); public static readonly Color ColorWindZone = new Color(1f, 1f, 1f); @@ -162,56 +164,142 @@ namespace MagicaCloth2 } //========================================================================================= - public static void DrawCollider(ColliderComponent collider, Quaternion camRot, bool useHandles, bool selected) + public static void DrawCollider(ColliderComponent collider, Quaternion camRot, bool selected) { if (collider == null) return; - var cpos = collider.transform.TransformPoint(collider.center); - var crot = collider.transform.rotation; - var cscl = Vector3.one * collider.GetScale(); // スケールはx軸のみ(つまり均等スケールのみ) + Handles.color = selected ? ColorCollider : ColorCollider * 0.5f; + // Main + var ct = collider.transform; + //var cpos = ct.TransformPoint(collider.center); + float3 cpos = ct.position; + quaternion crot = ct.rotation; + float3 cscl = ct.lossyScale; + // マイナススケール + float3 sclSign = math.sign(cscl); + // オフセット + cpos += math.mul(crot, collider.center * sclSign) * cscl * sclSign; // カメラ回転をコライダーのローカル回転に変換 - camRot = Quaternion.Inverse(crot) * camRot; + var camRotN = Quaternion.Inverse(crot) * camRot; + DrawColliderInternal(collider, camRotN, cpos, crot, cscl, 1.0f); - // サイズ - var size = collider.GetSize(); - - if (useHandles) + // Symmetry + // 実行時と同じ計算をして表示 + ColliderSymmetryMode? smode = ColliderSymmetryMode.None; + Transform symmetryParent = null; + if (EditorApplication.isPlaying) { - Handles.matrix = Matrix4x4.TRS(cpos, crot, cscl); - Handles.color = selected ? ColorCollider : ColorCollider * 0.5f; - switch (collider.GetColliderType()) - { - case ColliderManager.ColliderType.Sphere: - DrawWireSphere(Vector3.zero, Quaternion.identity, size.x, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleX_Center: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.right, Vector3.up, size.x, size.y, size.z, true, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleY_Center: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.up, Vector3.right, size.x, size.y, size.z, true, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleZ_Center: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.forward, Vector3.up, size.x, size.y, size.z, true, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleX_Start: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.right, Vector3.up, size.x, size.y, size.z, false, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleY_Start: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.up, Vector3.right, size.x, size.y, size.z, false, camRot, true); - break; - case ColliderManager.ColliderType.CapsuleZ_Start: - DrawWireCapsule(Vector3.zero, Quaternion.identity, Vector3.forward, Vector3.up, size.x, size.y, size.z, false, camRot, true); - break; - case ColliderManager.ColliderType.Plane: - DrawWireCube(Vector3.zero, Quaternion.identity, new Vector3(1.0f, 0.0f, 1.0f) * 1.0f, true); - break; - } + smode = collider.ActiveSymmetryMode; + symmetryParent = collider.ActiveSymmetryTarget; } - else + if (smode.HasValue == false || smode == ColliderSymmetryMode.None) + smode = collider.CalcSymmetryMode(out symmetryParent); + if (smode != ColliderSymmetryMode.None && symmetryParent) { + float3 lpos = ct.localPosition; + //float3 lerot = ct.localEulerAngles; + float3 lerot = MathUtility.ToEuler(ct.localRotation); + float3 lscl = ct.localScale; + float3 center = collider.center; + switch (smode) + { + case ColliderSymmetryMode.X_Symmetry: + lpos.x = -lpos.x; + center.x = -center.x; + lerot.y = -lerot.y; + lerot.z = -lerot.z; + break; + case ColliderSymmetryMode.Y_Symmetry: + lpos.y = -lpos.y; + center.y = -center.y; + lerot.x = -lerot.x; + lerot.z = -lerot.z; + break; + case ColliderSymmetryMode.Z_Symmetry: + lpos.z = -lpos.z; + center.z = -center.z; + lerot.x = -lerot.x; + lerot.y = -lerot.y; + break; + case ColliderSymmetryMode.XYZ_Symmetry: + lpos = -lpos; + center = -center; + break; + default: + return; + } + // 方向性 + float direction = 1.0f; + if (collider is MagicaCapsuleCollider) + { + var ccol = collider as MagicaCapsuleCollider; + if (smode == ColliderSymmetryMode.X_Symmetry && ccol.direction == MagicaCapsuleCollider.Direction.X) + direction = -1.0f; + else if (smode == ColliderSymmetryMode.Y_Symmetry && ccol.direction == MagicaCapsuleCollider.Direction.Y) + direction = -1.0f; + else if (smode == ColliderSymmetryMode.Z_Symmetry && ccol.direction == MagicaCapsuleCollider.Direction.Z) + direction = -1.0f; + else if (smode == ColliderSymmetryMode.XYZ_Symmetry) + direction = -1.0f; + } + else if (collider is MagicaPlaneCollider) + { + switch (smode) + { + case ColliderSymmetryMode.Y_Symmetry: + case ColliderSymmetryMode.XYZ_Symmetry: + direction = -1.0f; + break; + } + } + + // シンメトリーの親 + float3 ppos = symmetryParent.position; + quaternion prot = symmetryParent.rotation; + float3 pscl = symmetryParent.lossyScale; + + // マイナススケール + sclSign = math.sign(pscl); + float3 sclEulerSign = 1; + if (pscl.x < 0 || pscl.y < 0 || pscl.z < 0) + sclEulerSign = sclSign * -1; + + // シンメトリーコライダーの姿勢 + float3 wpos = MathUtility.TransformPoint(lpos, ppos, prot, pscl); + quaternion wrot = math.mul(prot, quaternion.Euler(math.radians(lerot * sclEulerSign))); + float3 wscl = pscl * lscl; + wpos += math.mul(wrot, center * sclSign) * wscl * sclSign; + + // カメラ回転をコライダーのローカル回転に変換 + var camRotS = Quaternion.Inverse(wrot) * camRot; + + Handles.color = selected ? ColorSymmetryCollider : ColorSymmetryCollider * 0.5f; + DrawColliderInternal(collider, camRotS, wpos, wrot, wscl, direction); + } + } + + static void DrawColliderInternal(ColliderComponent collider, Quaternion camRot, Vector3 cpos, Quaternion crot, Vector3 cscl, float direction) + { + var size = collider.GetSize(); + Handles.matrix = Matrix4x4.TRS(cpos, crot, cscl); + if (collider is MagicaSphereCollider) + { + DrawWireSphere(Vector3.zero, Quaternion.identity, size.x, camRot, true); + } + else if (collider is MagicaPlaneCollider) + { + DrawWireCube(Vector3.zero, Quaternion.identity, new Vector3(1.0f, 0.0f, 1.0f) * 1.0f, true); + DrawLine(Vector3.zero, Vector3.up * 0.25f * direction, true); + } + else if (collider is MagicaCapsuleCollider) + { + var c = collider as MagicaCapsuleCollider; + var ldir = c.GetLocalDir() * direction; + var lup = c.GetLocalUp(); + DrawWireCapsule(Vector3.zero, Quaternion.identity, ldir, lup, size.x, size.y, size.z, c.alignedOnCenter, camRot, true); } } @@ -300,23 +388,6 @@ namespace MagicaCloth2 Gizmos.matrix = Matrix4x4.identity; } - //public static void DrawWireSphere( - // Vector3 pos, Quaternion rot, Vector3 scl, float radius, - // Quaternion camRot, bool useHandles - // ) - //{ - // if(useHandles) - // { - // Handles.matrix = Matrix4x4.TRS(pos, rot, scl); - - // } - // else - // { - - // } - //} - - #if false /// /// ワイヤーボックスを描画する diff --git a/Assets/External/NiloToonURP/CHANGELOG.md b/Assets/External/NiloToonURP/CHANGELOG.md index dbff44a..8de0b73 100644 --- a/Assets/External/NiloToonURP/CHANGELOG.md +++ b/Assets/External/NiloToonURP/CHANGELOG.md @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cc629c75bfdb787d2133e0925fc129dbb872de57a9495b6596c482e2017a59b9 -size 234080 +oid sha256:3cf6a64a7edebcf281192cf6bb4893c2c362bc1e752843fe482f055d53ad1fd1 +size 245229 diff --git a/Assets/External/NiloToonURP/Editor/AutoGeneratePrefabVariantAndMaterialClone/NiloToonEditor_AutoGeneratePrefabVariantAndAssets.cs b/Assets/External/NiloToonURP/Editor/AutoGeneratePrefabVariantAndMaterialClone/NiloToonEditor_AutoGeneratePrefabVariantAndAssets.cs index fb9f167..03248f7 100644 --- a/Assets/External/NiloToonURP/Editor/AutoGeneratePrefabVariantAndMaterialClone/NiloToonEditor_AutoGeneratePrefabVariantAndAssets.cs +++ b/Assets/External/NiloToonURP/Editor/AutoGeneratePrefabVariantAndMaterialClone/NiloToonEditor_AutoGeneratePrefabVariantAndAssets.cs @@ -10,7 +10,8 @@ namespace NiloToon.NiloToonURP { public class NiloToonEditor_AutoGeneratePrefabVariantAndAssets : Editor { - [MenuItem("Window/NiloToonURP/Create Nilo Prefab Variant and Materials", priority = 0)] + [MenuItem("Window/NiloToonURP/[Prefab] Create NiloToon Prefab Variant and Materials", priority = 0)] + [MenuItem("Assets/NiloToon/[Prefab] Create NiloToon Prefab Variant and Materials", priority = 1100 + 0)] static void CreatePrefabVariantAndCloneMaterials() { // Get the selected prefab @@ -186,7 +187,8 @@ namespace NiloToon.NiloToonURP EditorUtility.DisplayDialog("Success", "Prefab variant created with cloned materials.", "OK"); } - [MenuItem("Window/NiloToonURP/Create Nilo Prefab Variant and Materials", priority = 0, validate = true)] + [MenuItem("Window/NiloToonURP/[Prefab] Create NiloToon Prefab Variant and Materials", priority = 0, validate = true)] + [MenuItem("Assets/NiloToon/[Prefab] Create NiloToon Prefab Variant and Materials", priority = 1100 + 0, validate = true)] public static bool ValidateCreatePrefabVariantAndCloneMaterials() { var allselectedObjects = Selection.objects; diff --git a/Assets/External/NiloToonURP/Editor/MaterialConvertor/NiloToonMaterialConvertor.cs b/Assets/External/NiloToonURP/Editor/MaterialConvertor/NiloToonMaterialConvertor.cs index 91b5ece..a2999e3 100644 --- a/Assets/External/NiloToonURP/Editor/MaterialConvertor/NiloToonMaterialConvertor.cs +++ b/Assets/External/NiloToonURP/Editor/MaterialConvertor/NiloToonMaterialConvertor.cs @@ -307,45 +307,41 @@ namespace NiloToon.NiloToonURP matOriginal.shader.name.Contains("Overlay"); bool isOutl = matOriginal.shader.name.Contains("Outline"); bool isTransparentQueue = matOriginal.renderQueue > 2500; + bool isZWrite = matOriginal.GetFloat("_ZWrite") > 0.5f; - if (!isCutout && !isTransparent && !isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Opaque; - else if (!isCutout && !isTransparent && !isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.TransparentQueueTransparent_ZWrite; - else if (!isCutout && !isTransparent && isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Opaque_Outline; - else if (!isCutout && !isTransparent && isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite_Outline; - else if (!isCutout && isTransparent && !isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite; - else if (!isCutout && isTransparent && !isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; - else if (!isCutout && isTransparent && isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite_Outline; - else if (!isCutout && isTransparent && isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.TransparentQueueTransparent_ZWrite; - else if (isCutout && !isTransparent && !isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque; - else if (isCutout && !isTransparent && !isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque; - else if (isCutout && !isTransparent && isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque_Outline; - else if (isCutout && !isTransparent && isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite_Outline; - else if (isCutout && isTransparent && !isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite; - else if (isCutout && isTransparent && !isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; - else if (isCutout && isTransparent && isOutl && !isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.CutoutTransparent_ZWrite_Outline; - else if (isCutout && isTransparent && isOutl && isTransparentQueue) - niloToonSurfaceTypePresetIDArray[i] = - NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite_Outline; + // if ZWrite is off, we treat the material as transparent + if (!isCutout && !isTransparent && !isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Opaque; // 1 + else if (!isCutout && !isTransparent && !isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 2 + else if (!isCutout && !isTransparent && !isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.TransparentQueueTransparent_ZWrite; // 3 + else if (!isCutout && !isTransparent && !isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 4 + else if (!isCutout && !isTransparent && isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Opaque_Outline; // 5 + else if (!isCutout && !isTransparent && isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 6 + else if (!isCutout && !isTransparent && isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite_Outline; // 7 + else if (!isCutout && !isTransparent && isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 8 + else if (!isCutout && isTransparent && !isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite; // 9 + else if (!isCutout && isTransparent && !isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 10 + else if (!isCutout && isTransparent && !isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite; // 11 + else if (!isCutout && isTransparent && !isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 12 + else if (!isCutout && isTransparent && isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent_ZWrite_Outline; // 13 + else if (!isCutout && isTransparent && isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 14 + else if (!isCutout && isTransparent && isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.TransparentQueueTransparent_ZWrite; // 15 + else if (!isCutout && isTransparent && isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.Transparent; // 16 + else if ( isCutout && !isTransparent && !isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque; // 17 + else if ( isCutout && !isTransparent && !isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 18 + else if ( isCutout && !isTransparent && !isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque; // 19 + else if ( isCutout && !isTransparent && !isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 20 + else if ( isCutout && !isTransparent && isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutOpaque_Outline; // 21 + else if ( isCutout && !isTransparent && isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 22 + else if ( isCutout && !isTransparent && isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite_Outline; // 23 + else if ( isCutout && !isTransparent && isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 24 + else if ( isCutout && isTransparent && !isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite; // 25 + else if ( isCutout && isTransparent && !isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 26 + else if ( isCutout && isTransparent && !isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent_ZWrite; // 27 + else if ( isCutout && isTransparent && !isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 28 + else if ( isCutout && isTransparent && isOutl && !isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent_ZWrite_Outline; // 29 + else if ( isCutout && isTransparent && isOutl && !isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 30 + else if ( isCutout && isTransparent && isOutl && isTransparentQueue && isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparentQueueTransparent_ZWrite_Outline; //31 + else if ( isCutout && isTransparent && isOutl && isTransparentQueue && !isZWrite) niloToonSurfaceTypePresetIDArray[i] = NiloToonSurfaceTypePreset.CutoutTransparent; // 32 } // since there are many model's texture that alpha is not used for transparency(e.g. store special data that is not alpha), @@ -516,7 +512,7 @@ namespace NiloToon.NiloToonURP }; string[] IsEyeBanNames = { "brown" }; // avoid "brown" treated as eye due to "brow" - string[] IsMouthTargetNames = { "mouth", "oral", "tongue", "kuchi", ".ha" }; + string[] IsMouthTargetNames = { "mouth", "oral", "tongue", "kuchi", ".ha", "kounai", "shita" }; string[] IsMouthBanNames = { ".hada" }; string[] IsTeethTargetNames = { "teeth", "tooth" }; @@ -540,6 +536,8 @@ namespace NiloToon.NiloToonURP IsFaceFinalTargetNames = IsFaceFinalTargetNames.Concat(IsMouthTargetNames).ToArray(); IsFaceFinalTargetNames = IsFaceFinalTargetNames.Concat(IsTeethTargetNames).ToArray(); + string[] IsFaceExactTargetNames = new string[]{ "me", "ha"}; + string[] IsFaceFinalBanNames = new string[] { }; IsFaceFinalBanNames = IsFaceFinalBanNames.Concat(IsFaceBanNames).ToArray(); IsFaceFinalBanNames = IsFaceFinalBanNames.Concat(IsEyeBanNames).ToArray(); @@ -561,6 +559,9 @@ namespace NiloToon.NiloToonURP IsFaceFinalTargetNames.Where(x => x != "face" && x != "head").ToList(); IsNoOutlineFinalTargetNames.Concat(IsNoOutlineTargetNames); + List IsNoOutlineExactTargetNames = new List(); + IsNoOutlineExactTargetNames.Concat(IsFaceExactTargetNames); + List IsNoOutlineFinalBanNames = IsFaceFinalBanNames.ToList(); IsNoOutlineFinalBanNames.Concat(IsNoOutlineBanNames); @@ -573,6 +574,11 @@ namespace NiloToon.NiloToonURP isNoOutline |= NiloToonUtils.NameHasKeyword(mat.name, keyword); } + foreach (var keyword in IsNoOutlineExactTargetNames) + { + isNoOutline |= NiloToonUtils.NameEqualsKeywordIgnoreCase(mat.name, keyword); + } + foreach (var keyword in IsNoOutlineFinalBanNames) { isNoOutline &= !NiloToonUtils.NameHasKeyword(mat.name, keyword); @@ -642,11 +648,11 @@ namespace NiloToon.NiloToonURP ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (originalMatClone.shader == VRMBRPMToon00Shader) { - const float niloToonWidthRelativeToMToon00 = 4; + const float niloToonWidthRelativeToMToon00 = 12; //12~18 is good mat.SetFloat("_OutlineWidthExtraMultiplier", niloToonWidthRelativeToMToon00); // extra check to limit any unexpected large outline width - float maxFinalWidth = 0.6f; // 0.6 is NiloToon's default outline width + float maxFinalWidth = 0.5f; // 0.5 is NiloToon's default outline width float finalWidth = Mathf.Min(maxFinalWidth, mat.GetFloat("_OutlineWidth") * niloToonWidthRelativeToMToon00); mat.SetFloat("_OutlineWidth", finalWidth / niloToonWidthRelativeToMToon00); @@ -662,7 +668,7 @@ namespace NiloToon.NiloToonURP mat.SetFloat("_OutlineWidthExtraMultiplier", niloToonWidthRelativeToMToon10); // extra check to limit any unexpected large outline width - float maxFinalWidth = 0.6f; // 0.6 is NiloToon's default outline width + float maxFinalWidth = 0.5f; // 0.5 is NiloToon's default outline width float finalWidth = Mathf.Min(maxFinalWidth, mat.GetFloat("_OutlineWidth") * niloToonWidthRelativeToMToon10); mat.SetFloat("_OutlineWidth", finalWidth / niloToonWidthRelativeToMToon10); @@ -865,6 +871,11 @@ namespace NiloToon.NiloToonURP isFace |= NiloToonUtils.NameHasKeyword(mat.name, keyword); } + foreach (var keyword in IsFaceExactTargetNames) + { + isFace |= NiloToonUtils.NameEqualsKeywordIgnoreCase(mat.name,keyword); + } + foreach (var keyword in IsFaceFinalBanNames) { isFace &= !NiloToonUtils.NameHasKeyword(mat.name, keyword); @@ -1377,7 +1388,7 @@ namespace NiloToon.NiloToonURP toNiloToonMat.SetFloat("_OutlineWidthExtraMultiplier", niloToonWidthRelativeTolilToon); // extra check to limit any unexpected large outline width - float maxFinalWidth = 0.6f; // 0.6 is NiloToon's default outline width + float maxFinalWidth = 0.5f; // 0.5 is NiloToon's default outline width float finalWidth = Mathf.Min(maxFinalWidth, _OutlineWidth * niloToonWidthRelativeTolilToon); toNiloToonMat.SetFloat("_OutlineWidth", finalWidth / niloToonWidthRelativeTolilToon); @@ -1797,7 +1808,8 @@ namespace NiloToon.NiloToonURP } #if UNITY_EDITOR - [MenuItem("Window/NiloToonURP/Convert Selected Materials to NiloToon", priority = 2)] + [MenuItem("Window/NiloToonURP/[Material] Convert Selected Materials to NiloToon", priority = 2)] + [MenuItem("Assets/NiloToon/[Material] Convert Selected Materials to NiloToon", priority = 1100 + 2)] public static void ConvertSelectedMaterialsToNiloToon_Character() { var allselectedObjects = Selection.objects; @@ -1817,7 +1829,8 @@ namespace NiloToon.NiloToonURP AutoConvertMaterialsToNiloToon(allInputMaterials); } - [MenuItem("Window/NiloToonURP/Convert Selected Materials to NiloToon", priority = 2, validate = true)] + [MenuItem("Window/NiloToonURP/[Material] Convert Selected Materials to NiloToon", priority = 2, validate = true)] + [MenuItem("Assets/NiloToon/[Material] Convert Selected Materials to NiloToon", priority = 1100 + 2, validate = true)] public static bool ValidateConvertSelectedMaterialsToNiloToon_Character() { var allselectedObjects = Selection.objects; diff --git a/Assets/External/NiloToonURP/Editor/MotionBlurVideoBaker/NiloEditorMotionBlurVideoBaker.cs b/Assets/External/NiloToonURP/Editor/MotionBlurVideoBaker/NiloEditorMotionBlurVideoBaker.cs index 14be25d..dc5d4f1 100644 --- a/Assets/External/NiloToonURP/Editor/MotionBlurVideoBaker/NiloEditorMotionBlurVideoBaker.cs +++ b/Assets/External/NiloToonURP/Editor/MotionBlurVideoBaker/NiloEditorMotionBlurVideoBaker.cs @@ -7,7 +7,9 @@ using System.IO; using System.Collections; using System.Text.RegularExpressions; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System; namespace NiloToon.NiloToonURP { @@ -15,16 +17,30 @@ namespace NiloToon.NiloToonURP { private string ffmpegPath; private string inputFilePath = string.Empty; - private string customSuffix = "(BakedMotionBlur)__"; // Custom suffix for the output file - private int crf = 0; // Default CRF value + private string customSuffix = "(BakedMotionBlur)___"; // Custom suffix for the output file + private int crf = 0; // Default CRF value (0 is lossless for CRF) private List fpsOptions = new List(); // List of possible FPS options private int selectedFPSIndex = 0; // Default FPS index private float inputVideoFPS = 0.0f; // FPS of the input video + private double inputVideoDuration = 0.0; // Duration of the input video in seconds + private int totalFrames = 0; // Total number of frames in the output video private float cameraExposureDuration = 1f / 48f; // 180 shutter angle in terms of 24fps private float motionBlurAmount = 1; - private string ffmpegArgumentsTemplate = - "-vf \"{0}format=yuv420p\" -r {1} -c:v libx264 -preset veryslow -crf {2} -pix_fmt yuv420p -x264opts \"keyint=12:min-keyint=1:ref=1:bframes=0:qcomp=0.8:aq-strength=0.5:direct=auto:fast-pskip=0:deblock=-2,-2\""; + private string ffmpegArgumentsTemplate_H264 = + "-vf \"{0}format=yuv420p\" -r {1} -c:v libx264 -preset veryslow -crf {2} -pix_fmt yuv420p -x264opts \"keyint=1:ref=4:bframes=0\""; + + private string ffmpegArgumentsTemplate_H265 = + "-vf \"{0}format=yuv420p\" -r {1} -c:v libx265 -preset veryslow -x265-params \"crf={2}:keyint=1:no-open-gop=1\" -pix_fmt yuv420p"; + + private string ffmpegArgumentsTemplate_H265_10bit = + "-vf \"{0}format=yuv420p10le\" -r {1} -c:v libx265 -preset veryslow -x265-params \"crf={2}:keyint=1:no-open-gop=1\" -pix_fmt yuv420p10le"; + + private string ffmpegArgumentsTemplate_ProRes_422HQ = + "-vf \"{0}\" -r {1} -c:v prores_ks -profile:v 3 -pix_fmt yuv422p10le"; // ProRes 422 HQ + + private string ffmpegArgumentsTemplate_ProRes = + "-vf \"{0}\" -r {1} -c:v prores_ks -profile:v 5 -pix_fmt yuv444p10le"; // ProRes 4444 XQ private Process ffmpegProcess; private Coroutine coroutine; @@ -36,6 +52,13 @@ namespace NiloToon.NiloToonURP private Vector2 scrollPosition; + private string[] codecOptions = new string[] { "H.264", "H.265 (8-bit)", "H.265 (10-bit)", "ProRes 422 HQ", "ProRes 4444 XQ" }; + private int selectedCodecIndex = 3; // Default to ProRes 422 HQ + + // Added variables for logging interval and process timing + private DateTime lastLogTime = DateTime.MinValue; + private DateTime processStartTime; + [MenuItem("Window/NiloToonURP/MotionBlur Video Baker", priority = 10000)] public static void ShowWindow() { @@ -43,29 +66,53 @@ namespace NiloToon.NiloToonURP window.LoadFFmpegPath(); // Load the FFmpeg path when the window is opened } + private bool ClickableLink(string text, string url) + { + GUIStyle linkStyle = new GUIStyle(GUI.skin.label) + { + richText = true, + normal = { textColor = Color.cyan }, + hover = { textColor = Color.cyan }, + alignment = TextAnchor.MiddleLeft + }; + + Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), linkStyle, GUILayout.Height(20)); + EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link); + + if (GUI.Button(rect, $"{text}", linkStyle)) + { + Application.OpenURL(url); + return true; + } + + return false; + } + private void OnGUI() { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); - - // 960fps will make cinemachine not working correctly, so we suggest max at 900fps + + // 960fps may make cinemachine not working correctly, so we suggest max at 900fps EditorGUILayout.HelpBox( - "[Purpose of this tool]\n" + - "Bake 480-900 fps video with zero or little motion blur -> 24/30/60 fps video with cinematic motion blur & AA produced by sub frame merging\n\n" + - "[How to use?]\n" + - "1.Locate your own ffmpeg.exe (download from ffmpeg.org)\n" + - "2.Prepare a video with 480~900FPS (e.g., Record using Unity's Recorder with a high custom FPS)\n" + - "3.Select that video as Input Video, wait for analysis\n" + - "4.(optional)Adjust other settings if needed\n" + - "5.Click 'Bake now!', this tool will bake cinematic motion blur & AA to a 24/30/60 fps output video (H.264)", MessageType.Info); + "[Purpose of this tool]\n" + + "Import a 480-960 fps short video, bake to a 24/30/60 fps video with high-quality motion blur & AA produced by sub-frame accumulation, similar to UnrealEngine Movie Render Queue's temporal sampling AA\n\n" + + "[How to use?]\n" + + "1. Locate your own ffmpeg.exe (download the latest from ffmpeg.org)\n" + + "2. Select a 480~960FPS video as Input Video(e.g., set NiloToonMotionBlurVolume = 0.5~0.25 intensity, then record using Unity's Recorder with 480~960 FPS into ProRes422LT or higher)\n" + + "3. Click 'Bake now!', this tool will bake motion blur & AA into a result 24/30/60 fps output video", MessageType.Info); + + // add here + ClickableLink("Online Document", "https://docs.google.com/document/d/1iEh1E5xLXnXuICM0ElV3F3x_J2LND9Du2SSKzcIuPXw/edit?tab=t.0#heading=h.tkl2vd8auzt9"); + ClickableLink("Download FFmpeg", "https://ffmpeg.org"); GUI.enabled = ffmpegProcess == null; - + //////////////////////////////////////////////////////////////////////// // FFmpeg Path //////////////////////////////////////////////////////////////////////// GUILayout.Label("FFmpeg Path", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); - ffmpegPath = EditorGUILayout.TextField("Path",ffmpegPath); + ffmpegPath = EditorGUILayout.TextField("Path", ffmpegPath); if (GUILayout.Button("...", GUILayout.Width(60))) { string selectedPath = EditorUtility.OpenFilePanel("Select FFmpeg Executable", "", "exe"); @@ -84,21 +131,21 @@ namespace NiloToon.NiloToonURP GUILayout.Label("Input Video", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); - inputFilePath = EditorGUILayout.TextField("Path",inputFilePath); + inputFilePath = EditorGUILayout.TextField("Path", inputFilePath); if (GUILayout.Button("...", GUILayout.Width(30)) && ffmpegProcess == null) { string newPath = EditorUtility.OpenFilePanel("Select Input File", "", "mov,mp4"); if (!string.IsNullOrEmpty(newPath)) { inputFilePath = newPath; - ExtractVideoFPS(inputFilePath); // Extract the FPS of the selected video + ExtractVideoInfo(inputFilePath); // Extract the FPS and duration of the selected video } } EditorGUILayout.EndHorizontal(); if (inputVideoFPS < 480) { - EditorGUILayout.HelpBox("Expect a video with 480~900FPS", MessageType.Info); + EditorGUILayout.HelpBox("Expect a video with 480~960FPS", MessageType.Info); } // Display error message if input video path is invalid @@ -108,7 +155,7 @@ namespace NiloToon.NiloToonURP } //////////////////////////////////////////////////////////////////////// - // input video fps + // Input Video FPS //////////////////////////////////////////////////////////////////////// if (inputVideoFPS > 0 && File.Exists(inputFilePath)) { @@ -118,11 +165,14 @@ namespace NiloToon.NiloToonURP GUILayout.Space(25); //////////////////////////////////////////////////////////////////////// - // output video (suffix,fps,CRF) + // Output Video Settings //////////////////////////////////////////////////////////////////////// - + GUILayout.Label("Output Video", EditorStyles.boldLabel); + // Codec Selection + selectedCodecIndex = EditorGUILayout.Popup(new GUIContent("Codec"), selectedCodecIndex, codecOptions); + if (fpsOptions.Count > 0) { selectedFPSIndex = Mathf.Clamp(selectedFPSIndex, 0, fpsOptions.Count - 1); @@ -130,7 +180,6 @@ namespace NiloToon.NiloToonURP if (newSelectedFPSIndex != selectedFPSIndex) { selectedFPSIndex = newSelectedFPSIndex; - UnityEngine.Debug.Log($"Selected FPS: {GetOutputFPS()}"); // Log the selected FPS } } @@ -140,63 +189,78 @@ namespace NiloToon.NiloToonURP } motionBlurAmount = EditorGUILayout.Slider("Motion Blur", motionBlurAmount, 0f, 4f); - crf = EditorGUILayout.IntSlider("CRF", crf, 0, 51); - EditorGUILayout.HelpBox( - "CRF (Constant Rate Factor) controls the quality of the video. Lower values mean higher quality and larger file sizes. The range is from 0 (lossless) to 51 (worst quality).", - MessageType.Info); + // CRF Slider (Only for codecs that support it) + if (selectedCodecIndex != 3 && selectedCodecIndex != 4) // Not ProRes + { + crf = EditorGUILayout.IntSlider(new GUIContent("CRF", "For lossless encoding, set CRF to 0. Higher values reduce quality."), crf, 0, 51); + if (crf == 0) + { + EditorGUILayout.HelpBox("CRF is set to 0: Lossless encoding. This results in the highest quality and largest file size.", MessageType.Info); + } + else + { + EditorGUILayout.HelpBox("CRF controls the quality of the video. Lower values mean higher quality and larger file sizes.", MessageType.Info); + } + } customSuffix = EditorGUILayout.TextField("Suffix", customSuffix); - + + // Open Destination Folder Button + GUI.enabled = !string.IsNullOrEmpty(inputFilePath) && File.Exists(inputFilePath); + if (GUILayout.Button("Open Destination Folder")) + { + string currentOutputFilePath = GenerateOutputFilePath(inputFilePath, customSuffix); + string folder = Path.GetDirectoryName(currentOutputFilePath); + if (Directory.Exists(folder)) + { + OpenFolder(folder); + } + else + { + EditorUtility.DisplayDialog("Folder Not Found", "The destination folder does not exist.", "OK"); + } + } + GUI.enabled = ffmpegProcess == null; + //////////////////////////////////////////////////////////////////////// - // output video info + // Output Video Info //////////////////////////////////////////////////////////////////////// if (fpsOptions.Count > 0) { Generate_tmixFilters(inputVideoFPS); - + EditorGUILayout.Space(10); EditorGUILayout.LabelField("Output info:", EditorStyles.boldLabel); EditorGUILayout.HelpBox( - $"- TMix Frame Count: {currenttmixFrameCount}\n" + - $"- Shutter Angle in terms of 24fps: {GetShutterAngleInTermsOf24fps()} degrees (~180 is a good default for cinematic output)\n" + - $"- Shutter Speed: {GetShutterSpeedDisplayString()} (~1/48 is a good default for cinematic output)" + $"- Temporal Sample(TMix) Count: {currenttmixFrameCount} (>=16 is good for cinematic output)\n" + + $"- Shutter Angle in terms of 24fps: {GetShutterAngleInTermsOf24fps()} degrees (~180 is a good default for cinematic output)\n" + + $"- Shutter Speed: {GetShutterSpeedDisplayString()} (~1/48 is a good default for cinematic output)" , MessageType.Info); - // check if shutter angle is too small - if (currenttmixFrameCount < Mathf.CeilToInt(inputVideoFPS / GetOutputFPS()/ 2)) + // Check if shutter angle is too small + if (currenttmixFrameCount < Mathf.CeilToInt(inputVideoFPS / GetOutputFPS() / 2)) { EditorGUILayout.HelpBox( $"Current Shutter Angle for {GetOutputFPS()}fps is < 180, while it is not wrong, it may produce not enough motion blur" , MessageType.Warning); } - - // it is ok to go over 360, so don't give warning. - // for example, 60fps output with 1/48th shutter speed - /* - // check if shutter angle is too big - if (currenttmixFrameCount > (inputVideoFPS / GetOutputFPS())) - { - EditorGUILayout.HelpBox( - $"Current Shutter Angle is too large, it may produce too much motion blur" - , MessageType.Warning); - } - */ } GUILayout.Space(25); - + EditorGUILayout.LabelField("Extra note:", EditorStyles.boldLabel); EditorGUILayout.HelpBox( $"- Make sure Project Settings > VFX > Fixed Time Step is using '1/fps of recorder' when recording\n" + - $"- Do not record in 960fps or higher, it may break cinemachine's camera movement" + $"- If fps is high (e.g., 900fps or higher), it may break cinemachine's camera movement\n" + + $"- Example input video: 1440p 960fps, or 2160p 480fps" , MessageType.Info); GUI.enabled = true; //////////////////////////////////////////////////////////////////////// - // Bake button + // Bake Button //////////////////////////////////////////////////////////////////////// - + // Disable the "Bake Now!" button if any condition is not met GUI.enabled = ffmpegProcess == null && ValidatePaths() && fpsOptions.Count > 0; if (GUILayout.Button("Bake now!") && ffmpegProcess == null && ValidatePaths() && fpsOptions.Count > 0) @@ -236,7 +300,7 @@ namespace NiloToon.NiloToonURP { CancelFFmpegProcess(); } - + EditorGUILayout.EndScrollView(); } @@ -279,6 +343,7 @@ namespace NiloToon.NiloToonURP { return (float)currenttmixFrameCount / (inputVideoFPS / 24f) * 360f; } + private float GetShutterSpeed() { return (1f / 24f) * (GetShutterAngleInTermsOf24fps() / 360f); @@ -286,17 +351,38 @@ namespace NiloToon.NiloToonURP private string GetShutterSpeedDisplayString() { - return $"1/{1 / GetShutterSpeed()}s"; + return $"1/{FormatNumber(1 / GetShutterSpeed())}s"; } private string GetShutterSpeedFileNameString() { - return $"OneOver{1 / GetShutterSpeed()}s"; + return $"OneOver{FormatNumber(1 / GetShutterSpeed())}s"; } + + // Helper method to format numbers without unnecessary trailing zeros + private string FormatNumber(double number) + { + if (number % 1 == 0) + return number.ToString("0"); + else + return number.ToString("0.##"); + } + private string GenerateOutputFilePath(string inputPath, string suffix) { suffix = suffix.Replace("", $"{GetOutputFPS()}fps"); suffix = suffix.Replace("", $"{GetShutterSpeedFileNameString()}"); + + // Handle codec placeholder + if (suffix.Contains("")) + { + // Get codec name and format it for filename + string codecName = codecOptions[selectedCodecIndex]; + codecName = codecName.Replace(" ", "").Replace("(", "").Replace(")", "").Replace(".", "").Replace("-", ""); + + suffix = suffix.Replace("", codecName); + } + string directory = Path.GetDirectoryName(inputPath); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(inputPath); string extension = Path.GetExtension(inputPath); @@ -306,30 +392,62 @@ namespace NiloToon.NiloToonURP private IEnumerator StartFFmpegProcessCoroutine(string outputFilePath, float selectedFPS) { string tmixFilters = Generate_tmixFilters(inputVideoFPS); - string ffmpegArguments = string.Format(ffmpegArgumentsTemplate, tmixFilters, selectedFPS, crf); + // Record start time + processStartTime = DateTime.Now; + + // Calculate totalFrames here, based on the selected output FPS and the input video duration + if (selectedFPS > 0 && inputVideoDuration > 0) + { + totalFrames = (int)(selectedFPS * inputVideoDuration); + UnityEngine.Debug.Log($"Calculated Total Output Frames (using output video FPS {selectedFPS}): {totalFrames}"); + } + else + { + totalFrames = 0; + UnityEngine.Debug.LogError("Failed to calculate total frames due to invalid output FPS or video duration."); + } + + // Log start of baking process with output file name + UnityEngine.Debug.Log($"Baking started. Output file: {outputFilePath}"); + + // Select the FFmpeg arguments template based on the selected codec + string ffmpegArgumentsTemplate = GetFFmpegArgumentsTemplate(); + + // Prepare the FFmpeg arguments + string ffmpegArguments = ""; + + if (selectedCodecIndex == 0 || selectedCodecIndex == 1 || selectedCodecIndex == 2) // H.264, H.265 + { + ffmpegArguments = string.Format(ffmpegArgumentsTemplate, tmixFilters, selectedFPS, crf); + } + else if (selectedCodecIndex == 3 || selectedCodecIndex == 4) // ProRes + { + ffmpegArguments = string.Format(ffmpegArgumentsTemplate, tmixFilters, selectedFPS); + } + + // Use '-hide_banner' to suppress unnecessary output ProcessStartInfo processStartInfo = new ProcessStartInfo { FileName = ffmpegPath, - Arguments = $"-i \"{inputFilePath}\" {ffmpegArguments} \"{outputFilePath}\"", - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, // must be false + Arguments = $"-hide_banner -i \"{inputFilePath}\" {ffmpegArguments} \"{outputFilePath}\"", + RedirectStandardOutput = false, // Do not redirect standard output + RedirectStandardError = true, // Redirect standard error to capture errors and progress + UseShellExecute = false, // Must be false CreateNoWindow = true }; ffmpegProcess = new Process { - StartInfo = processStartInfo + StartInfo = processStartInfo, + EnableRaisingEvents = true }; - ffmpegProcess.OutputDataReceived += (sender, args) => HandleFFmpegOutput(args.Data); - ffmpegProcess.ErrorDataReceived += (sender, args) => HandleFFmpegOutput(args.Data); + ffmpegProcess.ErrorDataReceived += FfmpegProcess_ErrorDataReceived; ffmpegProcess.Start(); - ffmpegProcess.BeginOutputReadLine(); ffmpegProcess.BeginErrorReadLine(); - // Wait for the process to exit while updating the progress bar + // Wait for the process to exit while (!ffmpegProcess.HasExited) { yield return null; @@ -338,27 +456,247 @@ namespace NiloToon.NiloToonURP ffmpegProcess.WaitForExit(); ffmpegProcess = null; - // Close the progress bar when the process exits - EditorUtility.ClearProgressBar(); + // Calculate elapsed time + TimeSpan elapsedTime = DateTime.Now - processStartTime; + + // Log completion message + string timeSpent = $"Time spent = {elapsedTime.Hours} hours {elapsedTime.Minutes} minutes {elapsedTime.Seconds} seconds, video completed ({Path.GetFileName(outputFilePath)})."; + UnityEngine.Debug.Log(timeSpent); + } + + private void FfmpegProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e) + { + if (!string.IsNullOrEmpty(e.Data)) + { + string data = e.Data; + HandleFFmpegOutput(data); + } + } + + private void HandleFFmpegOutput(string data) + { + // Parse FFmpeg output to extract meaningful information + if (IsCriticalFfmpegMessage(data)) + { + UnityEngine.Debug.LogError("FFmpeg Error: " + data); + } + else + { + // Parse progress information + // FFmpeg outputs progress in lines like: "frame=123 fps=45 q=28.0 size=1234kB time=00:00:05.12 bitrate=1976.3kbits/s speed=1.23x" + + if (data.StartsWith("frame=")) + { + // Regular expression to parse the progress line + var progressMatch = Regex.Match(data, @"frame=\s*(\d+)\s.*?time=\s*(\S+)\s.*?speed=\s*([\d\.]+)x"); + + if (progressMatch.Success) + { + string frameStr = progressMatch.Groups[1].Value; + string timeStr = progressMatch.Groups[2].Value; + string speedStr = progressMatch.Groups[3].Value; + + if (int.TryParse(frameStr, out int currentFrame)) + { + float percentage = 0f; + if (totalFrames > 0) + { + percentage = (float)currentFrame / totalFrames * 100f; + percentage = Mathf.Clamp(percentage, 0f, 100f); + } + + // Only log if at least 2 seconds have passed since last log + if ((DateTime.Now - lastLogTime).TotalSeconds >= 2) + { + TimeSpan elapsedTime = DateTime.Now - processStartTime; + + string estimatedTimeRemainingString = "Unknown"; + if (percentage > 0) + { + double estimatedTotalSeconds = elapsedTime.TotalSeconds / (percentage / 100); + TimeSpan estimatedRemainingTime = TimeSpan.FromSeconds(estimatedTotalSeconds - elapsedTime.TotalSeconds); + + estimatedTimeRemainingString = $"{(int)estimatedRemainingTime.TotalHours}h {estimatedRemainingTime.Minutes}m {estimatedRemainingTime.Seconds}s"; + } + + string elapsedTimeString = $"{(int)elapsedTime.TotalHours}h {elapsedTime.Minutes}m {elapsedTime.Seconds}s"; + + string logMessage = $"Frame {currentFrame}/{totalFrames} ({percentage:F1}%), Processed time: {elapsedTimeString}, Estimated time remaining: {estimatedTimeRemainingString}, Speed {speedStr}x"; + + UnityEngine.Debug.Log(logMessage); + + lastLogTime = DateTime.Now; + } + } + // Optionally, handle other outputs or suppress less important messages + } + } + } + } + + private bool IsCriticalFfmpegMessage(string message) + { + if (string.IsNullOrEmpty(message)) + return false; + + // Check if message contains 'Error' or 'Invalid' etc. + string lowerMessage = message.ToLowerInvariant(); + return lowerMessage.Contains("error") || lowerMessage.Contains("invalid") || lowerMessage.Contains("failed"); + } + + private void CancelFFmpegProcess() + { + if (ffmpegProcess != null && !ffmpegProcess.HasExited) + { + ffmpegProcess.Kill(); + ffmpegProcess.WaitForExit(); // Ensure the process has completely exited + ffmpegProcess = null; + if (coroutine != null) + { + EditorCoroutine.StopCoroutine(coroutine); + coroutine = null; + } + + UnityEngine.Debug.Log("FFmpeg process cancelled."); + + // Delete the incomplete output file + if (File.Exists(outputFilePath)) + { + try + { + File.Delete(outputFilePath); + UnityEngine.Debug.Log("Incomplete output file deleted."); + } + catch (IOException e) + { + UnityEngine.Debug.LogError($"Failed to delete incomplete output file: {e.Message}"); + } + } + } + } + + private void ExtractVideoInfo(string videoPath) + { + inputVideoFPS = 0f; + inputVideoDuration = 0.0; + + ProcessStartInfo processStartInfo = new ProcessStartInfo + { + FileName = ffmpegPath, + Arguments = $"-hide_banner -i \"{videoPath}\"", + RedirectStandardOutput = false, // FFmpeg outputs video information to standard error stream + RedirectStandardError = true, // Redirect standard error stream + UseShellExecute = false, + CreateNoWindow = true + }; + + Process process = new Process + { + StartInfo = processStartInfo + }; + + process.ErrorDataReceived += ProcessOutputHandler; + + process.Start(); + process.BeginErrorReadLine(); + process.WaitForExit(); + + // After processing, check if Duration was successfully extracted + if (inputVideoDuration <= 0) + { + UnityEngine.Debug.LogError("Failed to extract Duration from the input video."); + } + } + + private void ProcessOutputHandler(object sender, DataReceivedEventArgs e) + { + if (string.IsNullOrEmpty(e.Data)) + return; + + // UnityEngine.Debug.Log("FFmpeg Output: " + e.Data); // Optionally log output + + // Extract FPS (input video FPS) + var matchFPS = Regex.Match(e.Data, @"Video:.*?(\d+(\.\d+)?) fps"); + if (matchFPS.Success) + { + if (float.TryParse(matchFPS.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out float fps)) + { + inputVideoFPS = fps; + UnityEngine.Debug.Log("Input Video FPS: " + inputVideoFPS); + UpdateFPSOptions(inputVideoFPS); + } + } + + // Extract duration + var matchDuration = Regex.Match(e.Data, @"Duration: (\d+):(\d+):(\d+(\.\d+)?)"); + if (matchDuration.Success) + { + int hours = int.Parse(matchDuration.Groups[1].Value); + int minutes = int.Parse(matchDuration.Groups[2].Value); + double seconds = double.Parse(matchDuration.Groups[3].Value, CultureInfo.InvariantCulture); + inputVideoDuration = hours * 3600 + minutes * 60 + seconds; + UnityEngine.Debug.Log("Input Video Duration: " + inputVideoDuration + " seconds"); + } + } + + private void UpdateFPSOptions(float inputFPS) + { + fpsOptions.Clear(); + float[] supportedOutputFPS = { 23.976f, 24f, 25f, 29.97f, 30f, 48f, 50f, 59.94f, 60f, 72f, 90f, 100f, 120f, 144f, 240f }; + + foreach (var fps in supportedOutputFPS) + { + if (inputFPS >= fps * 2) + { + fpsOptions.Add(fps); + } + } + + // Find index of 60 fps or closest lower value if 60 is not available + int index60 = fpsOptions.FindIndex(fps => fps >= 60); + selectedFPSIndex = index60 >= 0 ? index60 : fpsOptions.Count - 1; + } + + private string GetFFmpegArgumentsTemplate() + { + switch (selectedCodecIndex) + { + case 0: // H.264 + return ffmpegArgumentsTemplate_H264; + case 1: // H.265 (8-bit) + return ffmpegArgumentsTemplate_H265; + case 2: // H.265 (10-bit) + return ffmpegArgumentsTemplate_H265_10bit; + case 3: // ProRes 422 HQ + return ffmpegArgumentsTemplate_ProRes_422HQ; + case 4: // ProRes 4444 XQ + return ffmpegArgumentsTemplate_ProRes; + default: + return ffmpegArgumentsTemplate_H264; + } } private string Generate_tmixFilters(float inputVideoFPS) { int numberOfTMixFrames = Mathf.FloorToInt(inputVideoFPS * cameraExposureDuration * motionBlurAmount); + + // ensure at least 1 frame when motionBlurAmount is 0 + numberOfTMixFrames = Mathf.Max(numberOfTMixFrames, 1); + currenttmixFrameCount = numberOfTMixFrames; if (currenttmixFrameCount == 0) { return ""; } - - #if METHOD1 + +#if METHOD1 string weightString = string.Join(" ", Enumerable.Repeat("1", numberOfTMixFrames)); - #endif - - #if METHOD2 +#endif + +#if METHOD2 // [2-way expo falloff] - + // Generate exponential falloff weights List weights = new List(); int centerFrame = numberOfTMixFrames / 2; @@ -376,10 +714,9 @@ namespace NiloToon.NiloToonURP string weightString = string.Join(" ", weights); //------------------------------------------------------------------------------------------------------- - #endif - - - #if METHOD3 +#endif + +#if METHOD3 //------------------------------------------------------------------------------------------------------- // [1-way expo falloff] @@ -402,17 +739,17 @@ namespace NiloToon.NiloToonURP // Ensure no weight is zero weights = weights.Select(w => Mathf.Max(w, 1)).ToList(); - + string weightString = string.Join(" ", weights); //------------------------------------------------------------------------------------------------------- - #endif - - #if METHOD4 +#endif + +#if METHOD4 string weightString = GenerateGaussianWeights(numberOfTMixFrames); - #endif +#endif return $"tmix=frames={numberOfTMixFrames}:weights='{weightString}',"; } - + private string GenerateGaussianWeights(int numberOfTMixFrames) { numberOfTMixFrames = Mathf.Min(40, Mathf.Max(1, numberOfTMixFrames)); @@ -428,7 +765,7 @@ namespace NiloToon.NiloToonURP weights.Add(weight); sum += weight; } - + const int scale = 1000; List scaledWeights = weights.Select(w => (int)Mathf.Round(w / sum * scale)).ToList(); @@ -443,104 +780,19 @@ namespace NiloToon.NiloToonURP return string.Join(" ", scaledWeights); } - private void CancelFFmpegProcess() + // New method to open the folder directly + private void OpenFolder(string folderPath) { - if (ffmpegProcess != null && !ffmpegProcess.HasExited) - { - ffmpegProcess.Kill(); - ffmpegProcess.WaitForExit(); // Ensure the process has completely exited - ffmpegProcess = null; - if (coroutine != null) - { - EditorCoroutine.StopCoroutine(coroutine); - coroutine = null; - } - - EditorUtility.ClearProgressBar(); - UnityEngine.Debug.Log("FFmpeg process cancelled."); - - // Delete the incomplete output file - if (File.Exists(outputFilePath)) - { - try - { - File.Delete(outputFilePath); - UnityEngine.Debug.Log("Incomplete output file deleted."); - } - catch (IOException e) - { - UnityEngine.Debug.LogError($"Failed to delete incomplete output file: {e.Message}"); - } - } - } - } - - private void HandleFFmpegOutput(string data) - { - UnityEngine.Debug.Log(data); - } - - private void ExtractVideoFPS(string videoPath) - { - ProcessStartInfo processStartInfo = new ProcessStartInfo - { - FileName = ffmpegPath, - Arguments = $"-i \"{videoPath}\" -vcodec copy -f null -", - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - Process process = new Process - { - StartInfo = processStartInfo - }; - - process.OutputDataReceived += ProcessOutputHandler; - process.ErrorDataReceived += ProcessOutputHandler; - - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - process.WaitForExit(); - } - - private void ProcessOutputHandler(object sender, DataReceivedEventArgs e) - { - if (string.IsNullOrEmpty(e.Data)) - return; - - UnityEngine.Debug.Log("FFmpeg Output: " + e.Data); // Log the output to debug - - // Example of how to parse the FPS from FFmpeg output - // Look for a line containing "fps" and extract the value - var match = Regex.Match(e.Data, @"(\d+(\.\d+)?) fps"); - if (match.Success) - { - if (float.TryParse(match.Groups[1].Value, out float fps)) - { - inputVideoFPS = fps; - UnityEngine.Debug.Log("Extracted FPS: " + inputVideoFPS); // Log the extracted FPS - UpdateFPSOptions(inputVideoFPS); // Update FPS options based on extracted FPS - } - } - } - - private void UpdateFPSOptions(float inputFPS) - { - fpsOptions.Clear(); - float[] supportedOutputFPS = { 24, 25, 30, 50, 60 }; - - foreach (var fps in supportedOutputFPS) - { - if (inputFPS >= fps * 2) - { - fpsOptions.Add(fps); - } - } - - selectedFPSIndex = fpsOptions.Count - 1; // Set the highest FPS +#if UNITY_EDITOR_WIN + folderPath = folderPath.Replace('/', '\\'); // Ensure correct path separator on Windows + System.Diagnostics.Process.Start("explorer.exe", folderPath); +#elif UNITY_EDITOR_OSX + System.Diagnostics.Process.Start("open", folderPath); +#elif UNITY_EDITOR_LINUX + System.Diagnostics.Process.Start("xdg-open", folderPath); +#else + Application.OpenURL("file://" + folderPath); +#endif } } diff --git a/Assets/External/NiloToonURP/Editor/NiloToonEditorPerCharacterRenderControllerCustomEditor.cs b/Assets/External/NiloToonURP/Editor/NiloToonEditorPerCharacterRenderControllerCustomEditor.cs index 1eecbcb..8e6e51d 100644 --- a/Assets/External/NiloToonURP/Editor/NiloToonEditorPerCharacterRenderControllerCustomEditor.cs +++ b/Assets/External/NiloToonURP/Editor/NiloToonEditorPerCharacterRenderControllerCustomEditor.cs @@ -85,7 +85,11 @@ namespace NiloToon.NiloToonURP Mesh mesh = null; switch (renderer) { - case MeshRenderer mr: mesh = mr.GetComponent().sharedMesh; break; + case MeshRenderer mr: + MeshFilter mf = mr.GetComponent(); + if(!mf) continue; + mesh = mf.sharedMesh; + break; case SkinnedMeshRenderer smr: mesh = smr.sharedMesh; ; break; default: break; // do nothing if not a supported renderer(e.g. particle system's renderer) @@ -112,7 +116,11 @@ namespace NiloToon.NiloToonURP Mesh mesh = null; switch (renderer) { - case MeshRenderer mr: mesh = mr.GetComponent().sharedMesh; break; + case MeshRenderer mr: + MeshFilter mf = mr.GetComponent(); + if(!mf) continue; + mesh = mf.sharedMesh; + break; case SkinnedMeshRenderer smr: mesh = smr.sharedMesh; break; default: break; // do nothing if not a supported renderer(e.g. particle system's renderer) @@ -381,7 +389,8 @@ namespace NiloToon.NiloToonURP public class NiloToonEditorAutoSetupCharacter { #if UNITY_EDITOR - [MenuItem("Window/NiloToonURP/Convert selected GameObjects to NiloToon", priority = 1)] + [MenuItem("Window/NiloToonURP/[GameObject] Convert Selected GameObjects to NiloToon", priority = 1)] + [MenuItem("Assets/NiloToon/[GameObject] Convert Selected GameObjects to NiloToon", priority = 1100 + 1)] public static void SetupSelectedCharacterGameObject() { var allselectedObjects = Selection.objects; @@ -394,7 +403,8 @@ namespace NiloToon.NiloToonURP } } - [MenuItem("Window/NiloToonURP/Convert selected GameObjects to NiloToon", priority = 1, validate = true)] + [MenuItem("Window/NiloToonURP/[GameObject] Convert Selected GameObjects to NiloToon", priority = 1, validate = true)] + [MenuItem("Assets/NiloToon/[GameObject] Convert Selected GameObjects to NiloToon", priority = 1100 + 1, validate = true)] public static bool ValidateSetupSelectedCharacterGameObject() { var allselectedObjects = Selection.objects; diff --git a/Assets/External/NiloToonURP/Editor/NiloToonEditorShaderStripping.cs b/Assets/External/NiloToonURP/Editor/NiloToonEditorShaderStripping.cs index 0d2fcf6..e7b0660 100644 --- a/Assets/External/NiloToonURP/Editor/NiloToonEditorShaderStripping.cs +++ b/Assets/External/NiloToonURP/Editor/NiloToonEditorShaderStripping.cs @@ -108,6 +108,7 @@ namespace NiloToon.NiloToonURP return true; } + // [It seems that we can't strip a local keyword based on local keyword..?] // In Unity2021.3's build, this section will incorrectly strip some keyword(e.g. _MATCAP_ADD _MATCAP_BLEND _RAMP_LIGHTING_SAMPLE_UVY_TEX _SKIN_MASK_ON _SPECULARHIGHLIGHTS), // we now disable this section for "Unity 2021.3 or later" temporary until bug is fixed. /* @@ -242,7 +243,8 @@ namespace NiloToon.NiloToonURP } // use targetResultSetting to add keywords that we want to strip to our ignore list - private static List GetStripKeywordList(Shader shader, NiloToonShaderStrippingSettingSO.Settings targetResultSetting) + private static List GetStripKeywordList(Shader shader, + NiloToonShaderStrippingSettingSO.Settings targetResultSetting) { List haveToStripList = new List(); @@ -251,10 +253,12 @@ namespace NiloToon.NiloToonURP { haveToStripList.Add(new ShaderKeyword("_NILOTOON_DEBUG_SHADING")); } + if (!targetResultSetting.include_NILOTOON_FORCE_MINIMUM_SHADER) { haveToStripList.Add(new ShaderKeyword("_NILOTOON_FORCE_MINIMUM_SHADER")); } + if (!targetResultSetting.include_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE) { haveToStripList.Add(new ShaderKeyword("_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE")); @@ -264,10 +268,12 @@ namespace NiloToon.NiloToonURP { haveToStripList.Add(new ShaderKeyword("_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE_V2")); } + if (!targetResultSetting.include_NILOTOON_RECEIVE_URP_SHADOWMAPPING) { haveToStripList.Add(new ShaderKeyword("_NILOTOON_RECEIVE_URP_SHADOWMAPPING")); } + if (!targetResultSetting.include_NILOTOON_RECEIVE_SELF_SHADOW) { haveToStripList.Add(new ShaderKeyword("_NILOTOON_RECEIVE_SELF_SHADOW")); @@ -298,15 +304,58 @@ namespace NiloToon.NiloToonURP { haveToStripList.Add(new ShaderKeyword(shader, "_NILOTOON_DITHER_FADEOUT")); } + if (!targetResultSetting.include_NILOTOON_DISSOLVE) { haveToStripList.Add(new ShaderKeyword(shader, "_NILOTOON_DISSOLVE")); } + if (!targetResultSetting.include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE) { haveToStripList.Add(new ShaderKeyword(shader, "_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE")); } + //---------------------------------------------------------------------------------------------------------------------------------- + // [strip Fog] + // https://docs.unity3d.com/6000.2/Documentation/Manual/urp/shader-stripping-fog.html + // We forced dynamic_branch for fog in NiloToonCharacter.shader for Unity6.1 or higher, so no need to strip them now. + //haveToStripList.Add(new ShaderKeyword(shader, "FOG_EXP")); + //haveToStripList.Add(new ShaderKeyword(shader, "FOG_EXP2")); + //haveToStripList.Add(new ShaderKeyword(shader, "FOG_LINEAR")); + + // [strip XR] + // By default, Unity adds this set of keywords to all graphics shader programs: + // - STEREO_INSTANCING_ON + // - STEREO_MULTIVIEW_ON + // - STEREO_CUBEMAP_RENDER_ON + // - UNITY_SINGLE_PASS_STEREO + // we by default strip these keywords since most user are not using NiloToon for XR. + // XR user should enable these keyword manually + // https://docs.unity3d.com/6000.2/Documentation/Manual/shader-keywords-default.html + if (!targetResultSetting.include_STEREO_INSTANCING_ON) + { + haveToStripList.Add(new ShaderKeyword(shader, "STEREO_INSTANCING_ON")); // safe to strip + } + if (!targetResultSetting.include_STEREO_MULTIVIEW_ON) + { + haveToStripList.Add(new ShaderKeyword(shader, "STEREO_MULTIVIEW_ON")); // safe to strip + } + if (!targetResultSetting.include_STEREO_CUBEMAP_RENDER_ON) + { + haveToStripList.Add(new ShaderKeyword(shader, "STEREO_CUBEMAP_RENDER_ON")); // safe to strip + } + if (!targetResultSetting.include_UNITY_SINGLE_PASS_STEREO) + { + haveToStripList.Add(new ShaderKeyword(shader, "UNITY_SINGLE_PASS_STEREO")); // safe to strip + } + + //haveToStripList.Add(new ShaderKeyword(shader, "_RECEIVE_URP_SHADOW")); // confirm not safe to strip a local material keyword + //haveToStripList.Add(new ShaderKeyword(shader, "_SCREENSPACE_OUTLINE")); // confirm not safe to strip a local material keyword + + // [URP multi_compile] + //haveToStripList.Add(new ShaderKeyword(shader, "_MAIN_LIGHT_SHADOWS_CASCADE")); // safe to strip? + //haveToStripList.Add(new ShaderKeyword(shader, "...")); // there are a lot of other keyword + //---------------------------------------------------------------------------------------------------------------------------------- return haveToStripList; } diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ExcludeFromBuild.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ExcludeFromBuild.cs index 2af862f..0071e61 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ExcludeFromBuild.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ExcludeFromBuild.cs @@ -1,12 +1,16 @@ -using System.Collections.Generic; -using System.IO; -using UnityEditor; -using UnityEditor.Build; -using UnityEditor.Build.Reporting; -using UnityEngine; +// using System.Collections.Generic; +// using System.IO; +// using UnityEditor; +// using UnityEditor.Build; +// using UnityEditor.Build.Reporting; +// using UnityEngine; namespace LWGUI { + /* + /// + /// Used to exclude textures referenced by ImageDrawer in Build + /// public class ExcludeFromBuild : IPreprocessBuildWithReport, IPostprocessBuildWithReport { public static List excludeAssetPaths = new List(); @@ -106,4 +110,5 @@ namespace LWGUI OutputLogs(); } } + */ } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderModifyListener.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ShaderModifyListener.cs similarity index 86% rename from Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderModifyListener.cs rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ShaderModifyListener.cs index dd0039f..f9df333 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderModifyListener.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ShaderModifyListener.cs @@ -6,6 +6,9 @@ using UnityEngine; namespace LWGUI { + /// + /// Used to listen for Shader updates and flush the LWGUI caches + /// public class ShaderModifyListener : AssetPostprocessor { private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderModifyListener.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ShaderModifyListener.cs.meta similarity index 100% rename from Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderModifyListener.cs.meta rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/AssetProcessor/ShaderModifyListener.cs.meta diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomFooter.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomFooter.cs index aa56fe9..1364ce9 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomFooter.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomFooter.cs @@ -15,7 +15,8 @@ namespace LWGUI.CustomGUISample [InitializeOnLoadMethod] private static void RegisterEvent() { - LWGUI.onDrawCustomFooter += DoCustomFooter; + // Register Event + // LWGUI.onDrawCustomFooter += DoCustomFooter; } } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomHeader.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomHeader.cs index 92894dc..6274785 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomHeader.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomHeader.cs @@ -15,7 +15,8 @@ namespace LWGUI.CustomGUISample [InitializeOnLoadMethod] private static void RegisterEvent() { - LWGUI.onDrawCustomHeader += DoCustomHeader; + // Register Event + // LWGUI.onDrawCustomHeader += DoCustomHeader; } } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs new file mode 100644 index 0000000..5be4e65 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs @@ -0,0 +1,48 @@ +using System.Linq; +using UnityEngine; +using UnityEditor; + +namespace LWGUI +{ + public static class CustomMaterialAssetFinder + { + public static Material FindMaterialAssetInRendererByMaterialInstance(Renderer renderer, Material materialInstance) + { + Material materialAsset = null; + + // Find the material asset by name + // if (materialAsset == null) + // { + // var name = materialInstance.name.Replace(" (Instance)", ""); + // var guids = AssetDatabase.FindAssets("t:Material " + name, new[] { "Assets" }).Select(guid => + // { + // var assetPath = AssetDatabase.GUIDToAssetPath(guid); + // if (string.IsNullOrEmpty(assetPath) || !assetPath.EndsWith(".mat")) + // return null; + // else + // return guid; + // }).ToArray(); + // + // if (guids != null && guids.Length > 0) + // { + // var matPath = AssetDatabase.GUIDToAssetPath(guids[0]); + // Selection.activeObject = AssetDatabase.LoadAssetAtPath(matPath); + // + // if (guids.Length > 1) + // { + // Debug.LogWarning($"LWGUI: Multiple materials with the same name were found, and the first one was selected: { matPath }"); + // } + // } + // } + + return materialAsset; + } + + [InitializeOnLoadMethod] + private static void RegisterEvent() + { + // Register Event + // Helper.onFindMaterialAssetInRendererByMaterialInstance = FindMaterialAssetInRendererByMaterialInstance; + } + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs.meta new file mode 100644 index 0000000..412ac87 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/CustomGUISample/CustomMaterialAssetFinder.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d476ea1a49c64eb4a29bca60d1e97c01 +timeCreated: 1732872239 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/Helper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/Helper.cs index 5828ded..97266c6 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/Helper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/Helper.cs @@ -177,57 +177,22 @@ namespace LWGUI // Tips: Use properties to fix null reference errors private static GUIStyle _guiStyles_IconButton; - - public static GUIStyle guiStyles_IconButton - { - get - { - if (_guiStyles_IconButton == null) - { - _guiStyles_IconButton = new GUIStyle(EditorStyles.iconButton) { fixedHeight = 0, fixedWidth = 0 }; - } - return _guiStyles_IconButton; - } - } + public static GUIStyle guiStyles_IconButton => _guiStyles_IconButton ?? new GUIStyle(EditorStyles.iconButton) { fixedHeight = 0, fixedWidth = 0 }; private static GUIStyle _guiStyle_Foldout; - - public static GUIStyle guiStyle_Foldout + public static GUIStyle guiStyle_Foldout => _guiStyle_Foldout ?? new GUIStyle(EditorStyles.miniButton) { - get - { - if (_guiStyle_Foldout == null) - { - _guiStyle_Foldout = - new GUIStyle(EditorStyles.miniButton) - { - contentOffset = new Vector2(22, 0), - fixedHeight = 27, - alignment = TextAnchor.MiddleLeft, - font = EditorStyles.boldLabel.font, - fontSize = EditorStyles.boldLabel.fontSize + 1, - }; - } - return _guiStyle_Foldout; - } - } + contentOffset = new Vector2(22, 0), + fixedHeight = 27, + alignment = TextAnchor.MiddleLeft, + font = EditorStyles.boldLabel.font, + fontSize = EditorStyles.boldLabel.fontSize + 1 + }; private static GUIStyle _guiStyle_Helpbox; - - public static GUIStyle guiStyle_Helpbox - { - get - { - if (_guiStyle_Helpbox == null) - { - _guiStyle_Helpbox = new GUIStyle(EditorStyles.helpBox) { fontSize = 12 }; - } - return _guiStyle_Helpbox; - } - } + public static GUIStyle guiStyle_Helpbox => _guiStyle_Helpbox ?? new GUIStyle(EditorStyles.helpBox) { fontSize = 12 }; private static GUIStyle _guiStyles_ToolbarSearchTextFieldPopup; - public static GUIStyle guiStyles_ToolbarSearchTextFieldPopup { get @@ -359,8 +324,10 @@ namespace LWGUI } } - private static Texture _logo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("26b9d845eb7b1a747bf04dc84e5bcc2c")); - private static GUIContent _logoGuiContent = new GUIContent(string.Empty, _logo, + private static Texture _logoCache; + private static GUIContent _logoGuiContentCache; + private static Texture _logo => _logoCache = _logoCache ?? AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("26b9d845eb7b1a747bf04dc84e5bcc2c")); + private static GUIContent _logoGuiContent => _logoGuiContentCache = _logoGuiContentCache ?? new GUIContent(string.Empty, _logo, "LWGUI (Light Weight Shader GUI)\n\n" + "A Lightweight, Flexible, Powerful Unity Shader GUI system.\n\n" + "Copyright (c) Jason Ma"); @@ -386,23 +353,38 @@ namespace LWGUI private static Material _copiedMaterial; private static List _copiedProps = new List(); - private static Texture _iconCopy = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9cdef444d18d2ce4abb6bbc4fed4d109")); - private static Texture _iconPaste = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("8e7a78d02e4c3574998524a0842a8ccb")); - private static Texture _iconSelect = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("6f44e40b24300974eb607293e4224ecc")); - private static Texture _iconCheckout = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("72488141525eaa8499e65e52755cb6d0")); - private static Texture _iconExpand = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("2382450e7f4ddb94c9180d6634c41378")); - private static Texture _iconCollapse = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("929b6e5dfacc42b429d715a3e1ca2b57")); - private static Texture _iconVisibility = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9576e23a695b35d49a9fc55c9a948b4f")); + private const string _iconCopyGUID = "9cdef444d18d2ce4abb6bbc4fed4d109"; + private const string _iconPasteGUID = "8e7a78d02e4c3574998524a0842a8ccb"; + private const string _iconSelectGUID = "6f44e40b24300974eb607293e4224ecc"; + private const string _iconCheckoutGUID = "72488141525eaa8499e65e52755cb6d0"; + private const string _iconExpandGUID = "2382450e7f4ddb94c9180d6634c41378"; + private const string _iconCollapseGUID = "929b6e5dfacc42b429d715a3e1ca2b57"; + private const string _iconVisibilityGUID = "9576e23a695b35d49a9fc55c9a948b4f"; - private static GUIContent _guiContentCopy = new GUIContent("", _iconCopy, "Copy Material Properties"); - private static GUIContent _guiContentPaste = new GUIContent("", _iconPaste, "Paste Material Properties\n\nRight-click to paste values by type."); - private static GUIContent _guiContentSelect = new GUIContent("", _iconSelect, "Select the Material Asset\n\nUsed to jump from a Runtime Material Instance to a Material Asset."); - private static GUIContent _guiContentChechout = new GUIContent("", _iconCheckout, "Checkout selected Material Assets"); - private static GUIContent _guiContentExpand = new GUIContent("", _iconExpand, "Expand All Groups"); - private static GUIContent _guiContentCollapse = new GUIContent("", _iconCollapse, "Collapse All Groups"); - private static GUIContent _guiContentVisibility = new GUIContent("", _iconVisibility, "Display Mode"); + private const string _iconCopyTooltip = "Copy Material Properties"; + private const string _iconPasteTooltip = "Paste Material Properties\n\nRight-click to paste values by type."; + private const string _iconSelectTooltip = "Select the Material Asset\n\nUsed to jump from a Runtime Material Instance to a Material Asset."; + private const string _iconCheckoutTooltip = "Checkout selected Material Assets"; + private const string _iconExpandTooltip = "Expand All Groups"; + private const string _iconCollapseTooltip = "Collapse All Groups"; + private const string _iconVisibilityTooltip = "Display Mode"; + + private static GUIContent _guiContentCopyCache; + private static GUIContent _guiContentPasteCache; + private static GUIContent _guiContentSelectCache; + private static GUIContent _guiContentChechoutCache; + private static GUIContent _guiContentExpandCache; + private static GUIContent _guiContentCollapseCache; + private static GUIContent _guiContentVisibilityCache; + + private static GUIContent _guiContentCopy => _guiContentCopyCache = _guiContentCopyCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconCopyGUID)), _iconCopyTooltip); + private static GUIContent _guiContentPaste => _guiContentPasteCache = _guiContentPasteCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconPasteGUID)), _iconPasteTooltip); + private static GUIContent _guiContentSelect => _guiContentSelectCache = _guiContentSelectCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconSelectGUID)), _iconSelectTooltip); + private static GUIContent _guiContentChechout => _guiContentChechoutCache = _guiContentChechoutCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconCheckoutGUID)), _iconCheckoutTooltip); + private static GUIContent _guiContentExpand => _guiContentExpandCache = _guiContentExpandCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconExpandGUID)), _iconExpandTooltip); + private static GUIContent _guiContentCollapse => _guiContentCollapseCache = _guiContentCollapseCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconCollapseGUID)), _iconCollapseTooltip); + private static GUIContent _guiContentVisibility => _guiContentVisibilityCache = _guiContentVisibilityCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(_iconVisibilityGUID)), _iconVisibilityTooltip); - private static string[] _materialInstanceNameEnd = new[] { "_Instantiated (Instance)", " (Instance)", "_Instantiated" }; private enum CopyMaterialValueMask { @@ -547,44 +529,9 @@ namespace LWGUI } else { - // Get Material Asset name - var name = material.name; - foreach (var nameEnd in _materialInstanceNameEnd) + if (FindMaterialAssetByMaterialInstance(material, metaDatas, out var materialAsset)) { - if (name.EndsWith(nameEnd)) - { - name = name.Substring(0, name.Length - nameEnd.Length); - break; - } - } - - // Get path - var guids = AssetDatabase.FindAssets("t:Material " + name); - var paths = guids.Select(((guid, i) => - { - var filePath = AssetDatabase.GUIDToAssetPath(guid); - var fileName = System.IO.Path.GetFileNameWithoutExtension(filePath); - return (fileName == name && filePath.EndsWith(".mat")) ? filePath : null; - })).Where((s => !string.IsNullOrEmpty(s))).ToArray(); - - // Select Asset - if (paths.Length == 0) - { - Debug.LogError("LWGUI: Can not find Material Assets with name: " + name); - } - else if (paths.Length > 1) - { - var str = string.Empty; - foreach (string path in paths) - { - str += "\n" + path; - } - Debug.LogWarning("LWGUI: Multiple Material Assets with the same name have been found, select only the first one:" + str); - Selection.activeObject = AssetDatabase.LoadAssetAtPath(paths[0]); - } - else - { - Selection.activeObject = AssetDatabase.LoadAssetAtPath(paths[0]); + Selection.activeObject = materialAsset; } } } @@ -631,16 +578,16 @@ namespace LWGUI if (GUI.Button(buttonRect, _guiContentVisibility, Helper.guiStyles_IconButton)) { // Build Display Mode Menu Items - string[] displayModeMenus = new[] + var displayModeMenus = new[] { "Show All Advanced Properties (" + displayModeData.advancedCount + " of " + perShaderData.propStaticDatas.Count + ")", "Show All Hidden Properties (" + displayModeData.hiddenCount + " of " + perShaderData.propStaticDatas.Count + ")", "Show Only Modified Properties (" + perMaterialData.modifiedCount + " of " + perShaderData.propStaticDatas.Count + ")", "Show Only Modified Properties by Group (" + perMaterialData.modifiedCount + " of " + perShaderData.propStaticDatas.Count + ")", }; - bool[] enabled = new[] { true, true, true, true }; - bool[] separator = new bool[4]; - int[] selected = new[] + var enabled = new[] { true, true, true, true }; + var separator = new bool[4]; + var selected = new[] { displayModeData.showAllAdvancedProperties ? 0 : -1, displayModeData.showAllHiddenProperties ? 1 : -1, @@ -682,20 +629,46 @@ namespace LWGUI toolBarRect.xMin += 2; } + public static Func onFindMaterialAssetInRendererByMaterialInstance; + + private static bool FindMaterialAssetByMaterialInstance(Material material, LWGUIMetaDatas metaDatas, out Material materialAsset) + { + materialAsset = null; + + var renderers = metaDatas.perInspectorData.materialEditor.GetMeshRenderersByMaterialEditor(); + foreach (var renderer in renderers) + { + if (onFindMaterialAssetInRendererByMaterialInstance != null) + { + materialAsset = onFindMaterialAssetInRendererByMaterialInstance(renderer, material); + } + + if (materialAsset == null) + { + int index = renderer.materials.ToList().FindIndex(materialInstance => materialInstance == material); + if (index >= 0 && index < renderer.sharedMaterials.Length) + { + materialAsset = renderer.sharedMaterials[index]; + } + } + + if (materialAsset != null && AssetDatabase.Contains(materialAsset)) + return true; + } + + Debug.LogError("LWGUI: Can not find the Material Assets of: " + material.name); + + return false; + } + #endregion #region Search Field private static readonly int s_TextFieldHash = "EditorTextField".GetHashCode(); - private static readonly GUIContent[] _searchModeMenus = - (new GUIContent[(int)SearchMode.Num]).Select(((guiContent, i) => - { - if (i == (int)SearchMode.Num) - return null; - - return new GUIContent(((SearchMode)i).ToString()); - })).ToArray(); + private static readonly GUIContent[] _searchModeMenus = Enumerable.Range(0, (int)SearchMode.Num - 1).Select(i => + new GUIContent(((SearchMode)i).ToString())).ToArray(); /// is has changed? public static bool DrawSearchField(Rect rect, LWGUIMetaDatas metaDatas) @@ -926,11 +899,16 @@ namespace LWGUI menus.AddSeparator(""); foreach (var activePresetData in perMaterialData.activePresetDatas) { + // Cull self if (activePresetData.property == prop) continue; var activePreset = activePresetData.preset; - var presetAsset = perShaderData.propStaticDatas[activePresetData.property.name].propertyPresetAsset; - var presetPropDisplayName = perShaderData.propStaticDatas[activePresetData.property.name].displayName; + var (presetPropStaticData, presetPropDynamicData) = metaDatas.GetPropDatas(activePresetData.property); + var presetAsset = presetPropStaticData.propertyPresetAsset; + var presetPropDisplayName = presetPropStaticData.displayName; + + // Cull invisible presets + if (!presetPropDynamicData.isShowing) continue; if (activePreset.GetPropertyValue(prop.name) != null) { diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/MetaDataHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/MetaDataHelper.cs index 64e7eca..db9ea18 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/MetaDataHelper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/MetaDataHelper.cs @@ -16,6 +16,7 @@ namespace LWGUI #region Get Prop Data + public PropertyStaticData GetPropStaticData(string propName) => perShaderData?.GetPropStaticData(propName); public PropertyStaticData GetPropStaticData(MaterialProperty prop) => GetPropStaticData(prop.name); @@ -27,15 +28,18 @@ namespace LWGUI public MaterialProperty GetProperty(string propName) => GetPropDynamicData(propName)?.property; public MaterialProperty GetDefaultProperty(string propName) => GetPropDynamicData(propName)?.defualtProperty; + #endregion #region Get Data Tuple + // var (perShaderData, perMaterialData, perInspectorData) = public (PerShaderData, PerMaterialData, PerInspectorData) GetDatas() => (perShaderData, perMaterialData, perInspectorData); // var (propStaticData, propDynamicData) = public (PropertyStaticData, PropertyDynamicData) GetPropDatas(MaterialProperty prop) => (GetPropStaticData(prop), GetPropDynamicData(prop)); + #endregion public MaterialProperty[] GetProps() => perMaterialData.props; @@ -45,12 +49,6 @@ namespace LWGUI public Shader GetShader() => perShaderData.shader; public MaterialEditor GetMaterialEditor() => perInspectorData.materialEditor; - - public void OnValidate() - { - MaterialEditor.ApplyMaterialPropertyDrawers(GetMaterialEditor()?.targets); - MetaDataHelper.ForceUpdateMaterialsMetadataCache(GetMaterialEditor()?.targets); - } } public class MetaDataHelper @@ -167,24 +165,6 @@ namespace LWGUI return str; } - private static readonly string _tooltipString = "#"; - private static readonly string _helpboxString = "%"; - - public static string GetPropertyDisplayName(Shader shader, MaterialProperty prop) - { - var tooltipIndex = prop.displayName.IndexOf(_tooltipString, StringComparison.Ordinal); - var helpboxIndex = prop.displayName.IndexOf(_helpboxString, StringComparison.Ordinal); - var minIndex = tooltipIndex == -1 ? helpboxIndex : tooltipIndex; - if (tooltipIndex != -1 && helpboxIndex != -1) - minIndex = Mathf.Min(minIndex, helpboxIndex); - if (minIndex == -1) - return prop.displayName; - else if (minIndex == 0) - return string.Empty; - else - return prop.displayName.Substring(0, minIndex); - } - public static bool GetPropertyVisibility(MaterialProperty prop, Material material, LWGUIMetaDatas metaDatas) { bool result = true; @@ -218,16 +198,14 @@ namespace LWGUI public static bool GetParentPropertyVisibility(PropertyStaticData parentPropStaticData, Material material, LWGUIMetaDatas metaDatas) { - bool result = true; - if (parentPropStaticData != null && (!metaDatas.GetPropStaticData(parentPropStaticData.name).isExpanding - || !MetaDataHelper.GetPropertyVisibility(metaDatas.GetProperty(parentPropStaticData.name), material, metaDatas))) + || !GetPropertyVisibility(metaDatas.GetProperty(parentPropStaticData.name), material, metaDatas))) { - result = false; + return false; } - return result; + return true; } } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/PresetHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/PresetHelper.cs index 001c94a..68d79c2 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/PresetHelper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/PresetHelper.cs @@ -45,6 +45,9 @@ namespace LWGUI public static ShaderPropertyPreset GetPresetFile(string presetFileName) { + if (string.IsNullOrEmpty(presetFileName)) + return null; + if (!_loadedPresets.ContainsKey(presetFileName) || !_loadedPresets[presetFileName]) ForceInit(); @@ -60,11 +63,10 @@ namespace LWGUI // For Developers: Call this after a material has modified in code public static void ApplyPresetsInMaterial(Material material) { - var props = MaterialEditor.GetMaterialProperties(new[] { material }); + var props = MaterialEditor.GetMaterialProperties(new UnityEngine.Object[] { material }); foreach (var prop in props) { - List decoratorDrawers; - var drawer = ReflectionHelper.GetPropertyDrawer(material.shader, prop, out decoratorDrawers); + var drawer = ReflectionHelper.GetPropertyDrawer(material.shader, prop, out _); // Apply active preset if (drawer != null && drawer is IBasePresetDrawer) @@ -73,9 +75,8 @@ namespace LWGUI if (activePreset != null) activePreset.ApplyToDefaultMaterial(material); } - } - MaterialEditor.ApplyMaterialPropertyDrawers(material); + UnityEditorExtension.ApplyMaterialPropertyAndDecoratorDrawers(material); } } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RampHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RampHelper.cs index 1c826b5..4558b47 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RampHelper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RampHelper.cs @@ -2,27 +2,20 @@ using System; using System.IO; using System.Linq; +using LWGUI.LwguiGradientEditor; +using LWGUI.Runtime.LwguiGradient; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; namespace LWGUI { - public class RampHelper + public static class RampHelper { #region RampEditor public static readonly string projectPath = Application.dataPath.Substring(0, Application.dataPath.Length - 6); - public static string lastSavePath - { - get { return EditorPrefs.GetString("LWGUI_GradientSavePath_" + Application.version, Application.dataPath); } - set - { - if (value.Contains(projectPath)) - EditorPrefs.SetString("LWGUI_GradientSavePath_" + Application.version, value); - } - } private static readonly GUIContent _iconAdd = new GUIContent(EditorGUIUtility.IconContent("d_Toolbar Plus").image, "Add"), _iconEdit = new GUIContent(EditorGUIUtility.IconContent("editicon.sml").image, "Edit"), @@ -30,22 +23,27 @@ namespace LWGUI _iconSave = new GUIContent(EditorGUIUtility.IconContent("SaveActive").image, "Save"); public static bool RampEditor( - Rect buttonRect, - MaterialProperty prop, - SerializedProperty serializedProperty, - bool isLinear, - bool isDirty, - string defaultFileName, - string rootPath, - int defaultWidth, - int defaultHeight, - out Texture2D newTexture, - out bool doSave, - out bool doDiscard) + Rect buttonRect, + MaterialProperty prop, + ref LwguiGradient gradient, + ColorSpace colorSpace, + LwguiGradient.ChannelMask viewChannelMask, + LwguiGradient.GradientTimeRange timeRange, + bool isDirty, + string defaultFileName, + string rootPath, + int defaultWidth, + int defaultHeight, + out bool doRegisterUndo, + out Texture2D newTexture, + out bool doSave, + out bool doDiscard + ) { newTexture = null; var hasChange = false; var shouldCreate = false; + var doOpenWindow = false; var singleButtonWidth = buttonRect.width * 0.25f; var editRect = new Rect(buttonRect.x + singleButtonWidth * 0, buttonRect.y, singleButtonWidth, buttonRect.height); var saveRect = new Rect(buttonRect.x + singleButtonWidth * 1, buttonRect.y, singleButtonWidth, buttonRect.height); @@ -53,38 +51,30 @@ namespace LWGUI var discardRect = new Rect(buttonRect.x + singleButtonWidth * 3, buttonRect.y, singleButtonWidth, buttonRect.height); // Edit button event - var currEvent = Event.current; - if (currEvent.type == EventType.MouseDown && editRect.Contains(currEvent.mousePosition)) { - // if the current edited texture is null, create new one - if (prop.textureValue == null) - { - shouldCreate = true; - currEvent.Use(); - } - else - { - // Undo.RecordObject(prop.textureValue, "Edit Gradient"); - } - } - - // Gradient Editor - if (GUI.enabled) - { - var gradientPropertyRect = new Rect(editRect.x + 2, editRect.y + 2, editRect.width - 2, editRect.height - 2); EditorGUI.BeginChangeCheck(); - EditorGUI.PropertyField(gradientPropertyRect, serializedProperty, GUIContent.none); + LwguiGradientEditorHelper.GradientEditButton(editRect, _iconEdit, gradient, colorSpace, viewChannelMask, timeRange, () => + { + // if the current edited texture is null, create new one + if (prop.textureValue == null) + { + shouldCreate = true; + Event.current.Use(); + return false; + } + else + { + doOpenWindow = true; + return true; + } + }); if (EditorGUI.EndChangeCheck()) { hasChange = true; + gradient = LwguiGradientWindow.instance.lwguiGradient; } - } - // Edit button overlay - if (currEvent.type == EventType.Repaint) - { - var isHover = editRect.Contains(currEvent.mousePosition); - (new GUIStyle("button")).Draw(editRect, _iconEdit, isHover, false, false, false); + doRegisterUndo = doOpenWindow; } // Create button @@ -101,7 +91,7 @@ namespace LWGUI { //Create texture and save PNG var saveUnityPath = absPath.Replace(projectPath, String.Empty); - CreateAndSaveNewGradientTexture(defaultWidth, defaultHeight, saveUnityPath, isLinear); + CreateAndSaveNewGradientTexture(defaultWidth, defaultHeight, saveUnityPath, colorSpace == ColorSpace.Linear); // VersionControlHelper.Add(saveUnityPath); //Load created texture newTexture = AssetDatabase.LoadAssetAtPath(saveUnityPath); @@ -120,11 +110,13 @@ namespace LWGUI } // Save button - var color = GUI.color; - if (isDirty) GUI.color = Color.yellow; - doSave = GUI.Button(saveRect, _iconSave); - GUI.color = color; - + { + var color = GUI.color; + if (isDirty) GUI.color = Color.yellow; + doSave = GUI.Button(saveRect, _iconSave); + GUI.color = color; + } + // Discard button doDiscard = GUI.Button(discardRect, _iconDiscard); @@ -133,17 +125,20 @@ namespace LWGUI public static bool HasGradient(AssetImporter assetImporter) { return assetImporter.userData.Contains("#");} - public static Gradient GetGradientFromTexture(Texture texture, out bool isDirty, bool doReimport = false) + public static LwguiGradient GetGradientFromTexture(Texture texture, out bool isDirty, bool doDiscard = false, bool doRegisterUndo = false) { isDirty = false; if (texture == null) return null; var assetImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)); + if (doRegisterUndo) + { + LwguiGradientWindow.RegisterRampMapUndo(texture, assetImporter); + } if (assetImporter != null && HasGradient(assetImporter)) { - GradientObject savedGradientObject, editingGradientObject; - isDirty = DecodeGradientFromJSON(assetImporter.userData, out savedGradientObject, out editingGradientObject); - var outGradient = doReimport ? savedGradientObject.gradient : editingGradientObject.gradient; + isDirty = DecodeGradientFromJSON(assetImporter.userData, out var savedGradient, out var editingGradient); + var outGradient = doDiscard ? savedGradient : editingGradient; return outGradient; } else @@ -156,25 +151,25 @@ namespace LWGUI } } - public static void SetGradientToTexture(Texture texture, GradientObject gradientObject, bool doSaveToDisk = false) + public static void SetGradientToTexture(Texture texture, LwguiGradient gradient, bool doSaveToDisk = false) { - if (texture == null || gradientObject.gradient == null) return; + if (texture == null || gradient == null) return; var texture2D = (Texture2D)texture; + var path = AssetDatabase.GetAssetPath(texture); + var assetImporter = AssetImporter.GetAtPath(path); VersionControlHelper.Checkout(texture2D); - Undo.RecordObject(texture2D, "LWGUI: Set Gradient To Texture"); + + LwguiGradientWindow.RegisterRampMapUndo(texture2D, assetImporter); // Save to texture - var path = AssetDatabase.GetAssetPath(texture); - var pixels = GetPixelsFromGradient(gradientObject.gradient, texture.width, texture.height); - texture2D.SetPixels32(pixels); + var pixels = gradient.GetPixels(texture.width, texture.height); + texture2D.SetPixels(pixels); texture2D.Apply(); // Save gradient JSON to userData - var assetImporter = AssetImporter.GetAtPath(path); - GradientObject savedGradientObject, editingGradientObject; - DecodeGradientFromJSON(assetImporter.userData, out savedGradientObject, out editingGradientObject); - assetImporter.userData = EncodeGradientToJSON(doSaveToDisk ? gradientObject : savedGradientObject, gradientObject); + DecodeGradientFromJSON(assetImporter.userData, out var savedGradient, out _); + assetImporter.userData = EncodeGradientToJSON(doSaveToDisk ? gradient : savedGradient, gradient); // Save texture to disk if (doSaveToDisk) @@ -186,39 +181,52 @@ namespace LWGUI } } - private static string EncodeGradientToJSON(GradientObject savedGradientObject, GradientObject editingGradientObject) + private static string EncodeGradientToJSON(LwguiGradient savedGradient, LwguiGradient editingGradient) { string savedJSON = " ", editingJSON = " "; - if (savedGradientObject != null) - savedJSON = EditorJsonUtility.ToJson(savedGradientObject); - if (editingGradientObject != null) - editingJSON = EditorJsonUtility.ToJson(editingGradientObject); + if (savedGradient != null) + savedJSON = EditorJsonUtility.ToJson(savedGradient); + if (editingGradient != null) + editingJSON = EditorJsonUtility.ToJson(editingGradient); return savedJSON + "#" + editingJSON; } - private static bool DecodeGradientFromJSON(string json, out GradientObject savedGradientObject, out GradientObject editingGradientObject) + private static bool DecodeGradientFromJSON(string json, out LwguiGradient savedGradient, out LwguiGradient editingGradient) { + savedGradient = new LwguiGradient(); + editingGradient = new LwguiGradient(); + + var isLegacyJSON = json.Contains("MonoBehaviour"); var subJSONs = json.Split('#'); - savedGradientObject = ScriptableObject.CreateInstance(); - if (subJSONs[0] != " ") - EditorJsonUtility.FromJsonOverwrite(subJSONs[0], savedGradientObject); - editingGradientObject = ScriptableObject.CreateInstance(); - if (subJSONs[1] != " ") - EditorJsonUtility.FromJsonOverwrite(subJSONs[1], editingGradientObject); + + // Upgrading from deprecated GradientObject to LwguiGradient + if (isLegacyJSON) + { + var savedGradientLegacy = ScriptableObject.CreateInstance(); + var editingGradientLegacy = ScriptableObject.CreateInstance(); + + EditorJsonUtility.FromJsonOverwrite(subJSONs[0], savedGradientLegacy); + EditorJsonUtility.FromJsonOverwrite(subJSONs[1], editingGradientLegacy); + + savedGradient = LwguiGradient.FromGradient(savedGradientLegacy.gradient); + editingGradient = LwguiGradient.FromGradient(editingGradientLegacy.gradient); + } + else + { + EditorJsonUtility.FromJsonOverwrite(subJSONs[0], savedGradient); + EditorJsonUtility.FromJsonOverwrite(subJSONs[1], editingGradient); + } + return subJSONs[0] != subJSONs[1]; } public static bool CreateAndSaveNewGradientTexture(int width, int height, string unityPath, bool isLinear) { - var gradientObject = ScriptableObject.CreateInstance(); - gradientObject.gradient = new Gradient(); - gradientObject.gradient.colorKeys = new[] { new GradientColorKey(Color.black, 0.0f), new GradientColorKey(Color.white, 1.0f) }; - gradientObject.gradient.alphaKeys = new[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }; + var gradient = new LwguiGradient(); - var ramp = CreateGradientTexture(gradientObject.gradient, width, height); + var ramp = gradient.GetPreviewRampTexture(width, height, ColorSpace.Linear); var png = ramp.EncodeToPNG(); - Object.DestroyImmediate(ramp); var systemPath = projectPath + unityPath; File.WriteAllBytes(systemPath, png); @@ -238,44 +246,18 @@ namespace LWGUI textureImporter.SetPlatformTextureSettings(platformTextureSettings); //Gradient data embedded in userData - textureImporter.userData = EncodeGradientToJSON(gradientObject, gradientObject); + textureImporter.userData = EncodeGradientToJSON(gradient, gradient); textureImporter.SaveAndReimport(); return true; } - private static Texture2D CreateGradientTexture(Gradient gradient, int width, int height) - { - var ramp = new Texture2D(width, height, TextureFormat.RGBA32, true, true); - var colors = GetPixelsFromGradient(gradient, width, height); - ramp.SetPixels32(colors); - ramp.Apply(); - return ramp; - } - - private static Color32[] GetPixelsFromGradient(Gradient gradient, int width, int height) - { - var pixels = new Color32[width * height]; - for (var x = 0; x < width; x++) - { - var delta = x / (float)width; - if (delta < 0) delta = 0; - if (delta > 1) delta = 1; - var col = gradient.Evaluate(delta); - for (int i = 0; i < height; i++) - { - pixels[x + i * width] = col; - } - } - return pixels; - } #endregion #region RampSelector - public delegate void SwitchRampMapEvent(Texture2D selectedRamp); - public static void RampSelector(Rect rect, string rootPath, SwitchRampMapEvent switchRampMapEvent) + public static void RampSelector(Rect rect, string rootPath, Action switchRampMapEvent) { var e = Event.current; if (e.type == UnityEngine.EventType.MouseDown && rect.Contains(e.mousePosition)) @@ -301,11 +283,11 @@ namespace LWGUI public class RampSelectorWindow : EditorWindow { - private Texture2D[] _rampMaps; - private Vector2 _scrollPosition; - private RampHelper.SwitchRampMapEvent _switchRampMapEvent; + private Texture2D[] _rampMaps; + private Vector2 _scrollPosition; + private Action _switchRampMapEvent; - public static void ShowWindow(Rect rect, Texture2D[] rampMaps, RampHelper.SwitchRampMapEvent switchRampMapEvent) + public static void ShowWindow(Rect rect, Texture2D[] rampMaps, Action switchRampMapEvent) { RampSelectorWindow window = ScriptableObject.CreateInstance(); window.titleContent = new GUIContent("Ramp Selector"); diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs deleted file mode 100644 index 727058e..0000000 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) Jason Ma - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace LWGUI -{ - public class ReflectionHelper - { - private static Assembly UnityEditor_Assembly = Assembly.GetAssembly(typeof(Editor)); - - - #region MaterialPropertyHandler - - private static Type MaterialPropertyHandler_Type = UnityEditor_Assembly.GetType("UnityEditor.MaterialPropertyHandler"); - private static MethodInfo MaterialPropertyHandler_GetHandler_Method = MaterialPropertyHandler_Type.GetMethod("GetHandler", BindingFlags.Static | BindingFlags.NonPublic); - private static PropertyInfo MaterialPropertyHandler_PropertyDrawer_Property = MaterialPropertyHandler_Type.GetProperty("propertyDrawer"); - private static FieldInfo MaterialPropertyHandler_DecoratorDrawers_Field = MaterialPropertyHandler_Type.GetField("m_DecoratorDrawers", BindingFlags.NonPublic | BindingFlags.Instance); - - public static MaterialPropertyDrawer GetPropertyDrawer(Shader shader, MaterialProperty prop, out List decoratorDrawers) - { - decoratorDrawers = new List(); - var handler = MaterialPropertyHandler_GetHandler_Method.Invoke(null, new System.Object[] { shader, prop.name }); - if (handler != null && handler.GetType() == MaterialPropertyHandler_Type) - { - decoratorDrawers = MaterialPropertyHandler_DecoratorDrawers_Field.GetValue(handler) as List; - return MaterialPropertyHandler_PropertyDrawer_Property.GetValue(handler, null) as MaterialPropertyDrawer; - } - return null; - } - - public static MaterialPropertyDrawer GetPropertyDrawer(Shader shader, MaterialProperty prop) - { - List decoratorDrawers; - return GetPropertyDrawer(shader, prop, out decoratorDrawers); - } - - #endregion - - - #region MaterialEditor - - private static Type MaterialEditor_Type = typeof(MaterialEditor); - private static MethodInfo MaterialEditor_DoPowerRangeProperty_Method = MaterialEditor_Type.GetMethod("DoPowerRangeProperty", BindingFlags.Static | BindingFlags.NonPublic); - private static MethodInfo MaterialEditor_DefaultShaderPropertyInternal_Method = MaterialEditor_Type.GetMethod("DefaultShaderPropertyInternal", BindingFlags.NonPublic | BindingFlags.Instance, null, - new[] { typeof(Rect), typeof(MaterialProperty), typeof(GUIContent) }, null); - - public static float DoPowerRangeProperty(Rect position, MaterialProperty prop, GUIContent label, float power) - { - return (float)MaterialEditor_DoPowerRangeProperty_Method.Invoke(null, new System.Object[] { position, prop, label, power }); - } - - public static void DefaultShaderPropertyInternal(MaterialEditor editor, Rect position, MaterialProperty prop, GUIContent label) - { - MaterialEditor_DefaultShaderPropertyInternal_Method.Invoke(editor, new System.Object[] { position, prop, label }); - } - - #endregion - - - #region EditorUtility - private static Type EditorUtility_Type = typeof(EditorUtility); - private static MethodInfo EditorUtility_DisplayCustomMenuWithSeparators_Method = EditorUtility_Type.GetMethod("DisplayCustomMenuWithSeparators", BindingFlags.NonPublic | BindingFlags.Static, null, - new []{typeof(Rect), typeof(string[]), typeof(bool[]), typeof(bool[]), typeof(int[]), typeof(EditorUtility.SelectMenuItemFunction), typeof(object), typeof(bool)}, null); - - public static void DisplayCustomMenuWithSeparators(Rect position, string[] options, bool[] enabled, bool[] separator, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData = null, bool showHotkey = false) - { - EditorUtility_DisplayCustomMenuWithSeparators_Method.Invoke(null, new System.Object[] { position, options, enabled, separator, selected, callback, userData, showHotkey }); - } - - #endregion - - - #region EditorGUI - - private static Type EditorGUI_Type = typeof(EditorGUI); - private static PropertyInfo EditorGUI_Indent_Property = EditorGUI_Type.GetProperty("indent", BindingFlags.NonPublic | BindingFlags.Static); - - public static float EditorGUI_Indent { get { return (float)EditorGUI_Indent_Property.GetValue(null, null); } } - - #endregion - - #region EditorGUILayout - - private static Type EditorGUILayout_Type = typeof(EditorGUILayout); - private static PropertyInfo EditorGUILayout_kLabelFloatMinW_Property = EditorGUILayout_Type.GetProperty("kLabelFloatMinW", BindingFlags.NonPublic | BindingFlags.Static); - - public static float EditorGUILayout_kLabelFloatMinW { get { return (float)EditorGUILayout_kLabelFloatMinW_Property.GetValue(null, null); } } - - #endregion - - - #region MaterialEnumDrawer - - // UnityEditor.MaterialEnumDrawer(string enumName) - private static System.Type[] _types; - - public static System.Type[] GetAllTypes() - { - if (_types == null) - { - _types = ((IEnumerable)AppDomain.CurrentDomain.GetAssemblies()) - .SelectMany((Func>) - (assembly => - { - if (assembly == null) - return (IEnumerable)(new System.Type[0]); - try - { - return (IEnumerable)assembly.GetTypes(); - } - catch (ReflectionTypeLoadException ex) - { - Debug.LogError(ex); - return (IEnumerable)(new System.Type[0]); - } - })).ToArray(); - } - return _types; - } - - #endregion - - - #region MaterialProperty.PropertyData - -#if UNITY_2022_1_OR_NEWER - private static Type MaterialProperty_Type = typeof(MaterialProperty); - private static Type PropertyData_Type = MaterialProperty_Type.GetNestedType("PropertyData", BindingFlags.NonPublic); - // MergeStack(out bool lockedInChildren, out bool lockedByAncestor, out bool overriden) - private static MethodInfo PropertyData_MergeStack_Method = PropertyData_Type.GetMethod("MergeStack", BindingFlags.Static | BindingFlags.NonPublic); - // HandleApplyRevert(GenericMenu menu, bool singleEditing, UnityEngine.Object[] targets) - private static MethodInfo PropertyData_HandleApplyRevert_Method = PropertyData_Type.GetMethod("HandleApplyRevert", BindingFlags.Static | BindingFlags.NonPublic); - - public static void HandleApplyRevert(GenericMenu menu, MaterialProperty prop) - { - System.Object[] parameters = new System.Object[3]; - ReflectionHelper.PropertyData_MergeStack_Method.Invoke(null, parameters); - bool lockedInChildren = (bool)parameters[0]; - bool lockedByAncestor = (bool)parameters[1]; - bool overriden = (bool)parameters[2]; - bool singleEditing = prop.targets.Length == 1; - - if (overriden) - { - ReflectionHelper.PropertyData_HandleApplyRevert_Method.Invoke(null, new System.Object[]{menu, singleEditing, prop.targets}); - menu.AddSeparator(""); - } - } -#endif - - #endregion - } -} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RevertableHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RevertableHelper.cs index 815ae2e..908cc01 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RevertableHelper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/RevertableHelper.cs @@ -160,7 +160,8 @@ namespace LWGUI } } - private static readonly Texture _icon = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("e7bc1130858d984488bca32b8512ca96")); + private static Texture _iconCache; + private static Texture _icon => _iconCache = _iconCache ?? AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("e7bc1130858d984488bca32b8512ca96")); public static bool DrawRevertButton(Rect rect) { diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/VersionControlHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/VersionControlHelper.cs index 9561281..80f20ca 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/VersionControlHelper.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/VersionControlHelper.cs @@ -11,7 +11,7 @@ namespace LWGUI { public class VersionControlHelper { - public static bool isVCEnabled { get { return Provider.enabled && Provider.isActive; } } + public static bool isVCEnabled => Provider.enabled && Provider.isActive; public static bool Checkout(UnityEngine.Object obj) { diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.asmdef b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.asmdef index b8ffd6a..c2c32c8 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.asmdef +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.asmdef @@ -1,7 +1,10 @@ { "name": "LWGUI", "rootNamespace": "", - "references": [], + "references": [ + "LWGUI.Runtime", + "Unity.InternalAPIEditorBridge.020" + ], "includePlatforms": [ "Editor" ], diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.cs index 4a80396..7cede9a 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/LWGUI.cs @@ -132,10 +132,11 @@ namespace LWGUI private void DrawAdvancedHeader(PropertyStaticData propStaticData, MaterialProperty prop) { + EditorGUILayout.Space(3); var rect = EditorGUILayout.GetControlRect(); var revertButtonRect = RevertableHelper.SplitRevertButtonRect(ref rect); var label = string.IsNullOrEmpty(propStaticData.advancedHeaderString) ? "Advanced" : propStaticData.advancedHeaderString; - propStaticData.isExpanding = EditorGUI.Foldout(rect, propStaticData.isExpanding, label); + propStaticData.isExpanding = EditorGUI.Foldout(rect, propStaticData.isExpanding, label, EditorStyles.foldoutHeader); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) propStaticData.isExpanding = !propStaticData.isExpanding; RevertableHelper.DrawRevertableProperty(revertButtonRect, prop, metaDatas, true); @@ -146,6 +147,9 @@ namespace LWGUI { var (propStaticData, propDynamicData) = metaDatas.GetPropDatas(prop); var materialEditor = metaDatas.GetMaterialEditor(); + + if (propStaticData.isAdvancedHeaderProperty) + EditorGUILayout.Space(3); Helper.DrawHelpbox(propStaticData, propDynamicData); @@ -181,11 +185,32 @@ namespace LWGUI MetaDataHelper.ReleaseMaterialMetadataCache(material); } - // Called after editing the material + public static void OnValidate(Object[] materials) + { + UnityEditorExtension.ApplyMaterialPropertyAndDecoratorDrawers(materials); + MetaDataHelper.ForceUpdateMaterialsMetadataCache(materials); + } + + // Called after edit in code + public static void OnValidate(LWGUIMetaDatas metaDatas) + { + OnValidate(metaDatas?.GetMaterialEditor()?.targets); + } + + // Called after edit or undo public override void ValidateMaterial(Material material) { base.ValidateMaterial(material); - metaDatas?.OnValidate(); + // Undo + if (metaDatas == null) + { + OnValidate(new Object[] { material }); + } + // Edit + else + { + OnValidate(metaDatas); + } } } } //namespace LWGUI \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerMaterialData.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerMaterialData.cs index 881fe69..c8d5ca0 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerMaterialData.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerMaterialData.cs @@ -62,10 +62,15 @@ namespace LWGUI // Get active presets foreach (var prop in props) { - var activePreset = perShaderData.propStaticDatas[prop.name].presetDrawer - ?.GetActivePreset(prop, perShaderData.propStaticDatas[prop.name].propertyPresetAsset); - if (activePreset != null) + var propStaticData = perShaderData.propStaticDatas[prop.name]; + var activePreset = propStaticData.presetDrawer?.GetActivePreset(prop, propStaticData.propertyPresetAsset); + if (activePreset != null + // Filter invisible preset properties + && (propStaticData.showIfDatas.Count == 0 + || ShowIfDecorator.GetShowIfResultFromMaterial(propStaticData.showIfDatas, this.material))) + { activePresetDatas.Add(new PersetDynamicData(activePreset, prop)); + } } { @@ -85,16 +90,6 @@ namespace LWGUI var defaultProperties = MaterialEditor.GetMaterialProperties(new[] { defaultMaterial }); Debug.Assert(defaultProperties.Length == props.Length); - // Override default value - for (int i = 0; i < props.Length; i++) - { - Debug.Assert(props[i].name == defaultProperties[i].name); - Debug.Assert(!propDynamicDatas.ContainsKey(props[i].name)); - - perShaderData.propStaticDatas[props[i].name].baseDrawers - ?.ForEach(baseDrawer => baseDrawer.OverrideDefaultValue(shader, props[i], defaultProperties[i], perShaderData)); - } - // Init propDynamicDatas for (int i = 0; i < props.Length; i++) { @@ -132,7 +127,7 @@ namespace LWGUI } } - // Store Show Modified Props Only Cache + // Store "Show Modified Props Only" Caches { if (perShaderData.displayModeData.showOnlyModifiedGroups || perShaderData.displayModeData.showOnlyModifiedProperties) { diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerShaderData.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerShaderData.cs index 653aed0..04318c4 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerShaderData.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/MetaData/PerShaderData.cs @@ -31,7 +31,7 @@ namespace LWGUI public bool IsDefaultDisplayMode() { return !(showAllAdvancedProperties || showAllHiddenProperties || showOnlyModifiedProperties || showOnlyModifiedGroups); } } - public class PropertyStaticData + public partial class PropertyStaticData { public string name = string.Empty; public string displayName = string.Empty; // Decoded displayName (Helpbox and Tooltip are encoded in displayName) @@ -105,6 +105,7 @@ namespace LWGUI propStaticDatas[prop.name] = propStaticData; // Get Drawers and Build Drawer StaticMetaData + bool hasDecodedStaticMetaData = false; { var drawer = ReflectionHelper.GetPropertyDrawer(shader, prop, out var decoratorDrawers); @@ -116,6 +117,7 @@ namespace LWGUI { propStaticData.baseDrawers = new List() { baseDrawer }; baseDrawer.BuildStaticMetaData(shader, prop, props, propStaticData); + hasDecodedStaticMetaData = true; } decoratorDrawers?.ForEach(decoratorDrawer => @@ -133,7 +135,8 @@ namespace LWGUI }); } - DecodeMetaDataFromDisplayName(prop, propStaticData); + if (!hasDecodedStaticMetaData) + DecodeMetaDataFromDisplayName(prop, propStaticData); } // Check Data @@ -245,7 +248,7 @@ namespace LWGUI private static readonly string _helpboxSplitter = "%"; - public void DecodeMetaDataFromDisplayName(MaterialProperty prop, PropertyStaticData propStaticData) + public static void DecodeMetaDataFromDisplayName(MaterialProperty prop, PropertyStaticData propStaticData) { var tooltips = prop.displayName.Split(new String[] { _tooltipSplitter }, StringSplitOptions.None); if (tooltips.Length > 1) diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ScriptableObject/ShaderPropertyPreset.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ScriptableObject/ShaderPropertyPreset.cs index 938373a..90da58a 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ScriptableObject/ShaderPropertyPreset.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ScriptableObject/ShaderPropertyPreset.cs @@ -1,13 +1,14 @@ // Copyright (c) Jason Ma using System; using System.Collections.Generic; +using System.Linq; using UnityEngine; using UnityEditor; using Object = UnityEngine.Object; namespace LWGUI { - [CreateAssetMenu(fileName = "LWGUI_ShaderPropertyPreset.asset", menuName = "LWGUI/Shader Property Preset")] + [CreateAssetMenu(fileName = "LWGUI_ShaderPropertyPreset.asset", menuName = "LWGUI/Shader Property Preset", order = 84)] public class ShaderPropertyPreset : ScriptableObject { public enum PropertyType @@ -75,7 +76,7 @@ namespace LWGUI break; } - MaterialEditor.ApplyMaterialPropertyDrawers(material); + UnityEditorExtension.ApplyMaterialPropertyAndDecoratorDrawers(material); } // is Property Primary Material else if (perMaterialData != null) @@ -145,6 +146,8 @@ namespace LWGUI public List propertyValues = new List(); public List enabledKeywords = new List(); public List disabledKeywords = new List(); + public List enabledPasses = new List(); + public List disabledPasses = new List(); public int renderQueue = -1; @@ -156,11 +159,15 @@ namespace LWGUI material.EnableKeyword(enabledKeyword); foreach (var disabledKeyword in disabledKeywords) material.DisableKeyword(disabledKeyword); + + Helper.SetShaderPassEnabled(new Object[] { material }, enabledPasses.Select(s => s.ToUpper()).ToArray(), true); + Helper.SetShaderPassEnabled(new Object[] { material }, disabledPasses.Select(s => s.ToUpper()).ToArray(), false); + if (renderQueue >= 0) material.renderQueue = renderQueue; } - public void ApplyToEditingMaterial(UnityEngine.Object[] materials, PerMaterialData perMaterialData) + public void ApplyToEditingMaterial(Object[] materials, PerMaterialData perMaterialData) { for (int i = 0; i < materials.Length; i++) { @@ -171,12 +178,16 @@ namespace LWGUI material.EnableKeyword(enabledKeyword); foreach (var disabledKeyword in disabledKeywords) material.DisableKeyword(disabledKeyword); + if (renderQueue >= 0) material.renderQueue = renderQueue; } + + Helper.SetShaderPassEnabled(materials, enabledPasses.Select(s => s.ToUpper()).ToArray(), true); + Helper.SetShaderPassEnabled(materials, disabledPasses.Select(s => s.ToUpper()).ToArray(), false); } - public void ApplyKeywordsToMaterials(UnityEngine.Object[] materials) + public void ApplyKeywordsAndPassesToMaterials(Object[] materials) { for (int i = 0; i < materials.Length; i++) { @@ -186,6 +197,9 @@ namespace LWGUI foreach (var disabledKeyword in disabledKeywords) material.DisableKeyword(disabledKeyword); } + + Helper.SetShaderPassEnabled(materials, enabledPasses.Select(s => s.ToUpper()).ToArray(), true); + Helper.SetShaderPassEnabled(materials, disabledPasses.Select(s => s.ToUpper()).ToArray(), false); } public PropertyValue GetPropertyValue(string propName) diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderDrawer.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderDrawer.cs index 4103990..754159d 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderDrawer.cs +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/ShaderDrawer.cs @@ -2,11 +2,14 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Reflection; +using LWGUI.LwguiGradientEditor; +using LWGUI.Runtime.LwguiGradient; using UnityEditor; using UnityEngine; using UnityEngine.Rendering; -using Object = UnityEngine.Object; namespace LWGUI { @@ -15,34 +18,45 @@ namespace LWGUI void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData){} void GetDefaultValueDescription(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData, PerMaterialData inoutPerMaterialData){} - - void OverrideDefaultValue(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData){} - } public interface IBasePresetDrawer { ShaderPropertyPreset.Preset GetActivePreset(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset); } + + public partial class PropertyStaticData + { + // Image + public Texture2D image; + + // Button + public List buttonDisplayNames = new(); + public List buttonCommands = new(); + public List buttonDisplayNameWidths = new(); + } /// /// Create a Folding Group - /// group:group name (Default: Property Name) - /// keyword:keyword used for toggle, "_" = ignore, none or "__" = Property Name + "_ON", always Upper (Default: none) + /// group: group name (Default: Property Name) + /// keyword: keyword used for toggle, "_" = ignore, none or "__" = Property Name + "_ON", always Upper (Default: none) /// default Folding State: "on" or "off" (Default: off) /// default Toggle Displayed: "on" or "off" (Default: on) + /// preset File Name: "Shader Property Preset" asset name, see Preset() for detail (Default: none) /// Target Property Type: FLoat, express Toggle value /// - public class MainDrawer : MaterialPropertyDrawer, IBaseDrawer + public class MainDrawer : MaterialPropertyDrawer, IBaseDrawer, IBasePresetDrawer { protected LWGUIMetaDatas metaDatas; + private static readonly float _height = 28f; + private bool _isFolding; private string _group; private string _keyword; private bool _defaultFoldingState; private bool _defaultToggleDisplayed; - private static readonly float _height = 28f; + private string _presetFileName; public MainDrawer() : this(String.Empty) { } @@ -51,13 +65,16 @@ namespace LWGUI public MainDrawer(string group, string keyword) : this(group, keyword, "off") { } public MainDrawer(string group, string keyword, string defaultFoldingState) : this(group, keyword, defaultFoldingState, "on") { } + + public MainDrawer(string group, string keyword, string defaultFoldingState, string defaultToggleDisplayed) : this(group, keyword, defaultFoldingState, defaultToggleDisplayed, String.Empty) { } - public MainDrawer(string group, string keyword, string defaultFoldingState, string defaultToggleDisplayed) + public MainDrawer(string group, string keyword, string defaultFoldingState, string defaultToggleDisplayed, string presetFileName) { this._group = group; this._keyword = keyword; this._defaultFoldingState = defaultFoldingState.ToLower() == "on"; this._defaultToggleDisplayed = defaultToggleDisplayed.ToLower() == "on"; + this._presetFileName = presetFileName; } public virtual void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) @@ -65,6 +82,8 @@ namespace LWGUI inoutPropertyStaticData.groupName = _group; inoutPropertyStaticData.isMain = true; inoutPropertyStaticData.isExpanding = _defaultFoldingState; + PerShaderData.DecodeMetaDataFromDisplayName(inProp, inoutPropertyStaticData); + PresetDrawer.SetPresetAssetToStaticData(inoutPropertyStaticData, _presetFileName); } public virtual void GetDefaultValueDescription(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData, PerMaterialData inoutPerMaterialData) @@ -72,6 +91,9 @@ namespace LWGUI inoutPerMaterialData.propDynamicDatas[inProp.name].defaultValueDescription = inDefaultProp.floatValue > 0 ? "On" : "Off"; } + public ShaderPropertyPreset.Preset GetActivePreset(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset) => + PresetDrawer.GetActivePresetFromFloatProperty(inProp, shaderPropertyPreset); + public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { metaDatas = Helper.GetLWGUIMetadatas(editor); @@ -86,6 +108,7 @@ namespace LWGUI { prop.floatValue = toggleResult ? 1.0f : 0.0f; Helper.SetShaderKeyWord(editor.targets, Helper.GetKeyWord(_keyword, prop.name), toggleResult); + PresetHelper.GetPresetFile(_presetFileName)?.presets[(int)prop.floatValue].ApplyToEditingMaterial(prop.targets, metaDatas.perMaterialData); } EditorGUI.showMixedValue = showMixedValue; } @@ -96,21 +119,21 @@ namespace LWGUI return _height; } - // Call when creating new material, used to set keywords + // Call when create/edit/undo materials, used to set keywords and presets public override void Apply(MaterialProperty prop) { base.Apply(prop); - if (!prop.hasMixedValue - && (prop.type == MaterialProperty.PropType.Float - || prop.type == MaterialProperty.PropType.Int - )) + if (!prop.hasMixedValue) + { Helper.SetShaderKeyWord(prop.targets, Helper.GetKeyWord(_keyword, prop.name), prop.floatValue > 0f); + PresetDrawer.ApplyPreset(_presetFileName, prop); + } } } /// /// Draw a property with default style in the folding group - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// Target Property Type: Any /// public class SubDrawer : MaterialPropertyDrawer, IBaseDrawer @@ -136,12 +159,11 @@ namespace LWGUI public virtual void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) { inoutPropertyStaticData.groupName = group; + PerShaderData.DecodeMetaDataFromDisplayName(inProp, inoutPropertyStaticData); } public virtual void GetDefaultValueDescription(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData, PerMaterialData inoutPerMaterialData) { } - public virtual void OverrideDefaultValue(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData) { } - public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { metaDatas = Helper.GetLWGUIMetadatas(editor); @@ -166,36 +188,50 @@ namespace LWGUI public virtual void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { RevertableHelper.FixGUIWidthMismatch(prop.type, editor); - ReflectionHelper.DefaultShaderPropertyInternal(editor, position, prop, label); + editor.DefaultShaderPropertyInternal(position, prop, label); } } /// /// Similar to builtin Toggle() - /// group:father group name, support suffix keyword for conditional display (Default: none) - /// keyword:keyword used for toggle, "_" = ignore, none or "__" = Property Name + "_ON", always Upper (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) + /// keyword: keyword used for toggle, "_" = ignore, none or "__" = Property Name + "_ON", always Upper (Default: none) + /// preset File Name: "Shader Property Preset" asset name, see Preset() for detail (Default: none) /// Target Property Type: FLoat /// - public class SubToggleDrawer : SubDrawer + public class SubToggleDrawer : SubDrawer, IBasePresetDrawer { - private string _keyWord = String.Empty; + private string _keyWord = String.Empty; + private string _presetFileName = String.Empty; public SubToggleDrawer() { } - public SubToggleDrawer(string group) : this(group, String.Empty) { } + public SubToggleDrawer(string group) : this(group, String.Empty, String.Empty) { } + + public SubToggleDrawer(string group, string keyWord) : this(group, keyWord, String.Empty) { } - public SubToggleDrawer(string group, string keyWord) + public SubToggleDrawer(string group, string keyWord, string presetFileName) { this.group = group; this._keyWord = keyWord; + this._presetFileName = presetFileName; } protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Float; } + public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) + { + base.BuildStaticMetaData(inShader, inProp, inProps, inoutPropertyStaticData); + PresetDrawer.SetPresetAssetToStaticData(inoutPropertyStaticData, _presetFileName); + } + public override void GetDefaultValueDescription(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData, PerMaterialData inoutPerMaterialData) { inoutPerMaterialData.propDynamicDatas[inProp.name].defaultValueDescription = inDefaultProp.floatValue > 0 ? "On" : "Off"; } + + public ShaderPropertyPreset.Preset GetActivePreset(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset) => + PresetDrawer.GetActivePresetFromFloatProperty(inProp, shaderPropertyPreset); public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { @@ -207,6 +243,7 @@ namespace LWGUI { prop.floatValue = value ? 1.0f : 0.0f; Helper.SetShaderKeyWord(editor.targets, k, value); + PresetHelper.GetPresetFile(_presetFileName)?.presets[(int)prop.floatValue].ApplyToEditingMaterial(prop.targets, metaDatas.perMaterialData); } EditorGUI.showMixedValue = false; } @@ -214,14 +251,17 @@ namespace LWGUI public override void Apply(MaterialProperty prop) { base.Apply(prop); - if (!prop.hasMixedValue && IsMatchPropType(prop)) + if (!prop.hasMixedValue) + { Helper.SetShaderKeyWord(prop.targets, Helper.GetKeyWord(_keyWord, prop.name), prop.floatValue > 0f); + PresetDrawer.ApplyPreset(_presetFileName, prop); + } } } /// /// Similar to builtin PowerSlider() - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// power: power of slider (Default: 1) /// Target Property Type: Range /// @@ -251,7 +291,7 @@ namespace LWGUI /// /// Similar to builtin IntRange() - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// Target Property Type: Range /// public class SubIntRangeDrawer : SubDrawer @@ -290,7 +330,7 @@ namespace LWGUI /// /// Draw a min max slider - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// minPropName: Output Min Property Name /// maxPropName: Output Max Property Name /// Target Property Type: Range, range limits express the MinMaxSlider value range @@ -402,7 +442,7 @@ namespace LWGUI /// /// Similar to builtin Enum() / KeywordEnum() - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// n(s): display name /// k(s): keyword /// v(s): value @@ -527,8 +567,10 @@ namespace LWGUI public override void Apply(MaterialProperty prop) { base.Apply(prop); - if (!prop.hasMixedValue && IsMatchPropType(prop)) + if (!prop.hasMixedValue) + { Helper.SetShaderKeyWord(prop.targets, GetKeywords(prop), (int)prop.floatValue); + } } } @@ -541,18 +583,17 @@ namespace LWGUI var array = ReflectionHelper.GetAllTypes(); try { - System.Type enumType = - ((IEnumerable)array).FirstOrDefault((Func)(x => x.IsSubclassOf(typeof(Enum)) && (x.Name == enumName || x.FullName == enumName))); + Type enumType = array.FirstOrDefault(x => x.IsSubclassOf(typeof(Enum)) && (x.Name == enumName || x.FullName == enumName)); string[] names = Enum.GetNames(enumType); Array valuesArray = Enum.GetValues(enumType); var values = new float[valuesArray.Length]; for (int index = 0; index < valuesArray.Length; ++index) - values[index] = (float)(int)valuesArray.GetValue(index); + values[index] = (int)valuesArray.GetValue(index); Init(group, names, null, values); } catch (Exception ex) { - Debug.LogWarningFormat("LWGUI: Failed to create SubEnum, enum {0} not found, {1}.", (object)enumName, ex); + Debug.LogWarningFormat("LWGUI: Failed to create SubEnum, enum {0} not found, {1}.", enumName, ex); throw; } } @@ -611,7 +652,7 @@ namespace LWGUI /// /// Draw a Texture property in single line with a extra property - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// extraPropName: extra property name (Default: none) /// Target Property Type: Texture /// Extra Property Type: Color, Vector @@ -691,15 +732,12 @@ namespace LWGUI } /// - /// Draw a read only texture preview. Select the default texture to be displayed in the shader import settings. - /// Note: Selected default textures will always be excluded from the build!!! - /// group:father group name, support suffix keyword for conditional display (Default: none) - /// Target Property Type: Texture + /// Draw an image preview. + /// display name: The path of the image file relative to the Unity project, such as: "Assets/test.png", "Doc/test.png", "../test.png" + /// group: father group name, support suffix keyword for conditional display (Default: none) /// public class ImageDrawer : SubDrawer { - private Texture _defaultTex = null; - public ImageDrawer() { } public ImageDrawer(string group) @@ -709,23 +747,39 @@ namespace LWGUI protected override float GetVisibleHeight(MaterialProperty prop) { return 0; } - protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Texture; } - - public override void OverrideDefaultValue(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData) + public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) { - // To disable revert button - _defaultTex = inDefaultProp.textureValue; - inDefaultProp.textureValue = null; + var imagePath = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + inProp.displayName; + if (File.Exists(imagePath)) + { + var fileData = File.ReadAllBytes(imagePath); + Texture2D texture = new Texture2D(2, 2); + + // LoadImage will auto-resize the texture dimensions + if (texture.LoadImage(fileData)) + { + inoutPropertyStaticData.image = texture; + } + else + { + Debug.LogError($"LWGUI: Failed to load image data into texture: { imagePath }"); + } + } + else + { + Debug.LogError($"LWGUI: Image path not found: { imagePath }"); + } } public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { - if (_defaultTex) + var image = metaDatas.GetPropStaticData(prop).image; + if (image) { - var scaledheight = Mathf.Max(0, _defaultTex.height / (_defaultTex.width / Helper.GetCurrentPropertyLayoutWidth())); + var scaledheight = Mathf.Max(0, image.height / (image.width / Helper.GetCurrentPropertyLayoutWidth())); var rect = EditorGUILayout.GetControlRect(true, scaledheight); rect = RevertableHelper.IndentRect(EditorGUI.IndentedRect(rect)); - EditorGUI.DrawPreviewTexture(rect, _defaultTex); + EditorGUI.DrawPreviewTexture(rect, image); if (GUI.enabled) prop.textureValue = null; @@ -735,7 +789,7 @@ namespace LWGUI /// /// Display up to 4 colors in a single line - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// color2-4: extra color property name /// Target Property Type: Color /// @@ -768,7 +822,7 @@ namespace LWGUI public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { - Stack cProps = new Stack(); + var cProps = new Stack(); for (int i = 0; i < 4; i++) { if (i == 0) @@ -782,27 +836,25 @@ namespace LWGUI cProps.Push(p); } - int count = cProps.Count; + var count = cProps.Count; var colorArray = cProps.ToArray(); - var rect = position; //EditorGUILayout.GetControlRect(); - EditorGUI.PrefixLabel(rect, label); + EditorGUI.PrefixLabel(position, label); for (int i = 0; i < count; i++) { EditorGUI.BeginChangeCheck(); var cProp = colorArray[i]; EditorGUI.showMixedValue = cProp.hasMixedValue; - Rect r = new Rect(rect); + var r = new Rect(position); var interval = 13 * i * (-0.25f + EditorGUI.indentLevel * 1.25f); - float w = EditorGUIUtility.fieldWidth * (0.8f + EditorGUI.indentLevel * 0.2f); + var w = EditorGUIUtility.fieldWidth * (0.8f + EditorGUI.indentLevel * 0.2f); r.xMin += r.width - w * (i + 1) + interval; r.xMax -= w * i - interval; - Color src, dst; - src = cProp.colorValue; + var src = cProp.colorValue; var isHdr = (colorArray[i].flags & MaterialProperty.PropFlags.HDR) != MaterialProperty.PropFlags.None; - dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, isHdr); + var dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, isHdr); if (Helper.EndChangeCheck(metaDatas, cProp)) { cProp.colorValue = dst; @@ -822,7 +874,7 @@ namespace LWGUI /// RGB Average = (1f / 3f, 1f / 3f, 1f / 3f, 0) /// RGB Luminance = (0.2126f, 0.7152f, 0.0722f, 0) /// None = (0, 0, 0, 0) - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// Target Property Type: Vector, used to dot() with Texture Sample Value /// public class ChannelDrawer : SubDrawer @@ -901,12 +953,15 @@ namespace LWGUI } /// - /// Draw a Ramp Map Editor (Defaulf Ramp Map Resolution: 512 * 2) - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// Draw an unreal style Ramp Map Editor (Default Ramp Map Resolution: 512 * 2) + /// NEW: The new LwguiGradient type has both the Gradient and Curve editors, and can be used in C# scripts and runtime, and is intended to replace UnityEngine.Gradient + /// group: father group name, support suffix keyword for conditional display (Default: none) /// defaultFileName: default Ramp Map file name when create a new one (Default: RampMap) /// rootPath: the path where ramp is stored, replace '/' with '.' (for example: Assets.Art.Ramps). when selecting ramp, it will also be filtered according to the path (Default: Assets) /// colorSpace: switch sRGB / Linear in ramp texture import setting (Default: sRGB) /// defaultWidth: default Ramp Width (Default: 512) + /// viewChannelMask: editable channels. (Default: RGBA) + /// timeRange: the abscissa display range (1/24/2400), is used to optimize the editing experience when the abscissa is time of day. (Default: 1) /// Target Property Type: Texture2D /// public class RampDrawer : SubDrawer @@ -915,13 +970,19 @@ namespace LWGUI protected string _rootPath; protected string _defaultFileName; - protected float _defaultWidth; - protected float _defaultHeight = 2; - protected bool _isLinear = false; + protected float _defaultWidth; + protected float _defaultHeight = 2; + protected ColorSpace _colorSpace; + protected LwguiGradient.ChannelMask _viewChannelMask; + protected LwguiGradient.GradientTimeRange _timeRange; + protected bool _doRegisterUndo; private static readonly GUIContent _iconMixImage = EditorGUIUtility.IconContent("darkviewbackground"); - protected override float GetVisibleHeight(MaterialProperty prop) { return EditorGUIUtility.singleLineHeight * 2f; } + private static readonly float _rampPreviewHeight = EditorGUIUtility.singleLineHeight; + private static readonly float _rampButtonsHeight = EditorGUIUtility.singleLineHeight; + + protected override float GetVisibleHeight(MaterialProperty prop) { return _rampPreviewHeight + _rampButtonsHeight; } public RampDrawer() : this(String.Empty) { } @@ -932,8 +993,12 @@ namespace LWGUI public RampDrawer(string group, string defaultFileName, float defaultWidth) : this(group, defaultFileName, DefaultRootPath, defaultWidth) { } public RampDrawer(string group, string defaultFileName, string rootPath, float defaultWidth) : this(group, defaultFileName, rootPath, "sRGB", defaultWidth) { } + + public RampDrawer(string group, string defaultFileName, string rootPath, string colorSpace, float defaultWidth) : this(group, defaultFileName, rootPath, colorSpace, defaultWidth, "RGBA") { } + + public RampDrawer(string group, string defaultFileName, string rootPath, string colorSpace, float defaultWidth, string viewChannelMask) : this(group, defaultFileName, rootPath, colorSpace, defaultWidth, viewChannelMask, 1) { } - public RampDrawer(string group, string defaultFileName, string rootPath, string colorSpace, float defaultWidth) + public RampDrawer(string group, string defaultFileName, string rootPath, string colorSpace, float defaultWidth, string viewChannelMask, float timeRange) { if (!rootPath.StartsWith(DefaultRootPath)) { @@ -943,8 +1008,24 @@ namespace LWGUI this.group = group; this._defaultFileName = defaultFileName; this._rootPath = rootPath.Replace('.', '/'); - this._isLinear = colorSpace.ToLower() == "linear"; + this._colorSpace = colorSpace.ToLower() == "linear" ? ColorSpace.Linear : ColorSpace.Gamma; this._defaultWidth = Mathf.Max(2.0f, defaultWidth); + this._viewChannelMask = LwguiGradient.ChannelMask.None; + { + viewChannelMask = viewChannelMask.ToLower(); + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + { + if (viewChannelMask.Contains(LwguiGradient.channelNames[c])) + _viewChannelMask |= LwguiGradient.ChannelIndexToMask(c); + } + } + this._timeRange = LwguiGradient.GradientTimeRange.One; + { + if ((int)timeRange == (int)LwguiGradient.GradientTimeRange.TwentyFour) + _timeRange = LwguiGradient.GradientTimeRange.TwentyFour; + else if ((int)timeRange == (int)LwguiGradient.GradientTimeRange.TwentyFourHundred) + _timeRange = LwguiGradient.GradientTimeRange.TwentyFourHundred; + } } protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Texture; } @@ -960,88 +1041,66 @@ namespace LWGUI // TODO: undo public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { - // When switch ramp map - RampHelper.SwitchRampMapEvent OnSwitchRampMapEvent = newRampMap => - { - prop.textureValue = newRampMap; - OnSwitchRampMap(prop.textureValue); - metaDatas.OnValidate(); - }; + var labelWidth = EditorGUIUtility.labelWidth; + var indentLevel = EditorGUI.indentLevel; - // When create new ramp map - RampHelper.SwitchRampMapEvent OnCreateNewRampMapEvent = newRampMap => - { - prop.textureValue = newRampMap; - OnCreateNewRampMap(prop.textureValue); - metaDatas.OnValidate(); - }; - - // per prop variables - bool isDirty; - // used to read/write Gradient value in code - GradientObject gradientObject = ScriptableObject.CreateInstance(); - // used to modify Gradient value for users - SerializedObject serializedObject = new SerializedObject(gradientObject); - SerializedProperty serializedProperty = serializedObject.FindProperty("gradient"); - - // Tex > GradientObject - gradientObject.gradient = RampHelper.GetGradientFromTexture(prop.textureValue, out isDirty); - // GradientObject > SerializedObject - serializedObject.Update(); + var gradient = RampHelper.GetGradientFromTexture(prop.textureValue, out var isDirty, false, _doRegisterUndo) ?? new LwguiGradient(); OnRampPropUpdate(position, prop, label, editor); // Draw Label var labelRect = new Rect(position); //EditorGUILayout.GetControlRect(); - labelRect.yMax -= position.height * 0.5f; - EditorGUI.PrefixLabel(labelRect, label); + { + labelRect.height = _rampPreviewHeight; + EditorGUI.PrefixLabel(labelRect, label); + } // Ramp buttons Rect - var labelWidth = EditorGUIUtility.labelWidth; - var indentLevel = EditorGUI.indentLevel; var buttonRect = new Rect(position); //EditorGUILayout.GetControlRect(); { EditorGUIUtility.labelWidth = 0; EditorGUI.indentLevel = 0; - buttonRect.yMin += position.height * 0.5f; + buttonRect.yMin = buttonRect.yMax - _rampPreviewHeight; buttonRect = MaterialEditor.GetRectAfterLabelWidth(buttonRect); if (buttonRect.width < 50f) return; } // Draw Ramp Editor - bool hasGradientChanges, doSaveGradient, doDiscardGradient; - Texture2D newCreatedTexture; - hasGradientChanges = RampHelper.RampEditor(buttonRect, prop, serializedProperty, _isLinear, isDirty, - _defaultFileName, _rootPath, (int)_defaultWidth, (int)_defaultHeight, - out newCreatedTexture, out doSaveGradient, out doDiscardGradient); + var hasGradientChanges = RampHelper.RampEditor(buttonRect, prop, ref gradient, _colorSpace, _viewChannelMask, _timeRange, + isDirty, _defaultFileName, _rootPath, (int)_defaultWidth, (int)_defaultHeight, out _doRegisterUndo, + out var newCreatedTexture, out var doSaveGradient, out var doDiscardGradient); + if (newCreatedTexture != null) - OnCreateNewRampMapEvent(newCreatedTexture); + { + LwguiGradientWindow.CloseWindow(); + prop.textureValue = newCreatedTexture; + OnCreateNewRampMap(prop.textureValue); + LWGUI.OnValidate(metaDatas); + } // Save gradient changes if (hasGradientChanges || doSaveGradient) { - // SerializedObject > GradientObject - serializedObject.ApplyModifiedProperties(); - // GradientObject > Tex - RampHelper.SetGradientToTexture(prop.textureValue, gradientObject, doSaveGradient); + // Gradient > Tex + RampHelper.SetGradientToTexture(prop.textureValue, gradient, doSaveGradient); OnEditRampMap(); } // Discard gradient changes if (doDiscardGradient) { - // Tex > GradientObject - gradientObject.gradient = RampHelper.GetGradientFromTexture(prop.textureValue, out isDirty, true); - // GradientObject > SerializedObject - serializedObject.Update(); + LwguiGradientWindow.CloseWindow(); + + // Tex > Gradient + gradient = RampHelper.GetGradientFromTexture(prop.textureValue, out isDirty, true); // GradientObject > Tex - RampHelper.SetGradientToTexture(prop.textureValue, gradientObject, true); + RampHelper.SetGradientToTexture(prop.textureValue, gradient, true); OnEditRampMap(); } // Texture object field, handle switch texture event var rampFieldRect = MaterialEditor.GetRectAfterLabelWidth(labelRect); - var previewRect = new Rect(rampFieldRect.x + 1, rampFieldRect.y + 1, rampFieldRect.width - 19, rampFieldRect.height - 2); + var previewRect = new Rect(rampFieldRect.x + 0.5f, rampFieldRect.y + 0.5f, rampFieldRect.width - 18, rampFieldRect.height - 0.5f); { var selectButtonRect = new Rect(previewRect.xMax, rampFieldRect.y, rampFieldRect.width - previewRect.width, rampFieldRect.height); RampHelper.RampSelector(selectButtonRect, _rootPath, OnSwitchRampMapEvent); @@ -1059,22 +1118,33 @@ namespace LWGUI } // Preview texture override (larger preview, hides texture name) - if (prop.hasMixedValue) { - EditorGUI.DrawPreviewTexture(previewRect, _iconMixImage.image); - GUI.Label(new Rect(previewRect.x + previewRect.width * 0.5f - 10, previewRect.y, previewRect.width * 0.5f, previewRect.height), "―"); + if (prop.hasMixedValue) + { + EditorGUI.DrawPreviewTexture(previewRect, _iconMixImage.image); + GUI.Label(new Rect(previewRect.x + previewRect.width * 0.5f - 10, previewRect.y, previewRect.width * 0.5f, previewRect.height), "―"); + } + else if (prop.textureValue != null) + LwguiGradientEditorHelper.DrawGradientWithSeparateAlphaChannel(previewRect, gradient, _colorSpace, _viewChannelMask); } - else if (prop.textureValue != null) - EditorGUI.DrawPreviewTexture(previewRect, prop.textureValue); EditorGUIUtility.labelWidth = labelWidth; EditorGUI.indentLevel = indentLevel; + return; + + void OnSwitchRampMapEvent(Texture2D newRampMap) + { + LwguiGradientWindow.CloseWindow(); + prop.textureValue = newRampMap; + OnSwitchRampMap(prop.textureValue); + LWGUI.OnValidate(metaDatas); + } } } /// /// Popping a menu, you can select the Shader Property Preset, the Preset values will replaces the default values - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// presetFileName: "Shader Property Preset" asset name, you can create new Preset by /// "Right Click > Create > LWGUI > Shader Property Preset" in Project window, /// *any Preset in the entire project cannot have the same name* @@ -1091,12 +1161,40 @@ namespace LWGUI this.presetFileName = presetFileName; } + public static void SetPresetAssetToStaticData(PropertyStaticData inoutPropertyStaticData, string presetFileName) + { + inoutPropertyStaticData.propertyPresetAsset = PresetHelper.GetPresetFile(presetFileName); + } + + public static ShaderPropertyPreset.Preset GetActivePresetFromFloatProperty(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset) + { + ShaderPropertyPreset.Preset preset = null; + var index = (int)inProp.floatValue; + if (shaderPropertyPreset && index >= 0 && index < shaderPropertyPreset.presets.Count) + { + preset = shaderPropertyPreset.presets[index]; + } + return preset; + } + + public static void ApplyPreset(string presetFileName, MaterialProperty prop) + { + var presetFile = PresetHelper.GetPresetFile(presetFileName); + if (presetFile != null + && prop.floatValue < presetFile.presets.Count + && ShowIfDecorator.GetShowIfResultToFilterDrawerApplying(prop) + ) + { + presetFile.presets[(int)prop.floatValue].ApplyKeywordsAndPassesToMaterials(prop.targets); + } + } + protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Float; } public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) { base.BuildStaticMetaData(inShader, inProp, inProps, inoutPropertyStaticData); - inoutPropertyStaticData.propertyPresetAsset = PresetHelper.GetPresetFile(presetFileName); + SetPresetAssetToStaticData(inoutPropertyStaticData, presetFileName); } public override void GetDefaultValueDescription(Shader inShader, MaterialProperty inProp, MaterialProperty inDefaultProp, PerShaderData inPerShaderData, PerMaterialData inoutPerMaterialData) @@ -1108,16 +1206,8 @@ namespace LWGUI inoutPerMaterialData.propDynamicDatas[inProp.name].defaultValueDescription = propertyPreset.presets[index].presetName; } - public ShaderPropertyPreset.Preset GetActivePreset(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset) - { - ShaderPropertyPreset.Preset preset = null; - var index = (int)inProp.floatValue; - if (shaderPropertyPreset && index >= 0 && index < shaderPropertyPreset.presets.Count) - { - preset = shaderPropertyPreset.presets[index]; - } - return preset; - } + public ShaderPropertyPreset.Preset GetActivePreset(MaterialProperty inProp, ShaderPropertyPreset shaderPropertyPreset) => + GetActivePresetFromFloatProperty(inProp, shaderPropertyPreset); public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { @@ -1138,7 +1228,7 @@ namespace LWGUI return; } - var presetNames = presetFile.presets.Select(((inPreset) => new GUIContent(inPreset.presetName))).ToArray(); + var presetNames = presetFile.presets.Select((inPreset) => new GUIContent(inPreset.presetName)).ToArray(); if (EditorGUI.showMixedValue) index = -1; else @@ -1155,15 +1245,179 @@ namespace LWGUI public override void Apply(MaterialProperty prop) { base.Apply(prop); - var presetFile = PresetHelper.GetPresetFile(presetFileName); - if (presetFile != null && prop.floatValue < presetFile.presets.Count) - presetFile.presets[(int)prop.floatValue].ApplyKeywordsToMaterials(prop.targets); + if (!prop.hasMixedValue) + { + ApplyPreset(presetFileName, prop); + } + } + } + + /// + /// Draw one or more Buttons within the same row, using the Display Name to control the appearance and behavior of the buttons + /// + /// Declaring a set of Button Name and Button Command in Display Name generates a Button, separated by '@': + /// ButtonName0@ButtonCommand0@ButtonName1@ButtonCommand1 + /// + /// Button Name can be any other string, the format of Button Command is: + /// TYPE:Argument + /// + /// The following TYPEs are currently supported: + /// - URL: Open the URL, Argument is the URL + /// - C#: Call the public static C# function, Argument is NameSpace.Class.Method(arg0, arg1, ...), + /// for target function signatures, see: LWGUI.ButtonDrawer.TestMethod(). + /// + /// The full example: + /// [Button(_)] _button0 ("URL Button@URL:https://github.com/JasonMa0012/LWGUI@C#:LWGUI.ButtonDrawer.TestMethod(1234, abcd)", Float) = 0 + /// + /// group: father group name, support suffix keyword for conditional display (Default: none) + /// + public class ButtonDrawer : SubDrawer + { + private const string _urlPrefix = "URL:"; + private const string _csPrefix = "C#:"; + private const string _separator = "@"; + + public ButtonDrawer() { } + + public ButtonDrawer(string group) + { + this.group = group; + } + + protected override float GetVisibleHeight(MaterialProperty prop) => 24; + + public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) + { + inoutPropertyStaticData.groupName = group; + + // Display Name: ButtonName@URL:XXX@ButtonName@CS:NameSpace.Class.Method(arg0, arg1, ...)@... + var buttonNameAndCommands = inProp.displayName.Split(_separator); + if (buttonNameAndCommands != null && buttonNameAndCommands.Length > 0 && buttonNameAndCommands.Length % 2 == 0) + { + for (int i = 0; i < buttonNameAndCommands.Length; i++) + { + if (i % 2 == 0) + { + inoutPropertyStaticData.buttonDisplayNames.Add(buttonNameAndCommands[i]); + inoutPropertyStaticData.buttonDisplayNameWidths.Add(EditorStyles.label.CalcSize(new GUIContent(buttonNameAndCommands[i])).x); + } + else + { + inoutPropertyStaticData.buttonCommands.Add(buttonNameAndCommands[i]); + } + } + } + else + { + Debug.LogError($"LWGUI: ButtonDrawer with invalid Display Name Commands: { buttonNameAndCommands } ! prop: { inProp.name }"); + } + } + + public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) + { + var buttonDisplayNames = metaDatas.GetPropStaticData(prop).buttonDisplayNames; + var buttonDisplayNameWidths = metaDatas.GetPropStaticData(prop).buttonDisplayNameWidths; + var buttonCommands = metaDatas.GetPropStaticData(prop).buttonCommands; + if (buttonDisplayNames == null || buttonCommands == null || buttonDisplayNames.Count == 0 || buttonCommands.Count == 0 + || buttonDisplayNames.Count != buttonCommands.Count) + { + return; + } + + var enbaled = GUI.enabled; + GUI.enabled = true; + + position = EditorGUI.IndentedRect(position); + var rect = new Rect(position.x, position.y, 0, position.height); + var spaceWidth = (position.width - buttonDisplayNameWidths.Sum()) / buttonDisplayNames.Count; + + for (int i = 0; i < buttonDisplayNames.Count; i++) + { + var displayName = buttonDisplayNames[i]; + var displayNameRelativeWidth = buttonDisplayNameWidths[i]; + var command = buttonCommands[i]; + rect.xMax = rect.xMin + displayNameRelativeWidth + spaceWidth; + + if (GUI.Button(rect, new GUIContent(displayName, command))) + { + if (command.StartsWith(_urlPrefix)) + { + Application.OpenURL(command.Substring(_urlPrefix.Length, command.Length - _urlPrefix.Length)); + } + else if (command.StartsWith(_csPrefix)) + { + var csCommand = command.Substring(_csPrefix.Length, command.Length - _csPrefix.Length); + + // Get method name and args + string className = null, methodName = null; + string[] args = null; + { + var lastPointIndex = csCommand.LastIndexOf('.'); + if (lastPointIndex != -1) + { + className = csCommand.Substring(0, lastPointIndex); + var leftBracketIndex = csCommand.IndexOf('('); + if (leftBracketIndex != -1) + { + methodName = csCommand.Substring(lastPointIndex + 1, leftBracketIndex - lastPointIndex - 1); + args = csCommand.Substring(leftBracketIndex + 1, csCommand.Length - leftBracketIndex - 2) + ?.Split(',').Select(s => s.TrimStart()).ToArray(); + } + } + } + + // Find and call method + if (!string.IsNullOrEmpty(className) && !string.IsNullOrEmpty(methodName) && args != null) + { + Type type = ReflectionHelper.GetAllTypes().FirstOrDefault((type1 => type1.Name == className || type1.FullName == className)); + if (type != null) + { + var methodInfo = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public); + if (methodInfo != null) + { + methodInfo.Invoke(null, new object[]{ prop, editor, metaDatas, args }); + } + else + { + Debug.LogError($"LWGUI: Method {methodName} not found in {className}"); + } + } + else + { + Debug.LogError($"LWGUI: Class {className} not found"); + } + } + else + { + Debug.LogError($"LWGUI: Invalid C# command: {csCommand}"); + } + } + else + { + Debug.LogError($"LWGUI: Unknown command type: {command}"); + } + } + + rect.xMin = rect.xMax; + } + + GUI.enabled = enbaled; + } + + public static void TestMethod(MaterialProperty prop, MaterialEditor editor, LWGUIMetaDatas metaDatas, string[] args) + { + Debug.Log($"LWGUI: ButtonDrawer.TestMethod({prop}, {editor}, {metaDatas}, {args})"); + + foreach (var arg in args) + { + Debug.Log(arg); + } } } /// /// Similar to Header() - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// header: string to display, "SpaceLine" or "_" = none (Default: none) /// height: line height (Default: 22) /// @@ -1203,7 +1457,7 @@ namespace LWGUI /// /// Similar to Title() - /// group:father group name, support suffix keyword for conditional display (Default: none) + /// group: father group name, support suffix keyword for conditional display (Default: none) /// header: string to display, "SpaceLine" or "_" = none (Default: none) /// height: line height (Default: 22) /// @@ -1217,7 +1471,7 @@ namespace LWGUI /// /// Tooltip, describes the details of the property. (Default: property.name and property default value) /// You can also use "#Text" in DisplayName to add Tooltip that supports Multi-Language. - /// tooltip:a single-line string to display, support up to 4 ','. (Default: Newline) + /// tooltip: a single-line string to display, support up to 4 ','. (Default: Newline) /// public class TooltipDecorator : SubDrawer { @@ -1254,7 +1508,7 @@ namespace LWGUI /// /// Display a Helpbox on the property /// You can also use "%Text" in DisplayName to add Helpbox that supports Multi-Language. - /// message:a single-line string to display, support up to 4 ','. (Default: Newline) + /// message: a single-line string to display, support up to 4 ','. (Default: Newline) /// public class HelpboxDecorator : TooltipDecorator { @@ -1313,7 +1567,7 @@ namespace LWGUI public PassSwitchDecorator(string lightModeName1, string lightModeName2, string lightModeName3, string lightModeName4, string lightModeName5, string lightModeName6) : this(new[] { lightModeName1, lightModeName2, lightModeName3, lightModeName4, lightModeName5, lightModeName6 }) { } - public PassSwitchDecorator(string[] passNames) { _lightModeNames = passNames.Select((s => s.ToUpper())).ToArray(); } + public PassSwitchDecorator(string[] lightModeNames) { _lightModeNames = lightModeNames.Select((s => s.ToUpper())).ToArray(); } #endregion @@ -1337,8 +1591,11 @@ namespace LWGUI public override void Apply(MaterialProperty prop) { base.Apply(prop); - if (!prop.hasMixedValue && IsMatchPropType(prop)) - Helper.SetShaderPassEnabled(prop.targets, _lightModeNames, prop.floatValue > 0); + if (!prop.hasMixedValue) + { + if (ShowIfDecorator.GetShowIfResultToFilterDrawerApplying(prop)) + Helper.SetShaderPassEnabled(prop.targets, _lightModeNames, prop.floatValue > 0); + } } } @@ -1438,8 +1695,9 @@ namespace LWGUI public float value = 0; } - private ShowIfData _showIfData = new ShowIfData(); - private readonly Dictionary _compareFunctionLUT = new Dictionary() + public ShowIfData showIfData = new(); + + private readonly Dictionary _compareFunctionLUT = new() { { "Less", "Less" }, { "L", "Less" }, @@ -1462,65 +1720,104 @@ namespace LWGUI public ShowIfDecorator(string logicalOperator, string propName, string compareFunction, float value) { - _showIfData.logicalOperator = logicalOperator.ToLower() == "or" ? LogicalOperator.Or : LogicalOperator.And; - _showIfData.targetPropertyName = propName; + showIfData.logicalOperator = logicalOperator.ToLower() == "or" ? LogicalOperator.Or : LogicalOperator.And; + showIfData.targetPropertyName = propName; if (!_compareFunctionLUT.ContainsKey(compareFunction) || !Enum.IsDefined(typeof(CompareFunction), _compareFunctionLUT[compareFunction])) Debug.LogError("LWGUI: Invalid compareFunction: '" + compareFunction + "', Must be one of the following: Less (L) | Equal (E) | LessEqual (LEqual / LE) | Greater (G) | NotEqual (NEqual / NE) | GreaterEqual (GEqual / GE)."); else - _showIfData.compareFunction = (CompareFunction)Enum.Parse(typeof(CompareFunction), _compareFunctionLUT[compareFunction]); - _showIfData.value = value; + showIfData.compareFunction = (CompareFunction)Enum.Parse(typeof(CompareFunction), _compareFunctionLUT[compareFunction]); + showIfData.value = value; + } + + private static void Compare(ShowIfData showIfData, float targetValue, ref bool result) + { + bool compareResult; + + switch (showIfData.compareFunction) + { + case CompareFunction.Less: + compareResult = targetValue < showIfData.value; + break; + case CompareFunction.LessEqual: + compareResult = targetValue <= showIfData.value; + break; + case CompareFunction.Greater: + compareResult = targetValue > showIfData.value; + break; + case CompareFunction.NotEqual: + compareResult = targetValue != showIfData.value; + break; + case CompareFunction.GreaterEqual: + compareResult = targetValue >= showIfData.value; + break; + default: + compareResult = targetValue == showIfData.value; + break; + } + + switch (showIfData.logicalOperator) + { + case LogicalOperator.And: + result &= compareResult; + break; + case LogicalOperator.Or: + result |= compareResult; + break; + } + } + + public static bool GetShowIfResultToFilterDrawerApplying(MaterialProperty prop) + { + var material = prop.targets[0] as Material; + var showIfDatas = new List(); + { + var drawer = ReflectionHelper.GetPropertyDrawer(material.shader, prop, out var decoratorDrawers); + if (decoratorDrawers != null && decoratorDrawers.Count > 0) + { + foreach (ShowIfDecorator showIfDecorator in decoratorDrawers.Where(drawer => drawer is ShowIfDecorator)) + { + showIfDatas.Add(showIfDecorator.showIfData); + } + } + else + { + return true; + } + } + + return GetShowIfResultFromMaterial(showIfDatas, material); + } + + public static bool GetShowIfResultFromMaterial(List showIfDatas, Material material) + { + bool result = true; + foreach (var showIfData in showIfDatas) + { + var targetValue = material.GetFloat(showIfData.targetPropertyName); + Compare(showIfData, targetValue, ref result); + } + + return result; + } + + public static void GetShowIfResult(PropertyStaticData propStaticData, PropertyDynamicData propDynamicData, PerMaterialData perMaterialData) + { + foreach (var showIfData in propStaticData.showIfDatas) + { + var targetValue = perMaterialData.propDynamicDatas[showIfData.targetPropertyName].property.floatValue; + Compare(showIfData, targetValue, ref propDynamicData.isShowing); + } } protected override float GetVisibleHeight(MaterialProperty prop) { return 0; } public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) { - inoutPropertyStaticData.showIfDatas.Add(_showIfData); + inoutPropertyStaticData.showIfDatas.Add(showIfData); } public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { } - - public static void GetShowIfResult(PropertyStaticData propStaticData, PropertyDynamicData propDynamicData, PerMaterialData perMaterialData) - { - foreach (var showIfData in propStaticData.showIfDatas) - { - var propCurrentValue = perMaterialData.propDynamicDatas[showIfData.targetPropertyName].property.floatValue; - bool compareResult; - - switch (showIfData.compareFunction) - { - case CompareFunction.Less: - compareResult = propCurrentValue < showIfData.value; - break; - case CompareFunction.LessEqual: - compareResult = propCurrentValue <= showIfData.value; - break; - case CompareFunction.Greater: - compareResult = propCurrentValue > showIfData.value; - break; - case CompareFunction.NotEqual: - compareResult = propCurrentValue != showIfData.value; - break; - case CompareFunction.GreaterEqual: - compareResult = propCurrentValue >= showIfData.value; - break; - default: - compareResult = propCurrentValue == showIfData.value; - break; - } - - switch (showIfData.logicalOperator) - { - case LogicalOperator.And: - propDynamicData.isShowing &= compareResult; - break; - case LogicalOperator.Or: - propDynamicData.isShowing |= compareResult; - break; - } - } - } } } //namespace LWGUI \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README.md b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README.md index fa17d4f..63dfd11 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README.md +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README.md @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58b8747c58101e50b8ba0c88514f58b2853a70f1d385e684b773a53460488d0c -size 29358 +oid sha256:b3d637e3b47f0aafe3f95523b772b7c62dca3f45a6c89e14676bbcbf8debeb5f +size 34713 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20220821234658509.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20220821234658509.png.meta index 93358c0..72f836a 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20220821234658509.png.meta +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20220821234658509.png.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 -guid: b3a047b5aeeebeb409a7ed0856959109 +guid: 5876caab7dc67af4d8e92317782da76f TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 1 @@ -20,11 +20,12 @@ TextureImporter: externalNormalMap: 0 heightScale: 0.25 normalMapFilter: 0 + flipGreenChannel: 0 isReadable: 0 streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 - ignoreMasterTextureLimit: 0 + ignoreMipmapLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -34,7 +35,7 @@ TextureImporter: textureSettings: serializedVersion: 2 filterMode: 1 - aniso: 2 + aniso: 1 mipBias: 0 wrapU: 0 wrapV: 0 @@ -63,10 +64,12 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform - maxTextureSize: 8192 + maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -74,11 +77,12 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 buildTarget: Standalone - maxTextureSize: 8192 + maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -86,35 +90,12 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 - buildTarget: iPhone - maxTextureSize: 8192 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 3 - buildTarget: Android - maxTextureSize: 8192 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 3 - buildTarget: Windows Store Apps - maxTextureSize: 8192 + buildTarget: Server + maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -122,6 +103,7 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: @@ -138,9 +120,8 @@ TextureImporter: weights: [] secondaryTextures: [] nameFileIdTable: {} - spritePackingTag: + mipmapLimitGroupName: pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240416142736663.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240416142736663.png index 7ddb604..4daa5db 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240416142736663.png +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240416142736663.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be93b4767856912aa154f6ddf9c2ed0f8226ebd606daf2ba80529825087209a2 -size 196113 +oid sha256:e8b435b7bdb19508991ac05a7690dc9d9a723d3f8efa27ab8628d6bf06032624 +size 180161 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png new file mode 100644 index 0000000..69849f2 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91eea4e2c4e13d16f8466a449be2a94eb87194ee3bb66422b4edb55994f498d9 +size 49964 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png.meta new file mode 100644 index 0000000..484a1d6 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716183800118.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: d728a6f19010f8747b8ac956860a5089 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png new file mode 100644 index 0000000..2460fc2 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:527c19745cdfec13839d19f9c2df427679b9c648f4de133d41df94227e5dfd94 +size 251381 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png.meta new file mode 100644 index 0000000..2747379 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240716184045776.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 56332e65f9dc7b44f83296f4b88f0f23 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png new file mode 100644 index 0000000..0b40594 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d539b16856b63a7fa63596ac690ba75bc3f4ec517869ab650b3a35518a3f6e2b +size 39725 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png.meta new file mode 100644 index 0000000..b718589 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104144821.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: d09eaf1bb9d214040a6cb0d350439f7f +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png new file mode 100644 index 0000000..bb84fa3 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:353237d29dc13e645c645e47a989bb04bae9521beff98bcb35965f5b9ab399e8 +size 39253 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png.meta new file mode 100644 index 0000000..556b605 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20240717104206365.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 43264f7caf023f740b5cc4dd66fa768b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png new file mode 100644 index 0000000..3019c9f --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a02740e8d37a5d6bbf726a413ea80da4e78ed909473a942e35f400acdd786079 +size 57206 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png.meta new file mode 100644 index 0000000..b12aa1f --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126105823397.png.meta @@ -0,0 +1,153 @@ +fileFormatVersion: 2 +guid: 0b6df23f9d012a74abed6b4f422d9442 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 25 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: VisionOS + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png new file mode 100644 index 0000000..08f7145 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:590e5ab8dcf596621ce6ecdd08f99eb35ea39ad54bcd5cdd5c8db7b98dcd14fc +size 26010 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png.meta new file mode 100644 index 0000000..ea662b6 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126110012922.png.meta @@ -0,0 +1,153 @@ +fileFormatVersion: 2 +guid: cc772ea50f72a6e44b0f6190010a6424 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 25 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: VisionOS + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png new file mode 100644 index 0000000..1103f21 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15f03d8381e642acba01338fe48a4400f64adac00c88db7d85f8847e8e32ad90 +size 43839 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png.meta new file mode 100644 index 0000000..025a4ea --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241126112320151.png.meta @@ -0,0 +1,153 @@ +fileFormatVersion: 2 +guid: c387c6327985b4f419caee4e22ffbb9b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 25 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 1024 + resizeAlgorithm: 0 + textureFormat: 50 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 1 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: VisionOS + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png new file mode 100644 index 0000000..0a8080e --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1028d04f9315b2210df3b67054d9f031c1c51ae276f0b774e6483abbc62d17e4 +size 4806 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png.meta new file mode 100644 index 0000000..4e548a2 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.assets/image-20241127180711449.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: b307e0433bc4e724180c49d205d9060e +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.md b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.md index 7eae75c..8659f49 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.md +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/README_CN.md @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed1e244651652166469c9c7b19c2c0531d511a428c03f2ba7268d4fa56faf2a4 -size 28664 +oid sha256:d6b08cc8a47f38d97481cdf2949ad636a8d11521b1862b3f9db950394fed84ea +size 34089 diff --git a/Assets/External/UnityMemoryMappedFile/UnityMemoryMappedFile.csproj.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime.meta similarity index 67% rename from Assets/External/UnityMemoryMappedFile/UnityMemoryMappedFile.csproj.meta rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime.meta index 5d30675..3e7a5fd 100644 --- a/Assets/External/UnityMemoryMappedFile/UnityMemoryMappedFile.csproj.meta +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime.meta @@ -1,5 +1,6 @@ fileFormatVersion: 2 -guid: d0ddbd505f5f46444b98a9285b7cdb8a +guid: 9c80aad1bb2dd5348bc922988445a5fb +folderAsset: yes DefaultImporter: externalObjects: {} userData: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef new file mode 100644 index 0000000..80b7bfc --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef @@ -0,0 +1,3 @@ +{ + "name": "LWGUI.Runtime" +} diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef.meta new file mode 100644 index 0000000..6aafee6 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LWGUI.Runtime.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 959b4969da7632b4e9d4dc209cce9cd6 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient.meta new file mode 100644 index 0000000..84bc895 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 756c9f5a40564b56bc263009a656acba +timeCreated: 1720764695 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs new file mode 100644 index 0000000..b45228d --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs @@ -0,0 +1,500 @@ +// Copyright (c) Jason Ma + +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace LWGUI.Runtime.LwguiGradient +{ + [Serializable] + public class LwguiGradient : IDisposable + { + #region Channel Enum + + public enum Channel + { + Red = 0, + Green = 1, + Blue = 2, + Alpha = 3, + Num = 4 + } + + [Flags] + public enum ChannelMask + { + None = 0, + Red = 1 << 0, + Green = 1 << 1, + Blue = 1 << 2, + Alpha = 1 << 3, + RGB = Red | Green | Blue, + All = RGB | Alpha + } + + public enum GradientTimeRange + { + One = 1, + TwentyFour = 24, + TwentyFourHundred = 2400 + } + + public static bool HasChannelMask(ChannelMask channelMaskA, ChannelMask channelMaskB) => ((uint)channelMaskA & (uint)channelMaskB) > 0; + + public static bool IsChannelIndexInMask(int channelIndex, ChannelMask channelMask) => ((uint)channelMask & (uint)(1 << channelIndex)) > 0; + + public static ChannelMask ChannelIndexToMask(int channelIndex) => (ChannelMask)(1 << channelIndex); + + #endregion + + #region Const + + public static readonly Color[] channelColors = new[] { Color.red, Color.green, Color.blue, Color.white }; + public static readonly char[] channelNames = new[] { 'r', 'g', 'b', 'a' }; + + public static AnimationCurve defaultCurve => new (new Keyframe(0, 1).SetLinearTangentMode(), new Keyframe(1, 1).SetLinearTangentMode()); + + #endregion + + #region Data + + // The complete data is stored by RGBA Curves and can be converted into Texture + [SerializeField] private List _curves; + + #endregion + + #region Constructor + + public LwguiGradient() + { + _curves = new List(); + for (int c = 0; c < (int)Channel.Num; c++) + _curves.Add(defaultCurve); + } + + public LwguiGradient(LwguiGradient src) + { + DeepCopyFrom(src); + } + + public LwguiGradient(params Keyframe[] keys) + { + _curves = new List(); + for (int c = 0; c < (int)Channel.Num; c++) + _curves.Add(new AnimationCurve()); + + if (keys?.Length > 0) + { + AddKeys(keys, ChannelMask.All); + } + } + + public LwguiGradient(Color[] colors, float[] times) + { + _curves = new List(); + for (int c = 0; c < (int)Channel.Num; c++) + _curves.Add(new AnimationCurve()); + + if (colors == null || times == null) + return; + + for (int i = 0; i < Mathf.Min(colors.Length, times.Length); i++) + { + for (int c = 0; c < (int)Channel.Num; c++) + { + _curves[c].AddKey(new Keyframe(times[i], colors[i][c]).SetLinearTangentMode()); + } + } + SetLinearTangentMode(); + } + + public LwguiGradient(List inRgbaCurves) => SetRgbaCurves(inRgbaCurves); + + public static LwguiGradient white + { + get => new (); + } + + public static LwguiGradient gray + { + get => new (new []{Color.gray, Color.gray}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient black + { + get => new (new []{Color.black, Color.black}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient red + { + get => new (new []{Color.red, Color.red}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient green + { + get => new (new []{Color.green, Color.green}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient blue + { + get => new (new []{Color.blue, Color.blue}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient cyan + { + get => new (new []{Color.cyan, Color.cyan}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient magenta + { + get => new (new []{Color.magenta, Color.magenta}, new []{0.0f, 1.0f}); + } + + public static LwguiGradient yellow + { + get => new (new []{Color.yellow, Color.yellow}, new []{0.0f, 1.0f}); + } + + #endregion + + public int GetValueBasedHashCode() + { + var hash = 17; + + if (_curves != null) + { + foreach (var curve in _curves) + { + if (curve != null) + { + hash = hash * 23 + curve.GetHashCode(); + } + } + } + + return hash; + } + + public void Dispose() + { + _curves?.Clear(); + } + + public void Clear(ChannelMask channelMask = ChannelMask.All) + { + _curves ??= new List(); + for (int c = 0; c < (int)Channel.Num; c++) + { + if (!IsChannelIndexInMask(c, channelMask)) continue; + + if (_curves.Count > c) _curves[c].keys = Array.Empty(); + else _curves.Add(new AnimationCurve()); + } + } + + public void DeepCopyFrom(LwguiGradient src) + { + _curves ??= new List(); + for (int c = 0; c < (int)Channel.Num; c++) + { + if (_curves.Count == c) + _curves.Add(new AnimationCurve()); + + _curves[c].keys = Array.Empty(); + } + + for (int c = 0; c < src._curves.Count; c++) + { + foreach (var key in src._curves[c].keys) + { + _curves[c].AddKey(key); + } + } + } + + public void SetCurve(AnimationCurve curve, ChannelMask channelMask) + { + curve ??= defaultCurve; + for (int c = 0; c < (int)Channel.Num; c++) + { + if (!IsChannelIndexInMask(c, channelMask)) continue; + + _curves[c] = curve; + } + } + + public void SetRgbaCurves(List inRgbaCurves) + { + _curves = new List(); + + for (int c = 0; c < (int)Channel.Num; c++) + { + if (inRgbaCurves?.Count > c && inRgbaCurves[c]?.keys.Length > 0) + { + _curves.Add(inRgbaCurves[c]); + } + else + { + _curves.Add(defaultCurve); + } + } + } + + public void AddKey(Keyframe key, ChannelMask channelMask) + { + for (int c = 0; c < (int)Channel.Num; c++) + { + if (!IsChannelIndexInMask(c, channelMask)) + continue; + + _curves[c].AddKey(key); + } + + } + + public void AddKeys(Keyframe[] keys, ChannelMask channelMask) + { + for (int i = 0; i < keys?.Length; i++) + { + AddKey(keys[i], channelMask); + } + } + + + public List rawCurves + { + get => _curves; + set => SetRgbaCurves(value); + } + + public AnimationCurve redCurve + { + get => _curves[(int)Channel.Red] ?? defaultCurve; + set => SetCurve(value, ChannelMask.Red); + } + + public AnimationCurve greenCurve + { + get => _curves[(int)Channel.Green] ?? defaultCurve; + set => SetCurve(value, ChannelMask.Green); + } + + public AnimationCurve blueCurve + { + get => _curves[(int)Channel.Blue] ?? defaultCurve; + set => SetCurve(value, ChannelMask.Blue); + } + + public AnimationCurve alphaCurve + { + get => _curves[(int)Channel.Alpha] ?? defaultCurve; + set => SetCurve(value, ChannelMask.Alpha); + } + + + public Color Evaluate(float time, ChannelMask channelMask = ChannelMask.All, GradientTimeRange timeRange = GradientTimeRange.One) + { + time /= (int)timeRange; + + if (channelMask == ChannelMask.Alpha) + { + var alpha = _curves[(int)Channel.Alpha].Evaluate(time); + return new Color(alpha, alpha, alpha, 1); + } + + return new Color( + IsChannelIndexInMask((int)Channel.Red, channelMask) ? _curves[(int)Channel.Red].Evaluate(time) : 0, + IsChannelIndexInMask((int)Channel.Green, channelMask) ? _curves[(int)Channel.Green].Evaluate(time) : 0, + IsChannelIndexInMask((int)Channel.Blue, channelMask) ? _curves[(int)Channel.Blue].Evaluate(time) : 0, + IsChannelIndexInMask((int)Channel.Alpha, channelMask) ? _curves[(int)Channel.Alpha].Evaluate(time) : 1); + } + + public void SetLinearTangentMode() + { + for (int c = 0; c < (int)Channel.Num; c++) + { + _curves[c].SetLinearTangents(); + } + } + + #region LwguiGradient <=> Ramp Texture + + public Color[] GetPixels(int width, int height, ChannelMask channelMask = ChannelMask.All) + { + var pixels = new Color[width * height]; + for (var x = 0; x < width; x++) + { + var u = x / (float)width; + var col = Evaluate(u, channelMask); + for (int i = 0; i < height; i++) + { + pixels[x + i * width] = col; + } + } + + return pixels; + } + + public Texture2D GetPreviewRampTexture(int width = 256, int height = 1, ColorSpace colorSpace = ColorSpace.Gamma, ChannelMask channelMask = ChannelMask.All) + { + if (LwguiGradientHelper.TryGetRampPreview(this, width, height, colorSpace, channelMask, out var cachedPreview)) + return cachedPreview; + + var rampPreview = new Texture2D(width, height, TextureFormat.RGBA32, false, colorSpace == ColorSpace.Linear); + var pixels = GetPixels(width, height, channelMask); + rampPreview.SetPixels(pixels); + rampPreview.wrapMode = TextureWrapMode.Clamp; + rampPreview.name = "LWGUI Gradient Preview"; + rampPreview.Apply(); + + LwguiGradientHelper.SetRampPreview(this, width, height, colorSpace, channelMask, rampPreview); + return rampPreview; + } + + #endregion + + #region LwguiGradient <=> Gradient + + public struct LwguiKeyframe + { + public float time; + public float value; + public int index; + + public LwguiKeyframe(float time, float value, int index) + { + this.time = time; + this.value = value; + this.index = index; + } + } + + public class LwguiMergedColorCurves : IDisposable + { + public List> curves = new (); + + public LwguiMergedColorCurves() + { + for (int c = 0; c < (int)Channel.Num; c++) + curves.Add(new List()); + } + + public LwguiMergedColorCurves(List rgbaCurves) + { + for (int c = 0; c < (int)Channel.Num; c++) + curves.Add(new List()); + + // Get color keys + { + var timeColorDic = new Dictionary>(); + for (int c = 0; c < (int)Channel.Num - 1; c++) + { + var keys = rgbaCurves[c].keys; + for (int j = 0; j < keys.Length; j++) + { + var keyframe = keys[j]; + if (timeColorDic.ContainsKey(keyframe.time)) + { + timeColorDic[keyframe.time].Add((keyframe.value, j)); + } + else + { + timeColorDic.Add(keyframe.time, new List<(float value, int index)> { (keyframe.value, j) }); + } + } + } + + foreach (var kwPair in timeColorDic) + { + if (kwPair.Value.Count == (int)Channel.Num - 1) + { + for (int c = 0; c < (int)Channel.Num - 1; c++) + { + curves[c].Add(new LwguiKeyframe(kwPair.Key, kwPair.Value[c].value, kwPair.Value[c].index)); + } + } + } + } + + // Get alpha keys + for (int i = 0; i < rgbaCurves[(int)Channel.Alpha].keys.Length; i++) + { + var alphaKey = rgbaCurves[(int)Channel.Alpha].keys[i]; + curves[(int)Channel.Alpha].Add(new LwguiKeyframe(alphaKey.time, alphaKey.value, i)); + } + } + + public LwguiMergedColorCurves(Gradient gradient) + { + for (int c = 0; c < (int)Channel.Num; c++) + curves.Add(new List()); + + foreach (var colorKey in gradient.colorKeys) + { + for (int c = 0; c < (int)Channel.Num - 1; c++) + { + curves[c].Add(new LwguiKeyframe(colorKey.time, colorKey.color[c], 0)); + } + } + foreach (var alphaKey in gradient.alphaKeys) + { + curves[(int)Channel.Alpha].Add(new LwguiKeyframe(alphaKey.time, alphaKey.alpha, 0)); + } + } + + public Gradient ToGradient(int maxGradientKeyCount = 8) => new Gradient + { + colorKeys = curves[(int)Channel.Red].Select((keyframe, i) => new GradientColorKey( + new Color( + curves[(int)Channel.Red][i].value, + curves[(int)Channel.Green][i].value, + curves[(int)Channel.Blue][i].value), + curves[(int)Channel.Red][i].time)) + .Where((key, i) => i < maxGradientKeyCount).ToArray(), + + alphaKeys = curves[(int)Channel.Alpha].Select(alphaKey => new GradientAlphaKey(alphaKey.value, alphaKey.time)) + .Where((key, i) => i < maxGradientKeyCount).ToArray() + }; + + public List ToAnimationCurves() + { + var outCurves = new List(); + for (int c = 0; c < (int)Channel.Num; c++) + { + var curve = new AnimationCurve(); + foreach (var key in curves[c]) + { + curve.AddKey(new Keyframe(key.time, key.value).SetLinearTangentMode()); + } + curve.SetLinearTangents(); + outCurves.Add(curve); + } + + return outCurves; + } + + public LwguiGradient ToLwguiGradient() + { + return new LwguiGradient(ToAnimationCurves()); + } + + public void Dispose() + { + curves?.Clear(); + } + } + + public static LwguiGradient FromGradient(Gradient gradient) + { + return new LwguiMergedColorCurves(gradient).ToLwguiGradient(); + } + + public Gradient ToGradient(int maxGradientKeyCount = 8) + { + return new LwguiMergedColorCurves(_curves).ToGradient(maxGradientKeyCount); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs.meta new file mode 100644 index 0000000..9a02db9 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradient.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a1c1406f2f784af489fb3758fb334d07 +timeCreated: 1716793021 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs new file mode 100644 index 0000000..318928c --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs @@ -0,0 +1,91 @@ +// Copyright (c) Jason Ma + +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +// Disable Keyframe.tangentMode obsolete warning +#pragma warning disable 0618 + + +namespace LWGUI.Runtime.LwguiGradient +{ + public static class LwguiGradientHelper + { + #region Extended Methods + + public static Keyframe SetLinearTangentMode(this Keyframe key) + { + key.tangentMode = 69; + return key; + } + + public static void SetLinearTangents(this AnimationCurve curve) + { + for (int i = 1; i < curve.keys.Length; i++) + { + var keyStart = curve.keys[i - 1]; + var keyEnd = curve.keys[i]; + float tangent = (keyEnd.value - keyStart.value) / (keyEnd.time - keyStart.time); + keyStart.outTangent = tangent; + keyEnd.inTangent = tangent; + curve.MoveKey(i - 1, keyStart); + curve.MoveKey(i, keyEnd); + } + } + + public static void DestroyInEditorOrRuntime(this UnityEngine.Object obj) + { +#if UNITY_EDITOR + Object.DestroyImmediate(obj); +#else + Object.Destroy(obj); +#endif + } + + #endregion + + #region Ramp Preview Caches + + private static Dictionary> _gradientToPreviewDic; + + public static bool TryGetRampPreview(LwguiGradient gradient, int width, int height, ColorSpace colorSpace, LwguiGradient.ChannelMask channelMask, + out Texture2D cachedPreview) + { + cachedPreview = _gradientToPreviewDic?.GetValueOrDefault(gradient.GetValueBasedHashCode())?.GetValueOrDefault((width, height, colorSpace, channelMask)); + return cachedPreview; + } + + public static void SetRampPreview(LwguiGradient gradient, int width, int height, ColorSpace colorSpace, LwguiGradient.ChannelMask channelMask, Texture2D newPreviewTex) + { + _gradientToPreviewDic ??= new Dictionary>(); + var hash = gradient.GetValueBasedHashCode(); + + if (!_gradientToPreviewDic.ContainsKey(hash)) + { + _gradientToPreviewDic[hash] = new Dictionary<(int, int, ColorSpace, LwguiGradient.ChannelMask), Texture2D>(); + } + + if (_gradientToPreviewDic[hash].ContainsKey((width, height, colorSpace, channelMask))) + { + _gradientToPreviewDic[hash][(width, height, colorSpace, channelMask)].DestroyInEditorOrRuntime(); + } + + _gradientToPreviewDic[hash][(width, height, colorSpace, channelMask)] = newPreviewTex; + } + + public static void ClearRampPreviewCaches() + { + if (_gradientToPreviewDic == null) return; + + foreach (var paramsToPreviewTexDic in _gradientToPreviewDic.Values) + { + paramsToPreviewTexDic.Values.ToList().ForEach(previewTex => previewTex.DestroyInEditorOrRuntime()); + } + _gradientToPreviewDic.Clear(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs.meta new file mode 100644 index 0000000..0871499 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Runtime/LwguiGradient/LwguiGradientHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dacb09adca6c4f07b8f5fa5acdc7cbfd +timeCreated: 1720172986 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_BlendModePreset.asset b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_BlendMode.asset similarity index 98% rename from Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_BlendModePreset.asset rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_BlendMode.asset index 986a4a0..5cf0fea 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_BlendModePreset.asset +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_BlendMode.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 28fbcbca3fb14507af6ed5c104c40b84, type: 3} - m_Name: LWGUI_BlendModePreset + m_Name: LWGUI_Preset_BlendMode m_EditorClassIdentifier: presets: - presetName: Opaque diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_BlendModePreset.asset.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_BlendMode.asset.meta similarity index 100% rename from Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_BlendModePreset.asset.meta rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_BlendMode.asset.meta diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset new file mode 100644 index 0000000..7be4bf7 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 28fbcbca3fb14507af6ed5c104c40b84, type: 3} + m_Name: LWGUI_Preset_Toggle + m_EditorClassIdentifier: + presets: + - presetName: Disable + propertyValues: [] + enabledKeywords: [] + disabledKeywords: [] + enabledPasses: [] + disabledPasses: [] + renderQueue: 2000 + - presetName: Enable + propertyValues: [] + enabledKeywords: [] + disabledKeywords: [] + enabledPasses: [] + disabledPasses: [] + renderQueue: 2001 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset.meta new file mode 100644 index 0000000..b094f4e --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_Preset_Toggle.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3b3b9433213824419f41452830ee4ea +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_SampleDrawer 1.mat b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_SampleDrawer 1.mat index e63a365..25da097 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_SampleDrawer 1.mat +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/LWGUI_SampleDrawer 1.mat @@ -9,16 +9,20 @@ Material: m_PrefabAsset: {fileID: 0} m_Name: LWGUI_SampleDrawer 1 m_Shader: {fileID: 4800000, guid: 7ee048c9536c0344bb8b4860595a4d9b, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 m_ValidKeywords: [] m_InvalidKeywords: - _GROUP_ON - _KEY2 + - _KEY3 m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: 3000 stringTagMap: {} disabledShaderPasses: [] + m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Linear.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Linear.png.meta index 74f4095..6b1d60e 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Linear.png.meta +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Linear.png.meta @@ -20,12 +20,11 @@ TextureImporter: externalNormalMap: 0 heightScale: 0.25 normalMapFilter: 0 - flipGreenChannel: 0 isReadable: 1 streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 - ignoreMipmapLimit: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -64,7 +63,6 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 - swizzle: 50462976 cookieLightType: 0 platformSettings: - serializedVersion: 3 @@ -77,7 +75,6 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 @@ -90,7 +87,6 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 @@ -103,7 +99,6 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: @@ -120,8 +115,9 @@ TextureImporter: weights: [] secondaryTextures: [] nameFileIdTable: {} - mipmapLimitGroupName: + spritePackingTag: pSDRemoveMatte: 0 - userData: '{"MonoBehaviour":{"m_Enabled":true,"m_EditorHideFlags":0,"m_Name":"","m_EditorClassIdentifier":"","gradient":{"serializedVersion":"2","key0":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"key1":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"key2":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key3":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key4":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key5":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key6":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key7":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"ctime0":0,"ctime1":65535,"ctime2":0,"ctime3":0,"ctime4":0,"ctime5":0,"ctime6":0,"ctime7":0,"atime0":0,"atime1":65535,"atime2":0,"atime3":0,"atime4":0,"atime5":0,"atime6":0,"atime7":0,"m_Mode":0,"m_ColorSpace":1,"m_NumColorKeys":2,"m_NumAlphaKeys":2}}}#{"MonoBehaviour":{"m_Enabled":true,"m_EditorHideFlags":0,"m_Name":"","m_EditorClassIdentifier":"","gradient":{"serializedVersion":"2","key0":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"key1":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"key2":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key3":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key4":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key5":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key6":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key7":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"ctime0":0,"ctime1":65535,"ctime2":0,"ctime3":0,"ctime4":0,"ctime5":0,"ctime6":0,"ctime7":0,"atime0":0,"atime1":65535,"atime2":0,"atime3":0,"atime4":0,"atime5":0,"atime6":0,"atime7":0,"m_Mode":0,"m_ColorSpace":1,"m_NumColorKeys":2,"m_NumAlphaKeys":2}}}' + pSDShowRemoveMatteOption: 0 + userData: '{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}#{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}' assetBundleName: assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png new file mode 100644 index 0000000..13e1481 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:feda8e28f7d6bb1418f3c2eab44de36149270b4afeedf7351d553a59bdbe3460 +size 100 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png.meta new file mode 100644 index 0000000..aa19c99 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_Test.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 1522a7c4f7317044ab912724c1594427 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 1 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 4 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: '{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}#{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}' + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_sRGB.png.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_sRGB.png.meta index 44c48f0..c33ff11 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_sRGB.png.meta +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/RampMap_sRGB.png.meta @@ -122,6 +122,6 @@ TextureImporter: nameFileIdTable: {} mipmapLimitGroupName: pSDRemoveMatte: 0 - userData: '{"MonoBehaviour":{"m_Enabled":true,"m_EditorHideFlags":0,"m_Name":"","m_EditorClassIdentifier":"","gradient":{"serializedVersion":"2","key0":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"key1":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"key2":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key3":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key4":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key5":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key6":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key7":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"ctime0":0,"ctime1":65535,"ctime2":0,"ctime3":0,"ctime4":0,"ctime5":0,"ctime6":0,"ctime7":0,"atime0":0,"atime1":65535,"atime2":0,"atime3":0,"atime4":0,"atime5":0,"atime6":0,"atime7":0,"m_Mode":0,"m_ColorSpace":0,"m_NumColorKeys":2,"m_NumAlphaKeys":2}}}#{"MonoBehaviour":{"m_Enabled":true,"m_EditorHideFlags":0,"m_Name":"","m_EditorClassIdentifier":"","gradient":{"serializedVersion":"2","key0":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"key1":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"key2":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key3":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key4":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key5":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key6":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"key7":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"ctime0":0,"ctime1":65535,"ctime2":0,"ctime3":0,"ctime4":0,"ctime5":0,"ctime6":0,"ctime7":0,"atime0":0,"atime1":65535,"atime2":0,"atime3":0,"atime4":0,"atime5":0,"atime6":0,"atime7":0,"m_Mode":0,"m_ColorSpace":0,"m_NumColorKeys":2,"m_NumAlphaKeys":2}}}' + userData: '{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":0.0,"inSlope":0.0,"outSlope":1.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":1.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":69,"weightedMode":0,"inWeight":0.0,"outWeight":0.0}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}#{"_curves":[{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.19993001222610475,"value":0.25,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.3509286344051361,"value":0.713207483291626,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.497556209564209,"value":0.4040227234363556,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.6422287225723267,"value":0.711692214012146,"inSlope":1.9705389738082886,"outSlope":1.9705389738082886,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.800000011920929,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.19993001222610475,"value":0.25,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.3509286344051361,"value":0.6254975199699402,"inSlope":1.174917459487915,"outSlope":1.174917459487915,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.497556209564209,"value":0.7129190564155579,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.6422287225723267,"value":0.46618008613586428,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.800000011920929,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.19993001222610475,"value":0.25,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.3509286344051361,"value":0.38082584738731387,"inSlope":1.6324135065078736,"outSlope":1.6324135065078736,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.497556209564209,"value":0.7358490228652954,"inSlope":1.55451500415802,"outSlope":1.55451500415802,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.6422287225723267,"value":0.849056601524353,"inSlope":0.8733886480331421,"outSlope":0.8733886480331421,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.800000011920929,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4},{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.20000000298023225,"value":0.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.3499511182308197,"value":0.13333334028720857,"inSlope":1.2060123682022095,"outSlope":1.2060123682022095,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.6422287225723267,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":0.800000011920929,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":136,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}]}' assetBundleName: assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer 1.shader b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer 1.shader index f521617..d618b59 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer 1.shader +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer 1.shader @@ -12,6 +12,7 @@ [Main(Group1, _KEYWORD, on)] _group1 ("Group - Default Open", float) = 1 [Preset(Group1, LWGUI_ShaderPropertyPreset)] _preset ("Preset Sample", float) = 0 [Preset(Group1, LWGUI_ShaderPropertyPreset1)] _preset1 ("Preset Sample 1", float) = 0 + [SubToggle(Group1, _, LWGUI_Preset_Toggle)] _preset_toggle ("Preset Toggle Sample", float) = 0 [Sub(Group1)] _float1 ("Sub Float", float) = 0 [Sub(Group1)] _vector1 ("Sub Vector", vector) = (1, 1, 1, 1) [Sub(Group1)] [HDR] _color1 ("Sub HDR Color", color) = (0.7, 0.7, 1, 1) @@ -36,7 +37,7 @@ [Advanced][Tex(Group2, _AdvancedColor0)] _AdvancedTex1 ("Advanced Tex 1", 2D) = "white" { } [Advanced][HideInInspector] _AdvancedColor0 ("Advanced Color 0", Color) = (1, 1, 1, 1) [AdvancedHeaderProperty][Sub(Group2)] _AdvancedFloat ("Advanced Image", float) = 0 - [Advanced][Image(Group2)] _AdvancedImage ("Advanced Image", 2D) = "white" { } + [Advanced][Image(Group2)] _AdvancedImage ("../image-20220828003810353.png", float) = 0 [Title(Channel Samples)] [Channel] _textureChannelMask ("Texture Channel Mask (Default G)", Vector) = (0, 1, 0, 0) @@ -76,6 +77,9 @@ [MinMaxSlider(_rangeStart, _rangeEnd)] _minMaxSlider ("Min Max Slider (0 - 1)", Range(0.0, 1.0)) = 1.0 _rangeStart ("Range Start", Range(0.0, 0.5)) = 0.0 [PowerSlider(10)] _rangeEnd ("Range End PowerSlider", Range(0.5, 1.0)) = 1.0 + + [Title(Button Samples)] + [Button(_)] _button0 ("URL Button@URL:https://github.com/JasonMa0012/LWGUI@C# Button@C#:LWGUI.ButtonDrawer.TestMethod(1234, abcd)", Float) = 0 } HLSLINCLUDE diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer.shader b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer.shader index aed9602..220d88a 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer.shader +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Test/SampleDrawer.shader @@ -44,7 +44,7 @@ [Main(Preset, _, on, off)] _PresetGroup ("Preset Samples", float) = 0 - [Preset(Preset, LWGUI_BlendModePreset)] _BlendMode ("Blend Mode Preset", float) = 0 + [Preset(Preset, LWGUI_Preset_BlendMode)] _BlendMode ("Blend Mode Preset", float) = 0 [SubEnum(Preset, UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 2 [SubEnum(Preset, UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Float) = 1 [SubEnum(Preset, UnityEngine.Rendering.BlendMode)] _DstBlend ("DstBlend", Float) = 0 diff --git a/Assets/Plugins/websocket-sharp/websocket-sharp.csproj.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension.meta similarity index 67% rename from Assets/Plugins/websocket-sharp/websocket-sharp.csproj.meta rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension.meta index a38868c..104e713 100644 --- a/Assets/Plugins/websocket-sharp/websocket-sharp.csproj.meta +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension.meta @@ -1,5 +1,6 @@ fileFormatVersion: 2 -guid: 6ea7dfa994ebd3c42aed7934d8377314 +guid: 56e3a65fe6e61904a94a3cd1ea19a8ee +folderAsset: yes DefaultImporter: externalObjects: {} userData: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor.meta new file mode 100644 index 0000000..749be8f --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 76783890193e4d1aaab781515ec60548 +timeCreated: 1720764555 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs new file mode 100644 index 0000000..cba2980 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs @@ -0,0 +1,58 @@ +// Copyright (c) Jason Ma + +using System; +using UnityEngine; +using UnityEditor; +using LWGUI.Runtime.LwguiGradient; + +namespace LWGUI.LwguiGradientEditor +{ + [System.AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)] + public sealed class LwguiGradientUsageAttribute : PropertyAttribute + { + public ColorSpace colorSpace; + public LwguiGradient.ChannelMask viewChannelMask; + public LwguiGradient.GradientTimeRange timeRange; + + public LwguiGradientUsageAttribute(ColorSpace colorSpace = ColorSpace.Gamma, LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One) + { + this.colorSpace = colorSpace; + this.viewChannelMask = viewChannelMask; + this.timeRange = timeRange; + } + } + + + [CustomPropertyDrawer(typeof(LwguiGradientUsageAttribute))] + internal sealed class LwguiGradientUsageDrawer : LwguiGradientPropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + var colorUsage = (LwguiGradientUsageAttribute)attribute; + + colorSpace = colorUsage.colorSpace; + viewChannelMask = colorUsage.viewChannelMask; + timeRange = colorUsage.timeRange; + base.OnGUI(position, property, label); + } + } + + + [CustomPropertyDrawer(typeof(LwguiGradient))] + public class LwguiGradientPropertyDrawer : PropertyDrawer + { + public ColorSpace colorSpace = ColorSpace.Gamma; + public LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All; + public LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUI.BeginChangeCheck(); + var gradient = (LwguiGradient)fieldInfo.GetValue(property.serializedObject.targetObject); + LwguiGradientEditorHelper.GradientField(position, label, property, gradient, colorSpace, viewChannelMask, timeRange); + if (EditorGUI.EndChangeCheck()) + { + } + } + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs.meta new file mode 100644 index 0000000..68f1358 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9672b824fb314326a5fd4078a7068d89 +timeCreated: 1716793950 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs new file mode 100644 index 0000000..8273e07 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs @@ -0,0 +1,851 @@ +// Copyright (c) Jason Ma + +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEditor; +using LWGUI.Runtime.LwguiGradient; + +namespace LWGUI.LwguiGradientEditor +{ + public class LwguiGradientEditor + { + private class CurveSelectionInfo + { + public List selectedAnimationCurves; + public Vector4 selectedVectorValue = Vector4.negativeInfinity; + public float selectedFloatValue = float.NegativeInfinity; + public float selectedTime = float.NegativeInfinity; + public bool isOnlyColorKeySelected; + public LwguiGradient.LwguiMergedColorCurves mergedCurves; + + public bool hasMixedTime; + public bool hasMixedFloatValue; // Selected multiple keys with different values in a same Curve + public bool hasMixedColorValue; // Selected multiple color keys with different values in the RGB Curves + public List hasMixedChannelValue = Enumerable.Repeat(false, (int)LwguiGradient.Channel.Num).ToList(); + + public CurveSelectionInfo(CurveEditor curveEditor) + { + selectedAnimationCurves = new List(); + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + selectedAnimationCurves.Add(new AnimationCurve()); + + if (curveEditor?.selectedCurves is { Count: > 0 }) + { + foreach (var curveSelection in curveEditor.selectedCurves.Where(selection => selection != null)) + { + var channelID = curveSelection.curveID; + var key = curveEditor.GetKeyframeFromSelection(curveSelection); + selectedAnimationCurves[channelID].AddKey(key); + + if (selectedTime != float.NegativeInfinity && selectedTime != key.time) + hasMixedTime = true; + selectedTime = key.time; + + if (selectedVectorValue[channelID] != Vector4.negativeInfinity[channelID] && selectedVectorValue[channelID] != key.value) + hasMixedChannelValue[channelID] = true; + selectedVectorValue[channelID] = key.value; + + if (selectedFloatValue != float.NegativeInfinity && selectedFloatValue != key.value) + hasMixedFloatValue = true; + selectedFloatValue = key.value; + } + + for (int i = 0; i < 4; i++) + { + if (selectedVectorValue[i] == Vector4.negativeInfinity[i]) + selectedVectorValue[i] = 0; + } + + if (selectedFloatValue == float.NegativeInfinity) + selectedFloatValue = 0; + + mergedCurves = new LwguiGradient.LwguiMergedColorCurves(selectedAnimationCurves); + + var noAlphaKeySelected = mergedCurves.curves[(int)LwguiGradient.Channel.Alpha].Count == 0; + hasMixedColorValue = noAlphaKeySelected && hasMixedChannelValue. Where((_, c) => c < (int)LwguiGradient.Channel.Alpha).Any(b => b); + isOnlyColorKeySelected = noAlphaKeySelected && selectedAnimationCurves.Where((_, c) => c < (int)LwguiGradient.Channel.Alpha).All(curve => curve.length == mergedCurves.curves[(int)LwguiGradient.Channel.Red].Count); + } + else + { + mergedCurves = new LwguiGradient.LwguiMergedColorCurves(); + } + } + } + + #region UI Layout + + private bool _useSignalLineEditField => _position.width > 1150; + + private float _gradientEditorHeisht => _useSignalLineEditField ? 160 : 160 + _editFieldHeight; + private float _margin => 8; + private float _editFieldHeight => EditorGUIUtility.singleLineHeight; // 18 + private float _editFieldMarginsHeight => _margin * (_useSignalLineEditField ? 2 : 3); + private float _gradientAndSwatchHeight => _gradientEditorHeisht - _margin - _editFieldMarginsHeight - _editFieldHeight - _secondEditFieldRect.height; + private float _swatchHeisht => _gradientAndSwatchHeight * 0.15f; + private float _alphaGradientHeisht => _rgbGradientHeisht * 0.5f; + private float _rgbGradientHeisht => (_gradientAndSwatchHeight - _swatchHeisht * 2) * 0.66666f; + + private Rect _gradientEditorRect => new Rect(0, 0, _position.width, _gradientEditorHeisht); + private Rect _editFieldRect => new Rect(_curveEditor.leftmargin, _margin, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _editFieldHeight); + private Rect _secondEditFieldRect => _useSignalLineEditField ? Rect.zero : new Rect(_curveEditor.leftmargin, _margin * 2 + _editFieldHeight, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _editFieldHeight); + private Rect _alphaSwatchesRect => new Rect(_curveEditor.leftmargin, _editFieldMarginsHeight + _editFieldHeight + _secondEditFieldRect.height, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _swatchHeisht); + private Rect _rgbSwatchesRect => new Rect(_curveEditor.leftmargin, _editFieldMarginsHeight + _editFieldHeight + _secondEditFieldRect.height + _swatchHeisht + _alphaGradientHeisht + _rgbGradientHeisht, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _swatchHeisht); + private Rect _alphaGradientRect => new Rect(_curveEditor.leftmargin, _editFieldMarginsHeight + _editFieldHeight + _secondEditFieldRect.height + _swatchHeisht, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _alphaGradientHeisht); + private Rect _rgbGradientRect => new Rect(_curveEditor.leftmargin, _editFieldMarginsHeight + _editFieldHeight + _secondEditFieldRect.height + _swatchHeisht + _alphaGradientHeisht, _position.width - _curveEditor.leftmargin - _curveEditor.rightmargin, _rgbGradientHeisht); + + private Rect _curveEditorRect => new Rect(0, _gradientEditorHeisht, _position.width, _position.height - _gradientEditorHeisht); + + + private static readonly GUIContent[] s_XYZWLabels = {EditorGUIUtility.TextContent("R"), EditorGUIUtility.TextContent("G"), EditorGUIUtility.TextContent("B"), EditorGUIUtility.TextContent("A")}; + + + private static GUIStyle _style_PopupCurveEditorBackground; + public static GUIStyle style_PopupCurveEditorBackground => _style_PopupCurveEditorBackground ??= "PopupCurveEditorBackground"; + + #endregion + + #region Math + + private const float TOLERANCE = 0.00001f; + + private static bool Equal(float a, float b) => Math.Abs(a - b) < TOLERANCE; + + private static bool Equal(GradientEditor.Swatch a, GradientEditor.Swatch b) => + a == b + || (a != null && b != null && a.m_Time == b.m_Time && a.m_Value == b.m_Value && a.m_IsAlpha == b.m_IsAlpha); + + #endregion + + #region Fields + + #region Inputs + + private Rect _position; + internal LwguiGradient lwguiGradient; + internal ColorSpace colorSpace; + internal LwguiGradient.ChannelMask viewChannelMask; + internal LwguiGradient.GradientTimeRange gradientTimeRange; + private Action _onChange; + + #endregion + + private GradientEditor _gradientEditor; + private CurveEditor _curveEditor; + private bool _viewSettingschanged; + private bool _curveEditorContextMenuChanged; + private bool _changed; + private bool _lastChanged; + + #region Gradient Editor + + private static readonly string[] timeRangeMenuNames = new string[] { "0-1", "0-24", "0-2400" }; + private static readonly List timeRangeMenuValues = new () { LwguiGradient.GradientTimeRange.One, LwguiGradient.GradientTimeRange.TwentyFour, LwguiGradient.GradientTimeRange.TwentyFourHundred }; + + private GradientEditor.Swatch _selectedGradientKey + { + get => _gradientEditor.GetSelectedSwatch(); + set => _gradientEditor.SetSelectedSwatch(value); + } + + private GradientEditor.Swatch _lastSelectedGradientKey; + private GradientEditor.Swatch _deletedGradientKey; + + private List _gradientRGBSwatches => _gradientEditor.GetRGBdSwatches(); + private List _gradientAlphaSwatches => _gradientEditor.GetAlphaSwatches(); + private int _lastGradientRGBSwatchesCount; + private int _lastGradientAlphaSwatchesCount; + + private float _lastEditingTime = float.NegativeInfinity; + + private static bool _isAddGradientKeyFailure; + + #endregion + + + #region Curve Editor + + private List _selectedCurves + { + get => _curveEditor.selectedCurves; + set => _curveEditor.selectedCurves = value; + } + + private List _deletedCurveKeys; + + private bool _shouldSyncSelectionFromCurveToGradient; + + #endregion + + #endregion + + #region Gradient Editor + + private void InitGradientEditor(bool force = false) + { + if (_gradientEditor != null && !force) return; + + var lastSelectedGradientKey = _gradientEditor != null && _selectedGradientKey != null ? new GradientEditor.Swatch(_selectedGradientKey.m_Time, _selectedGradientKey.m_Value, _selectedGradientKey.m_IsAlpha) : null; + + var lwguiMergedCurves = new LwguiGradient.LwguiMergedColorCurves(lwguiGradient.rawCurves); + _gradientEditor ??= new GradientEditor(); + _gradientEditor.Init(lwguiMergedCurves.ToGradient(ReflectionHelper.maxGradientKeyCount), 1024, colorSpace == ColorSpace.Linear, colorSpace); + + // When Curve has only one key, Gradient Editor will automatically add a key + { + void FixAutoAddedGradientKey(List swatches, LwguiGradient.Channel channel) + { + if (swatches.Count == 2 && lwguiMergedCurves.curves[(int)channel].Count == 1) + { + swatches.Clear(); + var curveKey = lwguiMergedCurves.curves[(int)channel][0]; + swatches.Add(channel == LwguiGradient.Channel.Alpha + ? new GradientEditor.Swatch(curveKey.time, new Color(curveKey.value, curveKey.value, curveKey.value, curveKey.value), true) + : new GradientEditor.Swatch(curveKey.time, new Color( + lwguiMergedCurves.curves[(int)LwguiGradient.Channel.Red][0].value, + lwguiMergedCurves.curves[(int)LwguiGradient.Channel.Green][0].value, + lwguiMergedCurves.curves[(int)LwguiGradient.Channel.Blue][0].value, + 1), false)); + } + } + + FixAutoAddedGradientKey(_gradientRGBSwatches, LwguiGradient.Channel.Red); + FixAutoAddedGradientKey(_gradientAlphaSwatches, LwguiGradient.Channel.Alpha); + } + + // Keep selected key + if (lastSelectedGradientKey != null) + { + _selectedGradientKey = (lastSelectedGradientKey.m_IsAlpha ? _gradientAlphaSwatches : _gradientRGBSwatches) + .Find(swatch => Equal(swatch.m_Time, lastSelectedGradientKey.m_Time)); + } + else + { + _selectedGradientKey = null; + } + } + + private void OnGradientEditorGUI() + { + OnGradientEditFieldGUI(); + + EditorGUI.DrawPreviewTexture(_alphaGradientRect, lwguiGradient.GetPreviewRampTexture(1024, 1, colorSpace, LwguiGradient.ChannelMask.Alpha & viewChannelMask)); + EditorGUI.DrawPreviewTexture(_rgbGradientRect, lwguiGradient.GetPreviewRampTexture(1024, 1, colorSpace, LwguiGradient.ChannelMask.RGB & viewChannelMask)); + + // Swatch Array + { + PrepareSyncSelectionFromGradientToCurve(); + EditorGUI.BeginChangeCheck(); + ShowGradientSwatchArray(_alphaSwatchesRect, _gradientAlphaSwatches, LwguiGradient.ChannelMask.Alpha); + ShowGradientSwatchArray(_rgbSwatchesRect, _gradientRGBSwatches, LwguiGradient.ChannelMask.RGB); + if (EditorGUI.EndChangeCheck()) + { + _changed = true; + ApplyGradientChangesToCurve(); + } + + SyncSelectionFromGradientToCurveWithoutChanges(); + } + } + + private void OnGradientEditFieldGUI() + { + // Prevent interrupting mouse drag event + if (Event.current.type is EventType.MouseDrag or EventType.MouseDown or EventType.MouseMove or EventType.MouseUp + && (!_editFieldRect.Contains(Event.current.mousePosition) + && !_secondEditFieldRect.Contains(Event.current.mousePosition))) + return; + + float space = 20; + float vectorValueWidth = 270; + float locationWidth = 70; + float locationTextWidth = 35; + float alphaOrColorTextWidth = 40; + float colorSpaceTextWidth = 87; + float colorSpaceToggleWidth = 16; + float channelsTextWidth = 60; + float channelsMenuWidth = 85; + float timeRangeTextWidth = 75; + float timeRangeMenuWidth = 70; + + Rect rect = _editFieldRect; + + // Color Space + { + rect.x = rect.xMax - colorSpaceToggleWidth - colorSpaceTextWidth; + rect.width = colorSpaceTextWidth + colorSpaceToggleWidth; + var labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = colorSpaceTextWidth; + EditorGUI.BeginChangeCheck(); + colorSpace = EditorGUI.Toggle(rect, "sRGB Preview", colorSpace == ColorSpace.Gamma) ? ColorSpace.Gamma : ColorSpace.Linear; + if (EditorGUI.EndChangeCheck()) + { + _viewSettingschanged = true; + InitGradientEditor(true); + } + EditorGUIUtility.labelWidth = labelWidth; + } + + // View Channel Mask + { + rect.x -= space + channelsMenuWidth + channelsTextWidth; + rect.width = channelsMenuWidth + channelsTextWidth; + var labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = channelsTextWidth; + EditorGUI.BeginChangeCheck(); + viewChannelMask = (LwguiGradient.ChannelMask)EditorGUI.EnumFlagsField(rect, "Channels", viewChannelMask); + if (EditorGUI.EndChangeCheck()) + { + _viewSettingschanged = true; + InitGradientEditor(true); + InitCurveEditor(true); + } + EditorGUIUtility.labelWidth = labelWidth; + } + + // Gradient Time Range + { + rect.x -= space + timeRangeMenuWidth + timeRangeTextWidth; + rect.width = timeRangeMenuWidth + timeRangeTextWidth; + var labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = timeRangeTextWidth; + EditorGUI.BeginChangeCheck(); + + gradientTimeRange = timeRangeMenuValues[EditorGUI.Popup(rect, "Time Range", timeRangeMenuValues.IndexOf(gradientTimeRange), timeRangeMenuNames)]; + if (EditorGUI.EndChangeCheck()) + { + _viewSettingschanged = true; + InitGradientEditor(true); + InitCurveEditor(true); + } + EditorGUIUtility.labelWidth = labelWidth; + } + + // Key edit field (GradientEditor.OnGUI()) + if (_selectedCurves is { Count: > 0 }) + { + var labelWidth = EditorGUIUtility.labelWidth; + var showMixedValue = EditorGUI.showMixedValue; + var selectionInfo = new CurveSelectionInfo(_curveEditor); + + // Time + { + if (_useSignalLineEditField) + { + rect.x -= space + locationTextWidth + locationWidth; + } + else + { + rect = _secondEditFieldRect; + rect.x = rect.xMax - (locationTextWidth + locationWidth); + } + rect.width = locationTextWidth + locationWidth; + EditorGUIUtility.labelWidth = locationTextWidth; + EditorGUI.showMixedValue = selectionInfo.hasMixedTime; + EditorGUI.BeginChangeCheck(); + var newTime = EditorGUI.FloatField(rect, "Time", selectionInfo.selectedTime * (int)gradientTimeRange) / (int)gradientTimeRange; + // When two keys have the same time, they will be merged, so avoid modifying the time in real time and only apply the changes at the end of the change + var hasChange = EditorGUI.EndChangeCheck(); + if (hasChange) _lastEditingTime = newTime; + if (_lastEditingTime != selectionInfo.selectedTime + && _lastEditingTime != float.NegativeInfinity + // End editing text + && (EditorGUI.IsEditingTextField() && Event.current.keyCode is KeyCode.Return or KeyCode.KeypadEnter + // Mouse drag + || !EditorGUI.IsEditingTextField() && hasChange)) + { + _changed = true; + _curveEditor.SetSelectedKeyPositions(Mathf.Clamp01(_lastEditingTime), 0, true, false); + InitGradientEditor(true); + SyncSelectionFromCurveToGradient(true); + } + } + + // Vector Value + { + rect.x -= space + vectorValueWidth; + rect.width = vectorValueWidth; + // EditorGUI.VectorField() + { + int channelCount = (int)LwguiGradient.Channel.Num; + float w = (rect.width - (channelCount - 1) * EditorGUI.kSpacingSubLabel) / channelCount; + Rect nr = new Rect(rect) {width = w}; + int l = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + for (int c = 0; c < channelCount; c++) + { + EditorGUIUtility.labelWidth = EditorGUI.GetLabelWidth(s_XYZWLabels[c], 0); + EditorGUI.showMixedValue = selectionInfo.hasMixedChannelValue[c]; + EditorGUI.BeginChangeCheck(); + var newValue = EditorGUI.FloatField(nr, s_XYZWLabels[c], selectionInfo.selectedVectorValue[c]); + if (EditorGUI.EndChangeCheck()) + { + _changed = true; + // Apply a curve's modification + foreach (var selection in _selectedCurves.Where(selection => selection.curveID == c)) + { + var cw = _curveEditor.animationCurves[selection.curveID]; + var key = cw.curve.keys[selection.key]; + key.value = newValue; + cw.MoveKey(selection.key, ref key); + cw.changed = true; + AnimationUtility.UpdateTangentsFromMode(cw.curve); + } + _curveEditor.InvalidateSelectionBounds(); + InitGradientEditor(true); + SyncSelectionFromCurveToGradient(true); + } + nr.x += w + EditorGUI.kSpacingSubLabel; + } + EditorGUI.indentLevel = l; + } + } + + // Alpha or Color field + { + rect = new Rect(_editFieldRect.x, rect.y, rect.x - _editFieldRect.x - space, rect.height); + EditorGUIUtility.labelWidth = alphaOrColorTextWidth; + EditorGUI.BeginChangeCheck(); + if (selectionInfo.isOnlyColorKeySelected) + { + EditorGUI.showMixedValue = selectionInfo.hasMixedColorValue; + var newColorValue = new Vector4(selectionInfo.selectedVectorValue.x, selectionInfo.selectedVectorValue.y, selectionInfo.selectedVectorValue.z, 1); + newColorValue = EditorGUI.ColorField(rect, new GUIContent("Value"), newColorValue, true, false, colorSpace == ColorSpace.Linear); + newColorValue.w = selectionInfo.selectedVectorValue.w; + if (EditorGUI.EndChangeCheck()) + { + _changed = true; + // Use EventCommandNames.ColorPickerChanged event to avoid ShowSwatchArray() Errors + Event.current.Use(); + // Apply RGB curve's modification + foreach (var selection in _selectedCurves.Where(selection => selection.curveID < (int)LwguiGradient.Channel.Alpha)) + { + var channelID = selection.curveID; + var cw = _curveEditor.animationCurves[channelID]; + var key = cw.curve.keys[selection.key]; + key.value = newColorValue[channelID]; + cw.MoveKey(selection.key, ref key); + cw.changed = true; + AnimationUtility.UpdateTangentsFromMode(cw.curve); + } + _curveEditor.InvalidateSelectionBounds(); + InitGradientEditor(true); + } + } + else + { + EditorGUI.showMixedValue = selectionInfo.hasMixedFloatValue; + var newValue = EditorGUI.IntSlider(rect, "Value", (int)(selectionInfo.selectedFloatValue * 255), 0, 255) / 255f; + if (EditorGUI.EndChangeCheck()) + { + _changed = true; + _curveEditor.SetSelectedKeyPositions(0, newValue, false, true); + InitGradientEditor(true); + } + } + } + + EditorGUIUtility.labelWidth = labelWidth; + EditorGUI.showMixedValue = showMixedValue; + } + } + + private void ShowGradientSwatchArray(Rect rect, List swatches, LwguiGradient.ChannelMask drawingChannelMask) + { + // GradientEditor.ShowSwatchArray() + ReflectionHelper.GradientEditor_SetStyles(); + + _isAddGradientKeyFailure = false; + _gradientEditor.ShowSwatchArray(rect, (viewChannelMask & drawingChannelMask) != drawingChannelMask ? new List() : swatches, drawingChannelMask == LwguiGradient.ChannelMask.Alpha); + + // Since the maximum number of Gradient Keys is hard-coded in the engine, keys that exceed the limit can only be displayed and edited in the Curve Editor + if (_isAddGradientKeyFailure) + { + _changed = true; + _curveEditor.SelectNone(); + float mouseSwatchTime = _gradientEditor.GetTime((Event.current.mousePosition.x - rect.x) / rect.width); + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + { + if (!LwguiGradient.IsChannelIndexInMask(c, drawingChannelMask)) + continue; + + var curveSelection = _curveEditor.AddKeyAtTime(_curveEditor.animationCurves[c], mouseSwatchTime); + _curveEditor.AddSelection(curveSelection); + } + _curveEditor.InvalidateSelectionBounds(); + _selectedGradientKey = null; + } + } + + private void ApplyGradientChangesToCurve() + { + var selectedKeyEqual = _selectedGradientKey == _lastSelectedGradientKey || Equal(_selectedGradientKey, _lastSelectedGradientKey); + var rgbKeyCountEqual = _gradientRGBSwatches.Count == _lastGradientRGBSwatchesCount; + var alphaKeyCountEqual = _gradientAlphaSwatches.Count == _lastGradientAlphaSwatchesCount; + var addRGBKey = _gradientRGBSwatches.Count > _lastGradientRGBSwatchesCount; + var addAlphaKey = _gradientAlphaSwatches.Count > _lastGradientAlphaSwatchesCount; + var delRGBKey = _gradientRGBSwatches.Count < _lastGradientRGBSwatchesCount; + var delAlphaKey = _gradientAlphaSwatches.Count < _lastGradientAlphaSwatchesCount; + + if (selectedKeyEqual && rgbKeyCountEqual && alphaKeyCountEqual) + { + return; + } + + // Change time or value + if ((!selectedKeyEqual && rgbKeyCountEqual && alphaKeyCountEqual) + // Del a key + || (delRGBKey || delAlphaKey)) + { + foreach (var curveSelection in _selectedCurves.Where(selection => LwguiGradient.IsChannelIndexInMask(selection.curveID, viewChannelMask))) + { + var cw = _curveEditor.animationCurves[curveSelection.curveID]; + var selectedKey = cw.curve.keys[curveSelection.key]; + if (rgbKeyCountEqual && alphaKeyCountEqual) + { + var newKey = selectedKey; + + // Change a key time + if (_selectedGradientKey.m_Time != _lastSelectedGradientKey.m_Time) + { + newKey.time = _selectedGradientKey.m_Time; + } + // Change a key value + else if (_selectedGradientKey.m_Value != _lastSelectedGradientKey.m_Value) + { + newKey.value = _selectedGradientKey.m_IsAlpha ? _selectedGradientKey.m_Value.r : _selectedGradientKey.m_Value[curveSelection.curveID]; + } + newKey = CheckNewKeyTime(cw, newKey, selectedKey.time); + curveSelection.key = cw.MoveKey(curveSelection.key, ref newKey); + } + else + { + // Mouse drag out of the swatch rect, save the key + if (_selectedGradientKey != null) + { + _deletedGradientKey = new GradientEditor.Swatch(_selectedGradientKey.m_Time, _selectedGradientKey.m_Value, _selectedGradientKey.m_IsAlpha); + _deletedCurveKeys ??= new List(new Keyframe[(int)LwguiGradient.Channel.Num]); + _deletedCurveKeys[curveSelection.curveID] = selectedKey; + } + + // Del a key + cw.curve.RemoveKey(curveSelection.key); + } + AnimationUtility.UpdateTangentsFromMode(cw.curve); + cw.changed = true; + } + + if (delRGBKey || delAlphaKey) + _curveEditor.SelectNone(); + } + else + { + var curveSelections = new List(); + + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + { + if (!LwguiGradient.IsChannelIndexInMask(c, viewChannelMask)) + continue; + + // Add a RGB Key + if ((c < (int)LwguiGradient.Channel.Alpha && addRGBKey) + // Add an Alpha Key + || (c == (int)LwguiGradient.Channel.Alpha && addAlphaKey)) + { + var cw = _curveEditor.animationCurves[c]; + + // Mouse drag back to the swatch rect, restore the key + if (_deletedGradientKey != null && _deletedCurveKeys != null + && _selectedGradientKey?.m_Value == _deletedGradientKey?.m_Value + && _selectedGradientKey?.m_IsAlpha == _deletedGradientKey?.m_IsAlpha) + { + var deletedKey = _deletedCurveKeys[c]; + var newKey = deletedKey; + newKey.time = _selectedGradientKey.m_Time; + newKey = CheckNewKeyTime(cw, newKey, deletedKey.time); + var addedKeyIndex = cw.AddKey(newKey); + curveSelections.Add(new CurveSelection(c, addedKeyIndex, CurveSelection.SelectionType.Key)); + } + // Add a new key + else + { + var curveSelection = _curveEditor.AddKeyAtTime(cw, _selectedGradientKey.m_Time); + curveSelections.Add(curveSelection); + } + + cw.selected = CurveWrapper.SelectionMode.Selected; + cw.changed = true; + } + } + + _deletedGradientKey = null; + _deletedCurveKeys = null; + _curveEditor.SelectNone(); + curveSelections.ForEach(selection => _curveEditor.AddSelection(selection)); + InitGradientEditor(true); + } + + _curveEditor.InvalidateSelectionBounds(); + InitCurveEditor(true); + + // Cannot overlap with the Time of an existing Key when adding or moving Keys + Keyframe CheckNewKeyTime(CurveWrapper cw, Keyframe newKey, float oldKeyTime = 0) + { + try + { + var sameTimeKey = cw.curve.keys.First(keyframe => keyframe.time == newKey.time); + if (newKey.time > oldKeyTime) + newKey.time += 0.00001f; + else + newKey.time -= 0.00001f; + } + catch (InvalidOperationException) { } + + return newKey; + } + } + + private void PrepareSyncSelectionFromGradientToCurve() + { + _lastSelectedGradientKey = _selectedGradientKey != null ? new GradientEditor.Swatch(_selectedGradientKey.m_Time, _selectedGradientKey.m_Value, _selectedGradientKey.m_IsAlpha) : null; + _lastGradientRGBSwatchesCount = _gradientRGBSwatches.Count; + _lastGradientAlphaSwatchesCount = _gradientAlphaSwatches.Count; + } + + private void SyncSelectionFromGradientToCurveWithoutChanges() + { + // Only detect when switching selected Key without modifying it + if (!_gradientEditorRect.Contains(Event.current.mousePosition) + // || Event.current.type != EventType.MouseDown + || _changed + || _lastChanged + || Equal(_lastSelectedGradientKey, _selectedGradientKey)) + return; + + if (_selectedGradientKey == null) + { + _curveEditor.SelectNone(); + return; + } + + // Get selected gradient key index + var selectedGradientKeyIndexes = Enumerable.Repeat(-1, (int)LwguiGradient.Channel.Num).ToArray(); + + if (_selectedGradientKey.m_IsAlpha) + { + selectedGradientKeyIndexes[(int)LwguiGradient.Channel.Alpha] = _gradientAlphaSwatches.FindIndex(swatch => swatch == _selectedGradientKey); + } + else + { + for (int c = 0; c < (int)LwguiGradient.Channel.Num - 1; c++) + { + selectedGradientKeyIndexes[c] = _gradientRGBSwatches.FindIndex(swatch => swatch == _selectedGradientKey); + } + } + + // Get curve key index + _curveEditor.SelectNone(); + var lwguiMergedCurves = new LwguiGradient.LwguiMergedColorCurves(lwguiGradient.rawCurves); + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + { + if (selectedGradientKeyIndexes[c] < 0) + continue; + + var curveKeyIndex = lwguiMergedCurves.curves[c][selectedGradientKeyIndexes[c]].index; + _selectedCurves.Add(new CurveSelection(c, curveKeyIndex)); + } + _curveEditor.InvalidateSelectionBounds(); + } + + #endregion + + #region Curve Editor + + private void InitCurveEditor(bool force = false) + { + if (_curveEditor != null && !force) + return; + + var firstOpenWindow = _curveEditor == null; + _curveEditor = CurveEditorWindow.instance.GetCurveEditor(); + + var cws = new CurveWrapper[(int)LwguiGradient.Channel.Num]; + for (int c = 0; c < (int)LwguiGradient.Channel.Num; c++) + { + var curve = lwguiGradient.rawCurves[c]; + var cw = new CurveWrapper(); + cw.id = c; + if (LwguiGradient.IsChannelIndexInMask(c, viewChannelMask)) + { + cw.color = LwguiGradient.channelColors[c]; + cw.renderer = new NormalCurveRenderer(curve); + cw.renderer.SetWrap(curve.preWrapMode, curve.postWrapMode); + } + else + { + cw.renderer = new NormalCurveRenderer(new AnimationCurve()); + } + cws[c] = cw; + } + + _curveEditor.animationCurves = cws; + _curveEditor.curvesUpdated = () => + { + _curveEditorContextMenuChanged = true; + }; + + SyncCurveEditorRect(); + + if (firstOpenWindow) + { + _curveEditor.Frame(new Bounds(new Vector2(0.5f, 0.5f), Vector2.one), true, true); + _curveEditor.SelectNone(); + } + } + + private void OnCurveEditorGUI() + { + GUI.Label(_curveEditorRect, GUIContent.none, style_PopupCurveEditorBackground); + EditorGUI.DrawRect(new Rect(_curveEditorRect.x, _curveEditorRect.y, _curveEditorRect.width, 1), new Color(0.5f, 0.5f, 0.5f, 0.5f)); + + PrepareSyncSelectionFromCurveToGradient(); + EditorGUI.BeginChangeCheck(); + _curveEditor.OnGUI(); + bool curveEditorChanged = EditorGUI.EndChangeCheck() || _curveEditorContextMenuChanged; + _changed |= curveEditorChanged; + if (curveEditorChanged) + { + InitGradientEditor(true); + foreach (var cw in _curveEditor.animationCurves) + { + cw.changed = false; + } + _curveEditorContextMenuChanged = false; + } + SyncSelectionFromCurveToGradient(); + } + + private void SyncCurveEditorRect() + { + _curveEditor.rect = _curveEditorRect; + } + + private void PrepareSyncSelectionFromCurveToGradient() + { + // var eventType = Event.current.GetTypeForControl(GUIUtility.GetControlID(897560, FocusType.Passive)); // CurveEditor.SelectPoints() + var eventType = Event.current.type; + + if (_curveEditorRect.Contains(Event.current.mousePosition) + && eventType is EventType.MouseDown or EventType.MouseDrag) + _shouldSyncSelectionFromCurveToGradient = true; + } + + private void SyncSelectionFromCurveToGradient(bool force = false) + { + if (!_shouldSyncSelectionFromCurveToGradient && !force) + return; + + _shouldSyncSelectionFromCurveToGradient = false; + _selectedGradientKey = null; + + var selectedGradientKeys = new List(); + var mergedCurves = new CurveSelectionInfo(_curveEditor).mergedCurves; + + FindSelectedGradientKey((int)LwguiGradient.Channel.Red, _gradientRGBSwatches); + FindSelectedGradientKey((int)LwguiGradient.Channel.Alpha, _gradientAlphaSwatches); + + // Sync selection to Gradient Editor only when single selection + if (selectedGradientKeys.Count == 1) + _selectedGradientKey = selectedGradientKeys[0]; + return; + + void FindSelectedGradientKey(int channel, List list) + { + foreach (var lwguiKeyframe in mergedCurves.curves[channel]) + { + if (selectedGradientKeys.Count > 1) return; + + var key = list.Find(swatch => Equal(swatch.m_Time, lwguiKeyframe.time)); + if (key != null) + selectedGradientKeys.Add(key); + } + } + } + + #endregion + + #region Events + + public void Init(Rect position, LwguiGradient gradient, ColorSpace colorSpace = ColorSpace.Gamma, LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One, Action onChange = null) + { + Clear(); + + this._position = position; + this.lwguiGradient = gradient; + this.colorSpace = colorSpace; + this.viewChannelMask = viewChannelMask; + this.gradientTimeRange = timeRange; + this._onChange = onChange; + } + + public void OnGUI(Rect position) + { + if (lwguiGradient == null) + return; + + // Debug.Log(JsonUtility.ToJson(lwguiGradient)); + + this._position = position; + + InitGradientEditor(); + InitCurveEditor(); + + // Gradient Editor + OnGradientEditorGUI(); + + // Curve Editor + SyncCurveEditorRect(); + OnCurveEditorGUI(); + + _lastChanged = _changed; + _changed = false; + + if (_lastChanged) + { + if (!EditorApplication.isPlaying) + UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty(); + + GUI.changed = true; + _onChange?.Invoke(lwguiGradient); + } + + if (_viewSettingschanged) + { + _viewSettingschanged = false; + GUI.changed = true; + } + } + + public void Clear() + { + lwguiGradient = null; + _gradientEditor = null; + _curveEditor?.OnDisable(); + _curveEditor = null; + _lastChanged = false; + _lastEditingTime = float.NegativeInfinity; + } + + public static void CheckAddGradientKeyFailureLog(string logString, string stackTrace, LogType type) + { + if (type == LogType.Warning + && logString == "Max " + ReflectionHelper.maxGradientKeyCount + " color keys and " + ReflectionHelper.maxGradientKeyCount + " alpha keys are allowed in a gradient.") + { + _isAddGradientKeyFailure = true; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs.meta new file mode 100644 index 0000000..7976182 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0a472009f0e9429c8d503438262f3d34 +timeCreated: 1720769127 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs new file mode 100644 index 0000000..813689d --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs @@ -0,0 +1,195 @@ +// Copyright (c) Jason Ma + +using System; +using UnityEditor; +using UnityEngine; +using LWGUI.Runtime.LwguiGradient; + +namespace LWGUI.LwguiGradientEditor +{ + public static class LwguiGradientEditorHelper + { + private static readonly int s_LwguiGradientHash = "s_LwguiGradientHash".GetHashCode(); + private static int s_LwguiGradientID; + + // GradientEditor.DrawGradientWithBackground() + public static void DrawGradientWithBackground(Rect position, LwguiGradient gradient, ColorSpace colorSpace, LwguiGradient.ChannelMask viewChannelMask) + { + Texture2D gradientTexture = gradient.GetPreviewRampTexture(256, 1, colorSpace, viewChannelMask); + Rect r2 = new Rect(position.x + 1, position.y + 1, position.width - 2, position.height - 2); + + // Background checkers + Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture(); + Rect texCoordsRect = new Rect(0, 0, r2.width / backgroundTexture.width, r2.height / backgroundTexture.height); + GUI.DrawTextureWithTexCoords(r2, backgroundTexture, texCoordsRect, false); + + // Outline for Gradinet Texture, used to be Frame over texture. + // LWGUI: GUI.Box() will cause subsequent attributes to be unable to be selected + // GUI.Box(position, GUIContent.none); + + // Gradient texture + Color oldColor = GUI.color; + GUI.color = Color.white; //Dont want the Playmode tint to be applied to gradient textures. + if (gradientTexture != null) + GUI.DrawTexture(r2, gradientTexture, ScaleMode.StretchToFill, true); + GUI.color = oldColor; + + // HDR label + // float maxColorComponent = GetMaxColorComponent(gradient); + // if (maxColorComponent > 1.0f) + // { + // GUI.Label(new Rect(position.x, position.y, position.width - 3, position.height), "HDR", EditorStyles.centeredGreyMiniLabel); + // } + } + + public static void DrawGradientWithSeparateAlphaChannel(Rect position, LwguiGradient gradient, ColorSpace colorSpace, LwguiGradient.ChannelMask viewChannelMask) + { + if (!LwguiGradient.HasChannelMask(viewChannelMask, LwguiGradient.ChannelMask.Alpha) || viewChannelMask == LwguiGradient.ChannelMask.Alpha) + { + DrawGradientWithBackground(position, gradient, colorSpace, viewChannelMask); + } + else + { + var r2 = new Rect(position.x + 1, position.y + 1, position.width - 2, position.height - 2); + var rgbRect = new Rect(r2.x, r2.y, r2.width, r2.height * 0.8f); + var alphaRect = new Rect(rgbRect.x, rgbRect.yMax, r2.width, r2.height * 0.2f); + + var rgbTexture = gradient.GetPreviewRampTexture(256, 1, colorSpace, viewChannelMask ^ LwguiGradient.ChannelMask.Alpha); + var alphaTexture = gradient.GetPreviewRampTexture(256, 1, colorSpace, LwguiGradient.ChannelMask.Alpha); + + Color oldColor = GUI.color; + GUI.color = Color.white; //Dont want the Playmode tint to be applied to gradient textures. + GUI.DrawTexture(rgbRect, rgbTexture, ScaleMode.StretchToFill, false); + GUI.DrawTexture(alphaRect, alphaTexture, ScaleMode.StretchToFill, false); + GUI.color = oldColor; + } + } + + public static void GradientField(Rect position, GUIContent label, LwguiGradient gradient, + ColorSpace colorSpace = ColorSpace.Gamma, + LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, + LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One, + Action onOpenWindow = null) + { + int id = GUIUtility.GetControlID(s_LwguiGradientHash, FocusType.Keyboard, position); + var rect = EditorGUI.PrefixLabel(position, id, label); + var evt = Event.current; + + + // internal static Gradient DoGradientField(Rect position, int id, Gradient value, SerializedProperty property, bool hdr, ColorSpace space) + switch (evt.GetTypeForControl(id)) + { + case EventType.MouseDown: + if (rect.Contains(evt.mousePosition)) + { + if (evt.button == 0) + { + s_LwguiGradientID = id; + GUIUtility.keyboardControl = id; + LwguiGradientWindow.Show(gradient, colorSpace, viewChannelMask, timeRange, GUIView.current); + onOpenWindow?.Invoke(); + GUIUtility.ExitGUI(); + } + else if (evt.button == 1) + { + // if (property != null) + // GradientContextMenu.Show(property.Copy()); + // // TODO: make work for Gradient value + } + } + break; + case EventType.KeyDown: + if (GUIUtility.keyboardControl == id && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)) + { + evt.Use(); + LwguiGradientWindow.Show(gradient, colorSpace, viewChannelMask, timeRange, GUIView.current); + onOpenWindow?.Invoke(); + GUIUtility.ExitGUI(); + } + + break; + case EventType.Repaint: + DrawGradientWithSeparateAlphaChannel(rect, gradient, colorSpace, viewChannelMask); + break; + case EventType.ExecuteCommand: + // When drawing the modifying Gradient Field and it has changed + if ((GUIUtility.keyboardControl == id || s_LwguiGradientID == id) + && (evt.commandName is LwguiGradientWindow.LwguiGradientChangedCommand)) + { + GUI.changed = true; + LwguiGradientHelper.ClearRampPreviewCaches(); + HandleUtility.Repaint(); + } + break; + case EventType.ValidateCommand: + // Sync Undo/Redo result to editor window + if (s_LwguiGradientID == id && evt.commandName == "UndoRedoPerformed") + { + LwguiGradientWindow.UpdateCurrentGradient(gradient); + } + break; + } + } + + /// Lwgui Gradient Field with full Undo/Redo/ContextMenu functions + public static void GradientField(Rect position, GUIContent label, SerializedProperty property, LwguiGradient gradient, + ColorSpace colorSpace = ColorSpace.Gamma, + LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, + LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One) + { + label = EditorGUI.BeginProperty(position, label, property); + EditorGUI.BeginChangeCheck(); + + GradientField(position, label, gradient, colorSpace, viewChannelMask, timeRange, + () => LwguiGradientWindow.RegisterSerializedObjectUndo(property.serializedObject.targetObject)); + + if (EditorGUI.EndChangeCheck()) + { + GUI.changed = true; + LwguiGradientWindow.RegisterSerializedObjectUndo(property.serializedObject.targetObject); + } + EditorGUI.EndProperty(); + } + + public static bool GradientEditButton(Rect position, GUIContent icon, LwguiGradient gradient, + ColorSpace colorSpace = ColorSpace.Gamma, + LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, + LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One, + Func shouldOpenWindowAfterClickingEvent = null) + { + int id = GUIUtility.GetControlID(s_LwguiGradientHash, FocusType.Keyboard, position); + var evt = Event.current; + + // When drawing the modifying Gradient Field and it has changed + if ((GUIUtility.keyboardControl == id || s_LwguiGradientID == id) + && evt.GetTypeForControl(id) == EventType.ExecuteCommand + && evt.commandName == LwguiGradientWindow.LwguiGradientChangedCommand) + { + GUI.changed = true; + HandleUtility.Repaint(); + } + + // Sync Undo/Redo result to editor window + if (s_LwguiGradientID == id + && evt.commandName == "UndoRedoPerformed") + { + LwguiGradientWindow.UpdateCurrentGradient(gradient); + } + + // Open editor window + var clicked = ReflectionHelper.GUI_Button(position, id, icon, GUI.skin.button); + if (clicked) + { + if (shouldOpenWindowAfterClickingEvent == null || shouldOpenWindowAfterClickingEvent.Invoke()) + { + s_LwguiGradientID = id; + GUIUtility.keyboardControl = id; + LwguiGradientWindow.Show(gradient, colorSpace, viewChannelMask, timeRange, GUIView.current); + GUIUtility.ExitGUI(); + } + } + + return clicked; + } + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs.meta new file mode 100644 index 0000000..fae178b --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientEditorHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 016014c82cb94b5d9f271b1b06986541 +timeCreated: 1720424032 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs new file mode 100644 index 0000000..d53cfb2 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs @@ -0,0 +1,117 @@ +// Copyright (c) Jason Ma + +using System.Collections.Generic; +using LWGUI.Runtime.LwguiGradient; +using UnityEditor; +using UnityEngine; +using UnityEngine.Serialization; + +namespace LWGUI.LwguiGradientEditor +{ + [ExcludeFromPreset] + class LwguiGradientPresetLibrary : PresetLibrary + { + [SerializeField] + List m_Presets = new List(); + + public override int Count() + { + return m_Presets.Count; + } + + public override object GetPreset(int index) + { + return m_Presets[index].lwguiGradient; + } + + public override void Add(object presetObject, string presetName) + { + LwguiGradient gradient = presetObject as LwguiGradient; + if (gradient == null) + { + Debug.LogError("Wrong type used in LwguiGradientPresetLibrary"); + return; + } + + m_Presets.Add(new LwguiGradientPreset(new LwguiGradient(gradient), presetName)); + } + + public override void Replace(int index, object newPresetObject) + { + LwguiGradient gradient = newPresetObject as LwguiGradient; + if (gradient == null) + { + Debug.LogError("Wrong type used in LwguiGradientPresetLibrary"); + return; + } + + m_Presets[index].lwguiGradient = new LwguiGradient(gradient); + } + + public override void Remove(int index) + { + m_Presets.RemoveAt(index); + } + + public override void Move(int index, int destIndex, bool insertAfterDestIndex) + { + PresetLibraryHelpers.MoveListItem(m_Presets, index, destIndex, insertAfterDestIndex); + } + + public override void Draw(Rect rect, int index) + { + Draw(rect, m_Presets[index].lwguiGradient, ColorSpace.Gamma, LwguiGradient.ChannelMask.All); + } + + public override void Draw(Rect rect, object presetObject) + { + Draw(rect, presetObject as LwguiGradient, ColorSpace.Gamma, LwguiGradient.ChannelMask.All); + } + + public void Draw(Rect rect, LwguiGradient gradient, ColorSpace colorSpace, LwguiGradient.ChannelMask viewChannelMask) + { + if (gradient == null) + return; + LwguiGradientEditorHelper.DrawGradientWithSeparateAlphaChannel(rect, gradient, colorSpace, viewChannelMask); + } + + public override string GetName(int index) + { + return m_Presets[index].name; + } + + public override void SetName(int index, string presetName) + { + m_Presets[index].name = presetName; + } + + + [System.Serializable] + class LwguiGradientPreset + { + [SerializeField] + string m_Name; + + [SerializeField] + LwguiGradient m_LwguiGradient; + + public LwguiGradientPreset(LwguiGradient preset, string presetName) + { + lwguiGradient = preset; + name = presetName; + } + + public LwguiGradient lwguiGradient + { + get => m_LwguiGradient; + set => m_LwguiGradient = value; + } + + public string name + { + get => m_Name; + set => m_Name = value; + } + } + } +} diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs.meta new file mode 100644 index 0000000..e362d70 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibrary.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6aa6b41078c94b978a355082d28769f0 +timeCreated: 1721013180 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs new file mode 100644 index 0000000..fd1a51b --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs @@ -0,0 +1,40 @@ +// Copyright (c) Jason Ma + +using LWGUI.Runtime.LwguiGradient; +using UnityEditor; +using UnityEngine; + +namespace LWGUI.LwguiGradientEditor +{ + [CustomEditor(typeof(LwguiGradientPresetLibrary))] + internal class LwguiGradientPresetLibraryEditor : Editor + { + private GenericPresetLibraryInspector m_GenericPresetLibraryInspector; + + public void OnEnable() + { + m_GenericPresetLibraryInspector = new GenericPresetLibraryInspector(target, "Lwgui Gradient Preset Library", OnEditButtonClicked) + { + presetSize = new Vector2(72, 16), + lineSpacing = 4f + }; + } + + public void OnDestroy() + { + m_GenericPresetLibraryInspector?.OnDestroy(); + } + + public override void OnInspectorGUI() + { + m_GenericPresetLibraryInspector.itemViewMode = PresetLibraryEditorState.GetItemViewMode("LwguiGradient"); // ensure in-sync + m_GenericPresetLibraryInspector?.OnInspectorGUI(); + } + + private void OnEditButtonClicked(string libraryPath) + { + LwguiGradientWindow.Show(new LwguiGradient()); + LwguiGradientWindow.instance.currentPresetLibrary = libraryPath; + } + } +} // namespace diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs.meta new file mode 100644 index 0000000..5f7dca0 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientPresetLibraryInspector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c5050da63672448d8f12cf3c82e12a6a +timeCreated: 1721013226 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs new file mode 100644 index 0000000..e2180a9 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs @@ -0,0 +1,318 @@ +// Copyright (c) Jason Ma + +using System; +using UnityEngine; +using UnityEditor; +using LWGUI.Runtime.LwguiGradient; +using UnityEngine.Serialization; +using Object = UnityEngine.Object; + +namespace LWGUI.LwguiGradientEditor +{ + internal class PresetLibraryLwguiGradientEditor : PresetLibraryEditor + { + public PresetLibraryLwguiGradientEditor(ScriptableObjectSaveLoadHelper helper, + PresetLibraryEditorState state, + Action itemClickedCallback + ) : base(helper, state, itemClickedCallback) + {} + + public ColorSpace colorSpace { get; set; } + public LwguiGradient.ChannelMask viewChannelMask { get; set; } + + protected override void DrawPreset(PresetLibrary lib, Rect rect, object presetObject) + { + ((LwguiGradientPresetLibrary)lib).Draw(rect, presetObject as LwguiGradient, colorSpace, viewChannelMask); + } + } + + public class LwguiGradientWindow : EditorWindow + { + #region Fields + + private static LwguiGradientWindow _lwguiGradientWindow; + public const string presetsEditorPrefID = "LwguiGradient"; + + private LwguiGradientEditor _lwguiGradientEditor; + private PresetLibraryLwguiGradientEditor _lwguiGradientLibraryEditor; + [SerializeField] private PresetLibraryEditorState _LwguiGradientLibraryEditorState; + + [NonSerialized] public LwguiGradient lwguiGradient; + [NonSerialized] public ColorSpace colorSpace; + [NonSerialized] public LwguiGradient.ChannelMask viewChannelMask; + [NonSerialized] public LwguiGradient.GradientTimeRange gradientTimeRange; + + private GUIView _viewToUpdate; + private Action _onChange; + + #endregion + + #region GUI Layout + + private static readonly Vector2 _minWindowSize = new (750, 500); + private static readonly float _presetLibraryHeight = 100; + private Rect _gradientEditorRect => new Rect(0, 0, position.width, position.height - _presetLibraryHeight); + private Rect _presetLibraryRect => new Rect(0, position.height - _presetLibraryHeight, position.width, _presetLibraryHeight); + + #endregion + + public static LwguiGradientWindow instance + { + get + { + if (!_lwguiGradientWindow) + Debug.LogError("Lwgui Gradient Window not initalized, did you call Show first?"); + return _lwguiGradientWindow; + } + } + + public string currentPresetLibrary + { + get + { + Init(false); + return _lwguiGradientLibraryEditor.currentLibraryWithoutExtension; + } + set + { + Init(false); + _lwguiGradientLibraryEditor.currentLibraryWithoutExtension = value; + } + } + + public static bool visible => _lwguiGradientWindow != null; + + public void Init(bool force = true, bool forceRecreate = false) + { + if (_lwguiGradientEditor == null || force || forceRecreate) + { + if (_lwguiGradientEditor == null || forceRecreate) + { + _lwguiGradientEditor = new LwguiGradientEditor(); + } + _lwguiGradientEditor.Init(_gradientEditorRect, lwguiGradient, colorSpace, viewChannelMask, gradientTimeRange, _onChange); + } + + if (_LwguiGradientLibraryEditorState == null || forceRecreate) + { + _LwguiGradientLibraryEditorState = new PresetLibraryEditorState(presetsEditorPrefID); + _LwguiGradientLibraryEditorState.TransferEditorPrefsState(true); + } + + if (_lwguiGradientLibraryEditor == null || force || forceRecreate) + { + if (_lwguiGradientLibraryEditor == null || forceRecreate) + { + var saveLoadHelper = new ScriptableObjectSaveLoadHelper("lwguigradients", SaveType.Text); + _lwguiGradientLibraryEditor = new PresetLibraryLwguiGradientEditor(saveLoadHelper, _LwguiGradientLibraryEditorState, PresetClickedCallback); + UpdatePresetLibraryViewSettings(); + } + _lwguiGradientLibraryEditor.showHeader = true; + _lwguiGradientLibraryEditor.minMaxPreviewHeight = new Vector2(14f, 14f); + } + } + + void UpdatePresetLibraryViewSettings() + { + _lwguiGradientLibraryEditor.colorSpace = _lwguiGradientEditor.colorSpace; + _lwguiGradientLibraryEditor.viewChannelMask = _lwguiGradientEditor.viewChannelMask; + } + + /// Used to modify the LwguiGradient value externally, such as: Undo/Redo/Select Preset + public static void UpdateCurrentGradient(LwguiGradient newGradient, bool doDeepCopy = false) + { + if (_lwguiGradientWindow == null) + return; + + if (doDeepCopy) + { + _lwguiGradientWindow.lwguiGradient.DeepCopyFrom(newGradient); + } + else + { + _lwguiGradientWindow.lwguiGradient = newGradient; + } + // Debug.Log("Update"); + _lwguiGradientWindow.Init(); + _lwguiGradientWindow.Repaint(); + GUI.changed = true; + LwguiGradientHelper.ClearRampPreviewCaches(); + } + + private static LwguiGradientWindow GetWindow(bool focus = true) => (LwguiGradientWindow)GetWindow(typeof(LwguiGradientWindow), true, "LWGUI Gradient Editor", focus); + + internal static void Show(LwguiGradient gradient, ColorSpace colorSpace = ColorSpace.Gamma, LwguiGradient.ChannelMask viewChannelMask = LwguiGradient.ChannelMask.All, LwguiGradient.GradientTimeRange timeRange = LwguiGradient.GradientTimeRange.One, GUIView viewToUpdate = null, Action onChange = null) + { + if (_lwguiGradientWindow == null) + { + _lwguiGradientWindow = GetWindow(); + _lwguiGradientWindow.minSize = _minWindowSize; + _lwguiGradientWindow.RegisterEvents(); + } + else + { + _lwguiGradientWindow = GetWindow(); + } + + _lwguiGradientWindow.lwguiGradient = gradient; + _lwguiGradientWindow.colorSpace = colorSpace; + _lwguiGradientWindow.viewChannelMask = viewChannelMask; + _lwguiGradientWindow.gradientTimeRange = timeRange; + _lwguiGradientWindow._viewToUpdate = viewToUpdate; + _lwguiGradientWindow._onChange = onChange; + + _lwguiGradientWindow.Init(); + _lwguiGradientWindow.Show(); + // window.ShowAuxWindow(); + + LwguiGradientHelper.ClearRampPreviewCaches(); + } + + public static void CloseWindow() + { + if (_lwguiGradientWindow == null) + return; + + _lwguiGradientWindow.UnregisterEvents(); + _lwguiGradientWindow.Close(); + // GUIUtility.ExitGUI(); + } + + public static void RepaintWindow() + { + if (_lwguiGradientWindow == null) + return; + _lwguiGradientWindow.Repaint(); + } + + public static void RegisterSerializedObjectUndo(Object targetObject) + { + Undo.RegisterCompleteObjectUndo(targetObject, "Lwgui Gradient Editor"); + EditorUtility.SetDirty(targetObject); + } + + public static void RegisterRampMapUndo(Object texture, Object assetImporter) + { + Undo.RecordObjects(new Object[]{ texture, assetImporter }, "Set Lwgui Gradient To Texture"); + EditorUtility.SetDirty(texture); + EditorUtility.SetDirty(assetImporter); + } + + private void OnGUI() + { + if (lwguiGradient == null) + return; + + Init(false); + + // Separator + EditorGUI.DrawRect(new Rect(_presetLibraryRect.x, _presetLibraryRect.y - 1, _presetLibraryRect.width, 1), new Color(0, 0, 0, 0.3f)); + EditorGUI.DrawRect(new Rect(_presetLibraryRect.x, _presetLibraryRect.y, _presetLibraryRect.width, 1), new Color(1, 1, 1, 0.1f)); + + + EditorGUI.BeginChangeCheck(); + _lwguiGradientEditor.OnGUI(_gradientEditorRect); + _lwguiGradientLibraryEditor.OnGUI(_presetLibraryRect, lwguiGradient); + if (EditorGUI.EndChangeCheck()) + { + LwguiGradientHelper.ClearRampPreviewCaches(); + UpdatePresetLibraryViewSettings(); + SendEvent(true); + } + } + + public const string LwguiGradientChangedCommand = "LwguiGradientChanged"; + + void SendEvent(bool exitGUI) + { + if (_viewToUpdate != null) + { + Event e = EditorGUIUtility.CommandEvent(LwguiGradientChangedCommand); + Repaint(); + _viewToUpdate.SendEvent(e); + if (exitGUI) + GUIUtility.ExitGUI(); + } + if (_onChange != null) + { + _onChange(lwguiGradient); + } + } + + private void OnEnable() + { + Application.logMessageReceived += LwguiGradientEditor.CheckAddGradientKeyFailureLog; + hideFlags = HideFlags.DontSave; + } + + private void OnDisable() + { + Application.logMessageReceived -= LwguiGradientEditor.CheckAddGradientKeyFailureLog; + + _LwguiGradientLibraryEditorState?.TransferEditorPrefsState(false); + + UnregisterEvents(); + Clear(); + } + + private void OnDestroy() + { + UnregisterEvents(); + _lwguiGradientLibraryEditor?.UnloadUsedLibraries(); + + Clear(); + } + + private void Clear() + { + _lwguiGradientEditor = null; + _lwguiGradientWindow = null; + _lwguiGradientLibraryEditor = null; + } + + private void RegisterEvents() + { +#if UNITY_2022_2_OR_NEWER + Undo.undoRedoEvent += OnUndoPerformed; +#endif + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; + } + + private void UnregisterEvents() + { +#if UNITY_2022_2_OR_NEWER + Undo.undoRedoEvent -= OnUndoPerformed; +#endif + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; + } + + #region Call Backs + +#if UNITY_2022_2_OR_NEWER + private void OnUndoPerformed(in UndoRedoInfo info) + { + // Debug.Log("Init"); + _lwguiGradientWindow.Init(); + _lwguiGradientWindow.Repaint(); + } +#endif + + void OnPlayModeStateChanged(PlayModeStateChange state) + { + Close(); + } + + void PresetClickedCallback(int clickCount, object presetObject) + { + LwguiGradient gradient = presetObject as LwguiGradient; + if (gradient == null) + Debug.LogError("Incorrect object passed " + presetObject); + + UpdateCurrentGradient(gradient, true); + // UnityEditorInternal.GradientPreviewCache.ClearCache(); + // LwguiGradientHelper.ClearRampPreviewCaches(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs.meta new file mode 100644 index 0000000..257d80d --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/LwguiGradientEditor/LwguiGradientWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 097db44e7f52445b80daf9c3c3e9f26b +timeCreated: 1716795885 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md new file mode 100644 index 0000000..f57ec94 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88860e5608ea81fdf6fc157eab86b84dce83707188b99d0eafc1a427f174f4fa +size 2713 diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md.meta new file mode 100644 index 0000000..5b2df73 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5d0d1d146a4108b4ebb49ce891131f50 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs new file mode 100644 index 0000000..408b376 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs @@ -0,0 +1,242 @@ +// Copyright (c) Jason Ma + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace LWGUI +{ + public static class ReflectionHelper + { + #region MaterialPropertyHandler + + private static readonly Type MaterialPropertyHandler_Type = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.MaterialPropertyHandler"); + private static readonly MethodInfo MaterialPropertyHandler_GetHandler_Method = MaterialPropertyHandler_Type.GetMethod("GetHandler", BindingFlags.Static | BindingFlags.NonPublic); + private static readonly PropertyInfo MaterialPropertyHandler_PropertyDrawer_Property = MaterialPropertyHandler_Type.GetProperty("propertyDrawer"); + private static readonly FieldInfo MaterialPropertyHandler_DecoratorDrawers_Field = MaterialPropertyHandler_Type.GetField("m_DecoratorDrawers", BindingFlags.NonPublic | BindingFlags.Instance); + + public static MaterialPropertyDrawer GetPropertyDrawer(Shader shader, MaterialProperty prop, out List decoratorDrawers) + { + decoratorDrawers = new List(); + var handler = MaterialPropertyHandler_GetHandler_Method.Invoke(null, new object[] { shader, prop.name }); + if (handler != null && handler.GetType() == MaterialPropertyHandler_Type) + { + decoratorDrawers = MaterialPropertyHandler_DecoratorDrawers_Field.GetValue(handler) as List; + return MaterialPropertyHandler_PropertyDrawer_Property.GetValue(handler, null) as MaterialPropertyDrawer; + } + + return null; + } + + public static MaterialPropertyDrawer GetPropertyDrawer(Shader shader, MaterialProperty prop) + { + return GetPropertyDrawer(shader, prop, out _); + } + + #endregion + + + #region MaterialEditor + + public static float DoPowerRangeProperty(Rect position, MaterialProperty prop, GUIContent label, float power) + { + return MaterialEditor.DoPowerRangeProperty(position, prop, label, power); + } + + public static void DefaultShaderPropertyInternal(this MaterialEditor editor, Rect position, MaterialProperty prop, GUIContent label) + { + editor.DefaultShaderPropertyInternal(position, prop, label); + } + + public static List GetMeshRenderersByMaterialEditor(this MaterialEditor materialEditor) + { + var outRenderers = new List(); + + // MaterialEditor.ShouldEditorBeHidden() + PropertyEditor property = materialEditor.propertyViewer as PropertyEditor; + if (property) + { + GameObject gameObject = property.tracker.activeEditors[0].target as GameObject; + if (gameObject) + { + outRenderers.AddRange(gameObject.GetComponents()); + outRenderers.AddRange(gameObject.GetComponents()); + } + } + + return outRenderers; + } + + #endregion + + + #region EditorUtility + + public static void DisplayCustomMenuWithSeparators(Rect position, string[] options, bool[] enabled, bool[] separator, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData = null, bool showHotkey = false) + { + EditorUtility.DisplayCustomMenuWithSeparators(position, options, enabled, separator, selected, callback, userData, showHotkey); + } + + #endregion + + + #region EditorGUI + + public static float EditorGUI_Indent => EditorGUI.indentLevel; + + #endregion + + #region EditorGUILayout + + public static float EditorGUILayout_kLabelFloatMinW => EditorGUILayout.kLabelFloatMinW; + + #endregion + + + #region MaterialEnumDrawer + + // UnityEditor.MaterialEnumDrawer(string enumName) + private static Type[] _types; + + public static Type[] GetAllTypes() + { + if (_types == null) + { + _types = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(assembly => + { + if (assembly == null) + return Type.EmptyTypes; + try + { + return assembly.GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + Debug.LogError(ex); + return Type.EmptyTypes; + } + }).ToArray(); + } + + return _types; + } + + #endregion + + + #region MaterialProperty.PropertyData + +#if UNITY_2022_1_OR_NEWER + private static readonly Type MaterialProperty_Type = typeof(MaterialProperty); + private static readonly Type PropertyData_Type = MaterialProperty_Type.GetNestedType("PropertyData", BindingFlags.NonPublic); + private static readonly MethodInfo PropertyData_MergeStack_Method = PropertyData_Type.GetMethod("MergeStack", BindingFlags.Static | BindingFlags.NonPublic); + private static readonly MethodInfo PropertyData_HandleApplyRevert_Method = PropertyData_Type.GetMethod("HandleApplyRevert", BindingFlags.Static | BindingFlags.NonPublic); + + public static void HandleApplyRevert(GenericMenu menu, MaterialProperty prop) + { + var parameters = new object[3]; + PropertyData_MergeStack_Method.Invoke(null, parameters); + var overriden = (bool)parameters[2]; + var singleEditing = prop.targets.Length == 1; + + if (overriden) + { + PropertyData_HandleApplyRevert_Method.Invoke(null, new object[] { menu, singleEditing, prop.targets }); + menu.AddSeparator(""); + } + } +#endif + + #endregion + + #region GUI + + private static readonly MethodInfo gui_Button_Method = typeof(GUI).GetMethod("Button", BindingFlags.Static | BindingFlags.NonPublic); + + public static bool GUI_Button(Rect position, int id, GUIContent content, GUIStyle style) + { + return (bool)gui_Button_Method.Invoke(null, new object[] { position, id, content, style }); + } + + #endregion + + #region GradientEditor + + private static readonly FieldInfo k_MaxNumKeys_Field = typeof(GradientEditor).GetField("k_MaxNumKeys", BindingFlags.Static | BindingFlags.NonPublic); + public static readonly int maxGradientKeyCount = (int)k_MaxNumKeys_Field.GetValue(null); + + + private static readonly FieldInfo m_SelectedSwatch_Field = typeof(GradientEditor).GetField("m_SelectedSwatch", BindingFlags.Instance | BindingFlags.NonPublic); + internal static GradientEditor.Swatch GetSelectedSwatch(this GradientEditor gradientEditor) + { + return m_SelectedSwatch_Field.GetValue(gradientEditor) as GradientEditor.Swatch; + } + + internal static void SetSelectedSwatch(this GradientEditor gradientEditor, GradientEditor.Swatch swatch) + { + m_SelectedSwatch_Field.SetValue(gradientEditor, swatch); + } + + + private static readonly FieldInfo m_RGBSwatches_Field = typeof(GradientEditor).GetField("m_RGBSwatches", BindingFlags.Instance | BindingFlags.NonPublic); + internal static List GetRGBdSwatches(this GradientEditor gradientEditor) + { + return m_RGBSwatches_Field.GetValue(gradientEditor) as List; + } + + + private static readonly FieldInfo m_AlphaSwatches_Field = typeof(GradientEditor).GetField("m_AlphaSwatches", BindingFlags.Instance | BindingFlags.NonPublic); + internal static List GetAlphaSwatches(this GradientEditor gradientEditor) + { + return m_AlphaSwatches_Field.GetValue(gradientEditor) as List; + } + + + private static object s_Styles_Value; + private static readonly FieldInfo s_Styles_Field = typeof(GradientEditor).GetField("s_Styles", BindingFlags.Static | BindingFlags.NonPublic); + public static void GradientEditor_SetStyles() + { + s_Styles_Value ??= Activator.CreateInstance(typeof(GradientEditor).GetNestedType("Styles", BindingFlags.NonPublic)); + s_Styles_Field.SetValue(null, s_Styles_Value); + } + + + private static readonly MethodInfo ShowSwatchArray_Method = typeof(GradientEditor) + .GetMethod("ShowSwatchArray", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Rect), typeof(List), typeof(bool) }, null); + + internal static void ShowSwatchArray(this GradientEditor gradientEditor, Rect position, List swatches, bool isAlpha) + { + ShowSwatchArray_Method.Invoke(gradientEditor, new object[] { position, swatches, isAlpha }); + } + + + private static readonly MethodInfo GetTime_Method = typeof(GradientEditor).GetMethod("GetTime", BindingFlags.Instance | BindingFlags.NonPublic); + internal static float GetTime(this GradientEditor gradientEditor, float actualTime) + { + return (float)GetTime_Method.Invoke(gradientEditor, new object[] { actualTime }); + } + + #endregion + + #region CurveEditor + + private static readonly FieldInfo m_CurveEditor_Field = typeof(CurveEditorWindow).GetField("m_CurveEditor", BindingFlags.Instance | BindingFlags.NonPublic); + internal static CurveEditor GetCurveEditor(this CurveEditorWindow curveEditorWindow) + { + return m_CurveEditor_Field.GetValue(curveEditorWindow) as CurveEditor; + } + + + private static readonly MethodInfo AddKeyAtTime_Method = typeof(CurveEditor).GetMethod("AddKeyAtTime", BindingFlags.Instance | BindingFlags.NonPublic); + internal static CurveSelection AddKeyAtTime(this CurveEditor curveEditor, CurveWrapper cw, float time) + { + return AddKeyAtTime_Method.Invoke(curveEditor, new object[] { cw, time }) as CurveSelection; + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs.meta similarity index 100% rename from Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/Editor/Helper/ReflectionHelper.cs.meta rename to Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/ReflectionHelper.cs.meta diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef new file mode 100644 index 0000000..d8bef4a --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef @@ -0,0 +1,18 @@ +{ + "name": "Unity.InternalAPIEditorBridge.020", + "rootNamespace": "", + "references": [ + "LWGUI.Runtime" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef.meta new file mode 100644 index 0000000..a47944c --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/Unity.InternalAPIEditorBridge.020.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d40b1b73ac7645c43af711c92abd00b3 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs new file mode 100644 index 0000000..a24c73c --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs @@ -0,0 +1,57 @@ +// Copyright (c) Jason Ma + +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace LWGUI +{ + public static class UnityEditorExtension + { + + #region MaterialEditor + + // For Developers: Call this after a material has modified in code + public static void ApplyMaterialPropertyAndDecoratorDrawers(Material material) + { + var objs = new Object[] { material }; + ApplyMaterialPropertyAndDecoratorDrawers(objs); + } + + // Called after edit or undo + public static void ApplyMaterialPropertyAndDecoratorDrawers(Object[] targets) + { + if (!EditorMaterialUtility.disableApplyMaterialPropertyDrawers) + { + if (targets == null || targets.Length == 0) + return; + var target = targets[0] as Material; + if (target == null) + return; + + var shader = target.shader; + string[] propNames = MaterialEditor.GetMaterialPropertyNames(targets); + for (int i = 0; i < propNames.Length; i++) + { + var prop = MaterialEditor.GetMaterialProperty(targets, i); + var drawer = ReflectionHelper.GetPropertyDrawer(shader, prop, out var decoratorDrawers); + + if (drawer != null) + { + drawer.Apply(prop); + } + if (decoratorDrawers != null) + { + foreach (var decoratorDrawer in decoratorDrawers) + { + decoratorDrawer.Apply(prop); + } + } + } + } + } + + #endregion + + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs.meta b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs.meta new file mode 100644 index 0000000..1e7d5b1 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/UnityEditorExtension/UnityEditorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c461331302de45948d270b0842238473 +timeCreated: 1726212440 \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/package.json b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/package.json index 8c1643a..9677d04 100644 --- a/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/package.json +++ b/Assets/External/NiloToonURP/Editor/ShaderGUI/LWGUI-main/package.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b373af80da50d1c8bb892e58b456437d3bd705c9e573ece11657875250cca56f -size 567 +oid sha256:c80b6ba30ddfaaa2e8722330f25dcd24f968d01ed72740d48fc75448ced0b13c +size 568 diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonBloomVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonBloomVolumeEditor.cs index cf57d90..d78140b 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonBloomVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonBloomVolumeEditor.cs @@ -18,9 +18,11 @@ namespace NiloToon.NiloToonURP { List messages = new List(); - messages.Add("- Like URP14's Bloom but with more controls.\n" + - "- Can supplement or replace URP's Bloom.\n" + - "* This Bloom is slower than URP's Bloom (GPU)"); + messages.Add("- Similar to URP's Bloom but with more controls\n" + + "- Great for preventing character become over bloom\n" + + "- Allows different setting for Character & non-Character pixels\n" + + "- Can supplement or replace URP's Bloom\n" + + "* This Bloom is slower than URP's Bloom (GPU), only recommended for PC/Console"); messages.Add(IsPostProcessMessage); diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonCharRenderingControlVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonCharRenderingControlVolumeEditor.cs index 514f7a8..e98505b 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonCharRenderingControlVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonCharRenderingControlVolumeEditor.cs @@ -19,7 +19,7 @@ namespace NiloToon.NiloToonURP List messages = new List(); messages.Add( - "- Great for helping NiloToon characters blend into any environment\n" + + "- Great for helping NiloToon characters to blend into any environment\n" + "- Great for artist-controlled lighting and rim light on NiloToon characters"); messages.Add(NonPostProcess_NotAffectPerformance_Message); diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonCinematicRimLightVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonCinematicRimLightVolumeEditor.cs index 358141e..50ff6ef 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonCinematicRimLightVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonCinematicRimLightVolumeEditor.cs @@ -19,10 +19,10 @@ namespace NiloToon.NiloToonURP List messages = new List(); messages.Add( - "Make NiloToon characters convert all received additional light into rim light.\n" + - "Useful if you want characters to receive many bright additional lights,\n" + - "yet maintain a pleasing lighting effect, without becoming overly bright or unappealing.\n" + - "(e.g., ideal for concert stage live performances or cinematic cut scenes)" + "- Converts all received additional light into rim light for NiloToon characters\n" + + "- Useful if you want characters to receive many bright additional lights,\n" + + " yet maintain a pleasing lighting effect, without becoming overly bright or unappealing.\n" + + "- Ideal for concert stage live performances or cinematic cut scenes" ); messages.Add(NonPostProcess_NotAffectPerformance_Message); diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonEnvironmentControlVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonEnvironmentControlVolumeEditor.cs index ccf1e4d..9775a84 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonEnvironmentControlVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonEnvironmentControlVolumeEditor.cs @@ -17,7 +17,9 @@ namespace NiloToon.NiloToonURP protected override List GetHelpBoxContent() { List messages = new List(); - + + messages.Add("- For extra color control of NiloToon_Environment shader\n" + + "- Or for debug which material is using NiloToon_Environment shader" ); messages.Add(NonPostProcess_NotAffectPerformance_Message); return messages; diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs new file mode 100644 index 0000000..5ad44d7 --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using NiloToon.NiloToonURP; +using UnityEditor; +using UnityEditor.Rendering; + +namespace NiloToon.NiloToonURP +{ + [CanEditMultipleObjects] +#if UNITY_2022_2_OR_NEWER + [CustomEditor(typeof(NiloToonMotionBlurVolume))] +#else + [VolumeComponentEditor(typeof(NiloToonMotionBlurVolume))] +#endif + public class NiloToonMotionBlurVolumeEditor : NiloToonVolumeComponentEditor + { + // Override GetHelpBoxContent to provide specific help box content + protected override List GetHelpBoxContent() + { + List messages = new List(); + + messages.Add( + "[Requires Unity2022.3 or above]\n" + + "- Cinematic object motion blur, usually used for character dance animations in music videos (MVs). It is better than URP's object motion blur but comes with a much higher GPU cost.\n" + + "- Recommended for PC/Console only"); + messages.Add(IsPostProcessMessage); + + return messages; + } + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs.meta b/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs.meta new file mode 100644 index 0000000..5710e7b --- /dev/null +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonMotionBlurVolumeEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2706839ba1d17584890ca7454f75e0ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonScreenSpaceOutlineControlVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonScreenSpaceOutlineControlVolumeEditor.cs index edae76f..4f80711 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonScreenSpaceOutlineControlVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonScreenSpaceOutlineControlVolumeEditor.cs @@ -18,7 +18,12 @@ namespace NiloToon.NiloToonURP { List messages = new List(); - messages.Add(NonPostProcess_NotAffectPerformance_Message); + messages.Add( + "- For producing NiloToon Character or Environment's screen space outline\n" + + "- Requires enabling 'Enable ScreenSpace Outline' in NiloToonAllInOne renderer feature\n" + + "- Requires temporal AA like TAA/STP/DLSS/XeSS/FSR... to produce stable result"); + + messages.Add(NonPostProcess_MayAffectPerformance_Message); return messages; } diff --git a/Assets/External/NiloToonURP/Editor/Volume/NiloToonShadowControlVolumeEditor.cs b/Assets/External/NiloToonURP/Editor/Volume/NiloToonShadowControlVolumeEditor.cs index 369c7ba..a1d380d 100644 --- a/Assets/External/NiloToonURP/Editor/Volume/NiloToonShadowControlVolumeEditor.cs +++ b/Assets/External/NiloToonURP/Editor/Volume/NiloToonShadowControlVolumeEditor.cs @@ -19,8 +19,9 @@ namespace NiloToon.NiloToonURP List messages = new List(); messages.Add( - "- If overridden, will use settings here instead of NiloToonAllInOneRendererFeature.\n" + - "- If not overridden, will use NiloToonAllInOneRendererFeature's settings."); + "- Great for controlling NiloToon characters' shadow results (e.g., shadow tint color)\n" + + "- When overridden, uses settings from here instead of NiloToonAllInOneRendererFeature\n" + + "- When not overridden, uses NiloToonAllInOneRendererFeature's settings"); messages.Add(NonPostProcess_MayAffectPerformance_Message); diff --git a/Assets/External/NiloToonURP/NiloToonURP user document.pdf b/Assets/External/NiloToonURP/NiloToonURP user document.pdf index 5524396..a0b5c4f 100644 --- a/Assets/External/NiloToonURP/NiloToonURP user document.pdf +++ b/Assets/External/NiloToonURP/NiloToonURP user document.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e782ab0240a2e43cd32abbaaa6c0b432a31a3325151af7d9dc6ef2b0bac56e4 -size 36925631 +oid sha256:495b3aa0e02b12fc24457b01c6f99f9492dddffe569fd46ae33f9800fd6d7fbb +size 46510058 diff --git a/Assets/External/NiloToonURP/RenderPipelineAsset.meta b/Assets/External/NiloToonURP/RenderPipelineAsset.meta index c8cd331..8f09415 100644 --- a/Assets/External/NiloToonURP/RenderPipelineAsset.meta +++ b/Assets/External/NiloToonURP/RenderPipelineAsset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a0890936ec94ed749881904e977d840d +guid: faa27ea2c11a8a34a99a3c5a2288129b folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/External/NiloToonURP/Runtime/BuildTimeShaderStripping/NiloToonShaderStrippingSettingSO.cs b/Assets/External/NiloToonURP/Runtime/BuildTimeShaderStripping/NiloToonShaderStrippingSettingSO.cs index 3bc5957..c0c38ab 100644 --- a/Assets/External/NiloToonURP/Runtime/BuildTimeShaderStripping/NiloToonShaderStrippingSettingSO.cs +++ b/Assets/External/NiloToonURP/Runtime/BuildTimeShaderStripping/NiloToonShaderStrippingSettingSO.cs @@ -20,7 +20,11 @@ namespace NiloToon.NiloToonURP include_NILOTOON_RECEIVE_SELF_SHADOW: true, // enabled include_NILOTOON_DITHER_FADEOUT: false, include_NILOTOON_DISSOLVE: false, - include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false); + include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false, + include_STEREO_INSTANCING_ON: false, + include_STEREO_MULTIVIEW_ON: false, + include_STEREO_CUBEMAP_RENDER_ON: false, + include_UNITY_SINGLE_PASS_STEREO: false); [Header("iOS Override")] public bool ShouldOverrideSettingForIOS = true; @@ -33,7 +37,11 @@ namespace NiloToon.NiloToonURP include_NILOTOON_RECEIVE_SELF_SHADOW: true, // enabled include_NILOTOON_DITHER_FADEOUT: false, include_NILOTOON_DISSOLVE: false, - include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false); + include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false, + include_STEREO_INSTANCING_ON: false, + include_STEREO_MULTIVIEW_ON: false, + include_STEREO_CUBEMAP_RENDER_ON: false, + include_UNITY_SINGLE_PASS_STEREO: false); [Header("WebGL Override")] public bool ShouldOverrideSettingForWebGL = true; @@ -46,7 +54,11 @@ namespace NiloToon.NiloToonURP include_NILOTOON_RECEIVE_SELF_SHADOW: true, // enabled include_NILOTOON_DITHER_FADEOUT: false, include_NILOTOON_DISSOLVE: false, - include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false); + include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE: false, + include_STEREO_INSTANCING_ON: false, + include_STEREO_MULTIVIEW_ON: false, + include_STEREO_CUBEMAP_RENDER_ON: false, + include_UNITY_SINGLE_PASS_STEREO: false); [System.Serializable] public class Settings @@ -129,7 +141,33 @@ namespace NiloToon.NiloToonURP [Tooltip("keyword: _NILOTOON_FORCE_MINIMUM_SHADER\n\n" + "Default value:\n" + "- All platforms: false")] - public bool include_NILOTOON_FORCE_MINIMUM_SHADER = false; + public bool include_NILOTOON_FORCE_MINIMUM_SHADER = false; + + [Header("XR")] + + [OverrideDisplayName("STEREO_INSTANCING_ON")] + [Tooltip("keyword: STEREO_INSTANCING_ON\n\n" + + "Default value:\n" + + "- All platforms: false")] + public bool include_STEREO_INSTANCING_ON = false; + + [OverrideDisplayName("STEREO_MULTIVIEW_ON")] + [Tooltip("keyword: STEREO_MULTIVIEW_ON\n\n" + + "Default value:\n" + + "- All platforms: false")] + public bool include_STEREO_MULTIVIEW_ON = false; + + [OverrideDisplayName("STEREO_CUBEMAP_RENDER_ON")] + [Tooltip("keyword: STEREO_CUBEMAP_RENDER_ON\n\n" + + "Default value:\n" + + "- All platforms: false")] + public bool include_STEREO_CUBEMAP_RENDER_ON = false; + + [OverrideDisplayName("UNITY_SINGLE_PASS_STEREO")] + [Tooltip("keyword: UNITY_SINGLE_PASS_STEREO\n\n" + + "Default value:\n" + + "- All platforms: false")] + public bool include_UNITY_SINGLE_PASS_STEREO = false; public Settings() { } public Settings( @@ -141,7 +179,11 @@ namespace NiloToon.NiloToonURP bool include_NILOTOON_RECEIVE_SELF_SHADOW, bool include_NILOTOON_DITHER_FADEOUT, bool include_NILOTOON_DISSOLVE, - bool include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE + bool include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE, + bool include_STEREO_INSTANCING_ON, + bool include_STEREO_MULTIVIEW_ON, + bool include_STEREO_CUBEMAP_RENDER_ON, + bool include_UNITY_SINGLE_PASS_STEREO ) { this.include_NILOTOON_DEBUG_SHADING = include_NILOTOON_DEBUG_SHADING; @@ -153,6 +195,11 @@ namespace NiloToon.NiloToonURP this.include_NILOTOON_DITHER_FADEOUT = include_NILOTOON_DITHER_FADEOUT; this.include_NILOTOON_DISSOLVE = include_NILOTOON_DISSOLVE; this.include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE = include_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE; + + this.include_STEREO_INSTANCING_ON = include_STEREO_INSTANCING_ON; + this.include_STEREO_MULTIVIEW_ON = include_STEREO_MULTIVIEW_ON; + this.include_STEREO_CUBEMAP_RENDER_ON = include_STEREO_CUBEMAP_RENDER_ON; + this.include_UNITY_SINGLE_PASS_STEREO = include_UNITY_SINGLE_PASS_STEREO; } } } diff --git a/Assets/External/NiloToonURP/Runtime/NiloToonPerCharacterRenderController.cs b/Assets/External/NiloToonURP/Runtime/NiloToonPerCharacterRenderController.cs index 7f8e221..1bfa783 100644 --- a/Assets/External/NiloToonURP/Runtime/NiloToonPerCharacterRenderController.cs +++ b/Assets/External/NiloToonURP/Runtime/NiloToonPerCharacterRenderController.cs @@ -262,6 +262,10 @@ namespace NiloToon.NiloToonURP "Default: Off")] [OverrideDisplayName("Show Gizmo?")] public bool showBoundingSphereGizmo = false; + //------------------------------------------------------------ + + + //------------------------------------------------------------ [Foldout("Base Map")] @@ -770,54 +774,9 @@ namespace NiloToon.NiloToonURP "Default: 0")] [OverrideDisplayName("ZOffset(meter)")] public float perCharacterZOffset = 0; - //------------------------------------------------------------------------- - [Foldout("Allowed Passes (PlayMode)")] - - [Tooltip( - "Enable to allow this character renders into URP's shadow maps.\n\n" + - "Requires (PlayMode)\n\n" + - "Name: allowRenderShadowCasterPass\n" + - "Default: On")] - [OverrideDisplayName("URP ShadowCasterPass")] - public bool allowRenderShadowCasterPass = true; - - [Tooltip( - "Enable to allow this character renders into URP's Depth texture/Normal texture.\n\n" + - "Requires (PlayMode)\n\n" + - "Name: allowRenderDepthOnlyAndDepthNormalsPass\n" + - "Default: On")] - [OverrideDisplayName("DepthOnly/DepthNormals")] - public bool allowRenderDepthOnlyAndDepthNormalsPass = true; - - [Tooltip( - "Enable to allow this character renders into NiloToon's shadowmap.\n\n" + - "Requires (PlayMode)\n\n" + - "Name: allowRenderNiloToonSelfShadowCasterPass\n" + - "Default: On")] - [OverrideDisplayName("NiloToonSelfShadowCaster")] - public bool allowRenderNiloToonSelfShadowCasterPass = true; - - [Tooltip( - "Enable to allow this character renders into NiloToon's prepass render texture.\n\n" + - "Requires (PlayMode)\n\n" + - "Name: allowRenderNiloToonPrepassBufferPass\n" + - "Default: On")] - [OverrideDisplayName("NiloToonPrepassBuffer")] - public bool allowRenderNiloToonPrepassBufferPass = true; - //------------------------------------------------------------------------- - /* - [Foldout("Optimization")] - [Tooltip( - "If turn this on, will boost CPU performance a lot, but switching material in playmode will require you to call RequestForceMaterialUpdateOnce() in C#.\n\n" + - "Requires (PlayMode)\n" + - "Name: allowCacheSystem\n" + - "Default: On")] - [OverrideDisplayName("Use Cache?")] - public bool allowCacheSystem = true; - */ //------------------------------------------------------------------------- - [Foldout("Misc")] + [Foldout("VRM")] [Tooltip( "Enable to keep material instance's name in PlayMode same as the original material name.\n" + "It is required by VRMBlendShapeProxy in order to let VRMBlendShapeProxy's material control works, so it is default on.\n\n" + @@ -840,6 +799,8 @@ namespace NiloToon.NiloToonURP )] public bool regenerateSmoothedNormalInUV8 = false; + //------------------------------------------------------------------------- + [Foldout("Compatibility mode")] [OverrideDisplayName("Compatible with 0.13.8 shader")] [Tooltip( "When turned on,\n" + @@ -980,11 +941,6 @@ namespace NiloToon.NiloToonURP bool? ShouldEnableDitherFadeOut_Cache; bool? ShouldEnableDissolve_Cache; bool? ShouldEnablePerCharacterBaseMapOverride_Cache; - bool? ShouldEnableDepthTextureRimLightAndShadow_Cache; - bool? allowRenderShadowCasterPass_Cache; - bool? allowRenderDepthOnlyAndDepthNormalsPass_Cache; - bool? allowRenderNiloToonSelfShadowCasterPass_Cache; - bool? allowRenderNiloToonPrepassBufferPass_Cache; // RequireMaterialSet or RequireSetShaderPassEnabledCall bool renderCharacter_RequireMaterialSet; @@ -1056,11 +1012,6 @@ namespace NiloToon.NiloToonURP bool ShouldEnableDitherFadeOut_RequireKeywordChangeCall; bool ShouldEnableDissolve_RequireKeywordChangeCall; bool ShouldEnablePerCharacterBaseMapOverride_RequireKeywordChangeCall; - bool ShouldEnableDepthTextureRimLightAndShadow_RequireKeywordChangeCall; - bool allowRenderShadowCasterPass_RequireSetShaderPassEnabledCall; - bool allowRenderDepthOnlyAndDepthNormalsPass_RequireSetShaderPassEnabledCall; - bool allowRenderNiloToonSelfShadowCasterPass_RequireSetShaderPassEnabledCall; - bool allowRenderNiloToonPrepassBufferPass_RequireSetShaderPassEnabledCall; // build current frame data cache (for avoid duplicated method calls which returns the same result within the same frame) bool isHeadBoneTransformExist; @@ -1143,6 +1094,21 @@ namespace NiloToon.NiloToonURP void OnDestroy() { + // Clean up all material instances when this script is destroyed + foreach (var materials in matListDictionary.Values) + { + foreach (var material in materials) + { + if (material != null) + { + Destroy(material); + } + } + } + + // Clear the dictionary (not strictly necessary since the script is being destroyed) + matListDictionary.Clear(); + // TODO: should we just delete this Resources.UnloadAsset, and rely on Unity's asset GC? // unload Resources.Load() if (defaultDissolveThresholdMap) @@ -1348,6 +1314,9 @@ namespace NiloToon.NiloToonURP /// bool forceUpdateMaterialNeeded bool GetMaterialsInstances(Renderer renderer) { + // Clear the list before reusing it + tempMaterialList.Clear(); + // Obtain the current material instances from the renderer // this line will generate material instances if the material is not yet an instance // this line can be performance heavy if some external C#/animation keep assigning new material to the renderer @@ -1356,7 +1325,7 @@ namespace NiloToon.NiloToonURP bool forceUpdateMaterialNeeded = false; // Check if the renderer already has a cached entry - // use InstanceID as key since it is int(value type), it is much faster the Renderer(reference type) as key + // use InstanceID as key since it is int(value type), it is much faster than Renderer(reference type) as key if (matListDictionary.TryGetValue(renderer.GetInstanceID(), out Material[] materialsCache)) { if (materialsCache.Length == tempMaterialList.Count) @@ -1372,12 +1341,19 @@ namespace NiloToon.NiloToonURP // this is an important step to prevent memory leak due to lost reference material instance(e.g., renderer's material changed by animation "material reference" key) if (materialsCache[i] != null) { - Destroy(materialsCache[i]); + // need to not delete material that exists in both materialsCache and tempMaterialList (result of renderer.GetMaterials) + // it can happen if user swap materials order in a renderer + if (!tempMaterialList.Contains(materialsCache[i])) + { + Destroy(materialsCache[i]); + } } - // Replace with the new material from the tempMaterialList + + // Replace cache with the new material from the tempMaterialList (result of renderer.GetMaterials) + // this line will update the content inside the dictionary due to materialsCache[i] is a reference pointing to the same Material[i] inside the dictionary materialsCache[i] = tempMaterialList[i]; - forceUpdateMaterialNeeded = true; + forceUpdateMaterialNeeded = true; // only goal is to reduce calling this to optimize CPU } } } @@ -1390,13 +1366,19 @@ namespace NiloToon.NiloToonURP { if (material != null) { - Destroy(material); + // need to not delete material that exists in both materialsCache and renderer.materials(tempMaterialList) + // it can happen if user append a new material to a renderer without changing one of the original materials + if (!tempMaterialList.Contains(material)) + { + Destroy(material); + } } } + // Update the dictionary with the new array of materials matListDictionary[renderer.GetInstanceID()] = tempMaterialList.ToArray(); - forceUpdateMaterialNeeded = true; + forceUpdateMaterialNeeded = true; // only goal is to reduce calling this to optimize CPU } } else @@ -1608,11 +1590,6 @@ namespace NiloToon.NiloToonURP ShouldEnableDitherFadeOut_RequireKeywordChangeCall = true; ShouldEnableDissolve_RequireKeywordChangeCall = true; ShouldEnablePerCharacterBaseMapOverride_RequireKeywordChangeCall = true; - ShouldEnableDepthTextureRimLightAndShadow_RequireKeywordChangeCall = true; - allowRenderShadowCasterPass_RequireSetShaderPassEnabledCall = true; - allowRenderDepthOnlyAndDepthNormalsPass_RequireSetShaderPassEnabledCall = true; - allowRenderNiloToonSelfShadowCasterPass_RequireSetShaderPassEnabledCall = true; - allowRenderNiloToonPrepassBufferPass_RequireSetShaderPassEnabledCall = true; // force update all and exit return; @@ -1701,11 +1678,6 @@ namespace NiloToon.NiloToonURP ShouldEnableDitherFadeOut_RequireKeywordChangeCall = ShouldEnableDitherFadeOut_Cache != GetShouldEnableDitherFadeOut(); ShouldEnableDissolve_RequireKeywordChangeCall = ShouldEnableDissolve_Cache != GetShouldEnableDissolve(); ShouldEnablePerCharacterBaseMapOverride_RequireKeywordChangeCall = ShouldEnablePerCharacterBaseMapOverride_Cache != GetShouldEnablePerCharacterBaseMapOverride(); - ShouldEnableDepthTextureRimLightAndShadow_RequireKeywordChangeCall = ShouldEnableDepthTextureRimLightAndShadow_Cache != GetShouldEnableDepthTextureRimLightAndShadow(); - allowRenderShadowCasterPass_RequireSetShaderPassEnabledCall = allowRenderShadowCasterPass_Cache != allowRenderShadowCasterPass; - allowRenderDepthOnlyAndDepthNormalsPass_RequireSetShaderPassEnabledCall = allowRenderDepthOnlyAndDepthNormalsPass_Cache != allowRenderDepthOnlyAndDepthNormalsPass; - allowRenderNiloToonSelfShadowCasterPass_RequireSetShaderPassEnabledCall = allowRenderNiloToonSelfShadowCasterPass_Cache != allowRenderNiloToonSelfShadowCasterPass; - allowRenderNiloToonPrepassBufferPass_RequireSetShaderPassEnabledCall = allowRenderNiloToonPrepassBufferPass_Cache != allowRenderNiloToonPrepassBufferPass; } private void CacheProprtiesForNextFrameOptimizationCheck() { @@ -1787,11 +1759,6 @@ namespace NiloToon.NiloToonURP ShouldEnableDitherFadeOut_Cache = GetShouldEnableDitherFadeOut(); ShouldEnableDissolve_Cache = GetShouldEnableDissolve(); ShouldEnablePerCharacterBaseMapOverride_Cache = GetShouldEnablePerCharacterBaseMapOverride(); - ShouldEnableDepthTextureRimLightAndShadow_Cache = GetShouldEnableDepthTextureRimLightAndShadow(); - allowRenderShadowCasterPass_Cache = allowRenderShadowCasterPass; - allowRenderDepthOnlyAndDepthNormalsPass_Cache = allowRenderDepthOnlyAndDepthNormalsPass; - allowRenderNiloToonSelfShadowCasterPass_Cache = allowRenderNiloToonSelfShadowCasterPass; - allowRenderNiloToonPrepassBufferPass_Cache = allowRenderNiloToonPrepassBufferPass; } public float GetCharacterBoundRadius() { @@ -2088,10 +2055,6 @@ namespace NiloToon.NiloToonURP { return perCharacterBaseMapOverrideAmount > 0.01f; } - bool GetShouldEnableDepthTextureRimLightAndShadow() - { - return allowRenderDepthOnlyAndDepthNormalsPass; - } int GetExtraThickOutlineZTest() { @@ -2242,7 +2205,6 @@ namespace NiloToon.NiloToonURP if (ReceiveNiloToonSelfShadowMap_RequireMaterialSet) input.SetFloat(_PerCharReceiveNiloToonSelfShadowMap, receiveNiloToonSelfShadowMap); if (perCharacterZOffset_RequireMaterialSet) input.SetFloat(_PerCharZOffset, perCharacterZOffset); if (shouldRenderSelfOutline_RequireMaterialSet) input.SetFloat(_PerCharacterRenderOutline, shouldRenderSelfOutline ? 1 : 0); - if (ShouldEnableDepthTextureRimLightAndShadow_RequireKeywordChangeCall) input.SetFloat("_NiloToonEnableDepthTextureRimLightAndShadow", GetShouldEnableDepthTextureRimLightAndShadow() ? 1 : 0); //================================================================================================================================================ @@ -2267,14 +2229,6 @@ namespace NiloToon.NiloToonURP if (ShouldEnableDitherFadeOut_RequireKeywordChangeCall) CoreUtils.SetKeyword(input, "_NILOTOON_DITHER_FADEOUT", GetShouldEnableDitherFadeOut()); if (ShouldEnableDissolve_RequireKeywordChangeCall) CoreUtils.SetKeyword(input, "_NILOTOON_DISSOLVE", GetShouldEnableDissolve()); if (ShouldEnablePerCharacterBaseMapOverride_RequireKeywordChangeCall) CoreUtils.SetKeyword(input, "_NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE", GetShouldEnablePerCharacterBaseMapOverride()); - - // optimization: allow user to control render these pass or not, so user can turn these off for non-important/far-away characters - // the first param equals to "LightMode" = "XXX" - if (allowRenderShadowCasterPass_RequireSetShaderPassEnabledCall) input.SetShaderPassEnabled("ShadowCaster", allowRenderShadowCasterPass); - if (allowRenderDepthOnlyAndDepthNormalsPass_RequireSetShaderPassEnabledCall) input.SetShaderPassEnabled("DepthOnly", allowRenderDepthOnlyAndDepthNormalsPass); - if (allowRenderDepthOnlyAndDepthNormalsPass_RequireSetShaderPassEnabledCall) input.SetShaderPassEnabled("DepthNormals", allowRenderDepthOnlyAndDepthNormalsPass); - if (allowRenderNiloToonSelfShadowCasterPass_RequireSetShaderPassEnabledCall) input.SetShaderPassEnabled("NiloToonSelfShadowCaster", allowRenderNiloToonSelfShadowCasterPass); - if (allowRenderNiloToonPrepassBufferPass_RequireSetShaderPassEnabledCall) input.SetShaderPassEnabled("NiloToonPrepassBuffer", allowRenderNiloToonPrepassBufferPass); } void UpdateMaterialPropertyBlock(MaterialPropertyBlock input) { @@ -2356,8 +2310,6 @@ namespace NiloToon.NiloToonURP if (ReceiveNiloToonSelfShadowMap_RequireMaterialSet) input.SetFloat(_PerCharReceiveNiloToonSelfShadowMap, receiveNiloToonSelfShadowMap); if (perCharacterZOffset_RequireMaterialSet) input.SetFloat(_PerCharZOffset, perCharacterZOffset); if (shouldRenderSelfOutline_RequireMaterialSet) input.SetFloat(_PerCharacterRenderOutline, shouldRenderSelfOutline ? 1 : 0); - - if (ShouldEnableDepthTextureRimLightAndShadow_RequireKeywordChangeCall) input.SetFloat("_NiloToonEnableDepthTextureRimLightAndShadow", GetShouldEnableDepthTextureRimLightAndShadow() ? 1 : 0); //================================================================================================================================================ // API EnableKeyword(...)/SetShaderPassEnabled(...) only works for Material class, so it only works in play mode diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/NiloToonAllInOneRendererFeature.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/NiloToonAllInOneRendererFeature.cs index ddae1bb..d98f297 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/NiloToonAllInOneRendererFeature.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/NiloToonAllInOneRendererFeature.cs @@ -24,6 +24,9 @@ namespace NiloToon.NiloToonURP [Header("Char SelfShadow")] public NiloToonCharSelfShadowMapRTPass.Settings charSelfShadowSettings = new NiloToonCharSelfShadowMapRTPass.Settings(); + [Header("Motion Blur")] + public NiloToonMotionBlurPass.Settings motionBlurSettings = new NiloToonMotionBlurPass.Settings(); + [Header("Override Shader stripping")] [OverrideDisplayName("Shader Stripping Settings")] [Tooltip("This slot is useful when you are in the following situation:\n" + @@ -57,6 +60,9 @@ namespace NiloToon.NiloToonURP NiloToonAnimePostProcessPass AnimePostProcessPass; NiloToonPrepassBufferRTPass PrepassBufferRTPass; NiloToonUberPostProcessPass UberPostProcessPass; +#if UNITY_2022_3_OR_NEWER + NiloToonMotionBlurPass MotionBlurPass; +#endif // This method is used to initialize the ScriptableRenderPass and any required resources. // Unity calls this method in OnEnable/OnValidate - @@ -105,6 +111,10 @@ namespace NiloToon.NiloToonURP PrepassBufferRTPass = new NiloToonPrepassBufferRTPass(settings); if (UberPostProcessPass == null) UberPostProcessPass = new NiloToonUberPostProcessPass(settings); +#if UNITY_2022_3_OR_NEWER + if (MotionBlurPass == null) + MotionBlurPass = new NiloToonMotionBlurPass(settings); +#endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Configures where the render pass should be injected. @@ -157,6 +167,15 @@ namespace NiloToon.NiloToonURP // a fix to any possible missing/null pass ReInitPassesIfNeeded(); + //---------------------------------------------------------------- + // temp fix for supporting SetToonParamPass+RenderGraph + // since we can't call ConfigureInput() inside RecordRenderGraph() + //---------------------------------------------------------------- + SetToonParamPass.ConfigureInputs(renderer); + ScreenSpaceOutlinePass.ConfigureInput(renderingData.cameraData.cameraType); +#if UNITY_2022_3_OR_NEWER + MotionBlurPass.ConfigureInputs(renderingData.cameraData.camera); +#endif // Also note that by default it would enqueue the pass for all cameras - // including ones used by the Unity Editor. // In order to avoid this, we can test the camera type and return before enqueueing @@ -215,6 +234,13 @@ namespace NiloToon.NiloToonURP } renderer.EnqueuePass(UberPostProcessPass); +#if UNITY_2022_3_OR_NEWER + if (renderingData.cameraData.postProcessEnabled && + renderingData.cameraData.cameraType == CameraType.Game) // only apply to game window + { + renderer.EnqueuePass(MotionBlurPass); + } +#endif } #if UNITY_2022_2_OR_NEWER @@ -242,6 +268,7 @@ namespace NiloToon.NiloToonURP CharSelfShadowMapRTRenderPass?.Dispose(); UberPostProcessPass?.Dispose(); SphereShadowTestRTPass?.Dispose(); + MotionBlurPass?.Dispose(); // null all passes SetToonParamPass = null; @@ -255,6 +282,7 @@ namespace NiloToon.NiloToonURP AnimePostProcessPass = null; PrepassBufferRTPass = null; UberPostProcessPass = null; + MotionBlurPass = null; } #endif diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAnimePostProcessPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAnimePostProcessPass.cs index 3129624..89000d6 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAnimePostProcessPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAnimePostProcessPass.cs @@ -4,6 +4,10 @@ using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.XR; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { /// @@ -50,6 +54,11 @@ namespace NiloToon.NiloToonURP } public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + SetRenderPassEvent(); + } + + private void SetRenderPassEvent() { var animePP = VolumeManager.instance.stack.GetComponent(); if (animePP.drawBeforePostProcess.value) @@ -68,37 +77,66 @@ namespace NiloToon.NiloToonURP Render(context, ref renderingData); } - private void Render(ScriptableRenderContext context, ref RenderingData renderingData) + private void InitMaterialIfNeeded() + { + // delay CreateEngineMaterial to as late as possible, to make it safe when ReimportAll is running + if (!material) + material = CoreUtils.CreateEngineMaterial("Hidden/NiloToon/AnimePostProcess"); + } + private bool ShouldRender(CameraType cameraType, bool postProcessingEnabled) { // we only want to render anime postprocess to Game window - if (renderingData.cameraData.cameraType != CameraType.Game) return; + if (cameraType != CameraType.Game) return false; var animePP = VolumeManager.instance.stack.GetComponent(); // respect Camera's PostProcessing toggle if (animePP.affectedByCameraPostprocessToggle.value) { - if (!renderingData.postProcessingEnabled) return; + if (!postProcessingEnabled) return false; } // volume control - if (!settings.allowRender || !animePP.IsActive()) return; + if (!settings.allowRender || !animePP.IsActive()) return false; // in XR, maybe not a good idea to render this pass, since it maybe disturbing - if (XRSettings.isDeviceActive) return; - - // delay CreateEngineMaterial to as late as possible, to make it safe when ReimportAll is running - if (!material) - material = CoreUtils.CreateEngineMaterial("Hidden/NiloToon/AnimePostProcess"); + if (XRSettings.isDeviceActive) return false; // sometimes the shader is not yet compile when first time opening the project or opening the project after deleting Library folder, // if material is not ready, cmd.DrawMesh will produce "Invalid pass" error log, so we need to skip it. if (!material) - return; + return false; - float topLightEffectIntensity = animePP.topLightEffectIntensity.value * animePP.intensity.value; - float bottomDarkenEffectIntensity = animePP.bottomDarkenEffectIntensity.value * animePP.intensity.value; + return true; + } + + private static void CMDAction(CommandBuffer cmd, float topLightEffectIntensity, NiloToonAnimePostProcessVolume animePP, + float bottomDarkenEffectIntensity, Camera camera, Material material) + { + // [how to draw a full screen quad without RT switch] + // https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@13.1/manual/renderer-features/how-to-fullscreen-blit-in-xr-spi.html + // https://gist.github.com/phi-lira/46c98fc67640cda47dcd27e9b3765b85#file-fullscreenquadpass-cs-L23 + cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity); // set V,P to identity matrix so we can draw full screen quad (mesh's vertex position used as final NDC position) + + // optimization: only draw if it is affecting result + if (topLightEffectIntensity > 0 && animePP.topLightEffectDrawHeight.value > 0) + { + // URP's RenderingUtils.fullscreenMesh is obsolete, so NiloToon write it's own NiloToonRenderingUtils.fullscreenMesh + cmd.DrawMesh(NiloToonRenderingUtils.fullscreenMesh, Matrix4x4.identity, material, 0, 0); // pass 0, top light pass + } + if (bottomDarkenEffectIntensity > 0 && animePP.bottomDarkenEffectDrawHeight.value > 0) + { + // URP's RenderingUtils.fullscreenMesh is obsolete, so NiloToon write it's own NiloToonRenderingUtils.fullscreenMesh + cmd.DrawMesh(NiloToonRenderingUtils.fullscreenMesh, Matrix4x4.identity, material, 0, 1); // pass 1, bottom darken pass + } + + cmd.SetViewProjectionMatrices(camera.worldToCameraMatrix, camera.projectionMatrix); // restore + } + + private void SetMaterial(NiloToonAnimePostProcessVolume animePP, float topLightEffectIntensity, + float bottomDarkenEffectIntensity) + { material.SetFloat(TopLightRotationDegree, animePP.rotation.value + animePP.topLightExtraRotation.value); material.SetFloat(TopLightIntensity, topLightEffectIntensity); material.SetFloat(TopLightDesaturate, animePP.topLightDesaturate.value); @@ -110,6 +148,19 @@ namespace NiloToon.NiloToonURP material.SetFloat(BottomDarkenRotationDegree, animePP.rotation.value + animePP.bottomDarkenExtraRotation.value); material.SetFloat(BottomDarkenIntensity, bottomDarkenEffectIntensity); material.SetFloat(BottomDarkenDrawAreaHeight, animePP.bottomDarkenEffectDrawHeight.value); + } + + private void Render(ScriptableRenderContext context, ref RenderingData renderingData) + { + InitMaterialIfNeeded(); + if(!ShouldRender(renderingData.cameraData.cameraType, renderingData.postProcessingEnabled)) return; + + var animePP = VolumeManager.instance.stack.GetComponent(); + + float topLightEffectIntensity = animePP.topLightEffectIntensity.value * animePP.intensity.value; + float bottomDarkenEffectIntensity = animePP.bottomDarkenEffectIntensity.value * animePP.intensity.value; + + SetMaterial(animePP, topLightEffectIntensity, bottomDarkenEffectIntensity); // NOTE: Do NOT mix ProfilingScope with named CommandBuffers i.e. CommandBufferPool.Get("name"). // Currently there's an issue which results in mismatched markers. @@ -125,26 +176,8 @@ namespace NiloToon.NiloToonURP // https://www.cyanilux.com/tutorials/custom-renderer-features/?fbclid=IwAR27j2f3VVo0IIYDa32Dh76G9KPYzwb8j1J5LllpSnLXJiGf_UHrQ_lDtKg context.ExecuteCommandBuffer(cmd); cmd.Clear(); - - // [how to draw a full screen quad without RT switch] - // https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@13.1/manual/renderer-features/how-to-fullscreen-blit-in-xr-spi.html - // https://gist.github.com/phi-lira/46c98fc67640cda47dcd27e9b3765b85#file-fullscreenquadpass-cs-L23 - cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity); // set V,P to identity matrix so we can draw full screen quad (mesh's vertex position used as final NDC position) - - // optimization: only draw if it is affecting result - if (topLightEffectIntensity > 0 && animePP.topLightEffectDrawHeight.value > 0) - { - // URP's RenderingUtils.fullscreenMesh is obsolete, so NiloToon write it's own NiloToonRenderingUtils.fullscreenMesh - cmd.DrawMesh(NiloToonRenderingUtils.fullscreenMesh, Matrix4x4.identity, material, 0, 0); // pass 0, top light pass - } - if (bottomDarkenEffectIntensity > 0 && animePP.bottomDarkenEffectDrawHeight.value > 0) - { - // URP's RenderingUtils.fullscreenMesh is obsolete, so NiloToon write it's own NiloToonRenderingUtils.fullscreenMesh - cmd.DrawMesh(NiloToonRenderingUtils.fullscreenMesh, Matrix4x4.identity, material, 0, 1); // pass 1, bottom darken pass - } - - cmd.SetViewProjectionMatrices(renderingData.cameraData.camera.worldToCameraMatrix, renderingData.cameraData.camera.projectionMatrix); // restore + CMDAction(cmd, topLightEffectIntensity, animePP, bottomDarkenEffectIntensity, renderingData.cameraData.camera, material); } // must write these line after using{} finished, to ensure profiler and frame debugger display correctness @@ -156,5 +189,60 @@ namespace NiloToon.NiloToonURP public override void OnCameraCleanup(CommandBuffer cmd) { } + + class PassData + { + } + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + // copy and edit of https://docs.unity3d.com/6000.0/Documentation/Manual/urp/render-graph-write-render-pass.html + string passName = "NiloToonAnimePostProcess(RG)"; + + SetRenderPassEvent(); + + // Add a raster render pass to the render graph. The PassData type parameter determines + // the type of the passData output variable. + using (var builder = renderGraph.AddUnsafePass(passName, + out var passData)) + { + // UniversalResourceData contains all the texture references used by URP, + // including the active color and depth textures of the camera. + var resourceData = frameData.Get(); + var cameraData = frameData.Get(); + + InitMaterialIfNeeded(); + if (!ShouldRender(cameraData.cameraType, cameraData.postProcessEnabled)) return; + + var animePP = VolumeManager.instance.stack.GetComponent(); + + float topLightEffectIntensity = animePP.topLightEffectIntensity.value * animePP.intensity.value; + float bottomDarkenEffectIntensity = animePP.bottomDarkenEffectIntensity.value * animePP.intensity.value; + + SetMaterial(animePP, topLightEffectIntensity, bottomDarkenEffectIntensity); + + // RenderGraph automatically determines that it can remove this render pass + // because its results, which are stored in the temporary destination texture, + // are not used by other passes. + // For demonstrative purposes, this sample turns off this behavior to make sure + // that render graph executes the render pass. + builder.AllowPassCulling(false); + + builder.AllowGlobalStateModification(true); + + // Set the ExecutePass method as the rendering function that render graph calls + // for the render pass. + // This sample uses a lambda expression to avoid memory allocations. + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => + { + CMDAction(CommandBufferHelpers.GetNativeCommandBuffer(context.cmd),topLightEffectIntensity, animePP, bottomDarkenEffectIntensity, cameraData.camera, material); + }); + } + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAverageShadowTestRTPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAverageShadowTestRTPass.cs index df64316..3714041 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAverageShadowTestRTPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonAverageShadowTestRTPass.cs @@ -4,6 +4,10 @@ using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +using UnityEngine.Rendering.RenderGraphModule.Util; +#endif namespace NiloToon.NiloToonURP { @@ -66,6 +70,28 @@ namespace NiloToon.NiloToonURP // in URP12(Unity2021.3), even there is no shadow caster to draw, URP will still allocate and clear a small 1x1 RT, used as shadowmap // see URP12 -> MainLightShadowCasterPass.cs's SetupForEmptyRendering(). + GetRTDescriptor(out var renderTextureDescriptor); + + // we need each pixel providing a per character average shadow attenuation value when sampling, so FilterMode is Point +#if UNITY_2022_2_OR_NEWER + RenderingUtils.ReAllocateIfNeeded(ref shadowTestResultRTH, renderTextureDescriptor, FilterMode.Point, TextureWrapMode.Clamp, name: "_NiloToonAverageShadowMapRT"); + cmd.SetGlobalTexture(shadowTestResultRTH.name, shadowTestResultRTH.nameID); +#else + cmd.GetTemporaryRT(shadowTestResultRTH.id, renderTextureDescriptor, FilterMode.Point); + cmd.SetGlobalTexture(_SphereShadowMapRT_SID, shadowTestResultRTH.Identifier()); +#endif + // still need to clear RT to white even average shadow is not enabled + // (in character shader we removed average shadow's multi_compile to save memory & build time/size, so character shader is always sampling this RT) +#if UNITY_2022_2_OR_NEWER + ConfigureTarget(shadowTestResultRTH); +#else + ConfigureTarget(shadowTestResultRTH.Identifier()); +#endif + ConfigureClear(ClearFlag.Color, Color.white); // default white = default no shadow + } + + private static void GetRTDescriptor(out RenderTextureDescriptor renderTextureDescriptor) + { // here we can't do this optimization, since character shader will LOAD texture using uv = (index,0), // this texture must be 128x1 int RTwidth = MAX_SHADOW_SLOT_COUNT; @@ -74,7 +100,7 @@ namespace NiloToon.NiloToonURP // RT height: RT height is 1 // RTFormat: RT format is RFloat, because we want to store a 0~1 average shadowAttenuation value // don't need depthbuffer/stencil/mipmap - RenderTextureDescriptor renderTextureDescriptor = new RenderTextureDescriptor(RTwidth, 1, RenderTextureFormat.RFloat, 0, 1); + renderTextureDescriptor = new RenderTextureDescriptor(RTwidth, 1, RenderTextureFormat.RFloat, 0, 1); // it is linear(non color) data renderTextureDescriptor.sRGB = false; @@ -96,28 +122,6 @@ namespace NiloToon.NiloToonURP { renderTextureDescriptor.graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm; } - else - { - Debug.LogError($"NiloToon: The creation of R8G8B8A8_UNorm RenderTexture of {nameof(NiloToonAverageShadowTestRTPass)} failed, contact email/discord for help."); - return; - } - - // we need each pixel providing a per character average shadow attenuation value when sampling, so FilterMode is Point -#if UNITY_2022_2_OR_NEWER - RenderingUtils.ReAllocateIfNeeded(ref shadowTestResultRTH, renderTextureDescriptor, FilterMode.Point, TextureWrapMode.Clamp, name: "_NiloToonAverageShadowMapRT"); - cmd.SetGlobalTexture(shadowTestResultRTH.name, shadowTestResultRTH.nameID); -#else - cmd.GetTemporaryRT(shadowTestResultRTH.id, renderTextureDescriptor, FilterMode.Point); - cmd.SetGlobalTexture(_SphereShadowMapRT_SID, shadowTestResultRTH.Identifier()); -#endif - // still need to clear RT to white even average shadow is not enabled - // (in character shader we removed average shadow's multi_compile to save memory & build time/size, so character shader is always sampling this RT) -#if UNITY_2022_2_OR_NEWER - ConfigureTarget(shadowTestResultRTH); -#else - ConfigureTarget(shadowTestResultRTH.Identifier()); -#endif - ConfigureClear(ClearFlag.Color, Color.white); // default white = default no shadow } // Here you can implement the rendering logic. @@ -126,7 +130,7 @@ namespace NiloToon.NiloToonURP // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { - if (!shouldRenderRT(renderingData)) return; + if (!shouldRenderRT(renderingData.cameraData.camera)) return; renderPerCharacterAverageShadowAtlaRT(context, renderingData); } @@ -145,7 +149,7 @@ namespace NiloToon.NiloToonURP shadowTestResultRTH?.Release(); } #endif - bool shouldRenderRT(RenderingData renderingData) + bool shouldRenderRT(Camera camera) { // TODO: // WebGL is not safe to run big foploop in shader @@ -154,7 +158,7 @@ namespace NiloToon.NiloToonURP return false; #endif - if (renderingData.cameraData.cameraType == CameraType.Preview) + if (camera.cameraType == CameraType.Preview) return false; var shadowControlVolumeEffect = VolumeManager.instance.stack.GetComponent(); @@ -165,16 +169,8 @@ namespace NiloToon.NiloToonURP } private void renderPerCharacterAverageShadowAtlaRT(ScriptableRenderContext context, RenderingData renderingData) { - // delay CreateEngineMaterial to as late as possible, to make it safe when ReimportAll is running - if (!material) - material = CoreUtils.CreateEngineMaterial("Hidden/NiloToon/AverageShadowTestRT"); - - // sometimes the shader is not yet compile when first time opening the project or opening the project after deleting Library folder, - // if material is not ready, cmd.DrawMesh will produce "Invalid pass" error log, so we need to skip it. - if (!material) - return; - - + if (!InitMaterialIfNeeded()) return; + // NOTE: Do NOT mix ProfilingScope with named CommandBuffers i.e. CommandBufferPool.Get("name"). // Currently there's an issue which results in mismatched markers. CommandBuffer cmd = CommandBufferPool.Get(); @@ -190,41 +186,9 @@ namespace NiloToon.NiloToonURP context.ExecuteCommandBuffer(cmd); cmd.Clear(); - // TODO: shadow will be wrong if number of active character in scene is more than MAX_SHADOW_SLOT_COUNT-1 + UpdateShaderDataArray(renderingData.cameraData.camera); - // reserve the right most slot for camera, other slots for each active character - for (int i = 0; i < Mathf.Min(MAX_SHADOW_SLOT_COUNT - 1, NiloToonAllInOneRendererFeature.characterList.Count); i++) - { - NiloToonPerCharacterRenderController controller = NiloToonAllInOneRendererFeature.characterList[i]; - - if (controller) - { - Vector3 centerPosWS = controller.GetCharacterBoundCenter(); - float radiusWS = controller.GetCharacterBoundRadius(); - - shaderDataArray[i * 4 + 0] = centerPosWS.x; - shaderDataArray[i * 4 + 1] = centerPosWS.y; - shaderDataArray[i * 4 + 2] = centerPosWS.z; - shaderDataArray[i * 4 + 3] = radiusWS; - } - else - { - shaderDataArray[i * 4 + 3] = 0; - } - } - - // RT's right most slot(pixel) for camera only - Camera cam = renderingData.cameraData.camera; - Vector3 cameraPosForTesting = cam.transform.position + cam.transform.forward * (cam.nearClipPlane + 1f); // add 1 unit offset to not use cam pos as testing center directly, to avoid wrong cascade shadowmap index(avoid testing outside of camera frustrum) - shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 0] = cameraPosForTesting.x; - shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 1] = cameraPosForTesting.y; - shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 2] = cameraPosForTesting.z; - shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 3] = 0.5f; // width is 0.5 unit, to avoid testing outside of camera frustrum - - var shadowControlVolumeEffect = VolumeManager.instance.stack.GetComponent(); - - cmd.SetGlobalFloatArray("_GlobalAverageShadowTestBoundingSphereDataArray", shaderDataArray); // once set, we can't change the size of array in GPU anymore, it is not Unity's fault but graphics API's design. - cmd.SetGlobalFloat("_GlobalAverageShadowStrength", shadowControlVolumeEffect.charAverageShadowStrength.value); + CMDSetGlobalParam(cmd); #if UNITY_2022_2_OR_NEWER Blitter.BlitTexture(cmd, shadowTestResultRTH, shadowTestResultRTH, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, material, 0); @@ -238,5 +202,189 @@ namespace NiloToon.NiloToonURP cmd.Clear(); CommandBufferPool.Release(cmd); } + + private void CMDSetGlobalParam(CommandBuffer cmd) + { + var shadowControlVolumeEffect = VolumeManager.instance.stack.GetComponent(); + + cmd.SetGlobalFloatArray("_GlobalAverageShadowTestBoundingSphereDataArray", shaderDataArray); // once set, we can't change the size of array in GPU anymore, it is not Unity's fault but graphics API's design. + cmd.SetGlobalFloat("_GlobalAverageShadowStrength", shadowControlVolumeEffect.charAverageShadowStrength.value); + } + + private bool InitMaterialIfNeeded() + { + // delay CreateEngineMaterial to as late as possible, to make it safe when ReimportAll is running + if (!material) + material = CoreUtils.CreateEngineMaterial("Hidden/NiloToon/AverageShadowTestRT"); + + // sometimes the shader is not yet compile when first time opening the project or opening the project after deleting Library folder, + // if material is not ready, cmd.DrawMesh will produce "Invalid pass" error log, so we need to skip it. + if (!material) + return false; + + return true; + } + + private void UpdateShaderDataArray(Camera camera) + { + // TODO: shadow will be wrong if number of active character in scene is more than MAX_SHADOW_SLOT_COUNT-1 + + // reserve the right most slot for camera, other slots for each active character + for (int i = 0; i < Mathf.Min(MAX_SHADOW_SLOT_COUNT - 1, NiloToonAllInOneRendererFeature.characterList.Count); i++) + { + NiloToonPerCharacterRenderController controller = NiloToonAllInOneRendererFeature.characterList[i]; + + if (controller) + { + Vector3 centerPosWS = controller.GetCharacterBoundCenter(); + float radiusWS = controller.GetCharacterBoundRadius(); + + shaderDataArray[i * 4 + 0] = centerPosWS.x; + shaderDataArray[i * 4 + 1] = centerPosWS.y; + shaderDataArray[i * 4 + 2] = centerPosWS.z; + shaderDataArray[i * 4 + 3] = radiusWS; + } + else + { + shaderDataArray[i * 4 + 3] = 0; + } + } + + // RT's right most slot(pixel) for camera only + Camera cam = camera; + Vector3 cameraPosForTesting = cam.transform.position + cam.transform.forward * (cam.nearClipPlane + 1f); // add 1 unit offset to not use cam pos as testing center directly, to avoid wrong cascade shadowmap index(avoid testing outside of camera frustrum) + shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 0] = cameraPosForTesting.x; + shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 1] = cameraPosForTesting.y; + shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 2] = cameraPosForTesting.z; + shaderDataArray[(MAX_SHADOW_SLOT_COUNT - 1) * 4 + 3] = 0.5f; // width is 0.5 unit, to avoid testing outside of camera frustum + } + + /////////////////////////////////////////////////////////////////////////// + /// RG support + /////////////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + public class PassData + { + public TextureHandle destTex; + } + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + // copy and edit of https://docs.unity3d.com/6000.0/Documentation/Manual/urp/render-graph-write-render-pass.html + string passName = "NiloToonAverageShadowTestRTPass-SetParam(RG)"; + + // Add a raster render pass to the render graph. The PassData type parameter determines + // the type of the passData output variable. + using (var builder = renderGraph.AddRasterRenderPass(passName, + out var passData)) + { + // UniversalResourceData contains all the texture references used by URP, + // including the active color and depth textures of the camera. + var resourceData = frameData.Get(); + var cameraData = frameData.Get(); + + if(!InitMaterialIfNeeded()) return; + + UpdateShaderDataArray(cameraData.camera); + + GetRTDescriptor(out var renderTextureDescriptor); + + // UniversalRenderer.CreateRenderGraphTexture is a helper method + // that calls the RenderGraph.CreateTexture method. + // Using a RenderTextureDescriptor instance instead of a TextureDesc instance + // simplifies your code. + TextureHandle destination = + UniversalRenderer.CreateRenderGraphTexture(renderGraph, renderTextureDescriptor, + "CopyTexture", true); + + passData.destTex = destination; + + // Declare that this render pass uses the temporary destination texture + // as its color render target. + // This is similar to cmd.SetRenderTarget prior to the RenderGraph API. + builder.SetRenderAttachment(destination, 0); + + // RenderGraph automatically determines that it can remove this render pass + // because its results, which are stored in the temporary destination texture, + // are not used by other passes. + // For demonstrative purposes, this sample turns off this behavior to make sure + // that render graph executes the render pass. + builder.AllowPassCulling(false); + + builder.AllowGlobalStateModification(true); + + // Set the ExecutePass method as the rendering function that render graph calls + // for the render pass. + // This sample uses a lambda expression to avoid memory allocations. + builder.SetRenderFunc((PassData data, RasterGraphContext context) => + { + context.cmd.ClearRenderTarget(true,true,Color.white); + + if (shouldRenderRT(cameraData.camera)) + { + //CMDSetGlobalParam(context.cmd); + var shadowControlVolumeEffect = VolumeManager.instance.stack.GetComponent(); + var cmd = context.cmd; + cmd.SetGlobalFloatArray("_GlobalAverageShadowTestBoundingSphereDataArray", shaderDataArray); // once set, we can't change the size of array in GPU anymore, it is not Unity's fault but graphics API's design. + cmd.SetGlobalFloat("_GlobalAverageShadowStrength", shadowControlVolumeEffect.charAverageShadowStrength.value); + + // special temp fix for RG + cmd.SetGlobalVector("_BlitScaleBias", new Vector4(1, 1, 0, 0)); + material.SetVector("_BlitScaleBias", new Vector4(1, 1, 0, 0)); + + // Records a rendering command to copy, or blit, the contents of the source texture + // to the color render target of the render pass. + // The RecordRenderGraph method sets the destination texture as the render target + // with the UseTextureFragment method. + CoreUtils.DrawFullScreen(cmd, material); + } + }); + + builder.SetGlobalTextureAfterPass(destination, Shader.PropertyToID("_NiloToonAverageShadowMapRT")); + } + + + + + + + + + /* + using (var builder = renderGraph.AddUnsafePass("NiloToonAverageShadowTestRTPass-SetParam(RG)", + out var passData, profilingSampler)) + { + builder.SetRenderFunc((PassData data, UnsafeGraphContext rgContext) => + { + // Convert UnsafeCommandBuffer to a regular CommandBuffer, our SetParamStaticShared use the regular CommandBuffer + CommandBuffer unsafeCommandBuffer = CommandBufferHelpers.GetNativeCommandBuffer(rgContext.cmd); + builder.AllowPassCulling(false); + CMDSetGlobalParam(unsafeCommandBuffer); + }); + } + + using (var builder = renderGraph.AddRasterRenderPass("Create yellow texture", out var passData)) + { + TextureHandle uselessTex = renderGraph.ImportTexture(RTHandles.Alloc(Texture2D.whiteTexture)); + TextureHandle destHandle = renderGraph.CreateTexture(destDesc); + + builder.SetRenderAttachmentDepth(destHandle, 0, AccessFlags.Write); + + builder.AllowPassCulling(false); + + builder.SetRenderFunc((PassData data, RasterGraphContext context) => + { + (data, context); + }); + } + */ + + /* + RenderGraphUtils.BlitMaterialParameters para = new(uselessTex, destHandle, material, 0); + renderGraph.AddBlitPass(para, passName: "NiloToonAverageShadowTestRTPass-Blit(RG)"); + + resourceData.cameraColor = destHandle; + */ + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonCharSelfShadowMapRTPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonCharSelfShadowMapRTPass.cs index 001de3a..661b624 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonCharSelfShadowMapRTPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonCharSelfShadowMapRTPass.cs @@ -8,6 +8,9 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif namespace NiloToon.NiloToonURP { @@ -180,7 +183,7 @@ namespace NiloToon.NiloToonURP int shadowMapSize = getShadowMapSize(volumeEffect); - if (!getShouldRender(volumeEffect, renderingData)) + if (!getShouldRender(volumeEffect, renderingData.cameraData.camera)) { shadowMapSize = 1; shouldRender = false; @@ -232,7 +235,7 @@ namespace NiloToon.NiloToonURP } #endif - bool getShouldRender(NiloToonShadowControlVolume volumeEffect, RenderingData renderingData) + bool getShouldRender(NiloToonShadowControlVolume volumeEffect, Camera camera) { // Let volume disable this pass if needed. // Due to performance cost of this pass, @@ -249,8 +252,8 @@ namespace NiloToon.NiloToonURP } // only game and scene view will render this pass - bool allowedCameraType = renderingData.cameraData.cameraType == CameraType.Game; - allowedCameraType |= renderingData.cameraData.cameraType == CameraType.SceneView; + bool allowedCameraType = camera.cameraType == CameraType.Game; + allowedCameraType |= camera.cameraType == CameraType.SceneView; shouldRender &= allowedCameraType; @@ -345,7 +348,7 @@ namespace NiloToon.NiloToonURP // do nothing since no new direction data is provided } - // [2.NiloToonCharacterMainLightOverrider override (before volume override] + // [2.NiloToonCharacterMainLightOverrider override (before volume override)] { NiloToonCharacterMainLightOverrider mainLightOverrider = NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.BeforeVolumeOverride); @@ -360,7 +363,7 @@ namespace NiloToon.NiloToonURP } // [3.NiloToonCharRenderingControlVolume override] - Vector3 volumeOverrideRotationVectorVS = new Vector3(charRenderingControlVolume.overridedLightUpDownAngle.value, -charRenderingControlVolume.overridedLightLRAngle.value, 0); + Vector3 volumeOverrideRotationVectorVS = new Vector3(charRenderingControlVolume.overridedLightUpDownAngle.value, charRenderingControlVolume.overridedLightLRAngle.value, 0); // WS -> VS -> apply rotation in VS -> WS Matrix4x4 volumeOverrideRotatedCamera_localToWorldMatrix = camera.cameraToWorldMatrix * Matrix4x4.Rotate(Quaternion.Euler(volumeOverrideRotationVectorVS)) * (camera.worldToCameraMatrix * camera.transform.localToWorldMatrix); Matrix4x4 volumeOverrideRotatedShadowCamViewMatrix = Matrix4x4.Rotate(Quaternion.Euler(0, 180, 0)) * volumeOverrideRotatedCamera_localToWorldMatrix.inverse; // inverse is worldToLocalMatrix @@ -406,7 +409,7 @@ namespace NiloToon.NiloToonURP if (!useMainLightCastShadowDirection || (shadowCamViewMatrix == Matrix4x4.zero)) { // if we go here, that means: - // - user explict only care the rotation of camera (useMainLightCastShadowDirection is false) + // - user explicit only care the rotation of camera (useMainLightCastShadowDirection is false) // or // - no main light information exist(URP main light/NiloToonCharacterMainLightOverrider/NiloToonCharRenderingControlVolume) (shadowCamViewMatrix is zero) // Then we will calculate shadow dir using "camera transform + rotation" @@ -765,5 +768,109 @@ namespace NiloToon.NiloToonURP } } } + + //====================================================================================================== + // RG support + //====================================================================================================== +#if UNITY_6000_0_OR_NEWER + + // copy and edit of https://docs.unity3d.com/6000.0/Documentation/Manual/urp/render-graph-draw-objects-in-a-pass.html + private class PassData + { + // Create a field to store the list of objects to draw + public RendererListHandle rendererListHandle; + public bool shouldRender; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) + { + using (var builder = renderGraph.AddRasterRenderPass("NiloToonCharSelfShadowMapRTPass(RG)", out var passData)) + { + // Get the data needed to create the list of objects to draw + UniversalCameraData cameraData = frameContext.Get(); + UniversalRenderingData renderingData = frameContext.Get(); + UniversalLightData lightData = frameContext.Get(); + + SortingCriteria sortFlags = SortingCriteria.CommonOpaque; //cameraData.defaultOpaqueSortFlags; + RenderQueueRange renderQueueRange = RenderQueueRange.opaque; + FilteringSettings filterSettings = new FilteringSettings(renderQueueRange, ~0); + + // Redraw only objects that have their LightMode tag set to toonOutlineLightModeShaderTagId + ShaderTagId shadersToOverride = new ShaderTagId("NiloToonSelfShadowCaster"); + + // Create drawing settings + DrawingSettings drawSettings = RenderingUtils.CreateDrawingSettings(shadersToOverride, renderingData, cameraData, lightData, sortFlags); + + // Create the list of objects to draw + var rendererListParameters = new RendererListParams(renderingData.cullResults, drawSettings, filterSettings); + + + + // create RT (temp) + // Create texture properties that match the screen size + var volumeEffect = VolumeManager.instance.stack.GetComponent(); + + int shadowMapSize = getShadowMapSize(volumeEffect); + + if (!getShouldRender(volumeEffect, cameraData.camera)) + { + shadowMapSize = 1; + shouldRender = false; + } + else + { + shouldRender = true; + } + + // Convert the list to a list handle that the render graph system can use + passData.rendererListHandle = renderGraph.CreateRendererList(rendererListParameters); + passData.shouldRender = shouldRender; + + RenderTextureDescriptor renderTextureDescriptor = new RenderTextureDescriptor(shadowMapSize, shadowMapSize, RenderTextureFormat.Shadowmap, 16); + + // Create a temporary texture + TextureHandle shadowMapRT = UniversalRenderer.CreateRenderGraphTexture(renderGraph, renderTextureDescriptor, "_NiloToonCharSelfShadowMapRT", true); + + // Set the render target as the color and depth textures of the active camera texture + UniversalResourceData resourceData = frameContext.Get(); + builder.UseRendererList(passData.rendererListHandle); + //builder.SetRenderAttachment(resourceData.activeColorTexture, 0); + builder.SetRenderAttachmentDepth(shadowMapRT, AccessFlags.Write); + + builder.AllowGlobalStateModification(true); + + builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context)); + } + } + + static void ExecutePass(PassData data, RasterGraphContext context) + { + var cmd = context.cmd; + + // temp WIP code: set the only required cmd + ; + cmd.SetKeyword(GlobalKeyword.Create(_NILOTOON_RECEIVE_SELF_SHADOW_Keyword), false); + return; + //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + // early exit if no render needed + if (!data.shouldRender) + { + // set the only required cmd + cmd.SetKeyword(new GlobalKeyword(_NILOTOON_RECEIVE_SELF_SHADOW_Keyword), false); + + // no draw + // (X) + + return; + } + + // set cmd + //... + + // Draw the objects in the list + cmd.DrawRendererList(data.rendererListHandle); + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonExtraThickToonOutlinePass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonExtraThickToonOutlinePass.cs index f1015b7..689349a 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonExtraThickToonOutlinePass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonExtraThickToonOutlinePass.cs @@ -2,6 +2,10 @@ using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { public class NiloToonExtraThickOutlinePass : ScriptableRenderPass @@ -175,5 +179,74 @@ namespace NiloToon.NiloToonURP cmd.Clear(); CommandBufferPool.Release(cmd); } + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + private class PassData + { + // Create a field to store the list of objects to draw + public RendererListHandle rendererListHandle; + } + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) + { + // Never draw in Preview + UniversalCameraData cameraData = frameContext.Get(); + Camera camera = cameraData.camera; + if (camera.cameraType == CameraType.Preview) + return; + + // Note: + // RenderQueueRange.Transparent should not be considered, since alpha can be 0~1, but stencil draw bit is 0/1 only + // Imagine a character with mostly transparent cloths where many pixels using 0~0.5 alpha for alpha blending, it will destroy all stencil-related rendering if we use RenderQueueRange.all + + DrawToActiveColorBufferByLightMode(renderGraph, frameContext, "NiloToonCharacterAreaStencilBufferFill", NiloToonCharacterAreaStencilBufferFill_LightModeShaderTagId, + SortingCriteria.CommonOpaque, RenderQueueRange.opaque); + DrawToActiveColorBufferByLightMode(renderGraph, frameContext, "NiloToonExtraThickOutline", NiloToonExtraThickOutline_LightModeShaderTagId, + SortingCriteria.CommonTransparent, RenderQueueRange.opaque); + DrawToActiveColorBufferByLightMode(renderGraph, frameContext, "NiloToonCharacterAreaColorFill", NiloToonCharacterAreaColorFill_LightModeShaderTagId, + SortingCriteria.CommonTransparent, RenderQueueRange.opaque); + } + + void DrawToActiveColorBufferByLightMode(RenderGraph renderGraph, ContextContainer frameContext, string passName, ShaderTagId lightMode, SortingCriteria sortFlags, RenderQueueRange renderQueueRange) + { + using (var builder = renderGraph.AddRasterRenderPass(passName, out var passData)) + { + // Get the data needed to create the list of objects to draw + UniversalRenderingData renderingData = frameContext.Get(); + UniversalCameraData cameraData = frameContext.Get(); + UniversalLightData lightData = frameContext.Get(); + UniversalResourceData resourceData = frameContext.Get(); + + FilteringSettings filterSettings = new FilteringSettings(renderQueueRange, ~0); + + // Redraw only objects that have their LightMode tag set to 'NiloToonCharacterAreaStencilBufferFill' + DrawingSettings drawSettings = + RenderingUtils.CreateDrawingSettings(lightMode, + renderingData, cameraData, lightData, sortFlags); + + // Create the list of objects to draw + var rendererListParameters = new RendererListParams(renderingData.cullResults, + drawSettings, filterSettings); + + // Convert the list to a list handle that the render graph system can use + passData.rendererListHandle = renderGraph.CreateRendererList(rendererListParameters); + + // Set the render target as the color and depth textures of the active camera texture + builder.UseRendererList(passData.rendererListHandle); + builder.SetRenderAttachment(resourceData.activeColorTexture, 0); + builder.SetRenderAttachmentDepth(resourceData.activeDepthTexture, AccessFlags.Write); + + builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context)); + } + } + + static void ExecutePass(PassData data, RasterGraphContext context) + { + // Draw the objects in the list + context.cmd.DrawRendererList(data.rendererListHandle); + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs new file mode 100644 index 0000000..d92a10e --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs @@ -0,0 +1,387 @@ +// Already existing Unity Motion Blur solutions (NiloToon's motion blur develop based on KinoMotion): +// https://github.com/keijiro/KinoMotion/tree/master +// https://github.com/keijiro/MotionBlurTest + +// Important Reference: +// https://casual-effects.com/research/McGuire2012Blur/McGuire12Blur.pdf + +// Other reference: +// https://github.com/raysjoshua/UnrealEngine/blob/master/Engine/Shaders/PostProcessMotionBlur.usf +// https://github.com/EpicGames/UnrealEngine/tree/release/Engine/Shaders/Private/MotionBlur +// https://john-chapman-graphics.blogspot.com/2013/01/per-object-motion-blur.html +// https://youtu.be/b0S6WMAfi0o?si=8KSxKDHz9Z95VbVt (A Reconstruction Filter for Plausible Motion Blur (I3D 12)) +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + +namespace NiloToon.NiloToonURP +{ + public class NiloToonMotionBlurPass : ScriptableRenderPass + { + [System.Serializable] + public class Settings + { + public bool allowRender = true; + } +#if UNITY_2022_3_OR_NEWER + private Material blurMaterial; + private RTHandle source; + private RTHandle tempRT0; + private RTHandle tempRT1; + private RTHandle copyRT; + + static class Uniforms + { + internal static readonly int _VelocityScale = Shader.PropertyToID("_VelocityScale"); + internal static readonly int _MaxBlurRadius = Shader.PropertyToID("_MaxBlurRadius"); + internal static readonly int _RcpMaxBlurRadius = Shader.PropertyToID("_RcpMaxBlurRadius"); + internal static readonly int _VelocityTex = Shader.PropertyToID("_VelocityTex"); + internal static readonly int _MainTex = Shader.PropertyToID("_MainTex"); + internal static readonly int _Tile2RT = Shader.PropertyToID("_Tile2RT"); + internal static readonly int _Tile4RT = Shader.PropertyToID("_Tile4RT"); + internal static readonly int _Tile8RT = Shader.PropertyToID("_Tile8RT"); + internal static readonly int _TileMaxOffs = Shader.PropertyToID("_TileMaxOffs"); + internal static readonly int _TileMaxLoop = Shader.PropertyToID("_TileMaxLoop"); + internal static readonly int _TileVRT = Shader.PropertyToID("_TileVRT"); + internal static readonly int _NeighborMaxTex = Shader.PropertyToID("_NeighborMaxTex"); + internal static readonly int _LoopCount = Shader.PropertyToID("_LoopCount"); + } + + enum Pass + { + VelocitySetup, + TileMax1, + TileMax2, + TileMaxV, + NeighborMax, + Reconstruction, + } + + private Settings settings; + private string profilerTag; + private float lastValidDeltaTime; + private Vector3 lastValidCameraPosWS; + private Matrix4x4 lastValidCameraViewProjMatrix; + private bool lastFrameIsSafeToApplyMotionBlur; + + public NiloToonMotionBlurPass(NiloToonRendererFeatureSettings settings) + { + this.settings = settings.motionBlurSettings; + renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; + profilerTag = "NiloToon Motion Blur"; + + if (blurMaterial == null) + { + blurMaterial = CoreUtils.CreateEngineMaterial("Hidden/NiloToon/NiloToonKinoMotionBlur"); + } + } + + // please always and only call this in ScriptableRendererFeature.AddRenderPasses() + public void ConfigureInputs(Camera camera) + { + ScriptableRenderPassInput input = ScriptableRenderPassInput.None; + + if (ShouldRender(camera)) + { + input = ScriptableRenderPassInput.Motion | ScriptableRenderPassInput.Depth; + } + + ConfigureInput(input); + } + + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + if(!ShouldRender(renderingData.cameraData.camera)) return; + + source = renderingData.cameraData.renderer.cameraColorTargetHandle; + + // Allocate temporary RTHandles + var descriptor = renderingData.cameraData.cameraTargetDescriptor; + descriptor.depthBufferBits = 0; + descriptor.colorFormat = RenderTextureFormat.RGHalf; // Use RGHalf for higher precision if needed + + float rt_TargetLength = GetRTTargetLength(descriptor); + float tileSize = GetTileSize(rt_TargetLength); + + int tileWidth = Mathf.CeilToInt(descriptor.width / tileSize); + int tileHeight = Mathf.CeilToInt(descriptor.height / tileSize); + + var tileDesc = descriptor; + tileDesc.width = tileWidth; + tileDesc.height = tileHeight; + + RenderingUtils.ReAllocateIfNeeded(ref tempRT0, tileDesc, name: "_TempRT0"); + RenderingUtils.ReAllocateIfNeeded(ref tempRT1, tileDesc, name: "_TempRT1"); + + var copyRTDesc = renderingData.cameraData.cameraTargetDescriptor; + copyRTDesc.depthBufferBits = 0; + RenderingUtils.ReAllocateIfNeeded(ref copyRT, copyRTDesc, name: "_CopyTex"); + } + + public float GetRTTargetLength(RenderTextureDescriptor descriptor) + { + return Mathf.Min(descriptor.width, descriptor.height); + } + + public float GetIntensity() + { + float deltaTime = Time.deltaTime; + + // handle editor pause, where Time.deltaTime is 0 + if (deltaTime <= 0f) + { + deltaTime = lastValidDeltaTime; + } + else + { + lastValidDeltaTime = deltaTime; + } + + if (deltaTime <= 0) return 0; // should not happen except the first frame + + var motionBlurPP = VolumeManager.instance.stack.GetComponent(); + + float intensity = motionBlurPP.intensity.value; // user custom multiplier control + + // make it fps independent (24fps 180 shutter angle as base, it is the perfect cinematic motion blur) + intensity /= deltaTime / (1f/24f); + + // * 0.5, so that when intensity in volume is 1, the result is matching ground truth 24fps 180 shutter angle from NiloToonMotionBlurVideoBaker) + intensity *= 0.5f; + return intensity; + } + public int GetTileSize(float rt_TargetLength) + { + // the ideal 1/48s shutter speed tileSize for: + // 4320p = 30 + // 2160p = 15 + // 1080p = 7.5 (=8) + int tileSize = Mathf.CeilToInt(rt_TargetLength / 4320f * 30f); + + // allow more blur bleed out + tileSize *= 4; + + return tileSize; + } + + bool IsCameraSafeToApplyMotionBlur( + Matrix4x4 prevViewProj, + Matrix4x4 currentViewProj, + Vector3 prevCamPos, + Vector3 currentCamPos) + { + // Default thresholds + const float maxPositionDiff = 2.0f; // units in world space + const float maxAngleDegrees = 15.0f; // degrees + const float maxSizeRatio = 2.0f; // maximum 2x screen size change (100% change) + + // 1. Position Check + float positionDiff = Vector3.Distance(currentCamPos, prevCamPos); + if (positionDiff > maxPositionDiff) + return false; + + // 2. Camera Direction Check + Vector3 prevForward = -new Vector3(prevViewProj.m20, prevViewProj.m21, prevViewProj.m22).normalized; + Vector3 currentForward = -new Vector3(currentViewProj.m20, currentViewProj.m21, currentViewProj.m22).normalized; + float dotProduct = Vector3.Dot(prevForward, currentForward); + float angleDiff = Mathf.Acos(Mathf.Clamp(dotProduct, -1.0f, 1.0f)) * Mathf.Rad2Deg; + + if (angleDiff > maxAngleDegrees) + return false; + + // 3. FOV Check - using screen size ratio directly + float prevTanHalfFOV = 1.0f / prevViewProj.m11; + float currentTanHalfFOV = 1.0f / currentViewProj.m11; + float screenSizeRatio = currentTanHalfFOV / prevTanHalfFOV; + + if (screenSizeRatio > maxSizeRatio || screenSizeRatio < 1.0f/maxSizeRatio) + return false; + + return true; + } + + public bool ShouldRender(Camera camera) + { + // if PIDI planar reflection enabled postFX, it will make the motion blur disable, + // so we need to disable motion blur for all PIDI planar reflection + if (NiloToonPlanarReflectionHelper.IsPlanarReflectionCamera(camera)) + return false; + + var motionBlurPP = VolumeManager.instance.stack.GetComponent(); + return motionBlurPP.IsActive() && settings.allowRender; + } + + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + if(!ShouldRender(renderingData.cameraData.camera)) return; + + if (blurMaterial == null || source == null) + { + Debug.LogError("Motion Blur: Missing required resources"); + return; + } + + CommandBuffer cmd = CommandBufferPool.Get(profilerTag); + + using (new ProfilingScope(cmd, new ProfilingSampler(profilerTag))) + { + var descriptor = renderingData.cameraData.cameraTargetDescriptor; + + float rt_TargetLength = GetRTTargetLength(descriptor); + + float intensity = GetIntensity(); + + Camera currentCam = renderingData.cameraData.camera; + bool thisFrameIsSafeToApplyMotionBlur = IsCameraSafeToApplyMotionBlur( + lastValidCameraViewProjMatrix, + currentCam.projectionMatrix * currentCam.worldToCameraMatrix, + lastValidCameraPosWS, + currentCam.transform.position); + + lastValidCameraPosWS = currentCam.transform.position; + lastValidCameraViewProjMatrix = currentCam.projectionMatrix * currentCam.worldToCameraMatrix; + + // debug + /* + if (lastFrameIsSafeToApplyMotionBlur == false && thisFrameIsSafeToApplyMotionBlur == false) + { + Debug.LogWarning("NiloToonMotionBlur 2 frames not safe to draw, is the auto detection too harsh?"); + } + */ + + lastFrameIsSafeToApplyMotionBlur = thisFrameIsSafeToApplyMotionBlur; + + + if (intensity > 0 && thisFrameIsSafeToApplyMotionBlur) + { + // [kino motion blur execute] + + // setup var (this section added by Nilo) + //----------------------------------------- + CommandBuffer cb = cmd; + const float kMaxBlurRadius = 5f; // max blur is 5% of screen + Material material = blurMaterial; + + // Texture format for storing 2D vectors. + RenderTextureFormat m_VectorRTFormat = RenderTextureFormat.RGHalf; + + // Texture format for storing packed velocity/depth. + RenderTextureFormat m_PackedRTFormat = RenderTextureFormat.ARGB2101010; + + float shutterAngle = 180f * intensity; + int sampleCount = 32; + + RTHandle destination =renderingData.cameraData.renderer.cameraColorTargetHandle; + //----------------------------------------- + + // Calculate the maximum blur radius in pixels. + int maxBlurPixels = (int)(kMaxBlurRadius * rt_TargetLength / 100); + + // Calculate the TileMax size. + // It should be a multiple of 8 and larger than maxBlur. + int tileSize = ((maxBlurPixels - 1) / 8 + 1) * 8; + + // Pass 1 - Velocity/depth packing + var velocityScale = shutterAngle / 360f; + cb.SetGlobalFloat(Uniforms._VelocityScale, velocityScale); + cb.SetGlobalFloat(Uniforms._MaxBlurRadius, maxBlurPixels); + cb.SetGlobalFloat(Uniforms._RcpMaxBlurRadius, 1f / maxBlurPixels); + + int vbuffer = Uniforms._VelocityTex; + cb.GetTemporaryRT(vbuffer, descriptor.width, descriptor.height, 0, FilterMode.Point, m_PackedRTFormat, RenderTextureReadWrite.Linear); + cb.Blit((Texture)null, vbuffer, material, (int)Pass.VelocitySetup); + + // Pass 2 - First TileMax filter (1/2 downsize) + int tile2 = Uniforms._Tile2RT; + cb.GetTemporaryRT(tile2, descriptor.width / 2, descriptor.height / 2, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear); + cb.SetGlobalTexture(Uniforms._MainTex, vbuffer); + cb.Blit(vbuffer, tile2, material, (int)Pass.TileMax1); + + // Pass 3 - Second TileMax filter (1/2 downsize) + int tile4 = Uniforms._Tile4RT; + cb.GetTemporaryRT(tile4, descriptor.width / 4, descriptor.height / 4, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear); + cb.SetGlobalTexture(Uniforms._MainTex, tile2); + cb.Blit(tile2, tile4, material, (int)Pass.TileMax2); + cb.ReleaseTemporaryRT(tile2); + + // Pass 4 - Third TileMax filter (1/2 downsize) + int tile8 = Uniforms._Tile8RT; + cb.GetTemporaryRT(tile8, descriptor.width / 8, descriptor.height / 8, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear); + cb.SetGlobalTexture(Uniforms._MainTex, tile4); + cb.Blit(tile4, tile8, material, (int)Pass.TileMax2); + cb.ReleaseTemporaryRT(tile4); + + // Pass 5 - Fourth TileMax filter (reduce to tileSize) + var tileMaxOffs = Vector2.one * (tileSize / 8f - 1f) * -0.5f; + cb.SetGlobalVector(Uniforms._TileMaxOffs, tileMaxOffs); + cb.SetGlobalFloat(Uniforms._TileMaxLoop, (int)(tileSize / 8f)); + + int tile = Uniforms._TileVRT; + cb.GetTemporaryRT(tile, descriptor.width / tileSize, descriptor.height / tileSize, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear); + cb.SetGlobalTexture(Uniforms._MainTex, tile8); + cb.Blit(tile8, tile, material, (int)Pass.TileMaxV); + cb.ReleaseTemporaryRT(tile8); + + // Pass 6 - NeighborMax filter + int neighborMax = Uniforms._NeighborMaxTex; + int neighborMaxWidth = descriptor.width / tileSize; + int neighborMaxHeight = descriptor.height / tileSize; + cb.GetTemporaryRT(neighborMax, neighborMaxWidth, neighborMaxHeight, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear); + cb.SetGlobalTexture(Uniforms._MainTex, tile); + cb.Blit(tile, neighborMax, material, (int)Pass.NeighborMax); + cb.ReleaseTemporaryRT(tile); + + // Copy the color buffer to use for sampling during the blur pass + Blitter.BlitCameraTexture(cmd, source, copyRT); + + // Pass 7 - Reconstruction pass + cb.SetGlobalFloat(Uniforms._LoopCount, Mathf.Clamp(sampleCount / 2, 1, 64)); + cb.SetGlobalTexture(Uniforms._MainTex, copyRT); + + cb.Blit(copyRT, destination, material, (int)Pass.Reconstruction); + + cb.ReleaseTemporaryRT(vbuffer); + cb.ReleaseTemporaryRT(neighborMax); + } + } + + context.ExecuteCommandBuffer(cmd); + CommandBufferPool.Release(cmd); + } + + public override void OnCameraCleanup(CommandBuffer cmd) + { + // do not write anything here + } + + public void Dispose() + { + tempRT0?.Release(); + tempRT1?.Release(); + copyRT?.Release(); + + CoreUtils.Destroy(blurMaterial); + } + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) + { + // TODO + } +#endif + +#else + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + // do nothing in Unity2021.3 (NiloToonMotionBlur requires Unity2022.3) + } +#endif + } +} diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs.meta b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs.meta new file mode 100644 index 0000000..4f15ada --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonMotionBlurPass.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 43e0ee4897ef30e419c96d4b44a18a2b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonPrepassBufferRTPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonPrepassBufferRTPass.cs index dda91b1..de34ee2 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonPrepassBufferRTPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonPrepassBufferRTPass.cs @@ -18,6 +18,10 @@ using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { public class NiloToonPrepassBufferRTPass : ScriptableRenderPass @@ -172,5 +176,15 @@ namespace NiloToon.NiloToonURP prepassBufferRTHDepth?.Release(); } #endif + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) + { + // TODO + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonScreenSpaceOutlinePass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonScreenSpaceOutlinePass.cs index f365ecf..3713fb9 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonScreenSpaceOutlinePass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonScreenSpaceOutlinePass.cs @@ -9,6 +9,10 @@ using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.XR; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { public class NiloToonScreenSpaceOutlinePass : ScriptableRenderPass @@ -67,15 +71,22 @@ namespace NiloToon.NiloToonURP // The render pipeline will ensure target setup and clearing happens in a performant manner. public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) { - ConfigureInput(renderingData); + ConfigureInput(renderingData.cameraData.cameraType); } - private void ConfigureInput(RenderingData renderingData) + public void ConfigureInput(CameraType cameraType) { // Nilotoon automatically turn on _CameraDepthTexture and _CameraNormalsTexture if needed, // so user don't need to turn on _CameraDepthTexture in their Universal Render Pipeline Asset manually. ScriptableRenderPassInput input = ScriptableRenderPassInput.None; - if (ShouldRenderScreenSpaceOutline(renderingData, false)) + + if (passDataCache == null) + { + passDataCache = new PassData(); + } + passDataCache.cameraType = cameraType; + + if (ShouldRenderScreenSpaceOutline(passDataCache, false)) { input |= ScriptableRenderPassInput.Depth; // screen space outline requires URP's _CameraDepthTexture input |= ScriptableRenderPassInput.Normal; // screen space outline requires URP's _CameraNormalsTexture @@ -83,9 +94,9 @@ namespace NiloToon.NiloToonURP ConfigureInput(input); } - private bool ShouldRenderScreenSpaceOutline(RenderingData renderingData, bool limitedToAllowedCameraTypeOnly) + private static bool ShouldRenderScreenSpaceOutline(PassData passData, bool limitedToAllowedCameraTypeOnly) { - bool shouldRenderScreenSpaceOutline = settings.AllowRenderScreenSpaceOutline; + bool shouldRenderScreenSpaceOutline = passData.AllowRenderScreenSpaceOutline; // when requesting URP to draw _CameraDepthTexture / _CameraNormalTexture via ConfigureInput(ScriptableRenderPassInput) (called inside OnCameraSetup()), // it is better to include all CameraType, else _CameraDepthTexture / _CameraNormalTexture maybe wrong when mouse is moving across different CameraType windows @@ -94,7 +105,7 @@ namespace NiloToon.NiloToonURP // In preview window, screenSpaceOutlineVolumeEffect.IsActive() will return false even volume exists in scene and is active, // which will produce screen space outline flicker problem, // so in preview window, we skip volume check - if (renderingData.cameraData.cameraType != CameraType.Preview) + if (passData.cameraType != CameraType.Preview) { var screenSpaceOutlineVolume = VolumeManager.instance.stack.GetComponent(); var screenSpaceOutlineV2Volume = VolumeManager.instance.stack.GetComponent(); @@ -106,12 +117,12 @@ namespace NiloToon.NiloToonURP if (limitedToAllowedCameraTypeOnly) { // CameraType.Game is always needed - bool isAllowedCameraType = renderingData.cameraData.cameraType == CameraType.Game; + bool isAllowedCameraType = passData.cameraType == CameraType.Game; // we still provided option to On/Off screen space outline's drawing in SceneView, default is off since it maybe disturbing due to low resolution - if (settings.AllowRenderScreenSpaceOutlineInSceneView) + if (passData.AllowRenderScreenSpaceOutlineInSceneView) { - isAllowedCameraType |= renderingData.cameraData.cameraType == CameraType.SceneView; + isAllowedCameraType |= passData.cameraType == CameraType.SceneView; } shouldRenderScreenSpaceOutline &= isAllowedCameraType; @@ -135,6 +146,8 @@ namespace NiloToon.NiloToonURP // do nothing } + private PassData passDataCache; + private void renderScreenSpaceOutline(ScriptableRenderContext context, RenderingData renderingData) { CommandBuffer cmd = CommandBufferPool.Get(); @@ -150,133 +163,16 @@ namespace NiloToon.NiloToonURP context.ExecuteCommandBuffer(cmd); cmd.Clear(); - bool shouldRenderScreenSpaceOutline = ShouldRenderScreenSpaceOutline(renderingData, true); - bool isScreenSpaceOutlineV1Active = VolumeManager.instance.stack.GetComponent().IsActive(); - bool isScreenSpaceOutlineV2Active = VolumeManager.instance.stack.GetComponent().IsActive(); - - // V1 will be override by V2 - bool shouldRenderScreenSpaceOutlineV2 = shouldRenderScreenSpaceOutline && isScreenSpaceOutlineV2Active; - bool shouldRenderScreenSpaceOutlineV1 = (shouldRenderScreenSpaceOutline && isScreenSpaceOutlineV1Active) && !shouldRenderScreenSpaceOutlineV2; - - // WIP temp code - // disable SS outline V2, prevent user using it - shouldRenderScreenSpaceOutlineV2 = false; - - if (shouldRenderScreenSpaceOutlineV1) + if (passDataCache == null) { - var v = VolumeManager.instance.stack.GetComponent(); - - float screenSpaceOutlineIntensityForChar = v.intensity.value * v.intensityForCharacter.value; - float screenSpaceOutlineIntensityForEnvi = v.intensity.value * v.intensityForEnvironment.value; - - float screenSpaceOutlineWidthMultiplierForChar = v.widthMultiplier.value * v.widthMultiplierForCharacter.value; - float screenSpaceOutlineWidthMultiplierForEnvi = v.widthMultiplier.value * v.widthMultiplierForEnvironment.value; - - // extra outline control if XR - if (XRSettings.isDeviceActive) - { - screenSpaceOutlineWidthMultiplierForChar *= v.extraWidthMultiplierForXR.value; - screenSpaceOutlineWidthMultiplierForEnvi *= v.extraWidthMultiplierForXR.value; - } - - float screenSpaceOutlineDepthSensitivityGlobalOffsetForChar = v.depthSensitivityOffset.value + v.depthSensitivityOffsetForCharacter.value; - float screenSpaceOutlineDepthSensitivityGlobalOffsetForEnvi = v.depthSensitivityOffset.value + v.depthSensitivityOffsetForEnvironment.value; - - float screenSpaceOutlineNormalsSensitivityGlobalOffsetForChar = v.normalsSensitivityOffset.value + v.normalsSensitivityOffsetForCharacter.value; - float screenSpaceOutlineNormalsSensitivityGlobalOffsetForEnvi = v.normalsSensitivityOffset.value + v.normalsSensitivityOffsetForEnvironment.value; - - float screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar = v.depthSensitivityDistanceFadeoutStrength.value * v.depthSensitivityDistanceFadeoutStrengthForCharacter.value; - float screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi = v.depthSensitivityDistanceFadeoutStrength.value * v.depthSensitivityDistanceFadeoutStrengthForEnvironment.value; - - Color screenSpaceOutlineTintColorForChar = v.outlineTintColor.value * v.outlineTintColorForChar.value; - Color screenSpaceOutlineTintColorForEnvi = v.outlineTintColor.value * v.outlineTintColorForEnvi.value; - - // values that send to shader is defined here, adjustment is applyied in order to make volume UI's default value always = 0 or 1 (easier for user) - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineIntensityForChar_SID, screenSpaceOutlineIntensityForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineIntensityForEnvi_SID, screenSpaceOutlineIntensityForEnvi); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineWidthMultiplierForChar_SID, screenSpaceOutlineWidthMultiplierForChar * 1.875f); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineWidthMultiplierForEnvi_SID, screenSpaceOutlineWidthMultiplierForEnvi * 1.875f); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityOffsetForChar_SID, screenSpaceOutlineDepthSensitivityGlobalOffsetForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityOffsetForEnvi_SID, screenSpaceOutlineDepthSensitivityGlobalOffsetForEnvi); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineNormalsSensitivityOffsetForChar_SID, screenSpaceOutlineNormalsSensitivityGlobalOffsetForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineNormalsSensitivityOffsetForEnvi_SID, screenSpaceOutlineNormalsSensitivityGlobalOffsetForEnvi + 0.25f); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar_SID, screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi_SID, screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi); - - cmd.SetGlobalColor(_GlobalScreenSpaceOutlineTintColorForChar_SID, screenSpaceOutlineTintColorForChar); - cmd.SetGlobalColor(_GlobalScreenSpaceOutlineTintColorForEnvi_SID, screenSpaceOutlineTintColorForEnvi); + passDataCache = new PassData(); } - CoreUtils.SetKeyword(cmd, "_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE", shouldRenderScreenSpaceOutlineV1); + passDataCache.cameraType = renderingData.cameraData.cameraType; + passDataCache.AllowRenderScreenSpaceOutline = settings.AllowRenderScreenSpaceOutline; + passDataCache.AllowRenderScreenSpaceOutlineInSceneView = settings.AllowRenderScreenSpaceOutlineInSceneView; - //--------------------------------------------------------------------------------------------------------------------------------------- - // V2 - //--------------------------------------------------------------------------------------------------------------------------------------- - if (shouldRenderScreenSpaceOutlineV2) - { - var v = VolumeManager.instance.stack.GetComponent(); - - //---------------------------------------------------------------------------------------------- - // Intensity - //---------------------------------------------------------------------------------------------- - float intensityForChar = v.intensity.value * v.intensityForCharacter.value; - float intensityForEnvi = v.intensity.value * v.intensityForEnvironment.value; - - //---------------------------------------------------------------------------------------------- - // Width - //---------------------------------------------------------------------------------------------- - float widthForChar = v.widthMultiplier.value * v.widthMultiplierForCharacter.value; - float widthForEnvi = v.widthMultiplier.value * v.widthMultiplierForEnvironment.value; - - //---------------------------------------------------------------------------------------------- - // Geometry Edge - //---------------------------------------------------------------------------------------------- - bool enableGeometryEdgeForChar = v.drawGeometryEdgeOutlineForChar.value && v.drawGeometryEdgeOutline.value; - bool enableGeometryEdgeForEnvi = v.drawGeometryEdgeOutlineForEnvi.value && v.drawGeometryEdgeOutline.value; - float geometryEdgeThresholdForChar = v.geometryEdgeThresholdForCharacter.overrideState ? v.geometryEdgeThresholdForCharacter.value : v.geometryEdgeThreshold.value; - float geometryEdgeThresholdForEnvi = v.geometryEdgeThresholdForEnvironment.overrideState ? v.geometryEdgeThresholdForEnvironment.value : v.geometryEdgeThreshold.value; - // 0.001 threshold value in volume = 0.0003cm, it is the smallest threshold that shows most of the wireframe but just before precision noise artifact comes out - const float safeMinGeometryEdgeThreshold = 0.001f; - geometryEdgeThresholdForChar = Mathf.Max(safeMinGeometryEdgeThreshold, geometryEdgeThresholdForChar); - geometryEdgeThresholdForEnvi = Mathf.Max(safeMinGeometryEdgeThreshold, geometryEdgeThresholdForEnvi); - // threshold used in shader is in meter unit, = 0.3cm when threshold value in volume is 1 - geometryEdgeThresholdForChar *= 0.003f; - geometryEdgeThresholdForEnvi *= 0.003f; - - //---------------------------------------------------------------------------------------------- - // Normal Angle - //---------------------------------------------------------------------------------------------- - bool enableNormalAngleEdgeForChar = v.drawNormalAngleOutlineForChar.value && v.drawNormalAngleOutline.value; - bool enableNormalAngleEdgeForEnvi = v.drawNormalAngleOutlineForEnvi.value && v.drawNormalAngleOutline.value; - float normalAngleThresholdForChar = v.normalAngleMinForCharacter.overrideState ? v.normalAngleMinForCharacter.value : v.normalAngleMin.value; - float normalAngleThresholdForEnvi = v.normalAngleMinForEnvironment.overrideState ? v.normalAngleMinForEnvironment.value : v.normalAngleMin.value; - float normalAngleCosThetaThresholdForChar = Mathf.Cos(Mathf.Deg2Rad * normalAngleThresholdForChar); - float normalAngleCosThetaThresholdForEnvi = Mathf.Cos(Mathf.Deg2Rad * normalAngleThresholdForEnvi); - - //---------------------------------------------------------------------------------------------- - // Set Global param for shader - //---------------------------------------------------------------------------------------------- - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2IntensityForChar_SID, intensityForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2IntensityForEnvi_SID, intensityForEnvi); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2WidthMultiplierForChar_SID, widthForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2WidthMultiplierForEnvi_SID, widthForEnvi); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableGeometryEdgeForChar_SID, enableGeometryEdgeForChar ? 1 : 0); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableGeometryEdgeForEnvi_SID, enableGeometryEdgeForEnvi ? 1 : 0); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2GeometryEdgeThresholdForChar_SID, geometryEdgeThresholdForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2GeometryEdgeThresholdForEnvi_SID,geometryEdgeThresholdForEnvi); - - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableNormalAngleEdgeForChar_SID, enableNormalAngleEdgeForChar ? 1 : 0); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableNormalAngleEdgeForEnvi_SID, enableNormalAngleEdgeForEnvi ? 1 : 0); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2NormalAngleCosThetaThresholdForChar_SID, normalAngleCosThetaThresholdForChar); - cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2NormalAngleCosThetaThresholdForEnvi_SID,normalAngleCosThetaThresholdForEnvi); - } - CoreUtils.SetKeyword(cmd, "_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE_V2", shouldRenderScreenSpaceOutlineV2); + ExecutePassShared(cmd, passDataCache); } // must write these line after using{} finished, to ensure profiler and frame debugger display correctness @@ -284,5 +180,191 @@ namespace NiloToon.NiloToonURP cmd.Clear(); CommandBufferPool.Release(cmd); } + + private static void ExecutePassShared(CommandBuffer cmd, PassData passData) + { + bool shouldRenderScreenSpaceOutline = ShouldRenderScreenSpaceOutline(passData, true); + bool isScreenSpaceOutlineV1Active = VolumeManager.instance.stack.GetComponent().IsActive(); + bool isScreenSpaceOutlineV2Active = VolumeManager.instance.stack.GetComponent().IsActive(); + + // V1 will be override by V2 + bool shouldRenderScreenSpaceOutlineV2 = shouldRenderScreenSpaceOutline && isScreenSpaceOutlineV2Active; + bool shouldRenderScreenSpaceOutlineV1 = (shouldRenderScreenSpaceOutline && isScreenSpaceOutlineV1Active) && !shouldRenderScreenSpaceOutlineV2; + + // WIP temp code + // disable SS outline V2, prevent user using it + shouldRenderScreenSpaceOutlineV2 = false; + + if (shouldRenderScreenSpaceOutlineV1) + { + var v = VolumeManager.instance.stack.GetComponent(); + + float screenSpaceOutlineIntensityForChar = v.intensity.value * v.intensityForCharacter.value; + float screenSpaceOutlineIntensityForEnvi = v.intensity.value * v.intensityForEnvironment.value; + + float screenSpaceOutlineWidthMultiplierForChar = v.widthMultiplier.value * v.widthMultiplierForCharacter.value; + float screenSpaceOutlineWidthMultiplierForEnvi = v.widthMultiplier.value * v.widthMultiplierForEnvironment.value; + + // extra outline control if XR + if (XRSettings.isDeviceActive) + { + screenSpaceOutlineWidthMultiplierForChar *= v.extraWidthMultiplierForXR.value; + screenSpaceOutlineWidthMultiplierForEnvi *= v.extraWidthMultiplierForXR.value; + } + + float screenSpaceOutlineDepthSensitivityGlobalOffsetForChar = v.depthSensitivityOffset.value + v.depthSensitivityOffsetForCharacter.value; + float screenSpaceOutlineDepthSensitivityGlobalOffsetForEnvi = v.depthSensitivityOffset.value + v.depthSensitivityOffsetForEnvironment.value; + + float screenSpaceOutlineNormalsSensitivityGlobalOffsetForChar = v.normalsSensitivityOffset.value + v.normalsSensitivityOffsetForCharacter.value; + float screenSpaceOutlineNormalsSensitivityGlobalOffsetForEnvi = v.normalsSensitivityOffset.value + v.normalsSensitivityOffsetForEnvironment.value; + + float screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar = v.depthSensitivityDistanceFadeoutStrength.value * v.depthSensitivityDistanceFadeoutStrengthForCharacter.value; + float screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi = v.depthSensitivityDistanceFadeoutStrength.value * v.depthSensitivityDistanceFadeoutStrengthForEnvironment.value; + + Color screenSpaceOutlineTintColorForChar = v.outlineTintColor.value * v.outlineTintColorForChar.value; + Color screenSpaceOutlineTintColorForEnvi = v.outlineTintColor.value * v.outlineTintColorForEnvi.value; + + // values that send to shader is defined here, adjustment is applyied in order to make volume UI's default value always = 0 or 1 (easier for user) + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineIntensityForChar_SID, screenSpaceOutlineIntensityForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineIntensityForEnvi_SID, screenSpaceOutlineIntensityForEnvi); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineWidthMultiplierForChar_SID, screenSpaceOutlineWidthMultiplierForChar * 1.875f); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineWidthMultiplierForEnvi_SID, screenSpaceOutlineWidthMultiplierForEnvi * 1.875f); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityOffsetForChar_SID, screenSpaceOutlineDepthSensitivityGlobalOffsetForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityOffsetForEnvi_SID, screenSpaceOutlineDepthSensitivityGlobalOffsetForEnvi); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineNormalsSensitivityOffsetForChar_SID, screenSpaceOutlineNormalsSensitivityGlobalOffsetForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineNormalsSensitivityOffsetForEnvi_SID, screenSpaceOutlineNormalsSensitivityGlobalOffsetForEnvi + 0.25f); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar_SID, screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi_SID, screenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi); + + cmd.SetGlobalColor(_GlobalScreenSpaceOutlineTintColorForChar_SID, screenSpaceOutlineTintColorForChar); + cmd.SetGlobalColor(_GlobalScreenSpaceOutlineTintColorForEnvi_SID, screenSpaceOutlineTintColorForEnvi); + } + + CoreUtils.SetKeyword(cmd, "_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE", shouldRenderScreenSpaceOutlineV1); + + //--------------------------------------------------------------------------------------------------------------------------------------- + // V2 + //--------------------------------------------------------------------------------------------------------------------------------------- + if (shouldRenderScreenSpaceOutlineV2) + { + var v = VolumeManager.instance.stack.GetComponent(); + + //---------------------------------------------------------------------------------------------- + // Intensity + //---------------------------------------------------------------------------------------------- + float intensityForChar = v.intensity.value * v.intensityForCharacter.value; + float intensityForEnvi = v.intensity.value * v.intensityForEnvironment.value; + + //---------------------------------------------------------------------------------------------- + // Width + //---------------------------------------------------------------------------------------------- + float widthForChar = v.widthMultiplier.value * v.widthMultiplierForCharacter.value; + float widthForEnvi = v.widthMultiplier.value * v.widthMultiplierForEnvironment.value; + + //---------------------------------------------------------------------------------------------- + // Geometry Edge + //---------------------------------------------------------------------------------------------- + bool enableGeometryEdgeForChar = v.drawGeometryEdgeOutlineForChar.value && v.drawGeometryEdgeOutline.value; + bool enableGeometryEdgeForEnvi = v.drawGeometryEdgeOutlineForEnvi.value && v.drawGeometryEdgeOutline.value; + float geometryEdgeThresholdForChar = v.geometryEdgeThresholdForCharacter.overrideState ? v.geometryEdgeThresholdForCharacter.value : v.geometryEdgeThreshold.value; + float geometryEdgeThresholdForEnvi = v.geometryEdgeThresholdForEnvironment.overrideState ? v.geometryEdgeThresholdForEnvironment.value : v.geometryEdgeThreshold.value; + // 0.001 threshold value in volume = 0.0003cm, it is the smallest threshold that shows most of the wireframe but just before precision noise artifact comes out + const float safeMinGeometryEdgeThreshold = 0.001f; + geometryEdgeThresholdForChar = Mathf.Max(safeMinGeometryEdgeThreshold, geometryEdgeThresholdForChar); + geometryEdgeThresholdForEnvi = Mathf.Max(safeMinGeometryEdgeThreshold, geometryEdgeThresholdForEnvi); + // threshold used in shader is in meter unit, = 0.3cm when threshold value in volume is 1 + geometryEdgeThresholdForChar *= 0.003f; + geometryEdgeThresholdForEnvi *= 0.003f; + + //---------------------------------------------------------------------------------------------- + // Normal Angle + //---------------------------------------------------------------------------------------------- + bool enableNormalAngleEdgeForChar = v.drawNormalAngleOutlineForChar.value && v.drawNormalAngleOutline.value; + bool enableNormalAngleEdgeForEnvi = v.drawNormalAngleOutlineForEnvi.value && v.drawNormalAngleOutline.value; + float normalAngleThresholdForChar = v.normalAngleMinForCharacter.overrideState ? v.normalAngleMinForCharacter.value : v.normalAngleMin.value; + float normalAngleThresholdForEnvi = v.normalAngleMinForEnvironment.overrideState ? v.normalAngleMinForEnvironment.value : v.normalAngleMin.value; + float normalAngleCosThetaThresholdForChar = Mathf.Cos(Mathf.Deg2Rad * normalAngleThresholdForChar); + float normalAngleCosThetaThresholdForEnvi = Mathf.Cos(Mathf.Deg2Rad * normalAngleThresholdForEnvi); + + //---------------------------------------------------------------------------------------------- + // Set Global param for shader + //---------------------------------------------------------------------------------------------- + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2IntensityForChar_SID, intensityForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2IntensityForEnvi_SID, intensityForEnvi); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2WidthMultiplierForChar_SID, widthForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2WidthMultiplierForEnvi_SID, widthForEnvi); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableGeometryEdgeForChar_SID, enableGeometryEdgeForChar ? 1 : 0); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableGeometryEdgeForEnvi_SID, enableGeometryEdgeForEnvi ? 1 : 0); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2GeometryEdgeThresholdForChar_SID, geometryEdgeThresholdForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2GeometryEdgeThresholdForEnvi_SID,geometryEdgeThresholdForEnvi); + + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableNormalAngleEdgeForChar_SID, enableNormalAngleEdgeForChar ? 1 : 0); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2EnableNormalAngleEdgeForEnvi_SID, enableNormalAngleEdgeForEnvi ? 1 : 0); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2NormalAngleCosThetaThresholdForChar_SID, normalAngleCosThetaThresholdForChar); + cmd.SetGlobalFloat(_GlobalScreenSpaceOutlineV2NormalAngleCosThetaThresholdForEnvi_SID,normalAngleCosThetaThresholdForEnvi); + } + CoreUtils.SetKeyword(cmd, "_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE_V2", shouldRenderScreenSpaceOutlineV2); + } + + class PassData + { + public CameraType cameraType; + public bool AllowRenderScreenSpaceOutline; + public bool AllowRenderScreenSpaceOutlineInSceneView; + } + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// + // copy and edit of https://docs.unity3d.com/6000.2/Documentation/Manual/urp/render-graph-write-render-pass.html +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + string passName = "NiloToonScreenSpaceOutline(RG)"; + + using (var builder = renderGraph.AddUnsafePass(passName, out var passData)) + { + UniversalResourceData resourceData = frameData.Get(); + + UniversalCameraData cameraData = frameData.Get(); + UniversalRenderingData renderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + //============================================ + // request URP depth texture + //============================================ + // DANGER!!!!!!!!!! + // Calling ConfigureInput(...) inside this RecordRenderGraph() method will prevent unity android build (error produced) (https://discussions.unity.com/t/introduction-of-render-graph-in-the-universal-render-pipeline-urp/930355/226) + // We now call ConfigureInput(...) in NiloToonAllInOneRenderereFeature's AddRenderPasses as a temp workaround. + //ConfigureInput(cameraData.cameraType); + + //-------------------------------------- + // fill in passData + //-------------------------------------- + passData.cameraType = cameraData.cameraType; + passData.AllowRenderScreenSpaceOutline = settings.AllowRenderScreenSpaceOutline; + passData.AllowRenderScreenSpaceOutlineInSceneView = settings.AllowRenderScreenSpaceOutlineInSceneView; + //-------------------------------------- + + builder.AllowPassCulling(false); + builder.AllowGlobalStateModification(true); + + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => ExecutePassRG(data, context)); + } + } + static void ExecutePassRG(PassData passData, UnsafeGraphContext context) + { + // Convert UnsafeCommandBuffer to a regular CommandBuffer, our ExecutePassShared() use the regular CommandBuffer + CommandBuffer rawCommandBuffer = CommandBufferHelpers.GetNativeCommandBuffer(context.cmd); + + ExecutePassShared(rawCommandBuffer, passData); + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonSetToonParamPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonSetToonParamPass.cs index b53e865..81eab6a 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonSetToonParamPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonSetToonParamPass.cs @@ -1,10 +1,19 @@ using System; +using System.Collections.Generic; using System.Reflection; +using Unity.Collections; using UnityEngine; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +#if UNITY_EDITOR +using UnityEditor.ShaderKeywordFilter; +#endif +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { public class NiloToonSetToonParamPass : ScriptableRenderPass @@ -15,6 +24,12 @@ namespace NiloToon.NiloToonURP { [Header("Receive URP Shadow map")] +#if UNITY_EDITOR + //[SerializeField] + //[RemoveIf(false, keywordNames: "_MAIN_LIGHT_SHADOWS", overridePriority: true)] + //[RemoveIf(false, keywordNames: "_MAIN_LIGHT_SHADOWS_CASCADE", overridePriority: true)] + //[RemoveIf(false, keywordNames: "_MAIN_LIGHT_SHADOWS_SCREEN", overridePriority: true)] +#endif [Tooltip( "- Turning ON allows NiloToon Characters to receive the URP shadow map, just like any Lit shader material.\n" + "- Turning OFF disables NiloToon Characters from receiving the URP shadow map, which can improve performance.\n\n" + "The default value is OFF because it generally looks better (visually more stable).\n" + @@ -266,10 +281,22 @@ namespace NiloToon.NiloToonURP // The render pipeline will ensure target setup and clearing happens in a performant manner. public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) { - // call per frame and cache result - isDeferredRendering = IsDeferredRendering(renderingData); + ConfigureInputs(renderingData.cameraData.renderer); + } + public void ConfigureInputs(ScriptableRenderer renderer) + { + var input = GetScriptableRenderPassInput(renderer); + + ConfigureInput(input); + } + + private ScriptableRenderPassInput GetScriptableRenderPassInput(ScriptableRenderer renderer) + { ScriptableRenderPassInput input = ScriptableRenderPassInput.None; + + // call per frame and cache result + isDeferredRendering = IsDeferredRendering(renderer); if (GetEnableDepthTextureRimLigthAndShadow(Setting)) { @@ -287,10 +314,10 @@ namespace NiloToon.NiloToonURP } } - ConfigureInput(input); + return input; } - private bool IsDeferredRendering(RenderingData renderingData) + private bool IsDeferredRendering(ScriptableRenderer renderer) { // [find out is Deferred Rendering or not] // we want to get UniversalRenderer.cs's actualRenderingMode, but it is internal, @@ -300,7 +327,6 @@ namespace NiloToon.NiloToonURP // in Unity2022.1, URP renamed URP12's actualRenderingMode to URP13's renderingModeActual actualRenderingMode_PropertyName = "renderingModeActual"; #endif - UniversalRenderer renderer = renderingData.cameraData.renderer as UniversalRenderer; if (actualRenderingMode_PropertyInfo == null) { @@ -316,10 +342,16 @@ namespace NiloToon.NiloToonURP // PropertyInfo.GetValue(...) is reflection, which will have GC allocate per frame, // but currently we don't have a way to avoid GC and at the same time ensure correct "actualRenderingMode" per frame, // since it is not safe the cache the result of GetValue(...) as user may change it anytime - RenderingMode actualRenderingMode = actualRenderingMode_Getter(renderer); + RenderingMode actualRenderingMode = actualRenderingMode_Getter(renderer as UniversalRenderer); //RenderingMode actualRenderingMode = (RenderingMode)actualRenderingMode_PropertyInfo.GetValue(renderer); // this also works and it is much more simpler, but will GC alloc more bool isDeferredRendering = actualRenderingMode == RenderingMode.Deferred; + +#if UNITY_6000_1_OR_NEWER + // Unity6.1 added Deferred+ + isDeferredRendering |= actualRenderingMode == RenderingMode.DeferredPlus; +#endif + return isDeferredRendering; } @@ -338,7 +370,7 @@ namespace NiloToon.NiloToonURP NiloToonPlanarReflectionHelper.EndPlanarReflectionCameraRender(ref cmd); } - private bool GetEnableDepthTextureRimLigthAndShadow(Settings settings) + private static bool GetEnableDepthTextureRimLigthAndShadow(Settings settings) { // VolumeManager null check, since this method can be called by RendererPass's constructor, which is not safe to call VolumeManager var performanceSettingVolume = VolumeManager.instance?.stack?.GetComponent(); @@ -355,17 +387,11 @@ namespace NiloToon.NiloToonURP return settings.EnableDepthTextureRimLigthAndShadow; } } + + private PassData passData; private void setParam(ScriptableRenderContext context, RenderingData renderingData) { - // these volumes will not be null, even if Volume doesn't exist in scene - var charRenderingControlVolume = VolumeManager.instance.stack.GetComponent(); - var cinematicAdditionalLightVolume = VolumeManager.instance.stack.GetComponent(); - var additionalLightStyleVolume = VolumeManager.instance.stack.GetComponent(); - var shadowControlVolume = VolumeManager.instance.stack.GetComponent(); - var environmentControlVolume = VolumeManager.instance.stack.GetComponent(); - var bloomVolume = VolumeManager.instance.stack.GetComponent(); - // NOTE: Do NOT mix ProfilingScope with named CommandBuffers i.e. CommandBufferPool.Get("name"). // Currently there's an issue which results in mismatched markers. CommandBuffer cmd = CommandBufferPool.Get(); @@ -381,416 +407,22 @@ namespace NiloToon.NiloToonURP context.ExecuteCommandBuffer(cmd); cmd.Clear(); - ////////////////////////////////////////////////////////////////////////////////////////////////// - // special process for any possible planar reflection camera - ////////////////////////////////////////////////////////////////////////////////////////////////// - if (NiloToonPlanarReflectionHelper.IsPlanarReflectionCamera(renderingData.cameraData.camera)) + if (passData == null) { - NiloToonPlanarReflectionHelper.BeginPlanarReflectionCameraRender(ref cmd); + passData = new PassData(); } - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // additional light keyword on/off - ////////////////////////////////////////////////////////////////////////////////////////////////// - // see URP's ForwardLights.cs -> SetUp(), where URP enable additional light keywords - // here we combine URP's per vertex / per pixel keywords into 1 keyword, to reduce multi_compile shader variant count, since we always need vertex light only by design - CoreUtils.SetKeyword(cmd, "_NILOTOON_ADDITIONAL_LIGHTS", renderingData.lightData.additionalLightsCount > 0); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // URP shadow related global settings - ////////////////////////////////////////////////////////////////////////////////////////////////// - // [findout main light's shadow is enabled or not] - // see URP's MainLightShadowCasterPass.cs -> RenderMainLightCascadeShadowmap(), where URP enable main light shadow keyword - int shadowLightIndex = renderingData.lightData.mainLightIndex; - bool mainLightEnabledShadow = shadowLightIndex != -1; - - // volume override URP shadow related params - bool receiveURPShadow = shadowControlVolume.receiveURPShadow.overrideState ? shadowControlVolume.receiveURPShadow.value : Setting.ShouldReceiveURPShadows; - float URPShadowIntensity = shadowControlVolume.URPShadowIntensity.overrideState ? shadowControlVolume.URPShadowIntensity.value : Setting.URPShadowIntensity; - Color URPShadowAsDirectLightTintColor = shadowControlVolume.URPShadowAsDirectLightTintColor.value; - URPShadowAsDirectLightTintColor *= shadowControlVolume.URPShadowAsDirectLightMultiplier.value; - float ReceiveURPShadowblurriness = shadowControlVolume.URPShadowblurriness.value * 0.5f; // in shader, we want 0 ~ 0.5, not 0 ~ 1 - float URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting = shadowControlVolume.URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting.value; - - // here we combine URP's main light shadow keyword and our ShouldReceiveURPShadows keyword into 1, to reduce the number of multi_compile shader variant - CoreUtils.SetKeyword(cmd, "_NILOTOON_RECEIVE_URP_SHADOWMAPPING", receiveURPShadow && mainLightEnabledShadow); - cmd.SetGlobalFloat(_GlobalReceiveURPShadowAmount_SID, URPShadowIntensity); - cmd.SetGlobalFloat(_GlobalToonShaderNormalBiasMultiplier_SID, Setting.URPShadowNormalBiasMultiplier); - cmd.SetGlobalFloat(_GlobalReceiveSelfShadowMappingPosOffset_SID, Setting.URPShadowDepthBias); - cmd.SetGlobalColor(_GlobalMainLightURPShadowAsDirectResultTintColor_SID, URPShadowAsDirectLightTintColor); - cmd.SetGlobalFloat(_GlobalNiloToonReceiveURPShadowblurriness_SID, ReceiveURPShadowblurriness); - cmd.SetGlobalFloat(_GlobalURPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting_SID, URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // RT(screen) aspect - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalVector(_GlobalAspectFix_SID, new Vector2((float)renderingData.cameraData.camera.pixelHeight / (float)renderingData.cameraData.camera.pixelWidth, 1f)); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // camera fov - ////////////////////////////////////////////////////////////////////////////////////////////////// - Camera camera = renderingData.cameraData.camera; - - // we need to calculate fov here, because if camera is using "Physical Camera", camera.fieldOfView is not correct, while camera.projectionMatrix is always correct - float cameraFieldOfView = 2 * Mathf.Atan(1f / camera.projectionMatrix.m11) * 180 / Mathf.PI; - cmd.SetGlobalFloat(_GlobalFOVorOrthoSizeFix_SID, 1f / (camera.orthographic ? camera.orthographicSize * 100f : cameraFieldOfView)); - cmd.SetGlobalFloat(_CurrentCameraFOV_SID, cameraFieldOfView); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // main light shader data override - ////////////////////////////////////////////////////////////////////////////////////////////////// - - // init with values when no light information(Light/NiloToonCharacterMainLightOverrider/NiloToonCharRenderingControlVolume) exist - Vector3 finalMainLightShaderDirWS = Vector3.up; - Color finalMainLightColor = Color.black; - - // [0.fill with URP's main light first] - int mainLightIndex = renderingData.lightData.mainLightIndex; + passData.camera = renderingData.cameraData.camera; + passData.additionalLightsCount = renderingData.lightData.additionalLightsCount; + passData.mainLightIndex = renderingData.lightData.mainLightIndex; + passData.Setting = Setting; + passData.visibleLights = renderingData.lightData.visibleLights; + passData.renderer = renderingData.cameraData.renderer; + passData.needCorrectDepthTextureDepthWrite = GetNeedCorrectDepthTextureDepthWrite(renderingData.cameraData.renderer); - // Note: when mainLight doesn't exist, mainLightIndex will be -1 - bool isURPMainLightExist = mainLightIndex != -1; - if (isURPMainLightExist) - { - // mainLight exist, get it's direction and color - VisibleLight mainLight = renderingData.lightData.visibleLights[mainLightIndex]; - finalMainLightShaderDirWS = -mainLight.light.transform.forward; - finalMainLightColor = mainLight.finalColor; - - // [1.Light modifier] - float finalContributeIntoMainLightColor = 1; - float finalContributeIntoMainLightDirection = 1; - float finalContributeIntoMainLightColorApplyDesaturation = 0; - - int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; - for (int lightModifierIndex = 0; lightModifierIndex < activeLightModifierScriptCount; lightModifierIndex++) - { - NiloToonLightSourceModifier script = NiloToonLightSourceModifier.AllNiloToonLightModifiers[lightModifierIndex]; - - if (!script) continue; - - if (script.AffectsLight(mainLight.light)) - { - finalContributeIntoMainLightColor *= script.contributeToMainLightColor; - finalContributeIntoMainLightDirection *= script.contributeToMainLightDirection; - finalContributeIntoMainLightColorApplyDesaturation = Mathf.Lerp(finalContributeIntoMainLightColorApplyDesaturation, 1, script.applyDesaturateWhenContributeToMainLightColor); - } - } - - finalMainLightColor *= finalContributeIntoMainLightColor; - finalMainLightShaderDirWS *= finalContributeIntoMainLightDirection; - finalMainLightColor = Color.Lerp(finalMainLightColor, finalMainLightColor.grayscale * Color.white, finalContributeIntoMainLightColorApplyDesaturation); - } + FillInPassDataArray(passData); - // [2.NiloToonCharacterMainLightOverrider override (before volume override)] - { - NiloToonCharacterMainLightOverrider mainLightOverrider = - NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.BeforeVolumeOverride); - if (mainLightOverrider) - { - if(mainLightOverrider.overrideDirection) - { - finalMainLightShaderDirWS = mainLightOverrider.shaderLightDirectionWS; - } - if (mainLightOverrider.overrideColorAndIntensity) - { - finalMainLightColor = mainLightOverrider.finalColor; - } - } - } - - // [3.NiloToonCharRenderingControlVolume override] - Vector3 finalMainLightDirVS = camera.worldToCameraMatrix.MultiplyVector(finalMainLightShaderDirWS); + cmd = ExecutePassShared(cmd, passData); - Matrix4x4 volumeOverrideRotationMatrixVS = Matrix4x4.Rotate(Quaternion.Euler(new Vector3(charRenderingControlVolume.overridedLightUpDownAngle.value, charRenderingControlVolume.overridedLightLRAngle.value, 0))); - Vector3 volumeOverridedLightDirVS = volumeOverrideRotationMatrixVS.MultiplyVector(Vector3.forward); - Vector3 volumeOverridedLightDirWS = camera.cameraToWorldMatrix.MultiplyVector(volumeOverridedLightDirVS); - - float volumeOverrideIntensity = charRenderingControlVolume.overrideLightDirectionIntensity.value; - finalMainLightShaderDirWS = Vector3.Slerp(finalMainLightShaderDirWS, volumeOverridedLightDirWS, volumeOverrideIntensity).normalized; - finalMainLightDirVS = Vector3.Slerp(finalMainLightDirVS, volumeOverridedLightDirVS, volumeOverrideIntensity).normalized; - - finalMainLightColor = Color.Lerp(finalMainLightColor, charRenderingControlVolume.overridedLightColor.value, charRenderingControlVolume.lightColorOverrideStrength.value); - - // [4.volume - desaturate, then add] - finalMainLightColor = Color.Lerp(finalMainLightColor, Color.white * finalMainLightColor.grayscale,charRenderingControlVolume.desaturateLightColor.value); - finalMainLightColor += charRenderingControlVolume.addMainLightColor.value; - - // [5.NiloToonCharacterMainLightOverrider override (after volume override)] - { - NiloToonCharacterMainLightOverrider mainLightOverrider = - NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.AfterVolumeOverride); - if (mainLightOverrider) - { - if (mainLightOverrider.overrideDirection) - { - finalMainLightShaderDirWS = mainLightOverrider.shaderLightDirectionWS; - } - - if (mainLightOverrider.overrideColorAndIntensity) - { - finalMainLightColor = mainLightOverrider.finalColor; - } - } - } - - // [6. set value to shader] - cmd.SetGlobalVector(_GlobalUserOverriddenMainLightDirWS_SID, finalMainLightShaderDirWS); - cmd.SetGlobalVector(_GlobalUserOverriddenMainLightDirVS_SID, finalMainLightDirVS); - cmd.SetGlobalVector("_GlobalUserOverridedMainLightDirWS", finalMainLightShaderDirWS); // only to supprt 0.13.8 shader - cmd.SetGlobalVector("_GlobalUserOverridedMainLightDirVS", finalMainLightDirVS); // only to supprt 0.13.8 shader - cmd.SetGlobalColor(_GlobalUserOverriddenMainLightColor_SID, finalMainLightColor); - - // [7. final (post additional light injection) light direction + color override] - { - NiloToonCharacterMainLightOverrider mainLightOverrider = - NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.AfterEverything); - - Vector4 finalMainLightDirWSParamVector = Vector4.zero; - Color finalMainLightColorParamVector = Vector4.zero; - if (mainLightOverrider) - { - if (mainLightOverrider.overrideTiming == NiloToonCharacterMainLightOverrider.OverrideTiming.AfterEverything) - { - if(mainLightOverrider.overrideDirection) - { - var dir = mainLightOverrider.shaderLightDirectionWS; - finalMainLightDirWSParamVector.x = dir.x; - finalMainLightDirWSParamVector.y = dir.y; - finalMainLightDirWSParamVector.z = dir.z; - finalMainLightDirWSParamVector.w = 1; - } - if (mainLightOverrider.overrideColorAndIntensity) - { - finalMainLightColorParamVector = mainLightOverrider.finalColor; - finalMainLightColorParamVector.a = 1; - } - } - } - - cmd.SetGlobalVector(_GlobalUserOverriddenFinalMainLightDirWSParam_SID, finalMainLightDirWSParamVector); - cmd.SetGlobalVector(_GlobalUserOverriddenFinalMainLightColorParam_SID, finalMainLightColorParamVector); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // 2D depth texture rim light (set global uniform) - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalFloat(_GlobalDepthTexRimLightAndShadowWidthMultiplier_SID, Setting.DepthTextureRimLightAndShadowWidthMultiplier * charRenderingControlVolume.depthTextureRimLightAndShadowWidthMultiplier.value * 1.25f); // 1.25 to make default == 1 on user's side GUI - cmd.SetGlobalFloat(_GlobalDepthTexRimLightDepthDiffThresholdOffset_SID, Setting.DepthTexRimLightDepthDiffThresholdOffset + charRenderingControlVolume.depthTexRimLightDepthDiffThresholdOffset.value); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // 2D depth texture rim light and shadow (let NiloToonPerCharacterRenderController knows enableDepthTextureRimLigthAndShadow's value) - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalFloat(_GlobalEnableDepthTextureRimLigthAndShadow_SID, GetEnableDepthTextureRimLigthAndShadow(Setting) ? 1 : 0); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // debug case - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalFloat(_GlobalToonShadeDebugCase_SID, (int)shadingDebugCase); - CoreUtils.SetKeyword(cmd, "_NILOTOON_DEBUG_SHADING", EnableShadingDebug); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // force minium shader - ////////////////////////////////////////////////////////////////////////////////////////////////// - CoreUtils.SetKeyword(cmd, "_NILOTOON_FORCE_MINIMUM_SHADER", Setting.ForceMinimumShader || ForceMinimumShader); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // rendering path related - ////////////////////////////////////////////////////////////////////////////////////////////////// - bool isForwardDepthPrimingModeActive = false; - - // URP added deferred rendering & forward depth priming in 2021.3LTS (URP12) - // NiloToon's character shader will support these options in the following code. - // If deferred rendering or forward depth priming is active, - // we need to force NiloToon's character shader's _CameraDepthTexture's write 100% equals character's body depth(not outline's extrude depth) - // else _CameraDepthTexture's value(outline's depth) will block _CameraColorTexture's body rendering due to depth priming ZTest - UniversalRenderer renderer = renderingData.cameraData.renderer as UniversalRenderer; - - // [find out is "Forward Rendering + depthPrimingMode active" or not] - if (!isDeferredRendering) - { - // we want to get UniversalRenderer.cs's useDepthPriming, but it is internal, - // so we use reflection to get it - if (useDepthPriming_PropertyInfo == null) - { - useDepthPriming_PropertyInfo = renderer.GetType().GetProperty("useDepthPriming", BindingFlags.NonPublic | BindingFlags.Instance); - } - if (useDepthPriming_Getter == null) - { - // cache Delegate to reduce GC alloc - MethodInfo getterMethod = useDepthPriming_PropertyInfo.GetGetMethod(true); - useDepthPriming_Getter = (Func)Delegate.CreateDelegate(typeof(Func), getterMethod); - } - isForwardDepthPrimingModeActive = useDepthPriming_Getter(renderer); - //isForwardDepthPrimingModeActive = (bool)useDepthPriming_PropertyInfo.GetValue(renderer); - } - bool needCorrectDepthTextureDepthWrite = isDeferredRendering || isForwardDepthPrimingModeActive; - cmd.SetGlobalFloat(_NiloToonGlobalAllowUnityCameraDepthTextureWriteOutlineExtrudedPosition_SID, needCorrectDepthTextureDepthWrite ? 0 : 1); - - if(!isDeferredRendering && isForwardDepthPrimingModeActive) - { - Debug.LogWarning("[NiloToon]Forward/Forward+ together with DepthPriming will make face pixel's rendering rejected, you need to set (DepthPrimingMode = Disable) when using NiloToon_Character's 'IsFace?' feature."); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Resolve LightModifier(s) for Main Light's rim multiplier - ////////////////////////////////////////////////////////////////////////////////////////////////// - float mainLightRimMultiplier = 1; - if (mainLightIndex != -1) - { - // mainLight exist, get it's direction and color - VisibleLight mainLight = renderingData.lightData.visibleLights[mainLightIndex]; - int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; - - for (int lightModifierIndex = 0; lightModifierIndex < activeLightModifierScriptCount; lightModifierIndex++) - { - NiloToonLightSourceModifier script = NiloToonLightSourceModifier.AllNiloToonLightModifiers[lightModifierIndex]; - - if (!script) continue; - - if (script.AffectsLight(mainLight.light)) - { - mainLightRimMultiplier *= script.contributeToAdditiveOrRimLightIntensity; - } - } - } - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Note: - // don't need to check null for Volume, - // because Volume will not be null even when no volume exists in scene - ////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // global volume (NiloToonCharRenderingControlVolume) - ////////////////////////////////////////////////////////////////////////////////////////////////// - - var c = charRenderingControlVolume; - Color lerpColorResult; - lerpColorResult = c.charLerpColor.value; - lerpColorResult.a = c.charLerpColorUsage.value; - cmd.SetGlobalColor(_GlobalVolumeLerpColor_SID, lerpColorResult); - - cmd.SetGlobalColor(_GlobalVolumeBaseColorTintColor_SID, c.charBaseColorMultiply.value * c.charBaseColorTintColor.value * bloomVolume.characterBaseColorBrightness.value); - cmd.SetGlobalColor(_GlobalVolumeMulColor_SID, c.charMulColor.value * c.charMulColorIntensity.value * bloomVolume.characterBrightness.value); - cmd.SetGlobalFloat(_GlobalOcclusionStrength_SID, c.charOcclusionUsage.value); - cmd.SetGlobalFloat(_GlobalIndirectLightMultiplier_SID, c.charIndirectLightMultiplier.value); - cmd.SetGlobalColor(_GlobalIndirectLightMinColor_SID, c.charIndirectLightMinColor.value); - cmd.SetGlobalColor(_GlobalIndirectLightMaxColor_SID,c.charIndirectLightMaxColor.value); - cmd.SetGlobalColor(_GlobalMainDirectionalLightMultiplier_SID, c.mainDirectionalLightIntensityMultiplier.value * c.mainDirectionalLightIntensityMultiplierColor.value); - cmd.SetGlobalColor(_GlobalMainDirectionalLightMaxContribution_SID, c.mainDirectionalLightMaxContribution.value * c.mainDirectionalLightMaxContributionColor.value); - cmd.SetGlobalColor(_GlobalAdditionalLightMultiplier_SID, c.additionalLightIntensityMultiplier.value * c.additionalLightIntensityMultiplierColor.value * cinematicAdditionalLightVolume.lightIntensityMultiplier.value); - cmd.SetGlobalColor(_GlobalAdditionalLightMultiplierForFaceArea_SID, c.additionalLightIntensityMultiplierForFaceArea.value * c.additionalLightIntensityMultiplierColorForFaceArea.value); - cmd.SetGlobalColor(_GlobalAdditionalLightMultiplierForOutlineArea_SID, c.additionalLightIntensityMultiplierForOutlineArea.value * c.additionalLightIntensityMultiplierColorForOutlineArea.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightApplyRimMask_SID, c.additionalLightApplyRimMask.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightRimMaskPower_SID, c.additionalLightRimMaskPower.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightRimMaskSoftness_SID, c.additionalLightRimMaskSoftness.value * 0.5f); - cmd.SetGlobalColor(_GlobalAdditionalLightMaxContribution_SID, c.additionalLightMaxContribution.value * c.additionalLightMaxContributionColor.value + Color.white * 100 * (cinematicAdditionalLightVolume.strengthRimMask3D_DynmaicStyle.value+ cinematicAdditionalLightVolume.strengthRimMask3D_StableStyle.value)); - cmd.SetGlobalColor(_GlobalRimLightMultiplier_SID, c.charRimLightMultiplier.value * c.charRimLightTintColor.value * mainLightRimMultiplier); - cmd.SetGlobalColor(_GlobalRimLightMultiplierForOutlineArea_SID, c.charRimLightMultiplierForOutlineArea.value * c.charRimLightTintColorForOutlineArea.value); - cmd.SetGlobalFloat(_GlobalDepthTexRimLightCameraDistanceFadeoutStartDistance_SID, c.charRimLightCameraDistanceFadeoutStartDistance.value); - cmd.SetGlobalFloat(_GlobalDepthTexRimLightCameraDistanceFadeoutEndDistance_SID, c.charRimLightCameraDistanceFadeoutEndDistance.value); - cmd.SetGlobalColor(_GlobalSpecularTintColor_SID, c.specularIntensityMultiplier.value * c.specularTintColor.value); - cmd.SetGlobalFloat(_GlobalSpecularInShadowMinIntensity_SID, c.specularInShadowMinIntensity.value); - cmd.SetGlobalFloat(_GlobalSpecularReactToLightDirectionChange_SID, c.specularReactToLightDirectionChange.value ? 1 : 0); - cmd.SetGlobalColor(_GlobalCharacterOverallShadowTintColor_SID, c.characterOverallShadowTintColor.value * shadowControlVolume.characterOverallShadowTintColor.value); - cmd.SetGlobalFloat(_GlobalCharacterOverallShadowStrength_SID, c.characterOverallShadowStrength.value * shadowControlVolume.characterOverallShadowStrength.value); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // global volume (NiloToonCinematicAdditionalLightVolume) - ////////////////////////////////////////////////////////////////////////////////////////////////// - float finalCinematic3DStrength_ClassicStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_ClassicStyle.value, 0.1f); - float finalCinematic3DStrength_DynamicStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_DynmaicStyle.value, 0.1f); - float finalCinematic3DStrength_StableStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_StableStyle.value, 0.1f); - float finalCinematic2DStrength = cinematicAdditionalLightVolume.strengthRimMask2D.value; - - float finalCinematic3DSharpness_DynamicStyle = Mathf.Lerp(4f, 19 * 4f, cinematicAdditionalLightVolume.sharpnessRimMask3D_DynamicStyle.value); - float finalCinematic3DSharpness_StableStyle = Mathf.Lerp(5f, 15f, cinematicAdditionalLightVolume.sharpnessRimMask3D_StableStyle.value); - - if(cinematicAdditionalLightVolume.enableStyleSafeGuard.value) - { - float maxStrengthFromAllStyle = - Mathf.Max(finalCinematic3DStrength_ClassicStyle, - Mathf.Max(finalCinematic3DStrength_DynamicStyle, - Mathf.Max(finalCinematic3DStrength_StableStyle, - finalCinematic2DStrength))); - - if (maxStrengthFromAllStyle > 0) - { - // [When any style is active, find the highest strength style, max it's strength to 1] - - // when 2 styles has the same highest strength, we pick only one of them, the picking order is the order of if-else chain, - // the order is: - // 1->2D - // 2->3D (Dynamic) - // 3->3D (Classic) - // 4->3D (Stable) - if (Math.Abs(finalCinematic2DStrength - maxStrengthFromAllStyle) < 0.001f) - { - finalCinematic2DStrength = 1; - } - else if (Math.Abs(finalCinematic3DStrength_DynamicStyle - maxStrengthFromAllStyle) < 0.001f) - { - finalCinematic3DStrength_DynamicStyle = 1; - } - else if (Math.Abs(finalCinematic3DStrength_ClassicStyle - maxStrengthFromAllStyle) < 0.001f) - { - finalCinematic3DStrength_ClassicStyle = 1; - } - else if (Math.Abs(finalCinematic3DStrength_StableStyle - maxStrengthFromAllStyle) < 0.001f) - { - finalCinematic3DStrength_StableStyle = 1; - } - } - else - { - // [When all styles are inactive, we hardcode pick '2D' as the default style since it is the safest option, max it's strength to 1] - finalCinematic2DStrength = 1; - } - } - - float finalCinematicEnabled = Mathf.Clamp01(finalCinematic3DStrength_ClassicStyle + finalCinematic3DStrength_DynamicStyle + finalCinematic3DStrength_StableStyle + finalCinematic2DStrength); - - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskEnabled_SID, finalCinematicEnabled); - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_ClassicStyle_SID, finalCinematic3DStrength_ClassicStyle); - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_DynamicStyle_SID, finalCinematic3DStrength_DynamicStyle); - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskSharpness_DynamicStyle_SID, finalCinematic3DSharpness_DynamicStyle); - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_StableStyle_SID, finalCinematic3DStrength_StableStyle); - cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskSharpness_StableStyle_SID, finalCinematic3DSharpness_StableStyle); - cmd.SetGlobalFloat(_GlobalCinematic2DRimMaskStrength_SID, finalCinematic2DStrength); - cmd.SetGlobalFloat(_GlobalCinematicRimTintBaseMap_SID, cinematicAdditionalLightVolume.tintBaseMap.value); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // global volume (NiloToonAdditionalLightStyleVolume) - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_Strength_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_Strength.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightDirection_Strength_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightDirection_Strength.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_AllowCloseLightOverBright_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_AllowCloseLightOverBright.value); - cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_Desaturate_SID, additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_Desaturate.value); - ////////////////////////////////////////////////////////////////////////////////////////////////// - // global volume (NiloToonEnvironmentControlVolume) - ////////////////////////////////////////////////////////////////////////////////////////////////// - cmd.SetGlobalColor(_NiloToonGlobalEnviGITintColor_SID, environmentControlVolume.GlobalIlluminationTintColor.value); - cmd.SetGlobalColor(_NiloToonGlobalEnviGIAddColor_SID, environmentControlVolume.GlobalIlluminationAddColor.value); - cmd.SetGlobalColor(_NiloToonGlobalEnviGIOverride_SID, environmentControlVolume.GlobalIlluminationOverrideColor.value); - cmd.SetGlobalColor(_NiloToonGlobalEnviAlbedoOverrideColor_SID, environmentControlVolume.GlobalAlbedoOverrideColor.value); - cmd.SetGlobalFloat(_NiloToonGlobalEnviMinimumShader_SID, Setting.ForceMinimumEnviShader ? 1 : 0); - cmd.SetGlobalColor(_NiloToonGlobalEnviShadowBorderTintColor_SID, environmentControlVolume.GlobalShadowBoaderTintColorOverrideColor.value); - cmd.SetGlobalColor(_NiloToonGlobalEnviSurfaceColorResultOverrideColor_SID, environmentControlVolume.GlobalSurfaceColorResultOverrideColor.value); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // per char script param to global array - ////////////////////////////////////////////////////////////////////////////////////////////////// - SetGlobalPerCharacterDataArray(cmd); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Character Light controllers to global array - ////////////////////////////////////////////////////////////////////////////////////////////////// - SetGlobalNiloToonCharacterLightControllerDataArray(cmd); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Light Modifier to global array - ////////////////////////////////////////////////////////////////////////////////////////////////// - SetGlobalNiloToonPerUnityVisibleLightDataArray(cmd,renderingData); - context.ExecuteCommandBuffer(cmd); cmd.Clear(); } @@ -801,6 +433,462 @@ namespace NiloToon.NiloToonURP CommandBufferPool.Release(cmd); } + public class PassData + { + public Camera camera; + public int additionalLightsCount; + public int mainLightIndex; + public Settings Setting; + public NativeArray visibleLights; + public ScriptableRenderer renderer; + public bool needCorrectDepthTextureDepthWrite; + + public Vector4[] perCharFaceForwardDirWSArray; + public Vector4[] perCharFaceUpwardDirWSArray; + public Vector4[] perCharBoundCenterPosWSArray; + public Vector4[] perCharPerspectiveRemovalCenterPosWSArray; + + public Vector4[] finalPerCharMainDirectionalLightTintColorArray; + public Vector4[] finalPerCharMainDirectionalLightAddColorArray; + + public Vector4[] perUnityVisibleLightNiloToonDataArray; + public Vector4[] perUnityVisibleLightNiloToonDataArray2; + } + + public bool GetNeedCorrectDepthTextureDepthWrite(ScriptableRenderer inputRenderer) + { + bool isForwardDepthPrimingModeActive = false; + + // URP added deferred rendering & forward depth priming in 2021.3LTS (URP12) + // NiloToon's character shader will support these options in the following code. + // If deferred rendering or forward depth priming is active, + // we need to force NiloToon's character shader's _CameraDepthTexture's write 100% equals character's body depth(not outline's extrude depth) + // else _CameraDepthTexture's value(outline's depth) will block _CameraColorTexture's body rendering due to depth priming ZTest + UniversalRenderer renderer = inputRenderer as UniversalRenderer; + + // [find out is "Forward Rendering + depthPrimingMode active" or not] + if (!isDeferredRendering) + { + // we want to get UniversalRenderer.cs's useDepthPriming, but it is internal, + // so we use reflection to get it + if (useDepthPriming_PropertyInfo == null) + { + useDepthPriming_PropertyInfo = renderer.GetType().GetProperty("useDepthPriming", BindingFlags.NonPublic | BindingFlags.Instance); + } + if (useDepthPriming_Getter == null) + { + // cache Delegate to reduce GC alloc + MethodInfo getterMethod = useDepthPriming_PropertyInfo.GetGetMethod(true); + useDepthPriming_Getter = (Func)Delegate.CreateDelegate(typeof(Func), getterMethod); + } + isForwardDepthPrimingModeActive = useDepthPriming_Getter(renderer); + //isForwardDepthPrimingModeActive = (bool)useDepthPriming_PropertyInfo.GetValue(renderer); + } + bool needCorrectDepthTextureDepthWrite = isDeferredRendering || isForwardDepthPrimingModeActive; + + if(!isDeferredRendering && isForwardDepthPrimingModeActive) + { + Debug.LogWarning("[NiloToon]Forward/Forward+ together with DepthPriming will make face pixel's rendering rejected, you need to set (DepthPrimingMode = Disable) when using NiloToon_Character's 'IsFace?' feature."); + } + + return needCorrectDepthTextureDepthWrite; + } + + private static CommandBuffer ExecutePassShared(CommandBuffer cmd, PassData passData) + { + var Setting = passData.Setting; + + // these volumes will not be null, even if Volume doesn't exist in scene + var charRenderingControlVolume = VolumeManager.instance.stack.GetComponent(); + var cinematicAdditionalLightVolume = VolumeManager.instance.stack.GetComponent(); + var additionalLightStyleVolume = VolumeManager.instance.stack.GetComponent(); + var shadowControlVolume = VolumeManager.instance.stack.GetComponent(); + var environmentControlVolume = VolumeManager.instance.stack.GetComponent(); + var bloomVolume = VolumeManager.instance.stack.GetComponent(); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // special process for any possible planar reflection camera + ////////////////////////////////////////////////////////////////////////////////////////////////// + if (NiloToonPlanarReflectionHelper.IsPlanarReflectionCamera(passData.camera)) + { + NiloToonPlanarReflectionHelper.BeginPlanarReflectionCameraRender(ref cmd); + } + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // additional light keyword on/off + ////////////////////////////////////////////////////////////////////////////////////////////////// + // see URP's ForwardLights.cs -> SetUp(), where URP enable additional light keywords + // here we combine URP's per vertex / per pixel keywords into 1 keyword, to reduce multi_compile shader variant count, since we always need vertex light only by design + CoreUtils.SetKeyword(cmd, "_NILOTOON_ADDITIONAL_LIGHTS", passData.additionalLightsCount > 0); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // URP shadow related global settings + ////////////////////////////////////////////////////////////////////////////////////////////////// + // [findout main light's shadow is enabled or not] + // see URP's MainLightShadowCasterPass.cs -> RenderMainLightCascadeShadowmap(), where URP enable main light shadow keyword + int shadowLightIndex = passData.mainLightIndex; + bool mainLightEnabledShadow = shadowLightIndex != -1; + + // volume override URP shadow related params + bool receiveURPShadow = shadowControlVolume.receiveURPShadow.overrideState ? shadowControlVolume.receiveURPShadow.value : Setting.ShouldReceiveURPShadows; + float URPShadowIntensity = shadowControlVolume.URPShadowIntensity.overrideState ? shadowControlVolume.URPShadowIntensity.value : Setting.URPShadowIntensity; + Color URPShadowAsDirectLightTintColor = shadowControlVolume.URPShadowAsDirectLightTintColor.value; + URPShadowAsDirectLightTintColor *= shadowControlVolume.URPShadowAsDirectLightMultiplier.value; + float ReceiveURPShadowblurriness = shadowControlVolume.URPShadowblurriness.value * 0.5f; // in shader, we want 0 ~ 0.5, not 0 ~ 1 + float URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting = shadowControlVolume.URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting.value; + + // here we combine URP's main light shadow keyword and our ShouldReceiveURPShadows keyword into 1, to reduce the number of multi_compile shader variant + CoreUtils.SetKeyword(cmd, "_NILOTOON_RECEIVE_URP_SHADOWMAPPING", receiveURPShadow && mainLightEnabledShadow); + cmd.SetGlobalFloat(_GlobalReceiveURPShadowAmount_SID, URPShadowIntensity); + cmd.SetGlobalFloat(_GlobalToonShaderNormalBiasMultiplier_SID, Setting.URPShadowNormalBiasMultiplier); + cmd.SetGlobalFloat(_GlobalReceiveSelfShadowMappingPosOffset_SID, Setting.URPShadowDepthBias); + cmd.SetGlobalColor(_GlobalMainLightURPShadowAsDirectResultTintColor_SID, URPShadowAsDirectLightTintColor); + cmd.SetGlobalFloat(_GlobalNiloToonReceiveURPShadowblurriness_SID, ReceiveURPShadowblurriness); + cmd.SetGlobalFloat(_GlobalURPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting_SID, URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // RT(screen) aspect + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalVector(_GlobalAspectFix_SID, new Vector2((float)passData.camera.pixelHeight / (float)passData.camera.pixelWidth, 1f)); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // camera fov + ////////////////////////////////////////////////////////////////////////////////////////////////// + Camera camera = passData.camera; + + // we need to calculate fov here, because if camera is using "Physical Camera", camera.fieldOfView is not correct, while camera.projectionMatrix is always correct + float cameraFieldOfView = 2 * Mathf.Atan(1f / camera.projectionMatrix.m11) * 180 / Mathf.PI; + cmd.SetGlobalFloat(_GlobalFOVorOrthoSizeFix_SID, 1f / (camera.orthographic ? camera.orthographicSize * 100f : cameraFieldOfView)); + cmd.SetGlobalFloat(_CurrentCameraFOV_SID, cameraFieldOfView); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // main light shader data override + ////////////////////////////////////////////////////////////////////////////////////////////////// + + // init with values when no light information(Light/NiloToonCharacterMainLightOverrider/NiloToonCharRenderingControlVolume) exist + Vector3 finalMainLightShaderDirWS = Vector3.up; + Color finalMainLightColor = Color.black; + + // [0.fill with URP's main light first] + int mainLightIndex = passData.mainLightIndex; + + // Note: when mainLight doesn't exist, mainLightIndex will be -1 + bool isURPMainLightExist = mainLightIndex != -1; + if (isURPMainLightExist) + { + // mainLight exist, get it's direction and color + VisibleLight mainLight = passData.visibleLights[mainLightIndex]; + finalMainLightShaderDirWS = -mainLight.light.transform.forward; + finalMainLightColor = mainLight.finalColor; + + // [1.Light modifier] + float finalContributeIntoMainLightColor = 1; + float finalContributeIntoMainLightDirection = 1; + float finalContributeIntoMainLightColorApplyDesaturation = 0; + + int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; + for (int lightModifierIndex = 0; lightModifierIndex < activeLightModifierScriptCount; lightModifierIndex++) + { + NiloToonLightSourceModifier script = NiloToonLightSourceModifier.AllNiloToonLightModifiers[lightModifierIndex]; + + if (!script) continue; + + if (script.AffectsLight(mainLight.light)) + { + finalContributeIntoMainLightColor *= script.contributeToMainLightColor; + finalContributeIntoMainLightDirection *= script.contributeToMainLightDirection; + finalContributeIntoMainLightColorApplyDesaturation = Mathf.Lerp(finalContributeIntoMainLightColorApplyDesaturation, 1, script.applyDesaturateWhenContributeToMainLightColor); + } + } + + finalMainLightColor *= finalContributeIntoMainLightColor; + finalMainLightShaderDirWS *= finalContributeIntoMainLightDirection; + finalMainLightColor = Color.Lerp(finalMainLightColor, finalMainLightColor.grayscale * Color.white, finalContributeIntoMainLightColorApplyDesaturation); + } + + // [2.NiloToonCharacterMainLightOverrider override (before volume override)] + { + NiloToonCharacterMainLightOverrider mainLightOverrider = + NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.BeforeVolumeOverride); + if (mainLightOverrider) + { + if(mainLightOverrider.overrideDirection) + { + finalMainLightShaderDirWS = mainLightOverrider.shaderLightDirectionWS; + } + if (mainLightOverrider.overrideColorAndIntensity) + { + finalMainLightColor = mainLightOverrider.finalColor; + } + } + } + + // [3.NiloToonCharRenderingControlVolume override] + Vector3 finalMainLightDirVS = camera.worldToCameraMatrix.MultiplyVector(finalMainLightShaderDirWS); + + Matrix4x4 volumeOverrideRotationMatrixVS = Matrix4x4.Rotate(Quaternion.Euler(new Vector3(charRenderingControlVolume.overridedLightUpDownAngle.value, charRenderingControlVolume.overridedLightLRAngle.value, 0))); + Vector3 volumeOverridedLightDirVS = volumeOverrideRotationMatrixVS.MultiplyVector(Vector3.forward); + Vector3 volumeOverridedLightDirWS = camera.cameraToWorldMatrix.MultiplyVector(volumeOverridedLightDirVS); + + float volumeOverrideIntensity = charRenderingControlVolume.overrideLightDirectionIntensity.value; + finalMainLightShaderDirWS = Vector3.Slerp(finalMainLightShaderDirWS, volumeOverridedLightDirWS, volumeOverrideIntensity).normalized; + finalMainLightDirVS = Vector3.Slerp(finalMainLightDirVS, volumeOverridedLightDirVS, volumeOverrideIntensity).normalized; + + finalMainLightColor = Color.Lerp(finalMainLightColor, charRenderingControlVolume.overridedLightColor.value, charRenderingControlVolume.lightColorOverrideStrength.value); + + // [4.volume - desaturate, then add] + finalMainLightColor = Color.Lerp(finalMainLightColor, Color.white * finalMainLightColor.grayscale,charRenderingControlVolume.desaturateLightColor.value); + finalMainLightColor += charRenderingControlVolume.addMainLightColor.value; + + // [5.NiloToonCharacterMainLightOverrider override (after volume override)] + { + NiloToonCharacterMainLightOverrider mainLightOverrider = + NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.AfterVolumeOverride); + if (mainLightOverrider) + { + if (mainLightOverrider.overrideDirection) + { + finalMainLightShaderDirWS = mainLightOverrider.shaderLightDirectionWS; + } + + if (mainLightOverrider.overrideColorAndIntensity) + { + finalMainLightColor = mainLightOverrider.finalColor; + } + } + } + + // [6. set value to shader] + cmd.SetGlobalVector(_GlobalUserOverriddenMainLightDirWS_SID, finalMainLightShaderDirWS); + cmd.SetGlobalVector(_GlobalUserOverriddenMainLightDirVS_SID, finalMainLightDirVS); + cmd.SetGlobalVector("_GlobalUserOverridedMainLightDirWS", finalMainLightShaderDirWS); // only to supprt 0.13.8 shader + cmd.SetGlobalVector("_GlobalUserOverridedMainLightDirVS", finalMainLightDirVS); // only to supprt 0.13.8 shader + cmd.SetGlobalColor(_GlobalUserOverriddenMainLightColor_SID, finalMainLightColor); + + // [7. final (post additional light injection) light direction + color override] + { + NiloToonCharacterMainLightOverrider mainLightOverrider = + NiloToonCharacterMainLightOverrider.GetHighestPriorityOverrider(NiloToonCharacterMainLightOverrider.OverrideTiming.AfterEverything); + + Vector4 finalMainLightDirWSParamVector = Vector4.zero; + Color finalMainLightColorParamVector = Vector4.zero; + if (mainLightOverrider) + { + if (mainLightOverrider.overrideTiming == NiloToonCharacterMainLightOverrider.OverrideTiming.AfterEverything) + { + if(mainLightOverrider.overrideDirection) + { + var dir = mainLightOverrider.shaderLightDirectionWS; + finalMainLightDirWSParamVector.x = dir.x; + finalMainLightDirWSParamVector.y = dir.y; + finalMainLightDirWSParamVector.z = dir.z; + finalMainLightDirWSParamVector.w = 1; + } + if (mainLightOverrider.overrideColorAndIntensity) + { + finalMainLightColorParamVector = mainLightOverrider.finalColor; + finalMainLightColorParamVector.a = 1; + } + } + } + + cmd.SetGlobalVector(_GlobalUserOverriddenFinalMainLightDirWSParam_SID, finalMainLightDirWSParamVector); + cmd.SetGlobalVector(_GlobalUserOverriddenFinalMainLightColorParam_SID, finalMainLightColorParamVector); + } + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // 2D depth texture rim light (set global uniform) + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalFloat(_GlobalDepthTexRimLightAndShadowWidthMultiplier_SID, Setting.DepthTextureRimLightAndShadowWidthMultiplier * charRenderingControlVolume.depthTextureRimLightAndShadowWidthMultiplier.value * 1.25f); // 1.25 to make default == 1 on user's side GUI + cmd.SetGlobalFloat(_GlobalDepthTexRimLightDepthDiffThresholdOffset_SID, Setting.DepthTexRimLightDepthDiffThresholdOffset + charRenderingControlVolume.depthTexRimLightDepthDiffThresholdOffset.value); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // 2D depth texture rim light and shadow (let NiloToonPerCharacterRenderController knows enableDepthTextureRimLigthAndShadow's value) + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalFloat(_GlobalEnableDepthTextureRimLigthAndShadow_SID, GetEnableDepthTextureRimLigthAndShadow(Setting) ? 1 : 0); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // debug case + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalFloat(_GlobalToonShadeDebugCase_SID, (int)shadingDebugCase); + CoreUtils.SetKeyword(cmd, "_NILOTOON_DEBUG_SHADING", EnableShadingDebug); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // force minium shader + ////////////////////////////////////////////////////////////////////////////////////////////////// + CoreUtils.SetKeyword(cmd, "_NILOTOON_FORCE_MINIMUM_SHADER", Setting.ForceMinimumShader || ForceMinimumShader); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // rendering path related + ////////////////////////////////////////////////////////////////////////////////////////////////// + + cmd.SetGlobalFloat(_NiloToonGlobalAllowUnityCameraDepthTextureWriteOutlineExtrudedPosition_SID, passData.needCorrectDepthTextureDepthWrite ? 0 : 1); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Resolve LightModifier(s) for Main Light's rim multiplier + ////////////////////////////////////////////////////////////////////////////////////////////////// + float mainLightRimMultiplier = 1; + if (mainLightIndex != -1) + { + // mainLight exist, get it's direction and color + VisibleLight mainLight = passData.visibleLights[mainLightIndex]; + int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; + + for (int lightModifierIndex = 0; lightModifierIndex < activeLightModifierScriptCount; lightModifierIndex++) + { + NiloToonLightSourceModifier script = NiloToonLightSourceModifier.AllNiloToonLightModifiers[lightModifierIndex]; + + if (!script) continue; + + if (script.AffectsLight(mainLight.light)) + { + mainLightRimMultiplier *= script.contributeToAdditiveOrRimLightIntensity; + } + } + } + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Note: + // don't need to check null for Volume, + // because Volume will not be null even when no volume exists in scene + ////////////////////////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // global volume (NiloToonCharRenderingControlVolume) + ////////////////////////////////////////////////////////////////////////////////////////////////// + + var c = charRenderingControlVolume; + Color lerpColorResult; + lerpColorResult = c.charLerpColor.value; + lerpColorResult.a = c.charLerpColorUsage.value; + cmd.SetGlobalColor(_GlobalVolumeLerpColor_SID, lerpColorResult); + + cmd.SetGlobalColor(_GlobalVolumeBaseColorTintColor_SID, c.charBaseColorMultiply.value * c.charBaseColorTintColor.value * bloomVolume.characterBaseColorBrightness.value); + cmd.SetGlobalColor(_GlobalVolumeMulColor_SID, c.charMulColor.value * c.charMulColorIntensity.value * bloomVolume.characterBrightness.value); + cmd.SetGlobalFloat(_GlobalOcclusionStrength_SID, c.charOcclusionUsage.value); + cmd.SetGlobalFloat(_GlobalIndirectLightMultiplier_SID, c.charIndirectLightMultiplier.value); + cmd.SetGlobalColor(_GlobalIndirectLightMinColor_SID, c.charIndirectLightMinColor.value); + cmd.SetGlobalColor(_GlobalIndirectLightMaxColor_SID,c.charIndirectLightMaxColor.value); + cmd.SetGlobalColor(_GlobalMainDirectionalLightMultiplier_SID, c.mainDirectionalLightIntensityMultiplier.value * c.mainDirectionalLightIntensityMultiplierColor.value); + cmd.SetGlobalColor(_GlobalMainDirectionalLightMaxContribution_SID, c.mainDirectionalLightMaxContribution.value * c.mainDirectionalLightMaxContributionColor.value); + cmd.SetGlobalColor(_GlobalAdditionalLightMultiplier_SID, c.additionalLightIntensityMultiplier.value * c.additionalLightIntensityMultiplierColor.value * cinematicAdditionalLightVolume.lightIntensityMultiplier.value); + cmd.SetGlobalColor(_GlobalAdditionalLightMultiplierForFaceArea_SID, c.additionalLightIntensityMultiplierForFaceArea.value * c.additionalLightIntensityMultiplierColorForFaceArea.value); + cmd.SetGlobalColor(_GlobalAdditionalLightMultiplierForOutlineArea_SID, c.additionalLightIntensityMultiplierForOutlineArea.value * c.additionalLightIntensityMultiplierColorForOutlineArea.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightApplyRimMask_SID, c.additionalLightApplyRimMask.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightRimMaskPower_SID, c.additionalLightRimMaskPower.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightRimMaskSoftness_SID, c.additionalLightRimMaskSoftness.value * 0.5f); + cmd.SetGlobalColor(_GlobalAdditionalLightMaxContribution_SID, c.additionalLightMaxContribution.value * c.additionalLightMaxContributionColor.value + Color.white * 100 * (cinematicAdditionalLightVolume.strengthRimMask3D_DynmaicStyle.value+ cinematicAdditionalLightVolume.strengthRimMask3D_StableStyle.value)); + cmd.SetGlobalColor(_GlobalRimLightMultiplier_SID, c.charRimLightMultiplier.value * c.charRimLightTintColor.value * mainLightRimMultiplier); + cmd.SetGlobalColor(_GlobalRimLightMultiplierForOutlineArea_SID, c.charRimLightMultiplierForOutlineArea.value * c.charRimLightTintColorForOutlineArea.value); + cmd.SetGlobalFloat(_GlobalDepthTexRimLightCameraDistanceFadeoutStartDistance_SID, c.charRimLightCameraDistanceFadeoutStartDistance.value); + cmd.SetGlobalFloat(_GlobalDepthTexRimLightCameraDistanceFadeoutEndDistance_SID, c.charRimLightCameraDistanceFadeoutEndDistance.value); + cmd.SetGlobalColor(_GlobalSpecularTintColor_SID, c.specularIntensityMultiplier.value * c.specularTintColor.value); + cmd.SetGlobalFloat(_GlobalSpecularInShadowMinIntensity_SID, c.specularInShadowMinIntensity.value); + cmd.SetGlobalFloat(_GlobalSpecularReactToLightDirectionChange_SID, c.specularReactToLightDirectionChange.value ? 1 : 0); + cmd.SetGlobalColor(_GlobalCharacterOverallShadowTintColor_SID, c.characterOverallShadowTintColor.value * shadowControlVolume.characterOverallShadowTintColor.value); + cmd.SetGlobalFloat(_GlobalCharacterOverallShadowStrength_SID, c.characterOverallShadowStrength.value * shadowControlVolume.characterOverallShadowStrength.value); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // global volume (NiloToonCinematicAdditionalLightVolume) + ////////////////////////////////////////////////////////////////////////////////////////////////// + float finalCinematic3DStrength_ClassicStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_ClassicStyle.value, 0.1f); + float finalCinematic3DStrength_DynamicStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_DynmaicStyle.value, 0.1f); + float finalCinematic3DStrength_StableStyle = Mathf.Pow(cinematicAdditionalLightVolume.strengthRimMask3D_StableStyle.value, 0.1f); + float finalCinematic2DStrength = cinematicAdditionalLightVolume.strengthRimMask2D.value; + + float finalCinematic3DSharpness_DynamicStyle = Mathf.Lerp(4f, 19 * 4f, cinematicAdditionalLightVolume.sharpnessRimMask3D_DynamicStyle.value); + + // ^5 is the PBR physical power from F term of DFG, which is the lowest power possible + // we allow ^5 to ^15 based on user preference of rim light "sharpness", default ^10 + float finalCinematic3DSharpness_StableStyle = Mathf.Lerp(5f, 15f, cinematicAdditionalLightVolume.sharpnessRimMask3D_StableStyle.value); + + if(cinematicAdditionalLightVolume.enableStyleSafeGuard.value) + { + float maxStrengthFromAllStyle = + Mathf.Max(finalCinematic3DStrength_ClassicStyle, + Mathf.Max(finalCinematic3DStrength_DynamicStyle, + Mathf.Max(finalCinematic3DStrength_StableStyle, + finalCinematic2DStrength))); + + if (maxStrengthFromAllStyle > 0) + { + // [When any style is active, find the highest strength style, max it's strength to 1] + + // when 2 styles has the same highest strength, we pick only one of them, the picking order is the order of if-else chain, + // the order is: + // 1->2D + // 2->3D (Dynamic) + // 3->3D (Classic) + // 4->3D (Stable) + if (Math.Abs(finalCinematic2DStrength - maxStrengthFromAllStyle) < 0.001f) + { + finalCinematic2DStrength = 1; + } + else if (Math.Abs(finalCinematic3DStrength_DynamicStyle - maxStrengthFromAllStyle) < 0.001f) + { + finalCinematic3DStrength_DynamicStyle = 1; + } + else if (Math.Abs(finalCinematic3DStrength_ClassicStyle - maxStrengthFromAllStyle) < 0.001f) + { + finalCinematic3DStrength_ClassicStyle = 1; + } + else if (Math.Abs(finalCinematic3DStrength_StableStyle - maxStrengthFromAllStyle) < 0.001f) + { + finalCinematic3DStrength_StableStyle = 1; + } + } + else + { + // [When all styles are inactive, we hardcode pick '2D' as the default style since it is the safest option, max it's strength to 1] + finalCinematic2DStrength = 1; + } + } + + float finalCinematicEnabled = Mathf.Clamp01(finalCinematic3DStrength_ClassicStyle + finalCinematic3DStrength_DynamicStyle + finalCinematic3DStrength_StableStyle + finalCinematic2DStrength); + + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskEnabled_SID, finalCinematicEnabled); + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_ClassicStyle_SID, finalCinematic3DStrength_ClassicStyle); + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_DynamicStyle_SID, finalCinematic3DStrength_DynamicStyle); + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskSharpness_DynamicStyle_SID, finalCinematic3DSharpness_DynamicStyle); + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskStrength_StableStyle_SID, finalCinematic3DStrength_StableStyle); + cmd.SetGlobalFloat(_GlobalCinematic3DRimMaskSharpness_StableStyle_SID, finalCinematic3DSharpness_StableStyle); + cmd.SetGlobalFloat(_GlobalCinematic2DRimMaskStrength_SID, finalCinematic2DStrength); + cmd.SetGlobalFloat(_GlobalCinematicRimTintBaseMap_SID, cinematicAdditionalLightVolume.tintBaseMap.value); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // global volume (NiloToonAdditionalLightStyleVolume) + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_Strength_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_Strength.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightDirection_Strength_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightDirection_Strength.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_AllowCloseLightOverBright_SID,additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_AllowCloseLightOverBright.value); + cmd.SetGlobalFloat(_GlobalAdditionalLightInjectIntoMainLightColor_Desaturate_SID, additionalLightStyleVolume.additionalLightInjectIntoMainLightColor_Desaturate.value); + ////////////////////////////////////////////////////////////////////////////////////////////////// + // global volume (NiloToonEnvironmentControlVolume) + ////////////////////////////////////////////////////////////////////////////////////////////////// + cmd.SetGlobalColor(_NiloToonGlobalEnviGITintColor_SID, environmentControlVolume.GlobalIlluminationTintColor.value); + cmd.SetGlobalColor(_NiloToonGlobalEnviGIAddColor_SID, environmentControlVolume.GlobalIlluminationAddColor.value); + cmd.SetGlobalColor(_NiloToonGlobalEnviGIOverride_SID, environmentControlVolume.GlobalIlluminationOverrideColor.value); + cmd.SetGlobalColor(_NiloToonGlobalEnviAlbedoOverrideColor_SID, environmentControlVolume.GlobalAlbedoOverrideColor.value); + cmd.SetGlobalFloat(_NiloToonGlobalEnviMinimumShader_SID, Setting.ForceMinimumEnviShader ? 1 : 0); + cmd.SetGlobalColor(_NiloToonGlobalEnviShadowBorderTintColor_SID, environmentControlVolume.GlobalShadowBoaderTintColorOverrideColor.value); + cmd.SetGlobalColor(_NiloToonGlobalEnviSurfaceColorResultOverrideColor_SID, environmentControlVolume.GlobalSurfaceColorResultOverrideColor.value); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // per char script param to global array + ////////////////////////////////////////////////////////////////////////////////////////////////// + SetGlobalPerCharacterDataArray(cmd, passData); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Character Light controllers to global array + ////////////////////////////////////////////////////////////////////////////////////////////////// + SetGlobalNiloToonCharacterLightControllerDataArray(cmd, passData); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Light Modifier to global array + ////////////////////////////////////////////////////////////////////////////////////////////////// + SetGlobalNiloToonPerUnityVisibleLightDataArray(cmd, passData); + return cmd; + } + // Must match: NiloToonCharacter_Shared.hlsl's MAX_CHARACTER_COUNT values! private const int k_MaxCharacterCountMobileShaderLevelLessThan45 = 16; private const int k_MaxCharacterCountMobile = 32; @@ -825,7 +913,7 @@ namespace NiloToon.NiloToonURP Vector4[] perCharFaceUpwardDirWSArray; Vector4[] perCharBoundCenterPosWSArray; Vector4[] perCharPerspectiveRemovalCenterPosWSArray; - void SetGlobalPerCharacterDataArray(CommandBuffer cmd) + void SetGlobalPerCharacterDataArray() { NiloToonAllInOneRendererFeature.CheckInit(); int characterCount = Mathf.Min(maxCharacterCount, NiloToonAllInOneRendererFeature.characterList.Count); @@ -864,15 +952,18 @@ namespace NiloToon.NiloToonURP perCharBoundCenterPosWSArray[i] = controller.characterBoundCenter; perCharPerspectiveRemovalCenterPosWSArray[i] = controller.perspectiveRemovalCenter; } - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharFaceForwardDirWSArray_SID,perCharFaceForwardDirWSArray); - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharFaceUpwardDirWSArray_SID,perCharFaceUpwardDirWSArray); - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharBoundCenterPosWSArray_SID,perCharBoundCenterPosWSArray); - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharHeadBonePosWSArray_SID,perCharPerspectiveRemovalCenterPosWSArray); + } + static void SetGlobalPerCharacterDataArray(CommandBuffer cmd, PassData passData) + { + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharFaceForwardDirWSArray_SID, passData.perCharFaceForwardDirWSArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharFaceUpwardDirWSArray_SID,passData.perCharFaceUpwardDirWSArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharBoundCenterPosWSArray_SID,passData.perCharBoundCenterPosWSArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharHeadBonePosWSArray_SID,passData.perCharPerspectiveRemovalCenterPosWSArray); } Vector4[] finalPerCharMainDirectionalLightTintColorArray; Vector4[] finalPerCharMainDirectionalLightAddColorArray; - void SetGlobalNiloToonCharacterLightControllerDataArray(CommandBuffer cmd) + void SetGlobalNiloToonCharacterLightControllerDataArray() { int MAX_CHARACTER_SLOT_COUNT = maxCharacterCount; int activeLightControllersCount = NiloToonCharacterLightController.AllNiloToonCharacterLightControllers.Count; @@ -947,16 +1038,25 @@ namespace NiloToon.NiloToonURP } } } - + } + static void SetGlobalNiloToonCharacterLightControllerDataArray(CommandBuffer cmd, PassData passData) + { // TODO: + dirty detect? don't call if the array is the same as previous frame - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharMainDirectionalLightTintColorArray_SID,finalPerCharMainDirectionalLightTintColorArray); - cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharMainDirectionalLightAddColorArray_SID,finalPerCharMainDirectionalLightAddColorArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharMainDirectionalLightTintColorArray_SID,passData.finalPerCharMainDirectionalLightTintColorArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerCharMainDirectionalLightAddColorArray_SID,passData.finalPerCharMainDirectionalLightAddColorArray); } private Vector4[] perUnityVisibleLightNiloToonDataArray; private Vector4[] perUnityVisibleLightNiloToonDataArray2; - void SetGlobalNiloToonPerUnityVisibleLightDataArray(CommandBuffer cmd, RenderingData renderingData) + private Dictionary visiableLightDictionary; + void SetGlobalNiloToonPerUnityVisibleLightDataArray(PassData passData) { + // cache per frame const for performance boost + var lights = passData.visibleLights; + int maxAdditionalLightsCount = UniversalRenderPipeline.maxVisibleAdditionalLights; + int mainLightIndex = passData.mainLightIndex; + int lightsLength = lights.Length; + int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; int MAX_UNITY_VISIBLE_LIGHT_SLOT_COUNT = UniversalRenderPipeline.maxVisibleAdditionalLights; // init array if not yet init @@ -969,65 +1069,177 @@ namespace NiloToon.NiloToonURP perUnityVisibleLightNiloToonDataArray2 = new Vector4[MAX_UNITY_VISIBLE_LIGHT_SLOT_COUNT]; } - // reset array - int visibleLightCount = renderingData.lightData.visibleLights.Length; - for (int i = 0; i < visibleLightCount; i++) + // reset data array to default value + int visibleLightCount = passData.visibleLights.Length; + for (int i = 0; i < visibleLightCount && i < MAX_UNITY_VISIBLE_LIGHT_SLOT_COUNT; i++) { - // after reset, if no NiloToonLightSourceModifier affect this array, then this array's value will not affect rendering in shader + // after reset, if no NiloToonLightSourceModifier edit this array, then this array's value will not affect rendering visual result in shader // (1,1,0,1) is the no-op value in shader perUnityVisibleLightNiloToonDataArray[i] = new Vector4(1,1,0,1); // (0,0,_,_) is the no-op value in shader perUnityVisibleLightNiloToonDataArray2[i] = new Vector4(0, 0, 0, 0); } + + // init Dictionary if not yet init + if (visiableLightDictionary == null) + { + visiableLightDictionary = new Dictionary(maxAdditionalLightsCount); + } - int activeLightModifierScriptCount = NiloToonLightSourceModifier.AllNiloToonLightModifiers.Count; + // rebuild Dictionary + visiableLightDictionary.Clear(); + for (int i = 0; i < lightsLength; i++) + { + Light targetLight = lights[i].light; + + if (visiableLightDictionary.ContainsKey(targetLight)) continue; + + visiableLightDictionary.Add(targetLight, i); + } + + // per active light modifier loop + var lightModifiersList = NiloToonLightSourceModifier.AllNiloToonLightModifiers; + bool isMainLightExist = mainLightIndex != -1; + int NiloToonDataArrayIndexOffset = isMainLightExist ? -1 : 0; for (int lightModifierIndex = 0; lightModifierIndex < activeLightModifierScriptCount; lightModifierIndex++) { - NiloToonLightSourceModifier script = NiloToonLightSourceModifier.AllNiloToonLightModifiers[lightModifierIndex]; + NiloToonLightSourceModifier script = lightModifiersList[lightModifierIndex]; if (!script) continue; - - // C# visibleLights array contains these lights in order: - // 1. Main Light x1 + + // C# visibleLights native array contains these lights in order: + // 1. Main Light x1 (always at index 0 if exists, it will not exist if main directional light is not active / intensity = 0) // 2. Additional Directional lights xN // 3. All point/spot lights x M - + // you must follow URP's ForwardLights.cs -> SetupAdditionalLightConstants(...) for how to match light index in shader // the NiloToon code below is following URP12.1.12's code light loop structure for setting up GPU light data array - ref LightData lightData = ref renderingData.lightData; - var lights = lightData.visibleLights; - int maxAdditionalLightsCount = UniversalRenderPipeline.maxVisibleAdditionalLights; - - for (int i = 0, lightIter = 0; i < lights.Length && lightIter < maxAdditionalLightsCount; ++i) + + if (script.enableTargetLightMask) { - VisibleLight light = lights[i]; - - if (lightData.mainLightIndex != i) + // faster loop (loops only lights in target list) + foreach (var light in script.targetLightsMask) { - if (script.AffectsLight(light.light)) - { - Vector4 data = perUnityVisibleLightNiloToonDataArray[lightIter]; - data.x *= script.contributeToMainLightColor; - data.y *= script.contributeToMainLightDirection; - data.z = Mathf.Lerp(data.z,1,script.applyDesaturateWhenContributeToMainLightColor); - data.w *= script.contributeToAdditiveOrRimLightIntensity; - perUnityVisibleLightNiloToonDataArray[lightIter] = data; - - Vector4 data2 = perUnityVisibleLightNiloToonDataArray2[lightIter]; - data2.x = Mathf.Lerp(data2.x,1,script.backLightOcclusion2DWhenContributeToMainLightColor); - data2.y = Mathf.Lerp(data2.y,1,script.backLightOcclusion3DWhenContributeToMainLightColor); - perUnityVisibleLightNiloToonDataArray2[lightIter] = data2; - } + // if it doesn't match, the TargetLight is not visible in camera + if (!visiableLightDictionary.ContainsKey(light)) continue; + + int lightIter = visiableLightDictionary[light]; + + if (lightIter == mainLightIndex) continue; + + // - if main light exists, we need to skip main light x1 at index 0, so 'index -1' is needed + // - if main light doesn't exist, we don't need to skip main light x1 at index 0, so 'index -1' is not needed + // see URP14 UniversalRenderPipeline.cs -> InitializeLightData(...) for example code about index offset + UpdatePerUnityVisibleLightNiloToonDataArray(lightIter + NiloToonDataArrayIndexOffset, script); + } + } + else + { + // slower loop (loops all visible lights) + for (int i = 0, lightIter = 0; i < lightsLength && lightIter < maxAdditionalLightsCount; ++i) + { + if (i == mainLightIndex) continue; + + UpdatePerUnityVisibleLightNiloToonDataArray(lightIter, script); lightIter++; } } } - - // TODO: + dirty detect? don't call if the array is the same as previous frame - cmd.SetGlobalVectorArray(_NiloToonGlobalPerUnityLightDataArray_SID,perUnityVisibleLightNiloToonDataArray); - cmd.SetGlobalVectorArray(_NiloToonGlobalPerUnityLightDataArray2_SID,perUnityVisibleLightNiloToonDataArray2); } + + private void UpdatePerUnityVisibleLightNiloToonDataArray(int lightIndex, NiloToonLightSourceModifier script) + { + Vector4 data = perUnityVisibleLightNiloToonDataArray[lightIndex]; + data.x *= script.contributeToMainLightColor; + data.y *= script.contributeToMainLightDirection; + data.z = Mathf.Lerp(data.z,1,script.applyDesaturateWhenContributeToMainLightColor); + data.w *= script.contributeToAdditiveOrRimLightIntensity; + perUnityVisibleLightNiloToonDataArray[lightIndex] = data; + + Vector4 data2 = perUnityVisibleLightNiloToonDataArray2[lightIndex]; + data2.x = Mathf.Lerp(data2.x,1,script.backLightOcclusion2DWhenContributeToMainLightColor); + data2.y = Mathf.Lerp(data2.y,1,script.backLightOcclusion3DWhenContributeToMainLightColor); + perUnityVisibleLightNiloToonDataArray2[lightIndex] = data2; + } + + static void SetGlobalNiloToonPerUnityVisibleLightDataArray(CommandBuffer cmd, PassData passData) + { + // TODO: + dirty detect? don't call if the array is the same as previous frame + cmd.SetGlobalVectorArray(_NiloToonGlobalPerUnityLightDataArray_SID,passData.perUnityVisibleLightNiloToonDataArray); + cmd.SetGlobalVectorArray(_NiloToonGlobalPerUnityLightDataArray2_SID,passData.perUnityVisibleLightNiloToonDataArray2); + } + + private void FillInPassDataArray(PassData passData) + { + SetGlobalPerCharacterDataArray(); + passData.perCharFaceForwardDirWSArray = perCharFaceForwardDirWSArray; + passData.perCharFaceUpwardDirWSArray = perCharFaceUpwardDirWSArray; + passData.perCharBoundCenterPosWSArray = perCharBoundCenterPosWSArray; + passData.perCharPerspectiveRemovalCenterPosWSArray = perCharPerspectiveRemovalCenterPosWSArray; + + SetGlobalNiloToonCharacterLightControllerDataArray(); + passData.finalPerCharMainDirectionalLightTintColorArray = finalPerCharMainDirectionalLightTintColorArray; + passData.finalPerCharMainDirectionalLightAddColorArray = finalPerCharMainDirectionalLightAddColorArray; + + SetGlobalNiloToonPerUnityVisibleLightDataArray(passData); + passData.perUnityVisibleLightNiloToonDataArray = perUnityVisibleLightNiloToonDataArray; + passData.perUnityVisibleLightNiloToonDataArray2 = perUnityVisibleLightNiloToonDataArray2; + } + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// + // copy and edit of https://docs.unity3d.com/6000.2/Documentation/Manual/urp/render-graph-write-render-pass.html +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + string passName = "NiloToonSetToonParam(RG)"; + + using (var builder = renderGraph.AddUnsafePass(passName, out var passData)) + { + UniversalResourceData resourceData = frameData.Get(); + + UniversalCameraData cameraData = frameData.Get(); + UniversalRenderingData renderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + //============================================ + // request URP depth texture + //============================================ + // DANGER!!!!!!!!!! + // Calling ConfigureInput(...) inside this RecordRenderGraph() method will prevent unity android build (error produced) (https://discussions.unity.com/t/introduction-of-render-graph-in-the-universal-render-pipeline-urp/930355/226) + // We now call ConfigureInput(...) in NiloToonAllInOneRenderereFeature's AddRenderPasses as a temp workaround. + //var input = GetScriptableRenderPassInput(cameraData.renderer); + //ConfigureInput(input); + + //-------------------------------------- + // fill in passData + //-------------------------------------- + passData.camera = cameraData.camera; + passData.additionalLightsCount = lightData.additionalLightsCount; + passData.mainLightIndex = lightData.mainLightIndex; + passData.Setting = Setting; + passData.visibleLights = lightData.visibleLights; + passData.renderer = cameraData.renderer; + passData.needCorrectDepthTextureDepthWrite = GetNeedCorrectDepthTextureDepthWrite(cameraData.renderer); + + FillInPassDataArray(passData); + //-------------------------------------- + + builder.AllowPassCulling(false); + + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => ExecutePassRG(data, context)); + } + } + static void ExecutePassRG(PassData passData, UnsafeGraphContext context) + { + // Convert UnsafeCommandBuffer to a regular CommandBuffer, our ExecutePassShared() use the regular CommandBuffer + CommandBuffer rawCommandBuffer = CommandBufferHelpers.GetNativeCommandBuffer(context.cmd); + + ExecutePassShared(rawCommandBuffer, passData); + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonToonOutlinePass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonToonOutlinePass.cs index 4b0df62..93bb0ec 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonToonOutlinePass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonToonOutlinePass.cs @@ -1,6 +1,9 @@ using System; using UnityEngine; using UnityEngine.Rendering; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif using UnityEngine.Rendering.Universal; using UnityEngine.XR; @@ -150,7 +153,7 @@ namespace NiloToon.NiloToonURP cmd.SetGlobalTexture("_CameraNormalRT", _normalRT.Identifier()); } context.ExecuteCommandBuffer(cmd); - CommandBufferPool.Release(cmd); + CommandBufferPool.Release(cmd); */ private void renderClassicOutline(ScriptableRenderContext context, RenderingData renderingData) @@ -168,51 +171,7 @@ namespace NiloToon.NiloToonURP context.ExecuteCommandBuffer(cmd); cmd.Clear(); - bool shouldRenderClassicOutline = settings.ShouldRenderOutline && !allSettings.MiscSettings.ForceNoOutline && !(allSettings.MiscSettings.ForceMinimumShader || NiloToonSetToonParamPass.ForceMinimumShader); - - if (NiloToonPlanarReflectionHelper.IsPlanarReflectionCamera(renderingData.cameraData.camera) && !settings.allowClassicOutlineInPlanarReflection) - { - shouldRenderClassicOutline = false; - } - - if (shouldRenderClassicOutline) - { - var volumeEffect = VolumeManager.instance.stack.GetComponent(); - - // set default value first because volume may not exist in scene - float outlineWidthMultiplierResult = settings.outlineWidthMultiplier * volumeEffect.charOutlineWidthMultiplier.value; - Color outlineTintColor = settings.outlineTintColor * volumeEffect.charOutlineMulColor.value; - float outlineWidthAutoAdjustToCameraDistanceAndFOV = settings.outlineWidthAutoAdjustToCameraDistanceAndFOV * volumeEffect.charOutlineWidthAutoAdjustToCameraDistanceAndFOV.value; - - // extra outline control if XR - if (XRSettings.isDeviceActive) - { - outlineWidthMultiplierResult *= volumeEffect.charOutlineWidthExtraMultiplierForXR.overrideState ? volumeEffect.charOutlineWidthExtraMultiplierForXR.value : settings.outlineWidthExtraMultiplierForXR; - } - - // set - cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 1); - cmd.SetGlobalFloat(_GlobalOutlineWidthMultiplier_SID, outlineWidthMultiplierResult); - cmd.SetGlobalColor(_GlobalOutlineTintColor_SID, outlineTintColor); - cmd.SetGlobalFloat(_GlobalOutlineWidthAutoAdjustToCameraDistanceAndFOV_SID, outlineWidthAutoAdjustToCameraDistanceAndFOV); - - // execute cmd before DrawRenderers - context.ExecuteCommandBuffer(cmd); - cmd.Clear(); - - // draw self classic outline - DrawingSettings drawingSettings = CreateDrawingSettings(toonOutlineLightModeShaderTagId, ref renderingData, SortingCriteria.CommonOpaque); - FilteringSettings filteringSettings = new FilteringSettings(renderQueueRange); - context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings); - } - else - { - // set - cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 0); - - // no draw - // (X) - } + ExecutePassShared(context, renderingData, cmd); } // must write these line after using{} finished, to ensure profiler and frame debugger display correctness @@ -220,5 +179,158 @@ namespace NiloToon.NiloToonURP cmd.Clear(); CommandBufferPool.Release(cmd); } + + private bool GetShouldRender(Camera camera) + { + bool shouldRenderClassicOutline = settings.ShouldRenderOutline && !allSettings.MiscSettings.ForceNoOutline && !(allSettings.MiscSettings.ForceMinimumShader || NiloToonSetToonParamPass.ForceMinimumShader); + + if (NiloToonPlanarReflectionHelper.IsPlanarReflectionCamera(camera) && !settings.allowClassicOutlineInPlanarReflection) + { + shouldRenderClassicOutline = false; + } + + return shouldRenderClassicOutline; + } + private void ExecutePassShared(ScriptableRenderContext context, RenderingData renderingData, CommandBuffer cmd) + { + // early exit if no render needed + if (!GetShouldRender(renderingData.cameraData.camera)) + { + // set the only required cmd + cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 0); + + // no draw + // (X) + + return; + } + + + var volumeEffect = VolumeManager.instance.stack.GetComponent(); + + // set default value first because volume may not exist in scene + float outlineWidthMultiplierResult = settings.outlineWidthMultiplier * volumeEffect.charOutlineWidthMultiplier.value; + Color outlineTintColor = settings.outlineTintColor * volumeEffect.charOutlineMulColor.value; + float outlineWidthAutoAdjustToCameraDistanceAndFOV = settings.outlineWidthAutoAdjustToCameraDistanceAndFOV * volumeEffect.charOutlineWidthAutoAdjustToCameraDistanceAndFOV.value; + + // extra outline control if XR + if (XRSettings.isDeviceActive) + { + outlineWidthMultiplierResult *= volumeEffect.charOutlineWidthExtraMultiplierForXR.overrideState ? volumeEffect.charOutlineWidthExtraMultiplierForXR.value : settings.outlineWidthExtraMultiplierForXR; + } + + // set + cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 1); + cmd.SetGlobalFloat(_GlobalOutlineWidthMultiplier_SID, outlineWidthMultiplierResult); + cmd.SetGlobalColor(_GlobalOutlineTintColor_SID, outlineTintColor); + cmd.SetGlobalFloat(_GlobalOutlineWidthAutoAdjustToCameraDistanceAndFOV_SID, outlineWidthAutoAdjustToCameraDistanceAndFOV); + + // execute cmd before DrawRenderers, to avoid 1 frame delay + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + + // draw self classic outline + DrawingSettings drawingSettings = CreateDrawingSettings(toonOutlineLightModeShaderTagId, ref renderingData, SortingCriteria.CommonOpaque); + FilteringSettings filteringSettings = new FilteringSettings(renderQueueRange); + context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings); + } + + + + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// + // copy and edit of https://docs.unity3d.com/6000.0/Documentation/Manual/urp/render-graph-draw-objects-in-a-pass.html +#if UNITY_6000_0_OR_NEWER + class PassData + { + // Create a field to store the list of objects to draw + public RendererListHandle rendererListHandle; + public Camera camera; + public bool shouldRender; + public float outlineWidthMultiplierResult; + public Color outlineTintColor; + public float outlineWidthAutoAdjustToCameraDistanceAndFOV; + } + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + string passName = "NiloToonClassicOutline(RG)"; + + using (var builder = renderGraph.AddRasterRenderPass(passName, out var passData)) + { + UniversalResourceData resourceData = frameData.Get(); + + UniversalCameraData cameraData = frameData.Get(); + UniversalRenderingData renderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + SortingCriteria sortFlags = SortingCriteria.CommonOpaque; //cameraData.defaultOpaqueSortFlags; + RenderQueueRange renderQueueRange = this.renderQueueRange; + FilteringSettings filterSettings = new FilteringSettings(renderQueueRange, ~0); + + // Redraw only objects that have their LightMode tag set to toonOutlineLightModeShaderTagId + ShaderTagId shadersToOverride = toonOutlineLightModeShaderTagId; + + // Create drawing settings + DrawingSettings drawSettings = RenderingUtils.CreateDrawingSettings(shadersToOverride, renderingData, cameraData, lightData, sortFlags); + + // Create the list of objects to draw + var rendererListParameters = new RendererListParams(renderingData.cullResults, drawSettings, filterSettings); + + //-------------------------------------- + // fill in passData + //-------------------------------------- + var volumeEffect = VolumeManager.instance.stack.GetComponent(); + passData.rendererListHandle = renderGraph.CreateRendererList(rendererListParameters); + passData.camera = cameraData.camera; + passData.shouldRender = GetShouldRender(cameraData.camera); + passData.outlineWidthMultiplierResult = settings.outlineWidthMultiplier * volumeEffect.charOutlineWidthMultiplier.value; + passData.outlineTintColor = settings.outlineTintColor * volumeEffect.charOutlineMulColor.value; + passData.outlineWidthAutoAdjustToCameraDistanceAndFOV = settings.outlineWidthAutoAdjustToCameraDistanceAndFOV * volumeEffect.charOutlineWidthAutoAdjustToCameraDistanceAndFOV.value; + + // extra outline control if XR + if (XRSettings.isDeviceActive) + { + passData.outlineWidthMultiplierResult *= volumeEffect.charOutlineWidthExtraMultiplierForXR.overrideState ? volumeEffect.charOutlineWidthExtraMultiplierForXR.value : settings.outlineWidthExtraMultiplierForXR; + } + + // Set the render target as the color and depth textures of the active camera texture + builder.UseRendererList(passData.rendererListHandle); + builder.SetRenderAttachment(resourceData.activeColorTexture, 0); + builder.SetRenderAttachmentDepth(resourceData.activeDepthTexture, AccessFlags.Write); + + builder.AllowGlobalStateModification(true); + + builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePassRG(data, context)); + } + } + + // run cmd similar to ExecutePassShared() + static void ExecutePassRG(PassData data, RasterGraphContext context) + { + var cmd = context.cmd; + + // early exit if no render needed + if (!data.shouldRender) + { + // set the only required cmd + cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 0); + + // no draw + // (X) + + return; + } + + // set cmd + cmd.SetGlobalFloat(_GlobalShouldRenderOutline_SID, 1); + cmd.SetGlobalFloat(_GlobalOutlineWidthMultiplier_SID, data.outlineWidthMultiplierResult); + cmd.SetGlobalColor(_GlobalOutlineTintColor_SID, data.outlineTintColor); + cmd.SetGlobalFloat(_GlobalOutlineWidthAutoAdjustToCameraDistanceAndFOV_SID, data.outlineWidthAutoAdjustToCameraDistanceAndFOV); + + // Draw the objects in the list + cmd.DrawRendererList(data.rendererListHandle); + } +#endif } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonUberPostProcessPass.cs b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonUberPostProcessPass.cs index 2202e3e..33b9f54 100644 --- a/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonUberPostProcessPass.cs +++ b/Assets/External/NiloToonURP/Runtime/RendererFeatures/Passes/NiloToonUberPostProcessPass.cs @@ -54,6 +54,10 @@ using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.XR; +#if UNITY_6000_0_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + namespace NiloToon.NiloToonURP { #if UNITY_2022_2_OR_NEWER @@ -343,7 +347,7 @@ namespace NiloToon.NiloToonURP var bloomMaterial = m_Materials.bloom; bloomMaterial.SetVector(ShaderConstants._Params, new Vector4(scatter, clamp, threshold, thresholdKnee)); CoreUtils.SetKeyword(bloomMaterial, ShaderKeywordStrings.BloomHQ, m_Bloom.highQualityFiltering.value); - CoreUtils.SetKeyword(bloomMaterial, ShaderKeywordStrings.UseRGBM, m_UseRGBM); + //CoreUtils.SetKeyword(bloomMaterial, ShaderKeywordStrings.UseRGBM, m_UseRGBM); // disabled due to Unity6000.0.23f1 release on 2024/10/17 // [NiloToon added] //==================================================================================== @@ -527,6 +531,16 @@ namespace NiloToon.NiloToonURP //==================================================================================== } + ///////////////////////////////////////////////////////////////////// + // RG support + ///////////////////////////////////////////////////////////////////// +#if UNITY_6000_0_OR_NEWER + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) + { + // TODO + } +#endif + class MaterialLibrary { public readonly Material bloom; diff --git a/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs b/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs new file mode 100644 index 0000000..2b91fa6 --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs @@ -0,0 +1,415 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace NiloToon.NiloToonURP.MiscUtil +{ + [Serializable] + public class RendererBlendshapes + { + [SerializeField] + public SkinnedMeshRenderer renderer; + + [SerializeField] + public List blendshapeNames = new List(); + + [SerializeField] + [HideInInspector] + public List blendshapeIndices = new List(); + + [SerializeField] + public List blendshapeMaxValues = new List(); + + public RendererBlendshapes() + { + blendshapeNames = new List(); + blendshapeIndices = new List(); + blendshapeMaxValues = new List(); + } + } + + public class AutoEyeBlink : MonoBehaviour + { + [SerializeField] + [Header("Targets")] + public List rendererTargets = new List(); + + [SerializeField] + [Header("Timing Settings")] + public float minCoolDown = 1f; + [SerializeField] + public float maxCoolDown = 3f; + [SerializeField] + public float minCloseAnimTime = 0.12f; + [SerializeField] + public float maxCloseAnimTime = 0.3f; + [SerializeField] + public float minHoldTime = 0.1f; + [SerializeField] + public float maxHoldTime = 0.2f; + + private void OnValidate() + { + foreach (var target in rendererTargets) + { + if (target.renderer != null && target.renderer.sharedMesh != null) + { + target.blendshapeIndices.Clear(); + foreach (var name in target.blendshapeNames) + { + target.blendshapeIndices.Add(target.renderer.sharedMesh.GetBlendShapeIndex(name)); + } + } + } + } + + private void Start() + { + rendererTargets.RemoveAll(target => target.renderer == null || target.blendshapeNames.Count == 0); + + if (rendererTargets.Count > 0) + { + StartCoroutine(EyeBlinkLoop()); + } + else + { + Debug.LogWarning("No valid blendshape targets set for AutoEyeBlink"); + } + } + + private IEnumerator EyeBlinkLoop() + { + while (true) + { + yield return new WaitForSeconds(UnityEngine.Random.Range(minCoolDown, maxCoolDown)); + + float closeTime = UnityEngine.Random.Range(minCloseAnimTime, maxCloseAnimTime); + + yield return StartCoroutine(AnimateBlendshapes(0f, 100f, closeTime * 0.5f)); + yield return new WaitForSeconds(UnityEngine.Random.Range(minHoldTime, maxHoldTime)); + yield return StartCoroutine(AnimateBlendshapes(100f, 0f, closeTime * 0.5f)); + } + } + + private IEnumerator AnimateBlendshapes(float startValue, float endValue, float duration) + { + float elapsed = 0f; + + while (elapsed < duration) + { + elapsed += Time.deltaTime; + float normalizedTime = Mathf.Clamp01(elapsed / duration); + float currentValue = Mathf.Lerp(startValue, endValue, normalizedTime); + + foreach (var target in rendererTargets) + { + if (target.renderer == null || target.renderer.sharedMesh == null) continue; + + for (int i = 0; i < target.blendshapeIndices.Count; i++) + { + if (target.blendshapeIndices[i] != -1) + { + float maxValue = (target.blendshapeMaxValues.Count > i) ? target.blendshapeMaxValues[i] : 1f; + target.renderer.SetBlendShapeWeight(target.blendshapeIndices[i], currentValue * maxValue); + } + } + } + + yield return null; + } + + foreach (var target in rendererTargets) + { + if (target.renderer == null || target.renderer.sharedMesh == null) continue; + + for (int i = 0; i < target.blendshapeIndices.Count; i++) + { + if (target.blendshapeIndices[i] != -1) + { + float maxValue = (target.blendshapeMaxValues.Count > i) ? target.blendshapeMaxValues[i] : 1f; + target.renderer.SetBlendShapeWeight(target.blendshapeIndices[i], endValue * maxValue); + } + } + } + } + +#if UNITY_EDITOR + [UnityEditor.CustomEditor(typeof(AutoEyeBlink))] + public class AutoEyeBlinkEditor : UnityEditor.Editor + { + private static class Styles + { + public static readonly GUIStyle headerStyle; + public static readonly GUIStyle sectionStyle; + public static readonly GUIStyle groupStyle; + + static Styles() + { + headerStyle = new GUIStyle(UnityEditor.EditorStyles.boldLabel); + headerStyle.fontSize = 14; + headerStyle.margin = new RectOffset(4, 4, 12, 8); + + sectionStyle = new GUIStyle(UnityEngine.GUI.skin.box); + sectionStyle.padding = new RectOffset(12, 12, 12, 12); + sectionStyle.margin = new RectOffset(0, 0, 8, 8); + + groupStyle = new GUIStyle(UnityEditor.EditorStyles.helpBox); + groupStyle.padding = new RectOffset(8, 8, 8, 8); + groupStyle.margin = new RectOffset(0, 0, 4, 4); + } + } + + private readonly Dictionary tooltips = new Dictionary + { + { "minCoolDown", "Minimum time to wait between blinks" }, + { "maxCoolDown", "Maximum time to wait between blinks" }, + { "minCloseAnimTime", "Minimum duration of the blink animation" }, + { "maxCloseAnimTime", "Maximum duration of the blink animation" }, + { "minHoldTime", "Minimum time to keep eyes closed" }, + { "maxHoldTime", "Maximum time to keep eyes closed" } + }; + + public override void OnInspectorGUI() + { + serializedObject.Update(); + AutoEyeBlink script = (AutoEyeBlink)target; + + // Timing Settings + UnityEditor.EditorGUILayout.Space(4); + using (new UnityEditor.EditorGUILayout.VerticalScope(Styles.sectionStyle)) + { + UnityEditor.EditorGUILayout.LabelField("Timing Settings", Styles.headerStyle); + + using (new UnityEditor.EditorGUILayout.VerticalScope(Styles.groupStyle)) + { + DrawFloatField("Min Cool Down", "minCoolDown", 0f, 10f); + DrawFloatField("Max Cool Down", "maxCoolDown", 0f, 10f); + DrawFloatField("Min Close Anim Time", "minCloseAnimTime", 0f, 1f); + DrawFloatField("Max Close Anim Time", "maxCloseAnimTime", 0f, 1f); + DrawFloatField("Min Hold Time", "minHoldTime", 0f, 1f); + DrawFloatField("Max Hold Time", "maxHoldTime", 0f, 1f); + } + + ValidateTimings(script); + } + + // Renderer Targets + UnityEditor.EditorGUILayout.Space(4); + using (new UnityEditor.EditorGUILayout.VerticalScope(Styles.sectionStyle)) + { + UnityEditor.EditorGUILayout.LabelField("Renderer Targets", Styles.headerStyle); + + SerializedProperty rendererTargetsProperty = serializedObject.FindProperty("rendererTargets"); + + for (int i = 0; i < script.rendererTargets.Count; i++) + { + using (new UnityEditor.EditorGUILayout.VerticalScope(Styles.groupStyle)) + { + var target = script.rendererTargets[i]; + SerializedProperty rendererTargetProperty = rendererTargetsProperty.GetArrayElementAtIndex(i); + SerializedProperty rendererProperty = rendererTargetProperty.FindPropertyRelative("renderer"); + + var rect = UnityEditor.EditorGUILayout.GetControlRect(); + UnityEditor.EditorGUI.BeginProperty(rect, new GUIContent("Renderer"), rendererProperty); + + using (var check = new UnityEditor.EditorGUI.ChangeCheckScope()) + { + var newRenderer = (SkinnedMeshRenderer)UnityEditor.EditorGUI.ObjectField( + rect, "Renderer", target.renderer, typeof(SkinnedMeshRenderer), true); + + if (check.changed) + { + UnityEditor.Undo.RecordObject(script, "Change Renderer"); + target.renderer = newRenderer; + target.blendshapeNames.Clear(); + target.blendshapeIndices.Clear(); + target.blendshapeMaxValues.Clear(); + UnityEditor.EditorUtility.SetDirty(script); + } + } + + UnityEditor.EditorGUI.EndProperty(); + + if (target.renderer != null && target.renderer.sharedMesh != null) + { + DrawBlendshapeSection(target, target.renderer.sharedMesh, script, i); + } + else + { + UnityEditor.EditorGUILayout.HelpBox("Please assign a SkinnedMeshRenderer with a valid mesh", UnityEditor.MessageType.Info); + } + + if (GUILayout.Button("Remove Renderer", GUILayout.Width(120))) + { + UnityEditor.Undo.RecordObject(script, "Remove Renderer"); + script.rendererTargets.RemoveAt(i); + UnityEditor.EditorUtility.SetDirty(script); + i--; + } + } + UnityEditor.EditorGUILayout.Space(2); + } + + UnityEditor.EditorGUILayout.Space(4); + if (GUILayout.Button("Add Renderer", GUILayout.Height(24))) + { + UnityEditor.Undo.RecordObject(script, "Add Renderer"); + script.rendererTargets.Add(new RendererBlendshapes()); + UnityEditor.EditorUtility.SetDirty(script); + } + } + + serializedObject.ApplyModifiedProperties(); + } + + private void DrawFloatField(string label, string propertyName, float min, float max) + { + var prop = serializedObject.FindProperty(propertyName); + var rect = UnityEditor.EditorGUILayout.GetControlRect(); + + UnityEditor.EditorGUI.BeginProperty(rect, new GUIContent(label, tooltips[propertyName]), prop); + float newValue = UnityEditor.EditorGUI.Slider(rect, label, prop.floatValue, min, max); + if (newValue != prop.floatValue) + { + prop.floatValue = newValue; + } + UnityEditor.EditorGUI.EndProperty(); + } + + private void ValidateTimings(AutoEyeBlink script) + { + if (script.minCoolDown > script.maxCoolDown) + UnityEditor.EditorGUILayout.HelpBox("Min Cool Down should be less than Max Cool Down", UnityEditor.MessageType.Warning); + + if (script.minCloseAnimTime > script.maxCloseAnimTime) + UnityEditor.EditorGUILayout.HelpBox("Min Close Anim Time should be less than Max Close Anim Time", UnityEditor.MessageType.Warning); + + if (script.minHoldTime > script.maxHoldTime) + UnityEditor.EditorGUILayout.HelpBox("Min Hold Time should be less than Max Hold Time", UnityEditor.MessageType.Warning); + } + + private void DrawBlendshapeSection(RendererBlendshapes target, UnityEngine.Mesh mesh, AutoEyeBlink script, int targetIndex) + { + var blendshapeNames = new List(); + for (int j = 0; j < mesh.blendShapeCount; j++) + { + blendshapeNames.Add(mesh.GetBlendShapeName(j)); + } + + if (blendshapeNames.Count == 0) + { + UnityEditor.EditorGUILayout.HelpBox("This mesh has no blendshapes", UnityEditor.MessageType.Info); + return; + } + + EditorGUILayout.LabelField("Blendshapes", EditorStyles.miniLabel); + EditorGUI.indentLevel++; + + for (int j = 0; j < target.blendshapeNames.Count; j++) + { + while (target.blendshapeMaxValues.Count <= j) + target.blendshapeMaxValues.Add(1f); + + EditorGUILayout.BeginHorizontal(); + { + // Label + EditorGUILayout.LabelField($"Shape {j + 1}", EditorStyles.miniLabel, GUILayout.Width(60)); + + // Dropdown + int currentIndex = blendshapeNames.IndexOf(target.blendshapeNames[j]); + if (currentIndex == -1) currentIndex = 0; + + using (var check = new EditorGUI.ChangeCheckScope()) + { + var dropdownStyle = new GUIStyle(EditorStyles.miniPullDown) + { + fixedWidth = 120, // Increased width to show full name + alignment = TextAnchor.MiddleLeft, + clipping = TextClipping.Clip + }; + + // Create the popup content with the actual blendshape names + int newIndex = EditorGUILayout.Popup(currentIndex, + blendshapeNames.ToArray(), + dropdownStyle); + + if (check.changed) + { + Undo.RecordObject(script, "Change Blendshape"); + target.blendshapeNames[j] = blendshapeNames[newIndex]; + EditorUtility.SetDirty(script); + } + } + + // Slider + using (var check = new EditorGUI.ChangeCheckScope()) + { + float newValue = EditorGUILayout.Slider(target.blendshapeMaxValues[j], 0f, 1f, GUILayout.ExpandWidth(true)); + if (check.changed) + { + Undo.RecordObject(script, "Change Max Value"); + target.blendshapeMaxValues[j] = newValue; + EditorUtility.SetDirty(script); + } + } + + GUILayout.Space(4); // Add small space before the X button + + // Remove button with dark theme style + var buttonStyle = new GUIStyle(EditorStyles.miniButton) + { + fixedWidth = 18, + fixedHeight = 16, + padding = new RectOffset(0, 0, 0, 0), + margin = new RectOffset(0, 0, 1, 0), + alignment = TextAnchor.MiddleCenter, + normal = new GUIStyleState + { + background = EditorGUIUtility.whiteTexture, + textColor = new Color(0.7f, 0.7f, 0.7f) + } + }; + + if (GUILayout.Button("X", buttonStyle)) + { + Undo.RecordObject(script, "Remove Blendshape"); + target.blendshapeNames.RemoveAt(j); + target.blendshapeMaxValues.RemoveAt(j); + EditorUtility.SetDirty(script); + j--; + } + } + EditorGUILayout.EndHorizontal(); + } + + EditorGUI.indentLevel--; + EditorGUILayout.Space(2); + + // Add Blendshape button + var addButtonStyle = new GUIStyle(GUI.skin.button) + { + fontSize = 11, + alignment = TextAnchor.MiddleCenter, + normal = new GUIStyleState { textColor = new Color(0.7f, 0.7f, 0.7f) } + }; + + if (GUILayout.Button("Add Blendshape", addButtonStyle)) + { + if (blendshapeNames.Count > 0) + { + Undo.RecordObject(script, "Add Blendshape"); + target.blendshapeNames.Add(blendshapeNames[0]); + target.blendshapeMaxValues.Add(1f); + EditorUtility.SetDirty(script); + } + } + } + } +#endif + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs.meta b/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs.meta new file mode 100644 index 0000000..a3d1b1e --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/Utility/AutoEyeBlink.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 58fa765bec005714d956eaab83a10668 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Runtime/Utility/NiloToonUtils.cs b/Assets/External/NiloToonURP/Runtime/Utility/NiloToonUtils.cs index fb1ae13..6e13bcf 100644 --- a/Assets/External/NiloToonURP/Runtime/Utility/NiloToonUtils.cs +++ b/Assets/External/NiloToonURP/Runtime/Utility/NiloToonUtils.cs @@ -14,6 +14,11 @@ namespace NiloToon.NiloToonURP { return name.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0; } + + public static bool NameEqualsKeywordIgnoreCase(string name, string keyword) + { + return string.Equals(name, keyword, StringComparison.OrdinalIgnoreCase); + } public static Transform DepthSearch(Transform parent, string targetName, string[] banNameList) { diff --git a/Assets/External/NiloToonURP/Runtime/Utility/UnlockFPS.cs b/Assets/External/NiloToonURP/Runtime/Utility/UnlockFPS.cs index c94f8ea..2f93d42 100644 --- a/Assets/External/NiloToonURP/Runtime/Utility/UnlockFPS.cs +++ b/Assets/External/NiloToonURP/Runtime/Utility/UnlockFPS.cs @@ -4,9 +4,12 @@ namespace NiloToon.NiloToonURP.MiscUtil { public class UnlockFPS : MonoBehaviour { + [Range(0,1000)] + public int targetFPS = 60; + void Start() { - Application.targetFrameRate = 60; + Application.targetFrameRate = targetFPS; } } } \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonCinematicRimLightVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonCinematicRimLightVolume.cs index 3cb7eed..8485832 100644 --- a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonCinematicRimLightVolume.cs +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonCinematicRimLightVolume.cs @@ -21,7 +21,7 @@ namespace NiloToon.NiloToonURP [OverrideDisplayName(" Rim Sharpness")] public ClampedFloatParameter sharpnessRimMask3D_DynamicStyle = new ClampedFloatParameter(0.375f, 0, 1); - [Header("Rim (3D BackLight only Style) (Experimental)")] + [Header("Rim (3D BackLight only Style)")] [OverrideDisplayName("Strength")] public ClampedFloatParameter strengthRimMask3D_StableStyle = new ClampedFloatParameter(0, 0, 1); [OverrideDisplayName(" Rim Sharpness")] diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonEnvironmentControlVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonEnvironmentControlVolume.cs index b8e9a07..ebadb50 100644 --- a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonEnvironmentControlVolume.cs +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonEnvironmentControlVolume.cs @@ -7,20 +7,30 @@ namespace NiloToon.NiloToonURP [System.Serializable, VolumeComponentMenu("NiloToon/Environment Control (NiloToon)")] public class NiloToonEnvironmentControlVolume : VolumeComponent, IPostProcessComponent { - [Header("Global GI edit")] + [Header("GI Edit")] + [OverrideDisplayName("Tint Color")] public ColorParameter GlobalIlluminationTintColor = new ColorParameter(Color.white, true, false, true); + [OverrideDisplayName("Add Color")] public ColorParameter GlobalIlluminationAddColor = new ColorParameter(Color.black, true, false, true); - [Header("Global GI override")] + [Header("GI Override")] + [OverrideDisplayName("Override Color")] + [Tooltip("Alpha = override strength")] public ColorParameter GlobalIlluminationOverrideColor = new ColorParameter(Color.clear,true,true,true); - [Header("Global Albedo override")] + [Header("Albedo Override")] + [OverrideDisplayName("Override Color")] + [Tooltip("Alpha = override strength")] public ColorParameter GlobalAlbedoOverrideColor = new ColorParameter(new Color(1, 1, 1, 0), true, true, true); - [Header("Global Surface Color Result override")] + [Header("Surface Color Result Override")] + [OverrideDisplayName("Override Color")] + [Tooltip("Alpha = override strength")] public ColorParameter GlobalSurfaceColorResultOverrideColor = new ColorParameter(new Color(1, 1, 1, 0), true, true, true); - [Header("Global shadow boader tint color override")] + [Header("Shadow Boarder Tint Color")] + [OverrideDisplayName("Override Color")] + [Tooltip("Alpha = override strength")] public ColorParameter GlobalShadowBoaderTintColorOverrideColor = new ColorParameter(new Color(0, 0, 0, 0), true, true, true); public bool IsActive() => true; diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs new file mode 100644 index 0000000..8f99fc7 --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +namespace NiloToon.NiloToonURP +{ + [System.Serializable, VolumeComponentMenu("NiloToon/Motion Blur (NiloToon)")] + public class NiloToonMotionBlurVolume : VolumeComponent, IPostProcessComponent + { + [Header("Master control")] + public ClampedFloatParameter intensity = new ClampedFloatParameter(0, 0, 2); + + public bool IsActive() => intensity.value > 0f; + + public bool IsTileCompatible() => false; + } +} + diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs.meta b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs.meta new file mode 100644 index 0000000..001727e --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonMotionBlurVolume.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae2b217974b749d4b97b47bae772aee5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonScreenSpaceOutlineControlVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonScreenSpaceOutlineControlVolume.cs index d0e2020..d432929 100644 --- a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonScreenSpaceOutlineControlVolume.cs +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonScreenSpaceOutlineControlVolume.cs @@ -7,42 +7,56 @@ namespace NiloToon.NiloToonURP [System.Serializable, VolumeComponentMenu("NiloToon/Screen Space Outline Control (NiloToon)")] public class NiloToonScreenSpaceOutlineControlVolume : VolumeComponent, IPostProcessComponent { - [HelpBox( - "Requires 'enable ScreenSpace outline' in NiloToonAllInOne renderer feature in order for this volume to become effective.\n" + - "*In Camera, turn on TAA is critical for screen space outline to look stable when camera moves, or you can use DLSS/FSR")] - [Header("--------------------------")] - [Header("Master control")] + [Header("Intensity")] public ClampedFloatParameter intensity = new ClampedFloatParameter(0, 0, 1); + [OverrideDisplayName("Intensity (Character)")] public ClampedFloatParameter intensityForCharacter = new ClampedFloatParameter(1, 0, 1); + [OverrideDisplayName("Intensity (Environment)")] public ClampedFloatParameter intensityForEnvironment = new ClampedFloatParameter(1, 0, 1); - [Header("Global width multiplier")] + [Header("Width")] + [OverrideDisplayName("Width")] public ClampedFloatParameter widthMultiplier = new ClampedFloatParameter(1, 0, 10f); + [OverrideDisplayName("Width (Character)")] public ClampedFloatParameter widthMultiplierForCharacter = new ClampedFloatParameter(1, 0, 10f); + [OverrideDisplayName("Width (Environment)")] public ClampedFloatParameter widthMultiplierForEnvironment = new ClampedFloatParameter(1, 0, 10f); + [OverrideDisplayName("Width (XR)")] public ClampedFloatParameter extraWidthMultiplierForXR = new ClampedFloatParameter(0.2f, 0, 10f); - [Header("Global normal sensitivityOffset")] + [Header("Normal Sensitivity Offset")] + [OverrideDisplayName("Offset")] public ClampedFloatParameter normalsSensitivityOffset = new ClampedFloatParameter(0, -10f, 10f); + [OverrideDisplayName("Offset (Character)")] public ClampedFloatParameter normalsSensitivityOffsetForCharacter = new ClampedFloatParameter(0, -10f, 10f); + [OverrideDisplayName("Offset (Environment)")] public ClampedFloatParameter normalsSensitivityOffsetForEnvironment = new ClampedFloatParameter(0, -10f, 10f); - [Header("Global depth sensitivityOffset")] + [Header("Depth Sensitivity Offset")] + [OverrideDisplayName("Offset")] public ClampedFloatParameter depthSensitivityOffset = new ClampedFloatParameter(0, -10f, 10f); + [OverrideDisplayName("Offset (Character)")] public ClampedFloatParameter depthSensitivityOffsetForCharacter = new ClampedFloatParameter(0, -10f, 10f); + [OverrideDisplayName("Offset (Environment)")] public ClampedFloatParameter depthSensitivityOffsetForEnvironment = new ClampedFloatParameter(0, -10f, 10f); - [Header("Global depth sensitivity Distance Fadeout Strength")] + [Header("Depth Sensitivity Distance Fadeout Strength")] [Tooltip("Fadeout depth sensitivity on far objects, to avoid artifact")] + [OverrideDisplayName("Strength")] public ClampedFloatParameter depthSensitivityDistanceFadeoutStrength = new ClampedFloatParameter(1, 0, 10); [Tooltip("Fadeout depth sensitivity on far objects (for character shader), to avoid artifact")] + [OverrideDisplayName("Strength (Character)")] public ClampedFloatParameter depthSensitivityDistanceFadeoutStrengthForCharacter = new ClampedFloatParameter(1, 0, 10); [Tooltip("Fadeout depth sensitivity on far objects (for environment shader), to avoid artifact")] + [OverrideDisplayName("Strength (Environment")] public ClampedFloatParameter depthSensitivityDistanceFadeoutStrengthForEnvironment = new ClampedFloatParameter(1, 0, 10); - [Header("Outline Tint Color (environment)")] + [Header("Outline Tint Color")] + [OverrideDisplayName("Tint Color")] public ColorParameter outlineTintColor = new ColorParameter(Color.white, true, false, true); + [OverrideDisplayName("Tint Color (Character)")] public ColorParameter outlineTintColorForChar = new ColorParameter(Color.white, true, false, true); + [OverrideDisplayName("Tint Color (Environment)")] public ColorParameter outlineTintColorForEnvi = new ColorParameter(new Color(0.12f, 0.12f, 0.12f), true, false, true); public bool IsActive() => intensity.value > 0.0f && widthMultiplier.value > 0.0f; diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonShadowControlVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonShadowControlVolume.cs index 8bddb88..d9ae1f3 100644 --- a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonShadowControlVolume.cs +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonShadowControlVolume.cs @@ -7,17 +7,23 @@ namespace NiloToon.NiloToonURP [System.Serializable, VolumeComponentMenu("NiloToon/Shadow Control (NiloToon)")] public class NiloToonShadowControlVolume : VolumeComponent, IPostProcessComponent { - [Header("Overall shadow")] + [Header("All Shadows")] + [OverrideDisplayName("Shadow Tint Color")] public ColorParameter characterOverallShadowTintColor = new ColorParameter(Color.white, true, false, true); + [OverrideDisplayName("Shadow Strength")] public ClampedFloatParameter characterOverallShadowStrength = new ClampedFloatParameter(1, 0, 2); - [Header("Character NiloToon Average shadow map")] + [Header("Average Shadow")] + [OverrideDisplayName("Enable?")] public BoolParameter enableCharAverageShadow = new BoolParameter(true); + [OverrideDisplayName("Shadow Strength")] public ClampedFloatParameter charAverageShadowStrength = new ClampedFloatParameter(1, 0, 1); - [Header("Character NiloToon self shadow map")] + [Header("Self Shadow Map")] // all default values copy from NiloToonCharSelfShadowMapRTPass.Settings + [OverrideDisplayName("Enable?")] public BoolParameter enableCharSelfShadow = new BoolParameter(true); + [OverrideDisplayName("Shadow Strength")] public ClampedFloatParameter charSelfShadowStrength = new ClampedFloatParameter(1, 0, 1); [Tooltip( "- If overridden to false, will use camera's forward(with the shadowAngle & shadowLRAngle applied) as cast shadow direction.\n" + @@ -46,13 +52,19 @@ namespace NiloToon.NiloToonURP "In some situation you may want to reduce it to keep the shadow shape closer to the character(e.g. finger shape).")] public ClampedFloatParameter normalBias = new ClampedFloatParameter(1, 0, 4); - [Header("Character receiving URP's shadow map")] + [Header("Receive URP's Shadow Map")] + [OverrideDisplayName("Enable?")] public BoolParameter receiveURPShadow = new BoolParameter(false); + [OverrideDisplayName("Shadow Strength")] public ClampedFloatParameter URPShadowIntensity = new ClampedFloatParameter(1, 0, 1); [Tooltip("Drag to 0 to produce regular URP shadow result (block all direct light)")] + [OverrideDisplayName("As DirectLight Multiplier")] public ClampedFloatParameter URPShadowAsDirectLightMultiplier = new ClampedFloatParameter(1, 0, 1); + [OverrideDisplayName("As DirectLight Tint Color")] public ColorParameter URPShadowAsDirectLightTintColor = new ColorParameter(Color.white,false,false,true); + [OverrideDisplayName("As DirectLight Tint Ignore Material URP Usage Setting")] public ClampedFloatParameter URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting = new ClampedFloatParameter(1, 0, 1); + [OverrideDisplayName("Blurriness")] public ClampedFloatParameter URPShadowblurriness = new ClampedFloatParameter(1, 0, 1); public bool IsActive() => true; diff --git a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonTonemappingVolume.cs b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonTonemappingVolume.cs index e3a6036..7afa288 100644 --- a/Assets/External/NiloToonURP/Runtime/Volume/NiloToonTonemappingVolume.cs +++ b/Assets/External/NiloToonURP/Runtime/Volume/NiloToonTonemappingVolume.cs @@ -18,10 +18,10 @@ namespace NiloToon.NiloToonURP [InspectorName("Khronos PBR Neutral")] KhronosPBRNeutral, - [InspectorName("Nilo NPR Neutral V1 (experimental)")] + [InspectorName("Nilo NPR Neutral V1")] NiloNPRNeutralV1, - [InspectorName("Nilo Hybird ACES (experimental)")] + [InspectorName("Nilo Hybird ACES")] NiloHybirdACES } diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/Resources/NiloToonVolumePresetPicker.prefab b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/Resources/NiloToonVolumePresetPicker.prefab index 2e98433..802e91f 100644 --- a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/Resources/NiloToonVolumePresetPicker.prefab +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/Resources/NiloToonVolumePresetPicker.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97e1737f6ede0611cd94b53138ff52e066dcb2cec44756fbf5a433c4c071f9a5 -size 4169 +oid sha256:3e1b887dd69f3bd379335b861df05c950b1297c00a85eeafc6e9acef9b8574f5 +size 4313 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo002-CharStrongRim&Shadow(NiloToonVolumePreset).asset b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo002-CharStrongRim&Shadow(NiloToonVolumePreset).asset index 3926777..48aa8e7 100644 --- a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo002-CharStrongRim&Shadow(NiloToonVolumePreset).asset +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo002-CharStrongRim&Shadow(NiloToonVolumePreset).asset @@ -15,10 +15,10 @@ MonoBehaviour: active: 1 threshold: m_OverrideState: 1 - m_Value: 0.98 + m_Value: 10 intensity: m_OverrideState: 1 - m_Value: 1.13 + m_Value: 0.6 scatter: m_OverrideState: 1 m_Value: 0.6 @@ -31,12 +31,9 @@ MonoBehaviour: highQualityFiltering: m_OverrideState: 0 m_Value: 0 - downscale: + skipIterations: m_OverrideState: 0 - m_Value: 0 - maxIterations: - m_OverrideState: 0 - m_Value: 8 + m_Value: 1 dirtTexture: m_OverrideState: 0 m_Value: {fileID: 0} @@ -294,7 +291,7 @@ MonoBehaviour: m_Value: 5 charRimLightTintColor: m_OverrideState: 1 - m_Value: {r: 1, g: 1, b: 1, a: 0} + m_Value: {r: 1, g: 0.6396751, b: 0.41037738, a: 0} charRimLightMultiplierForOutlineArea: m_OverrideState: 0 m_Value: 0 @@ -340,7 +337,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5aa15fc7246432d4fb73e65893caaa4b, type: 3} m_Name: NiloToonAnimePostProcessVolume m_EditorClassIdentifier: - active: 0 + active: 1 intensity: m_OverrideState: 1 m_Value: 0.3 @@ -380,9 +377,6 @@ MonoBehaviour: drawBeforePostProcess: m_OverrideState: 0 m_Value: 0 - affectedByCameraPostprocessToggle: - m_OverrideState: 0 - m_Value: 1 --- !u!114 &4888551859540240522 MonoBehaviour: m_ObjectHideFlags: 3 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo028-Concert005_StyleDark_ACES(NiloToonVolumePreset).asset b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo028-Concert005_StyleDark_ACES(NiloToonVolumePreset).asset index b4528d0..b017112 100644 --- a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo028-Concert005_StyleDark_ACES(NiloToonVolumePreset).asset +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo028-Concert005_StyleDark_ACES(NiloToonVolumePreset).asset @@ -224,12 +224,12 @@ MonoBehaviour: active: 1 mode: m_OverrideState: 1 - m_Value: 2 + m_Value: 7 intensity: m_OverrideState: 0 m_Value: 1 ApplyToCharacter: - m_OverrideState: 0 + m_OverrideState: 1 m_Value: 1 ApplyToNonCharacter: m_OverrideState: 0 @@ -1248,25 +1248,25 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d89c46e6b4f031541986f8d6bdbad145, type: 3} m_Name: NiloToonCinematicRimLightVolume m_EditorClassIdentifier: - active: 0 + active: 1 strengthRimMask2D: m_OverrideState: 0 m_Value: 1 strengthRimMask3D_ClassicStyle: - m_OverrideState: 1 - m_Value: 1 + m_OverrideState: 0 + m_Value: 0 strengthRimMask3D_DynmaicStyle: m_OverrideState: 0 - m_Value: 1 + m_Value: 0 sharpnessRimMask3D_DynamicStyle: m_OverrideState: 0 - m_Value: 0.375 + m_Value: 0.1 strengthRimMask3D_StableStyle: - m_OverrideState: 0 + m_OverrideState: 1 m_Value: 1 sharpnessRimMask3D_StableStyle: - m_OverrideState: 0 - m_Value: 0.5 + m_OverrideState: 1 + m_Value: 0.25 lightIntensityMultiplier: m_OverrideState: 1 m_Value: 1 @@ -1303,6 +1303,7 @@ MonoBehaviour: - {fileID: 962140819579389808} - {fileID: -3973662611378603825} - {fileID: 411203215106509782} + - {fileID: 5875841107899412797} --- !u!114 &411203215106509782 MonoBehaviour: m_ObjectHideFlags: 3 @@ -1602,7 +1603,7 @@ MonoBehaviour: m_Value: 1 topLightSunTintColor: m_OverrideState: 1 - m_Value: {r: 0.24526887, g: 0.2759902, b: 0.319, a: 1} + m_Value: {r: 0.16862746, g: 0.1882353, b: 0.21568628, a: 1} topLightDesaturate: m_OverrideState: 0 m_Value: 0 @@ -1753,7 +1754,7 @@ MonoBehaviour: m_Value: 1.25 charRimLightMultiplier: m_OverrideState: 1 - m_Value: 16 + m_Value: 6 charRimLightTintColor: m_OverrideState: 0 m_Value: {r: 1, g: 1, b: 1, a: 0} @@ -1790,6 +1791,22 @@ MonoBehaviour: charOutlineMulColor: m_OverrideState: 0 m_Value: {r: 0.25, g: 0.25, b: 0.25, a: 1} +--- !u!114 &5875841107899412797 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae2b217974b749d4b97b47bae772aee5, type: 3} + m_Name: NiloToonMotionBlurVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 1 --- !u!114 &7773777288705028284 MonoBehaviour: m_ObjectHideFlags: 3 @@ -1882,7 +1899,7 @@ MonoBehaviour: m_Value: 0 SaturationBoost: m_OverrideState: 1 - m_Value: 0.25 + m_Value: 0.1 ValueMultiply: m_OverrideState: 0 m_Value: 1 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo029-Concert006_StyleBright(NiloToonVolumePreset).asset b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo029-Concert006_StyleBright(NiloToonVolumePreset).asset index aec635d..56f792c 100644 --- a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo029-Concert006_StyleBright(NiloToonVolumePreset).asset +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo029-Concert006_StyleBright(NiloToonVolumePreset).asset @@ -718,7 +718,7 @@ MonoBehaviour: m_OverrideState: 0 m_Value: {r: 1, g: 1, b: 1, a: 0} charOutlineWidthMultiplier: - m_OverrideState: 1 + m_OverrideState: 0 m_Value: 1.125 charOutlineWidthExtraMultiplierForXR: m_OverrideState: 0 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset new file mode 100644 index 0000000..e905866 --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset @@ -0,0 +1,2267 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-6740973590107075020 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f53d442396c644b198ad641a34212ce, type: 3} + m_Name: RadiantGlobalIllumination + m_EditorClassIdentifier: + active: 0 + indirectIntensity: + m_OverrideState: 1 + m_Value: 0.25 + indirectDistanceAttenuation: + m_OverrideState: 0 + m_Value: 0 + indirectMaxSourceBrightness: + m_OverrideState: 0 + m_Value: 8 + normalMapInfluence: + m_OverrideState: 0 + m_Value: 1 + rayBounce: + m_OverrideState: 1 + m_Value: 1 + lumaInfluence: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscurance: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscuranceSpread: + m_OverrideState: 0 + m_Value: 0.2 + nearFieldObscuranceMaxCameraDistance: + m_OverrideState: 0 + m_Value: 125 + nearFieldObscuranceOccluderDistance: + m_OverrideState: 0 + m_Value: 0.825 + nearFieldObscuranceTintColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + virtualEmitters: + m_OverrideState: 0 + m_Value: 0 + organicLight: + m_OverrideState: 0 + m_Value: 0 + organicLightThreshold: + m_OverrideState: 0 + m_Value: 0.5 + organicLightSpread: + m_OverrideState: 0 + m_Value: 0.98 + organicLightNormalsInfluence: + m_OverrideState: 0 + m_Value: 0.95 + organicLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + organicLightAnimationSpeed: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + organicLightDistanceScaling: + m_OverrideState: 0 + m_Value: 0 + rayCount: + m_OverrideState: 0 + m_Value: 1 + rayMaxLength: + m_OverrideState: 0 + m_Value: 8 + rayMaxSamples: + m_OverrideState: 0 + m_Value: 32 + rayJitter: + m_OverrideState: 0 + m_Value: 0 + thickness: + m_OverrideState: 0 + m_Value: 1 + rayBinarySearch: + m_OverrideState: 0 + m_Value: 1 + fallbackReuseRays: + m_OverrideState: 1 + m_Value: 1 + rayReuse: + m_OverrideState: 1 + m_Value: 0.9 + fallbackReflectionProbes: + m_OverrideState: 0 + m_Value: 0 + probesIntensity: + m_OverrideState: 0 + m_Value: 1 + fallbackReflectiveShadowMap: + m_OverrideState: 0 + m_Value: 0 + reflectiveShadowMapIntensity: + m_OverrideState: 0 + m_Value: 0.8 + downsampling: + m_OverrideState: 0 + m_Value: 1 + raytracerAccuracy: + m_OverrideState: 0 + m_Value: 8 + smoothing: + m_OverrideState: 0 + m_Value: 3 + temporalReprojection: + m_OverrideState: 0 + m_Value: 1 + temporalResponseSpeed: + m_OverrideState: 0 + m_Value: 12 + temporalCameraTranslationResponse: + m_OverrideState: 0 + m_Value: 100 + temporalDepthRejection: + m_OverrideState: 0 + m_Value: 1 + temporalChromaThreshold: + m_OverrideState: 0 + m_Value: 0.2 + showInEditMode: + m_OverrideState: 0 + m_Value: 1 + showInSceneView: + m_OverrideState: 0 + m_Value: 1 + brightnessThreshold: + m_OverrideState: 0 + m_Value: 0 + brightnessMax: + m_OverrideState: 0 + m_Value: 8 + specularContribution: + m_OverrideState: 0 + m_Value: 0.75 + sourceBrightness: + m_OverrideState: 0 + m_Value: 1 + giWeight: + m_OverrideState: 0 + m_Value: 0 + nearCameraAttenuation: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 2 + limitToVolumeBounds: + m_OverrideState: 0 + m_Value: 0 + stencilCheck: + m_OverrideState: 0 + m_Value: 0 + stencilValue: + m_OverrideState: 0 + m_Value: 1 + stencilCompareFunction: + m_OverrideState: 0 + m_Value: 6 + aoInfluence: + m_OverrideState: 0 + m_Value: 0 + debugView: + m_OverrideState: 0 + m_Value: 70 + debugDepthMultiplier: + m_OverrideState: 0 + m_Value: 10 + compareMode: + m_OverrideState: 0 + m_Value: 0 + compareSameSide: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 +--- !u!114 &-6636676602098857160 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 81180773991d8724ab7f2d216912b564, type: 3} + m_Name: ChromaticAberration + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.05 +--- !u!114 &-5934634642679004759 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 905ab376be722a641bd27d7ae304cedd, type: 3} + m_Name: NiloToonTonemappingVolume + m_EditorClassIdentifier: + active: 1 + mode: + m_OverrideState: 1 + m_Value: 7 + intensity: + m_OverrideState: 1 + m_Value: 1 + ApplyToCharacter: + m_OverrideState: 1 + m_Value: 1 + ApplyToNonCharacter: + m_OverrideState: 1 + m_Value: 0.5 + BrightnessMulForCharacter: + m_OverrideState: 1 + m_Value: 0.7 + BrightnessMulForNonCharacter: + m_OverrideState: 1 + m_Value: 1 +--- !u!114 &-4188649219325671941 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c133717c76e564a5fa90d7f12908d17e, type: 3} + m_Name: Beautify + m_EditorClassIdentifier: + active: 1 + disabled: + m_OverrideState: 1 + m_Value: 0 + compareMode: + m_OverrideState: 1 + m_Value: 0 + compareStyle: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 + flipY: + m_OverrideState: 1 + m_Value: 0 + hideInSceneView: + m_OverrideState: 1 + m_Value: 0 + debugOutput: + m_OverrideState: 0 + m_Value: 0 + turboMode: + m_OverrideState: 1 + m_Value: 0 + directWrite: + m_OverrideState: 1 + m_Value: 0 + ignoreDepthTexture: + m_OverrideState: 1 + m_Value: 0 + downsampling: + m_OverrideState: 1 + m_Value: 0 + downsamplingMode: + m_OverrideState: 0 + m_Value: 0 + downsamplingMultiplier: + m_OverrideState: 0 + m_Value: 1 + downsamplingBilinear: + m_OverrideState: 0 + m_Value: 0 + optimizeBuildBeautifyAuto: + m_OverrideState: 1 + m_Value: 1 + stripBeautifyTonemapping: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyTonemappingACESFitted: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyTonemappingAGX: + m_OverrideState: 1 + m_Value: 0 + stripBeautifySharpen: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyDithering: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyEdgeAA: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyLUT: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyLUT3D: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyColorTweaks: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyBloom: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyLensDirt: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyChromaticAberration: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyDoF: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyDoFTransparentSupport: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyEyeAdaptation: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyPurkinje: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyVignetting: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyOutline: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyNightVision: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyThermalVision: + m_OverrideState: 1 + m_Value: 0 + stripBeautifyFrame: + m_OverrideState: 1 + m_Value: 0 + optimizeBuildUnityPPSAuto: + m_OverrideState: 1 + m_Value: 0 + stripUnityFilmGrain: + m_OverrideState: 1 + m_Value: 0 + stripUnityDithering: + m_OverrideState: 1 + m_Value: 0 + stripUnityTonemapping: + m_OverrideState: 1 + m_Value: 0 + stripUnityBloom: + m_OverrideState: 1 + m_Value: 0 + stripUnityChromaticAberration: + m_OverrideState: 1 + m_Value: 0 + stripUnityDistortion: + m_OverrideState: 1 + m_Value: 0 + stripUnityDebugVariants: + m_OverrideState: 1 + m_Value: 0 + sharpenIntensity: + m_OverrideState: 0 + m_Value: 0 + sharpenDepthThreshold: + m_OverrideState: 0 + m_Value: 0.035 + sharpenMinMaxDepth: + m_OverrideState: 0 + m_Value: {x: 0, y: 0.999} + min: 0 + max: 1.1 + sharpenMinMaxDepthFallOff: + m_OverrideState: 0 + m_Value: 0 + sharpenRelaxation: + m_OverrideState: 0 + m_Value: 0.08 + sharpenClamp: + m_OverrideState: 0 + m_Value: 0.45 + sharpenMotionSensibility: + m_OverrideState: 0 + m_Value: 0.5 + sharpenMotionRestoreSpeed: + m_OverrideState: 0 + m_Value: 0.5 + antialiasStrength: + m_OverrideState: 0 + m_Value: 0 + antialiasDepthThreshold: + m_OverrideState: 0 + m_Value: 0.000001 + antialiasSpread: + m_OverrideState: 0 + m_Value: 3 + antialiasDepthAttenuation: + m_OverrideState: 0 + m_Value: 0 + tonemap: + m_OverrideState: 0 + m_Value: 0 + tonemapAGXGamma: + m_OverrideState: 0 + m_Value: 2.5 + tonemapMaxInputBrightness: + m_OverrideState: 0 + m_Value: 1000 + tonemapExposurePre: + m_OverrideState: 0 + m_Value: 1 + tonemapBrightnessPost: + m_OverrideState: 0 + m_Value: 1 + saturate: + m_OverrideState: 0 + m_Value: 1 + brightness: + m_OverrideState: 0 + m_Value: 1 + contrast: + m_OverrideState: 0 + m_Value: 1 + daltonize: + m_OverrideState: 0 + m_Value: 0 + sepia: + m_OverrideState: 0 + m_Value: 0 + tintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + colorTemp: + m_OverrideState: 0 + m_Value: 6550 + colorTempBlend: + m_OverrideState: 0 + m_Value: 0 + lut: + m_OverrideState: 0 + m_Value: 0 + lutIntensity: + m_OverrideState: 0 + m_Value: 0 + lutTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + bloomIntensity: + m_OverrideState: 0 + m_Value: 0 + bloomThreshold: + m_OverrideState: 0 + m_Value: 0.75 + bloomConservativeThreshold: + m_OverrideState: 0 + m_Value: 0 + bloomSpread: + m_OverrideState: 0 + m_Value: 0.5 + bloomMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + bloomTint: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 0.5, b: 1, a: 0} + bloomDepthAtten: + m_OverrideState: 0 + m_Value: 0 + bloomNearAtten: + m_OverrideState: 0 + m_Value: 0 + bloomExcludeLayers: + m_OverrideState: 0 + m_Value: 0 + bloomLayersFilterMethod: + m_OverrideState: 0 + m_Value: 1 + bloomExclusionLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 0 + bloomAntiflicker: + m_OverrideState: 0 + m_Value: 0 + bloomResolution: + m_OverrideState: 0 + m_Value: 1 + bloomQuickerBlur: + m_OverrideState: 0 + m_Value: 0 + bloomCustomize: + m_OverrideState: 0 + m_Value: 0 + bloomWeight0: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost0: + m_OverrideState: 0 + m_Value: 0 + bloomTint0: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight1: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost1: + m_OverrideState: 0 + m_Value: 0 + bloomTint1: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight2: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost2: + m_OverrideState: 0 + m_Value: 0 + bloomTint2: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight3: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost3: + m_OverrideState: 0 + m_Value: 0 + bloomTint3: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight4: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost4: + m_OverrideState: 0 + m_Value: 0 + bloomTint4: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight5: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost5: + m_OverrideState: 0 + m_Value: 0 + bloomTint5: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + anamorphicFlaresIntensity: + m_OverrideState: 1 + m_Value: 0.01 + anamorphicFlaresThreshold: + m_OverrideState: 1 + m_Value: 3 + anamorphicFlaresConservativeThreshold: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresTint: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 0.5, b: 1, a: 0} + anamorphicFlaresVertical: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresSpread: + m_OverrideState: 1 + m_Value: 1 + anamorphicFlaresMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + anamorphicFlaresDepthAtten: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresNearAtten: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresExcludeLayers: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresLayersFilterMethod: + m_OverrideState: 0 + m_Value: 1 + anamorphicFlaresExclusionLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 0 + anamorphicFlaresAntiflicker: + m_OverrideState: 1 + m_Value: 1 + anamorphicFlaresResolution: + m_OverrideState: 0 + m_Value: 1 + anamorphicFlaresQuickerBlur: + m_OverrideState: 0 + m_Value: 0 + sunFlaresIntensity: + m_OverrideState: 0 + m_Value: 0 + sunFlaresTint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + sunFlaresSolarWindSpeed: + m_OverrideState: 0 + m_Value: 0.01 + sunFlaresRotationDeadZone: + m_OverrideState: 0 + m_Value: 0 + sunFlaresDownsampling: + m_OverrideState: 0 + m_Value: 1 + sunFlaresDepthOcclusionMode: + m_OverrideState: 0 + m_Value: 1 + sunFlaresDepthOcclusionThreshold: + m_OverrideState: 0 + m_Value: 0.5 + sunFlaresUseLayerMask: + m_OverrideState: 0 + m_Value: 0 + sunFlaresLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + sunFlaresAttenSpeed: + m_OverrideState: 0 + m_Value: 30 + sunFlaresSunIntensity: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresSunDiskSize: + m_OverrideState: 0 + m_Value: 0.05 + sunFlaresSunRayDiffractionIntensity: + m_OverrideState: 0 + m_Value: 3.5 + sunFlaresSunRayDiffractionThreshold: + m_OverrideState: 0 + m_Value: 0.13 + sunFlaresCoronaRays1Length: + m_OverrideState: 0 + m_Value: 0.02 + sunFlaresCoronaRays1Streaks: + m_OverrideState: 0 + m_Value: 12 + sunFlaresCoronaRays1Spread: + m_OverrideState: 0 + m_Value: 0.001 + sunFlaresCoronaRays1AngleOffset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresCoronaRays2Length: + m_OverrideState: 0 + m_Value: 0.05 + sunFlaresCoronaRays2Streaks: + m_OverrideState: 0 + m_Value: 12 + sunFlaresCoronaRays2Spread: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresCoronaRays2AngleOffset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresGhosts1Size: + m_OverrideState: 0 + m_Value: 0.03 + sunFlaresGhosts1Offset: + m_OverrideState: 0 + m_Value: 1.04 + sunFlaresGhosts1Brightness: + m_OverrideState: 0 + m_Value: 0.037 + sunFlaresGhosts2Size: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresGhosts2Offset: + m_OverrideState: 0 + m_Value: 0.71 + sunFlaresGhosts2Brightness: + m_OverrideState: 0 + m_Value: 0.03 + sunFlaresGhosts3Size: + m_OverrideState: 0 + m_Value: 0.24 + sunFlaresGhosts3Offset: + m_OverrideState: 0 + m_Value: 0.31 + sunFlaresGhosts3Brightness: + m_OverrideState: 0 + m_Value: 0.025 + sunFlaresGhosts4Size: + m_OverrideState: 0 + m_Value: 0.016 + sunFlaresGhosts4Offset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresGhosts4Brightness: + m_OverrideState: 0 + m_Value: 0.017 + sunFlaresHaloOffset: + m_OverrideState: 0 + m_Value: 0.22 + sunFlaresHaloAmplitude: + m_OverrideState: 0 + m_Value: 15.1415 + sunFlaresHaloIntensity: + m_OverrideState: 0 + m_Value: 0.01 + lensDirtIntensity: + m_OverrideState: 0 + m_Value: 0 + lensDirtThreshold: + m_OverrideState: 0 + m_Value: 0.5 + lensDirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + lensDirtSpread: + m_OverrideState: 0 + m_Value: 3 + chromaticAberrationIntensity: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationShift: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationSmoothing: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationSeparatePass: + m_OverrideState: 0 + m_Value: 0 + depthOfField: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldFocusMode: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusMinDistance: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusMaxDistance: + m_OverrideState: 0 + m_Value: 10000 + depthOfFieldTargetFallback: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldTargetFallbackFixedDistance: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldAutofocusViewportPoint: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + depthOfFieldAutofocusDistanceShift: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + depthOfFieldDistance: + m_OverrideState: 0 + m_Value: 10 + depthOfFieldCameraSettings: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldFocalLength: + m_OverrideState: 0 + m_Value: 0.05 + depthOfFieldAperture: + m_OverrideState: 0 + m_Value: 2.8 + depthOfFieldFocalLengthReal: + m_OverrideState: 0 + m_Value: 50 + depthOfFieldFStop: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldImageSensorHeight: + m_OverrideState: 0 + m_Value: 24 + depthOfFieldFocusSpeed: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldTransparentSupport: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldTransparentLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 1 + depthOfFieldTransparentDoubleSided: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAlphaTestSupport: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAlphaTestLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 1 + depthOfFieldAlphaTestDoubleSided: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldForegroundBlur: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldForegroundBlurHQ: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldForegroundBlurHQSpread: + m_OverrideState: 0 + m_Value: 4 + depthOfFieldForegroundDistance: + m_OverrideState: 0 + m_Value: 0.25 + depthOfFieldBokeh: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldBokehComposition: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldBokehThreshold: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldBokehIntensity: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldDownsampling: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldMaxSamples: + m_OverrideState: 0 + m_Value: 6 + depthOfFieldMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldMaxBlurRadius: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldResolutionInvariant: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldMaxDistance: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldFilterMode: + m_OverrideState: 0 + m_Value: 1 + eyeAdaptation: + m_OverrideState: 0 + m_Value: 0 + eyeAdaptationMinExposure: + m_OverrideState: 0 + m_Value: 0.2 + eyeAdaptationMaxExposure: + m_OverrideState: 0 + m_Value: 5 + eyeAdaptationSpeedToLight: + m_OverrideState: 0 + m_Value: 0.4 + eyeAdaptationSpeedToDark: + m_OverrideState: 0 + m_Value: 0.2 + purkinje: + m_OverrideState: 0 + m_Value: 0 + purkinjeAmount: + m_OverrideState: 0 + m_Value: 1 + purkinjeLuminanceThreshold: + m_OverrideState: 0 + m_Value: 0.15 + vignettingOuterRing: + m_OverrideState: 0 + m_Value: 0 + vignettingInnerRing: + m_OverrideState: 0 + m_Value: 0 + vignettingFade: + m_OverrideState: 0 + m_Value: 0 + vignettingCircularShape: + m_OverrideState: 0 + m_Value: 0 + vignettingCircularShapeFitMode: + m_OverrideState: 0 + m_Value: 0 + vignettingAspectRatio: + m_OverrideState: 0 + m_Value: 1 + vignettingBlink: + m_OverrideState: 0 + m_Value: 0 + vignettingBlinkStyle: + m_OverrideState: 0 + m_Value: 0 + vignettingCenter: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + vignettingColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + vignettingMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + outline: + m_OverrideState: 0 + m_Value: 0 + outlineColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 0.8} + outlineTechnique: + m_OverrideState: 0 + m_Value: 0 + outlineMinSeparation: + m_OverrideState: 0 + m_Value: 1 + outlineThreshold: + m_OverrideState: 0 + m_Value: 0.2 + outlineMinDepthThreshold: + m_OverrideState: 0 + m_Value: 0.0005 + outlineSaturationDiffThreshold: + m_OverrideState: 0 + m_Value: 0.015 + outlineCustomize: + m_OverrideState: 0 + m_Value: 0 + outlineLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + outlineStageParameter: + m_OverrideState: 0 + m_Value: 0 + outlineSpread: + m_OverrideState: 0 + m_Value: 1 + outlineBlurPassCount: + m_OverrideState: 0 + m_Value: 1 + outlineBlurDownscale: + m_OverrideState: 0 + m_Value: 0 + outlineIntensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + outlineDistanceFade: + m_OverrideState: 0 + m_Value: 0 + outlineUsesOptimizedShader: + m_OverrideState: 0 + m_Value: 0 + outlineLayerCutOff: + m_OverrideState: 0 + m_Value: 0 + nightVision: + m_OverrideState: 0 + m_Value: 0 + nightVisionColor: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 1, b: 0.5, a: 0.5} + nightVisionDepth: + m_OverrideState: 0 + m_Value: 100000 + nightVisionDepthFallOff: + m_OverrideState: 0 + m_Value: 1 + thermalVision: + m_OverrideState: 0 + m_Value: 0 + thermalVisionScanLines: + m_OverrideState: 0 + m_Value: 1 + thermalVisionDistortionAmount: + m_OverrideState: 0 + m_Value: 9 + ditherIntensity: + m_OverrideState: 0 + m_Value: 0 + frame: + m_OverrideState: 0 + m_Value: 0 + frameStyle: + m_OverrideState: 0 + m_Value: 0 + frameBandHorizontalSize: + m_OverrideState: 0 + m_Value: 0 + frameBandHorizontalSmoothness: + m_OverrideState: 0 + m_Value: 0 + frameBandVerticalSize: + m_OverrideState: 0 + m_Value: 0.1 + frameBandVerticalSmoothness: + m_OverrideState: 0 + m_Value: 0 + frameColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0.047} + frameMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + blurIntensity: + m_OverrideState: 0 + m_Value: 0 + blurMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + blurKeepSourceOnTop: + m_OverrideState: 0 + m_Value: 0 + blurSourceRect: + m_OverrideState: 0 + m_Value: {x: 0.1, y: 0.1, z: 0.8, w: 0.8} + blurSourceEdgeBlendWidth: + m_OverrideState: 0 + m_Value: 0 + blurSourceEdgeBlendStrength: + m_OverrideState: 0 + m_Value: 20 +--- !u!114 &-4175720902093087789 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf9669dd43d41362b826cb959e024e98, type: 3} + m_Name: TinyMotionComponent + m_EditorClassIdentifier: + active: 0 + blurMode: + m_OverrideState: 0 + m_Value: 1 + sampleCountMode: + m_OverrideState: 0 + m_Value: 1 + samples: + m_OverrideState: 0 + m_Value: 6 + minSampleCount: + m_OverrideState: 0 + m_Value: 2 + maxSampleCount: + m_OverrideState: 0 + m_Value: 6 + motionTextureQuality: + m_OverrideState: 0 + m_Value: 1 + downsample: + m_OverrideState: 0 + m_Value: 1 + noiseMode: + m_OverrideState: 0 + m_Value: 0 + animateNoise: + m_OverrideState: 0 + m_Value: 0 + skipSecondPass: + m_OverrideState: 0 + m_Value: 0 + intensity: + m_OverrideState: 1 + m_Value: 1 + shutterSpeed: + m_OverrideState: 0 + m_Value: 250 + threshold: + m_OverrideState: 0 + m_Value: 0.001 + depthSeparationTreshold: + m_OverrideState: 0 + m_Value: 0 + depthSeparationBothWays: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocity: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocityTreshold: + m_OverrideState: 0 + m_Value: 0.25 + clampVelocity: + m_OverrideState: 0 + m_Value: 1 + viewInEditor: + m_OverrideState: 0 + m_Value: 0 + includeTransparentObjects: + m_OverrideState: 0 + m_Value: 0 + debugMode: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &-1703029571481380811 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 853cfdf4b80146545b90713442d462cf, type: 3} + m_Name: NiloToonAdditionalLightStyleVolume + m_EditorClassIdentifier: + active: 1 + additionalLightInjectIntoMainLightColor_Strength: + m_OverrideState: 1 + m_Value: 0.15 + additionalLightInjectIntoMainLightDirection_Strength: + m_OverrideState: 1 + m_Value: 0 + additionalLightInjectIntoMainLightColor_Desaturate: + m_OverrideState: 1 + m_Value: 1 + additionalLightInjectIntoMainLightColor_AllowCloseLightOverBright: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-598188741750761343 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d89c46e6b4f031541986f8d6bdbad145, type: 3} + m_Name: NiloToonCinematicRimLightVolume + m_EditorClassIdentifier: + active: 1 + strengthRimMask2D: + m_OverrideState: 1 + m_Value: 0.7 + strengthRimMask3D_ClassicStyle: + m_OverrideState: 1 + m_Value: 0.7 + strengthRimMask3D_DynmaicStyle: + m_OverrideState: 0 + m_Value: 0.7 + sharpnessRimMask3D_DynamicStyle: + m_OverrideState: 0 + m_Value: 0.375 + strengthRimMask3D_StableStyle: + m_OverrideState: 0 + m_Value: 0.7 + sharpnessRimMask3D_StableStyle: + m_OverrideState: 0 + m_Value: 0.5 + lightIntensityMultiplier: + m_OverrideState: 1 + m_Value: 20 + tintBaseMap: + m_OverrideState: 1 + m_Value: 0.5 + enableStyleSafeGuard: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-426318345093102539 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d89c46e6b4f031541986f8d6bdbad145, type: 3} + m_Name: NiloToonCinematicRimLightVolume + m_EditorClassIdentifier: + active: 1 + strengthRimMask2D: + m_OverrideState: 0 + m_Value: 0.85 + strengthRimMask3D_ClassicStyle: + m_OverrideState: 0 + m_Value: 1 + strengthRimMask3D_DynmaicStyle: + m_OverrideState: 1 + m_Value: 1 + sharpnessRimMask3D_DynamicStyle: + m_OverrideState: 1 + m_Value: 0.1 + strengthRimMask3D_StableStyle: + m_OverrideState: 1 + m_Value: 1 + sharpnessRimMask3D_StableStyle: + m_OverrideState: 1 + m_Value: 0.25 + lightIntensityMultiplier: + m_OverrideState: 1 + m_Value: 6.6 + tintBaseMap: + m_OverrideState: 1 + m_Value: 1 + enableStyleSafeGuard: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset) + m_EditorClassIdentifier: + components: + - {fileID: 5018692330182970109} + - {fileID: 8623061367897789741} + - {fileID: 4675053336608618770} + - {fileID: -6636676602098857160} + - {fileID: 7773777288705028284} + - {fileID: 1392042495390883562} + - {fileID: 744989890794951721} + - {fileID: -426318345093102539} + - {fileID: -5934634642679004759} + - {fileID: -1703029571481380811} + - {fileID: 411203215106509782} + - {fileID: 8741824591765560128} +--- !u!114 &411203215106509782 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} + m_Name: ColorAdjustments + m_EditorClassIdentifier: + active: 0 + postExposure: + m_OverrideState: 0 + m_Value: 0 + contrast: + m_OverrideState: 1 + m_Value: 10 + colorFilter: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + hueShift: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 1 + m_Value: 10 +--- !u!114 &744989890794951721 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 39dc1fe45bfcc1e4eaa9ae19ecefd49c, type: 3} + m_Name: NiloToonShadowControlVolume + m_EditorClassIdentifier: + active: 1 + characterOverallShadowTintColor: + m_OverrideState: 1 + m_Value: {r: 0.69803923, g: 0.5127904, b: 0.48862746, a: 1} + characterOverallShadowStrength: + m_OverrideState: 0 + m_Value: 1 + enableCharAverageShadow: + m_OverrideState: 0 + m_Value: 1 + charAverageShadowStrength: + m_OverrideState: 0 + m_Value: 1 + enableCharSelfShadow: + m_OverrideState: 0 + m_Value: 1 + charSelfShadowStrength: + m_OverrideState: 0 + m_Value: 1 + useMainLightAsCastShadowDirection: + m_OverrideState: 0 + m_Value: 1 + shadowAngle: + m_OverrideState: 0 + m_Value: 30 + shadowLRAngle: + m_OverrideState: 0 + m_Value: 0 + shadowRange: + m_OverrideState: 0 + m_Value: 10 + shadowMapSize: + m_OverrideState: 0 + m_Value: 4096 + depthBias: + m_OverrideState: 0 + m_Value: 1 + normalBias: + m_OverrideState: 0 + m_Value: 1 + receiveURPShadow: + m_OverrideState: 0 + m_Value: 0 + URPShadowIntensity: + m_OverrideState: 0 + m_Value: 1 + URPShadowAsDirectLightMultiplier: + m_OverrideState: 0 + m_Value: 1 + URPShadowAsDirectLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting: + m_OverrideState: 0 + m_Value: 1 + URPShadowblurriness: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &1392042495390883562 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eecc32444ea4503479fa0394f277db7d, type: 3} + m_Name: NiloToonScreenSpaceOutlineControlVolume + m_EditorClassIdentifier: + active: 0 + intensity: + m_OverrideState: 1 + m_Value: 1 + intensityForCharacter: + m_OverrideState: 0 + m_Value: 1 + intensityForEnvironment: + m_OverrideState: 0 + m_Value: 1 + widthMultiplier: + m_OverrideState: 1 + m_Value: 0.4 + widthMultiplierForCharacter: + m_OverrideState: 0 + m_Value: 1 + widthMultiplierForEnvironment: + m_OverrideState: 0 + m_Value: 1 + extraWidthMultiplierForXR: + m_OverrideState: 0 + m_Value: 0.2 + normalsSensitivityOffset: + m_OverrideState: 0 + m_Value: 0 + normalsSensitivityOffsetForCharacter: + m_OverrideState: 0 + m_Value: 0 + normalsSensitivityOffsetForEnvironment: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffset: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffsetForCharacter: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffsetForEnvironment: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityDistanceFadeoutStrength: + m_OverrideState: 0 + m_Value: 1 + depthSensitivityDistanceFadeoutStrengthForCharacter: + m_OverrideState: 0 + m_Value: 1 + depthSensitivityDistanceFadeoutStrengthForEnvironment: + m_OverrideState: 0 + m_Value: 1 + outlineTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + outlineTintColorForChar: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + outlineTintColorForEnvi: + m_OverrideState: 0 + m_Value: {r: 0.12, g: 0.12, b: 0.12, a: 1} +--- !u!114 &2527076536399353016 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 48c981ee17d53ea42b3cb31ca0b891a4, type: 3} + m_Name: MKGlow + m_EditorClassIdentifier: + active: 0 + showEditorMainBehavior: + m_OverrideState: 0 + m_Value: 1 + showEditorBloomBehavior: + m_OverrideState: 0 + m_Value: 1 + showEditorLensSurfaceBehavior: + m_OverrideState: 0 + m_Value: 1 + showEditorLensFlareBehavior: + m_OverrideState: 0 + m_Value: 1 + showEditorGlareBehavior: + m_OverrideState: 0 + m_Value: 1 + isInitialized: + m_OverrideState: 1 + m_Value: 1 + allowGeometryShaders: + m_OverrideState: 1 + m_Value: 1 + allowComputeShaders: + m_OverrideState: 1 + m_Value: 1 + renderPriority: + m_OverrideState: 1 + m_Value: 1 + debugView: + m_OverrideState: 1 + m_Value: 0 + quality: + m_OverrideState: 1 + m_Value: 2 + antiFlickerMode: + m_OverrideState: 1 + m_Value: 1 + workflow: + m_OverrideState: 1 + m_Value: 0 + selectiveRenderLayerMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 2 + m_Bits: 384 + anamorphicRatio: + m_OverrideState: 1 + m_Value: 0 + lumaScale: + m_OverrideState: 1 + m_Value: 0.5 + blooming: + m_OverrideState: 0 + m_Value: 0 + bloomThreshold: + m_OverrideState: 0 + m_Value: + minValue: 1.25 + maxValue: 10 + bloomScattering: + m_OverrideState: 0 + m_Value: 7 + bloomIntensity: + m_OverrideState: 0 + m_Value: 1 + allowLensSurface: + m_OverrideState: 1 + m_Value: 0 + lensSurfaceDirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + lensSurfaceDirtIntensity: + m_OverrideState: 1 + m_Value: 2.5 + lensSurfaceDiffractionTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + lensSurfaceDiffractionIntensity: + m_OverrideState: 1 + m_Value: 2 + allowLensFlare: + m_OverrideState: 1 + m_Value: 0 + lensFlareStyle: + m_OverrideState: 0 + m_Value: 1 + lensFlareGhostFade: + m_OverrideState: 0 + m_Value: 10 + lensFlareGhostIntensity: + m_OverrideState: 1 + m_Value: 1 + lensFlareThreshold: + m_OverrideState: 0 + m_Value: + minValue: 1.3 + maxValue: 10 + lensFlareScattering: + m_OverrideState: 0 + m_Value: 5 + lensFlareColorRamp: + m_OverrideState: 0 + m_Value: {fileID: 0} + lensFlareChromaticAberration: + m_OverrideState: 0 + m_Value: 53 + lensFlareGhostCount: + m_OverrideState: 0 + m_Value: 3 + lensFlareGhostDispersal: + m_OverrideState: 0 + m_Value: 0.6 + lensFlareHaloFade: + m_OverrideState: 0 + m_Value: 2 + lensFlareHaloIntensity: + m_OverrideState: 1 + m_Value: 1 + lensFlareHaloSize: + m_OverrideState: 0 + m_Value: 0.4 + allowGlare: + m_OverrideState: 1 + m_Value: 1 + glareBlend: + m_OverrideState: 1 + m_Value: 0.098 + glareIntensity: + m_OverrideState: 1 + m_Value: 1.81 + glareAngle: + m_OverrideState: 1 + m_Value: 0 + glareThreshold: + m_OverrideState: 1 + m_Value: + minValue: 2.967955 + maxValue: 10 + glareStreaks: + m_OverrideState: 0 + m_Value: 4 + glareScattering: + m_OverrideState: 1 + m_Value: 1.73 + glareStyle: + m_OverrideState: 1 + m_Value: 5 + glareSample0Scattering: + m_OverrideState: 0 + m_Value: 5 + glareSample0Angle: + m_OverrideState: 0 + m_Value: 0 + glareSample0Intensity: + m_OverrideState: 1 + m_Value: 1 + glareSample0Offset: + m_OverrideState: 0 + m_Value: 0 + glareSample1Scattering: + m_OverrideState: 0 + m_Value: 5 + glareSample1Angle: + m_OverrideState: 0 + m_Value: 45 + glareSample1Intensity: + m_OverrideState: 1 + m_Value: 1 + glareSample1Offset: + m_OverrideState: 0 + m_Value: 0 + glareSample2Scattering: + m_OverrideState: 0 + m_Value: 5 + glareSample2Angle: + m_OverrideState: 0 + m_Value: 90 + glareSample2Intensity: + m_OverrideState: 1 + m_Value: 1 + glareSample2Offset: + m_OverrideState: 0 + m_Value: 0 + glareSample3Scattering: + m_OverrideState: 0 + m_Value: 5 + glareSample3Angle: + m_OverrideState: 0 + m_Value: 135 + glareSample3Intensity: + m_OverrideState: 1 + m_Value: 1 + glareSample3Offset: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &3331279558105876180 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf9669dd43d41362b826cb959e024e98, type: 3} + m_Name: TinyMotionComponent + m_EditorClassIdentifier: + active: 0 + blurMode: + m_OverrideState: 0 + m_Value: 1 + sampleCountMode: + m_OverrideState: 0 + m_Value: 1 + samples: + m_OverrideState: 0 + m_Value: 6 + minSampleCount: + m_OverrideState: 0 + m_Value: 2 + maxSampleCount: + m_OverrideState: 0 + m_Value: 6 + motionTextureQuality: + m_OverrideState: 0 + m_Value: 1 + downsample: + m_OverrideState: 0 + m_Value: 1 + noiseMode: + m_OverrideState: 0 + m_Value: 0 + animateNoise: + m_OverrideState: 0 + m_Value: 0 + skipSecondPass: + m_OverrideState: 0 + m_Value: 0 + intensity: + m_OverrideState: 1 + m_Value: 2 + shutterSpeed: + m_OverrideState: 0 + m_Value: 250 + threshold: + m_OverrideState: 0 + m_Value: 0.001 + depthSeparationTreshold: + m_OverrideState: 0 + m_Value: 0 + depthSeparationBothWays: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocity: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocityTreshold: + m_OverrideState: 0 + m_Value: 0.25 + clampVelocity: + m_OverrideState: 0 + m_Value: 1 + viewInEditor: + m_OverrideState: 0 + m_Value: 0 + includeTransparentObjects: + m_OverrideState: 0 + m_Value: 0 + debugMode: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &4675053336608618770 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5aa15fc7246432d4fb73e65893caaa4b, type: 3} + m_Name: NiloToonAnimePostProcessVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.583 + rotation: + m_OverrideState: 0 + m_Value: 0 + topLightEffectDrawHeight: + m_OverrideState: 0 + m_Value: 0.3 + topLightEffectIntensity: + m_OverrideState: 0 + m_Value: 1 + topLightMultiplyLightColor: + m_OverrideState: 0 + m_Value: 1 + topLightSunTintColor: + m_OverrideState: 1 + m_Value: {r: 0.24526887, g: 0.2759902, b: 0.319, a: 1} + topLightDesaturate: + m_OverrideState: 0 + m_Value: 0 + topLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + topLightExtraRotation: + m_OverrideState: 0 + m_Value: 0 + bottomDarkenEffectDrawHeight: + m_OverrideState: 0 + m_Value: 0.3 + bottomDarkenEffectIntensity: + m_OverrideState: 0 + m_Value: 0.25 + bottomDarkenExtraRotation: + m_OverrideState: 0 + m_Value: 0 + drawBeforePostProcess: + m_OverrideState: 1 + m_Value: 1 + affectedByCameraPostprocessToggle: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &5018692330182970109 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4a104dcd31bca784aaed640904c00a0b, type: 3} + m_Name: NiloToonCharRenderingControlVolume + m_EditorClassIdentifier: + active: 1 + charBaseColorMultiply: + m_OverrideState: 0 + m_Value: 1 + charBaseColorTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + charMulColorIntensity: + m_OverrideState: 0 + m_Value: 0.95 + charMulColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + charLerpColorUsage: + m_OverrideState: 0 + m_Value: 0 + charLerpColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charOcclusionUsage: + m_OverrideState: 0 + m_Value: 1 + charIndirectLightMultiplier: + m_OverrideState: 1 + m_Value: 0 + charIndirectLightMinColor: + m_OverrideState: 1 + m_Value: {r: 0.01, g: 0.01, b: 0.01, a: 0} + charIndirectLightMaxColor: + m_OverrideState: 1 + m_Value: {r: 0.01, g: 0.01, b: 0.01, a: 1} + mainDirectionalLightIntensityMultiplier: + m_OverrideState: 0 + m_Value: 0.55 + mainDirectionalLightIntensityMultiplierColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + addMainLightColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + mainDirectionalLightMaxContribution: + m_OverrideState: 0 + m_Value: 1 + mainDirectionalLightMaxContributionColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + overrideLightDirectionIntensity: + m_OverrideState: 1 + m_Value: 1 + overridedLightUpDownAngle: + m_OverrideState: 0 + m_Value: -45 + overridedLightLRAngle: + m_OverrideState: 0 + m_Value: -30 + lightColorOverrideStrength: + m_OverrideState: 0 + m_Value: 0.695 + overridedLightColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + desaturateLightColor: + m_OverrideState: 0 + m_Value: 0 + additionalLightIntensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + additionalLightIntensityMultiplierColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightIntensityMultiplierForFaceArea: + m_OverrideState: 0 + m_Value: 0 + additionalLightIntensityMultiplierColorForFaceArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightIntensityMultiplierForOutlineArea: + m_OverrideState: 0 + m_Value: 1 + additionalLightIntensityMultiplierColorForOutlineArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightApplyRimMask: + m_OverrideState: 0 + m_Value: 1 + additionalLightRimMaskPower: + m_OverrideState: 0 + m_Value: 1 + additionalLightRimMaskSoftness: + m_OverrideState: 0 + m_Value: 1 + additionalLightMaxContribution: + m_OverrideState: 0 + m_Value: 1 + additionalLightMaxContributionColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + specularIntensityMultiplier: + m_OverrideState: 0 + m_Value: 20 + specularTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + specularInShadowMinIntensity: + m_OverrideState: 0 + m_Value: 0.25 + specularReactToLightDirectionChange: + m_OverrideState: 0 + m_Value: 0 + depthTextureRimLightAndShadowWidthMultiplier: + m_OverrideState: 1 + m_Value: 1 + charRimLightMultiplier: + m_OverrideState: 1 + m_Value: 12 + charRimLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charRimLightMultiplierForOutlineArea: + m_OverrideState: 1 + m_Value: 1 + charRimLightTintColorForOutlineArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + depthTexRimLightDepthDiffThresholdOffset: + m_OverrideState: 1 + m_Value: 0.25 + charRimLightCameraDistanceFadeoutStartDistance: + m_OverrideState: 0 + m_Value: 1000 + charRimLightCameraDistanceFadeoutEndDistance: + m_OverrideState: 0 + m_Value: 2000 + characterOverallShadowStrength: + m_OverrideState: 0 + m_Value: 1 + characterOverallShadowTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charOutlineWidthMultiplier: + m_OverrideState: 0 + m_Value: 1.125 + charOutlineWidthExtraMultiplierForXR: + m_OverrideState: 0 + m_Value: 0.5 + charOutlineWidthAutoAdjustToCameraDistanceAndFOV: + m_OverrideState: 0 + m_Value: 1 + charOutlineMulColor: + m_OverrideState: 0 + m_Value: {r: 0.25, g: 0.25, b: 0.25, a: 1} +--- !u!114 &6151919630086296333 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae2b217974b749d4b97b47bae772aee5, type: 3} + m_Name: NiloToonMotionBlurVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.5 +--- !u!114 &7065021110100587840 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f53d442396c644b198ad641a34212ce, type: 3} + m_Name: RadiantGlobalIllumination + m_EditorClassIdentifier: + active: 0 + indirectIntensity: + m_OverrideState: 0 + m_Value: 0 + indirectDistanceAttenuation: + m_OverrideState: 0 + m_Value: 0 + indirectMaxSourceBrightness: + m_OverrideState: 0 + m_Value: 8 + normalMapInfluence: + m_OverrideState: 0 + m_Value: 1 + rayBounce: + m_OverrideState: 0 + m_Value: 0 + lumaInfluence: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscurance: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscuranceSpread: + m_OverrideState: 0 + m_Value: 0.2 + nearFieldObscuranceMaxCameraDistance: + m_OverrideState: 0 + m_Value: 125 + nearFieldObscuranceOccluderDistance: + m_OverrideState: 0 + m_Value: 0.825 + nearFieldObscuranceTintColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + virtualEmitters: + m_OverrideState: 0 + m_Value: 0 + organicLight: + m_OverrideState: 0 + m_Value: 0 + organicLightThreshold: + m_OverrideState: 0 + m_Value: 0.5 + organicLightSpread: + m_OverrideState: 0 + m_Value: 0.98 + organicLightNormalsInfluence: + m_OverrideState: 0 + m_Value: 0.95 + organicLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + organicLightAnimationSpeed: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + organicLightDistanceScaling: + m_OverrideState: 0 + m_Value: 0 + rayCount: + m_OverrideState: 0 + m_Value: 1 + rayMaxLength: + m_OverrideState: 0 + m_Value: 8 + rayMaxSamples: + m_OverrideState: 0 + m_Value: 32 + rayJitter: + m_OverrideState: 0 + m_Value: 0 + thickness: + m_OverrideState: 0 + m_Value: 1 + rayBinarySearch: + m_OverrideState: 0 + m_Value: 1 + fallbackReuseRays: + m_OverrideState: 0 + m_Value: 0 + rayReuse: + m_OverrideState: 0 + m_Value: 0 + fallbackReflectionProbes: + m_OverrideState: 0 + m_Value: 0 + probesIntensity: + m_OverrideState: 0 + m_Value: 1 + fallbackReflectiveShadowMap: + m_OverrideState: 0 + m_Value: 0 + reflectiveShadowMapIntensity: + m_OverrideState: 0 + m_Value: 0.8 + downsampling: + m_OverrideState: 0 + m_Value: 1 + raytracerAccuracy: + m_OverrideState: 0 + m_Value: 8 + smoothing: + m_OverrideState: 0 + m_Value: 3 + temporalReprojection: + m_OverrideState: 0 + m_Value: 1 + temporalResponseSpeed: + m_OverrideState: 0 + m_Value: 12 + temporalCameraTranslationResponse: + m_OverrideState: 0 + m_Value: 100 + temporalDepthRejection: + m_OverrideState: 0 + m_Value: 1 + temporalChromaThreshold: + m_OverrideState: 0 + m_Value: 0.2 + showInEditMode: + m_OverrideState: 0 + m_Value: 1 + showInSceneView: + m_OverrideState: 0 + m_Value: 1 + brightnessThreshold: + m_OverrideState: 0 + m_Value: 0 + brightnessMax: + m_OverrideState: 0 + m_Value: 8 + specularContribution: + m_OverrideState: 0 + m_Value: 0.75 + sourceBrightness: + m_OverrideState: 0 + m_Value: 1 + giWeight: + m_OverrideState: 0 + m_Value: 0 + nearCameraAttenuation: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 1 + limitToVolumeBounds: + m_OverrideState: 0 + m_Value: 0 + stencilCheck: + m_OverrideState: 0 + m_Value: 0 + stencilValue: + m_OverrideState: 0 + m_Value: 1 + stencilCompareFunction: + m_OverrideState: 0 + m_Value: 6 + aoInfluence: + m_OverrideState: 0 + m_Value: 0 + debugView: + m_OverrideState: 0 + m_Value: 0 + debugDepthMultiplier: + m_OverrideState: 0 + m_Value: 10 + compareMode: + m_OverrideState: 0 + m_Value: 0 + compareSameSide: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 +--- !u!114 &7773777288705028284 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3} + m_Name: Vignette + m_EditorClassIdentifier: + active: 0 + color: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + center: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + intensity: + m_OverrideState: 1 + m_Value: 0.207 + smoothness: + m_OverrideState: 0 + m_Value: 0.2 + rounded: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &8623061367897789741 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8a10bd7999fb5fe43ab7b08bda3fe53f, type: 3} + m_Name: NiloToonBloomVolume + m_EditorClassIdentifier: + active: 1 + threshold: + m_OverrideState: 1 + m_Value: 0.2 + intensity: + m_OverrideState: 1 + m_Value: 1 + scatter: + m_OverrideState: 1 + m_Value: 0.7 + tint: + m_OverrideState: 1 + m_Value: {r: 0.98, g: 0.9856, b: 1, a: 1} + clamp: + m_OverrideState: 0 + m_Value: 500 + highQualityFiltering: + m_OverrideState: 1 + m_Value: 1 + skipIterations: + m_OverrideState: 0 + m_Value: 1 + dirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + dirtIntensity: + m_OverrideState: 0 + m_Value: 0 + characterBaseColorBrightness: + m_OverrideState: 0 + m_Value: 1 + characterBrightness: + m_OverrideState: 1 + m_Value: 0.75 + characterPreTonemapBrightness: + m_OverrideState: 0 + m_Value: 0.95 + characterAreaBloomEmitMultiplier: + m_OverrideState: 0 + m_Value: 1 + characterAreaOverridedThreshold: + m_OverrideState: 1 + m_Value: 0.2 + characterAreaOverridedIntensity: + m_OverrideState: 1 + m_Value: 0.9 + HueOffset: + m_OverrideState: 0 + m_Value: 0 + SaturationBoost: + m_OverrideState: 1 + m_Value: 0.45 + ValueMultiply: + m_OverrideState: 1 + m_Value: 1 + ApplyHSVToCharAreaOnly: + m_OverrideState: 0 + m_Value: 1 + renderTextureOverridedToFixedHeight: + m_OverrideState: 1 + m_Value: 2160 +--- !u!114 &8741824591765560128 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae2b217974b749d4b97b47bae772aee5, type: 3} + m_Name: NiloToonMotionBlurVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.5 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta new file mode 100644 index 0000000..aa3ad6f --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo030-Concert007_StyleBright_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d199ed6fd969d14c8c146eed807eda6 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset new file mode 100644 index 0000000..656ab85 --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset @@ -0,0 +1,2251 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-9061293308887506662 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f53d442396c644b198ad641a34212ce, type: 3} + m_Name: RadiantGlobalIllumination + m_EditorClassIdentifier: + active: 1 + indirectIntensity: + m_OverrideState: 1 + m_Value: 0.25 + indirectDistanceAttenuation: + m_OverrideState: 0 + m_Value: 0 + indirectMaxSourceBrightness: + m_OverrideState: 0 + m_Value: 8 + normalMapInfluence: + m_OverrideState: 0 + m_Value: 1 + rayBounce: + m_OverrideState: 0 + m_Value: 0 + lumaInfluence: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscurance: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscuranceSpread: + m_OverrideState: 0 + m_Value: 0.2 + nearFieldObscuranceMaxCameraDistance: + m_OverrideState: 0 + m_Value: 125 + nearFieldObscuranceOccluderDistance: + m_OverrideState: 0 + m_Value: 0.825 + nearFieldObscuranceTintColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + virtualEmitters: + m_OverrideState: 0 + m_Value: 0 + organicLight: + m_OverrideState: 0 + m_Value: 0 + organicLightThreshold: + m_OverrideState: 0 + m_Value: 0.5 + organicLightSpread: + m_OverrideState: 0 + m_Value: 0.98 + organicLightNormalsInfluence: + m_OverrideState: 0 + m_Value: 0.95 + organicLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + organicLightAnimationSpeed: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + organicLightDistanceScaling: + m_OverrideState: 0 + m_Value: 0 + rayCount: + m_OverrideState: 0 + m_Value: 1 + rayMaxLength: + m_OverrideState: 0 + m_Value: 8 + rayMaxSamples: + m_OverrideState: 0 + m_Value: 32 + rayJitter: + m_OverrideState: 0 + m_Value: 0 + thickness: + m_OverrideState: 0 + m_Value: 1 + rayBinarySearch: + m_OverrideState: 0 + m_Value: 1 + fallbackReuseRays: + m_OverrideState: 1 + m_Value: 1 + rayReuse: + m_OverrideState: 1 + m_Value: 0.9 + fallbackReflectionProbes: + m_OverrideState: 0 + m_Value: 0 + probesIntensity: + m_OverrideState: 0 + m_Value: 1 + fallbackReflectiveShadowMap: + m_OverrideState: 0 + m_Value: 0 + reflectiveShadowMapIntensity: + m_OverrideState: 0 + m_Value: 0.8 + downsampling: + m_OverrideState: 0 + m_Value: 1 + raytracerAccuracy: + m_OverrideState: 0 + m_Value: 8 + smoothing: + m_OverrideState: 0 + m_Value: 3 + temporalReprojection: + m_OverrideState: 0 + m_Value: 1 + temporalResponseSpeed: + m_OverrideState: 0 + m_Value: 12 + temporalCameraTranslationResponse: + m_OverrideState: 0 + m_Value: 100 + temporalDepthRejection: + m_OverrideState: 0 + m_Value: 1 + temporalChromaThreshold: + m_OverrideState: 0 + m_Value: 0.2 + showInEditMode: + m_OverrideState: 0 + m_Value: 1 + showInSceneView: + m_OverrideState: 0 + m_Value: 1 + brightnessThreshold: + m_OverrideState: 0 + m_Value: 0 + brightnessMax: + m_OverrideState: 0 + m_Value: 8 + specularContribution: + m_OverrideState: 0 + m_Value: 0.75 + sourceBrightness: + m_OverrideState: 0 + m_Value: 1 + giWeight: + m_OverrideState: 0 + m_Value: 0 + nearCameraAttenuation: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 1 + limitToVolumeBounds: + m_OverrideState: 0 + m_Value: 0 + stencilCheck: + m_OverrideState: 0 + m_Value: 0 + stencilValue: + m_OverrideState: 0 + m_Value: 1 + stencilCompareFunction: + m_OverrideState: 0 + m_Value: 6 + aoInfluence: + m_OverrideState: 0 + m_Value: 0 + debugView: + m_OverrideState: 0 + m_Value: 0 + debugDepthMultiplier: + m_OverrideState: 0 + m_Value: 10 + compareMode: + m_OverrideState: 0 + m_Value: 0 + compareSameSide: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 +--- !u!114 &-6740973590107075020 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f53d442396c644b198ad641a34212ce, type: 3} + m_Name: RadiantGlobalIllumination + m_EditorClassIdentifier: + active: 0 + indirectIntensity: + m_OverrideState: 1 + m_Value: 0.25 + indirectDistanceAttenuation: + m_OverrideState: 0 + m_Value: 0 + indirectMaxSourceBrightness: + m_OverrideState: 0 + m_Value: 8 + normalMapInfluence: + m_OverrideState: 0 + m_Value: 1 + rayBounce: + m_OverrideState: 1 + m_Value: 1 + lumaInfluence: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscurance: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscuranceSpread: + m_OverrideState: 0 + m_Value: 0.2 + nearFieldObscuranceMaxCameraDistance: + m_OverrideState: 0 + m_Value: 125 + nearFieldObscuranceOccluderDistance: + m_OverrideState: 0 + m_Value: 0.825 + nearFieldObscuranceTintColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + virtualEmitters: + m_OverrideState: 0 + m_Value: 0 + organicLight: + m_OverrideState: 0 + m_Value: 0 + organicLightThreshold: + m_OverrideState: 0 + m_Value: 0.5 + organicLightSpread: + m_OverrideState: 0 + m_Value: 0.98 + organicLightNormalsInfluence: + m_OverrideState: 0 + m_Value: 0.95 + organicLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + organicLightAnimationSpeed: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + organicLightDistanceScaling: + m_OverrideState: 0 + m_Value: 0 + rayCount: + m_OverrideState: 0 + m_Value: 1 + rayMaxLength: + m_OverrideState: 0 + m_Value: 8 + rayMaxSamples: + m_OverrideState: 0 + m_Value: 32 + rayJitter: + m_OverrideState: 0 + m_Value: 0 + thickness: + m_OverrideState: 0 + m_Value: 1 + rayBinarySearch: + m_OverrideState: 0 + m_Value: 1 + fallbackReuseRays: + m_OverrideState: 1 + m_Value: 1 + rayReuse: + m_OverrideState: 1 + m_Value: 0.9 + fallbackReflectionProbes: + m_OverrideState: 0 + m_Value: 0 + probesIntensity: + m_OverrideState: 0 + m_Value: 1 + fallbackReflectiveShadowMap: + m_OverrideState: 0 + m_Value: 0 + reflectiveShadowMapIntensity: + m_OverrideState: 0 + m_Value: 0.8 + downsampling: + m_OverrideState: 0 + m_Value: 1 + raytracerAccuracy: + m_OverrideState: 0 + m_Value: 8 + smoothing: + m_OverrideState: 0 + m_Value: 3 + temporalReprojection: + m_OverrideState: 0 + m_Value: 1 + temporalResponseSpeed: + m_OverrideState: 0 + m_Value: 12 + temporalCameraTranslationResponse: + m_OverrideState: 0 + m_Value: 100 + temporalDepthRejection: + m_OverrideState: 0 + m_Value: 1 + temporalChromaThreshold: + m_OverrideState: 0 + m_Value: 0.2 + showInEditMode: + m_OverrideState: 0 + m_Value: 1 + showInSceneView: + m_OverrideState: 0 + m_Value: 1 + brightnessThreshold: + m_OverrideState: 0 + m_Value: 0 + brightnessMax: + m_OverrideState: 0 + m_Value: 8 + specularContribution: + m_OverrideState: 0 + m_Value: 0.75 + sourceBrightness: + m_OverrideState: 0 + m_Value: 1 + giWeight: + m_OverrideState: 0 + m_Value: 0 + nearCameraAttenuation: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 2 + limitToVolumeBounds: + m_OverrideState: 0 + m_Value: 0 + stencilCheck: + m_OverrideState: 0 + m_Value: 0 + stencilValue: + m_OverrideState: 0 + m_Value: 1 + stencilCompareFunction: + m_OverrideState: 0 + m_Value: 6 + aoInfluence: + m_OverrideState: 0 + m_Value: 0 + debugView: + m_OverrideState: 0 + m_Value: 70 + debugDepthMultiplier: + m_OverrideState: 0 + m_Value: 10 + compareMode: + m_OverrideState: 0 + m_Value: 0 + compareSameSide: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 +--- !u!114 &-6636676602098857160 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 81180773991d8724ab7f2d216912b564, type: 3} + m_Name: ChromaticAberration + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.05 +--- !u!114 &-5934634642679004759 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 905ab376be722a641bd27d7ae304cedd, type: 3} + m_Name: NiloToonTonemappingVolume + m_EditorClassIdentifier: + active: 1 + mode: + m_OverrideState: 1 + m_Value: 7 + intensity: + m_OverrideState: 1 + m_Value: 1 + ApplyToCharacter: + m_OverrideState: 1 + m_Value: 0.5 + ApplyToNonCharacter: + m_OverrideState: 0 + m_Value: 1 + BrightnessMulForCharacter: + m_OverrideState: 0 + m_Value: 1 + BrightnessMulForNonCharacter: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-4188649219325671941 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c133717c76e564a5fa90d7f12908d17e, type: 3} + m_Name: Beautify + m_EditorClassIdentifier: + active: 1 + disabled: + m_OverrideState: 1 + m_Value: 0 + compareMode: + m_OverrideState: 1 + m_Value: 0 + compareStyle: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 + flipY: + m_OverrideState: 1 + m_Value: 0 + hideInSceneView: + m_OverrideState: 1 + m_Value: 0 + debugOutput: + m_OverrideState: 0 + m_Value: 0 + turboMode: + m_OverrideState: 1 + m_Value: 0 + directWrite: + m_OverrideState: 1 + m_Value: 0 + ignoreDepthTexture: + m_OverrideState: 1 + m_Value: 0 + downsampling: + m_OverrideState: 1 + m_Value: 0 + downsamplingMode: + m_OverrideState: 0 + m_Value: 0 + downsamplingMultiplier: + m_OverrideState: 0 + m_Value: 1 + downsamplingBilinear: + m_OverrideState: 0 + m_Value: 0 + sharpenIntensity: + m_OverrideState: 0 + m_Value: 0 + sharpenDepthThreshold: + m_OverrideState: 0 + m_Value: 0.035 + sharpenMinMaxDepth: + m_OverrideState: 0 + m_Value: {x: 0, y: 0.999} + min: 0 + max: 1.1 + sharpenMinMaxDepthFallOff: + m_OverrideState: 0 + m_Value: 0 + sharpenRelaxation: + m_OverrideState: 0 + m_Value: 0.08 + sharpenClamp: + m_OverrideState: 0 + m_Value: 0.45 + sharpenMotionSensibility: + m_OverrideState: 0 + m_Value: 0.5 + sharpenMotionRestoreSpeed: + m_OverrideState: 0 + m_Value: 0.5 + antialiasStrength: + m_OverrideState: 0 + m_Value: 0 + antialiasDepthThreshold: + m_OverrideState: 0 + m_Value: 0.000001 + antialiasSpread: + m_OverrideState: 0 + m_Value: 3 + antialiasDepthAttenuation: + m_OverrideState: 0 + m_Value: 0 + tonemap: + m_OverrideState: 0 + m_Value: 0 + tonemapAGXGamma: + m_OverrideState: 0 + m_Value: 2.5 + tonemapMaxInputBrightness: + m_OverrideState: 0 + m_Value: 1000 + tonemapExposurePre: + m_OverrideState: 0 + m_Value: 1 + tonemapBrightnessPost: + m_OverrideState: 0 + m_Value: 1 + saturate: + m_OverrideState: 0 + m_Value: 1 + brightness: + m_OverrideState: 0 + m_Value: 1 + contrast: + m_OverrideState: 0 + m_Value: 1 + daltonize: + m_OverrideState: 0 + m_Value: 0 + sepia: + m_OverrideState: 0 + m_Value: 0 + tintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + colorTempBlend: + m_OverrideState: 0 + m_Value: 0 + colorTemp: + m_OverrideState: 0 + m_Value: 6550 + lut: + m_OverrideState: 0 + m_Value: 0 + lutIntensity: + m_OverrideState: 0 + m_Value: 0 + lutTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + bloomIntensity: + m_OverrideState: 0 + m_Value: 0 + bloomThreshold: + m_OverrideState: 0 + m_Value: 0.75 + bloomConservativeThreshold: + m_OverrideState: 0 + m_Value: 0 + bloomSpread: + m_OverrideState: 0 + m_Value: 0.5 + bloomMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + bloomTint: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 0.5, b: 1, a: 0} + bloomDepthAtten: + m_OverrideState: 0 + m_Value: 0 + bloomNearAtten: + m_OverrideState: 0 + m_Value: 0 + bloomExcludeLayers: + m_OverrideState: 0 + m_Value: 0 + bloomLayersFilterMethod: + m_OverrideState: 0 + m_Value: 1 + bloomExclusionLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 0 + bloomAntiflicker: + m_OverrideState: 0 + m_Value: 0 + bloomResolution: + m_OverrideState: 0 + m_Value: 1 + bloomQuickerBlur: + m_OverrideState: 0 + m_Value: 0 + bloomCustomize: + m_OverrideState: 0 + m_Value: 0 + bloomWeight0: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost0: + m_OverrideState: 0 + m_Value: 0 + bloomTint0: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight1: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost1: + m_OverrideState: 0 + m_Value: 0 + bloomTint1: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight2: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost2: + m_OverrideState: 0 + m_Value: 0 + bloomTint2: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight3: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost3: + m_OverrideState: 0 + m_Value: 0 + bloomTint3: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight4: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost4: + m_OverrideState: 0 + m_Value: 0 + bloomTint4: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomWeight5: + m_OverrideState: 0 + m_Value: 0.5 + bloomBoost5: + m_OverrideState: 0 + m_Value: 0 + bloomTint5: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + anamorphicFlaresIntensity: + m_OverrideState: 1 + m_Value: 0.01 + anamorphicFlaresThreshold: + m_OverrideState: 1 + m_Value: 3 + anamorphicFlaresConservativeThreshold: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresTint: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 0.5, b: 1, a: 0} + anamorphicFlaresVertical: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresSpread: + m_OverrideState: 1 + m_Value: 1 + anamorphicFlaresMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + anamorphicFlaresDepthAtten: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresNearAtten: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresExcludeLayers: + m_OverrideState: 0 + m_Value: 0 + anamorphicFlaresLayersFilterMethod: + m_OverrideState: 0 + m_Value: 1 + anamorphicFlaresExclusionLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 0 + anamorphicFlaresAntiflicker: + m_OverrideState: 1 + m_Value: 1 + anamorphicFlaresResolution: + m_OverrideState: 0 + m_Value: 1 + anamorphicFlaresQuickerBlur: + m_OverrideState: 0 + m_Value: 0 + sunFlaresIntensity: + m_OverrideState: 0 + m_Value: 0 + sunFlaresTint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + sunFlaresSolarWindSpeed: + m_OverrideState: 0 + m_Value: 0.01 + sunFlaresRotationDeadZone: + m_OverrideState: 0 + m_Value: 0 + sunFlaresDownsampling: + m_OverrideState: 0 + m_Value: 1 + sunFlaresDepthOcclusionMode: + m_OverrideState: 0 + m_Value: 1 + sunFlaresDepthOcclusionThreshold: + m_OverrideState: 0 + m_Value: 0.5 + sunFlaresUseLayerMask: + m_OverrideState: 0 + m_Value: 0 + sunFlaresLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + sunFlaresAttenSpeed: + m_OverrideState: 0 + m_Value: 30 + sunFlaresSunIntensity: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresSunDiskSize: + m_OverrideState: 0 + m_Value: 0.05 + sunFlaresSunRayDiffractionIntensity: + m_OverrideState: 0 + m_Value: 3.5 + sunFlaresSunRayDiffractionThreshold: + m_OverrideState: 0 + m_Value: 0.13 + sunFlaresCoronaRays1Length: + m_OverrideState: 0 + m_Value: 0.02 + sunFlaresCoronaRays1Streaks: + m_OverrideState: 0 + m_Value: 12 + sunFlaresCoronaRays1Spread: + m_OverrideState: 0 + m_Value: 0.001 + sunFlaresCoronaRays1AngleOffset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresCoronaRays2Length: + m_OverrideState: 0 + m_Value: 0.05 + sunFlaresCoronaRays2Streaks: + m_OverrideState: 0 + m_Value: 12 + sunFlaresCoronaRays2Spread: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresCoronaRays2AngleOffset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresGhosts1Size: + m_OverrideState: 0 + m_Value: 0.03 + sunFlaresGhosts1Offset: + m_OverrideState: 0 + m_Value: 1.04 + sunFlaresGhosts1Brightness: + m_OverrideState: 0 + m_Value: 0.037 + sunFlaresGhosts2Size: + m_OverrideState: 0 + m_Value: 0.1 + sunFlaresGhosts2Offset: + m_OverrideState: 0 + m_Value: 0.71 + sunFlaresGhosts2Brightness: + m_OverrideState: 0 + m_Value: 0.03 + sunFlaresGhosts3Size: + m_OverrideState: 0 + m_Value: 0.24 + sunFlaresGhosts3Offset: + m_OverrideState: 0 + m_Value: 0.31 + sunFlaresGhosts3Brightness: + m_OverrideState: 0 + m_Value: 0.025 + sunFlaresGhosts4Size: + m_OverrideState: 0 + m_Value: 0.016 + sunFlaresGhosts4Offset: + m_OverrideState: 0 + m_Value: 0 + sunFlaresGhosts4Brightness: + m_OverrideState: 0 + m_Value: 0.017 + sunFlaresHaloOffset: + m_OverrideState: 0 + m_Value: 0.22 + sunFlaresHaloAmplitude: + m_OverrideState: 0 + m_Value: 15.1415 + sunFlaresHaloIntensity: + m_OverrideState: 0 + m_Value: 0.01 + lensDirtIntensity: + m_OverrideState: 0 + m_Value: 0 + lensDirtThreshold: + m_OverrideState: 0 + m_Value: 0.5 + lensDirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + lensDirtSpread: + m_OverrideState: 0 + m_Value: 3 + chromaticAberrationIntensity: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationShift: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationSmoothing: + m_OverrideState: 0 + m_Value: 0 + chromaticAberrationSeparatePass: + m_OverrideState: 0 + m_Value: 0 + depthOfField: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldFocusMode: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusMinDistance: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusMaxDistance: + m_OverrideState: 0 + m_Value: 10000 + depthOfFieldTargetFallback: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldTargetFallbackFixedDistance: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldAutofocusViewportPoint: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + depthOfFieldAutofocusDistanceShift: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAutofocusLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + depthOfFieldDistance: + m_OverrideState: 0 + m_Value: 10 + depthOfFieldCameraSettings: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldFocalLength: + m_OverrideState: 0 + m_Value: 0.05 + depthOfFieldAperture: + m_OverrideState: 0 + m_Value: 2.8 + depthOfFieldFocalLengthReal: + m_OverrideState: 0 + m_Value: 50 + depthOfFieldFStop: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldImageSensorHeight: + m_OverrideState: 0 + m_Value: 24 + depthOfFieldFocusSpeed: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldTransparentSupport: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldTransparentLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 1 + depthOfFieldTransparentDoubleSided: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAlphaTestSupport: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldAlphaTestLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 1 + depthOfFieldAlphaTestDoubleSided: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldForegroundBlur: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldForegroundBlurHQ: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldForegroundBlurHQSpread: + m_OverrideState: 0 + m_Value: 4 + depthOfFieldForegroundDistance: + m_OverrideState: 0 + m_Value: 0.25 + depthOfFieldBokeh: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldBokehComposition: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldBokehThreshold: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldBokehIntensity: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldDownsampling: + m_OverrideState: 0 + m_Value: 2 + depthOfFieldMaxSamples: + m_OverrideState: 0 + m_Value: 6 + depthOfFieldMaxBrightness: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldMaxBlurRadius: + m_OverrideState: 0 + m_Value: 1000 + depthOfFieldResolutionInvariant: + m_OverrideState: 0 + m_Value: 0 + depthOfFieldMaxDistance: + m_OverrideState: 0 + m_Value: 1 + depthOfFieldFilterMode: + m_OverrideState: 0 + m_Value: 1 + eyeAdaptation: + m_OverrideState: 0 + m_Value: 0 + eyeAdaptationMinExposure: + m_OverrideState: 0 + m_Value: 0.2 + eyeAdaptationMaxExposure: + m_OverrideState: 0 + m_Value: 5 + eyeAdaptationSpeedToLight: + m_OverrideState: 0 + m_Value: 0.4 + eyeAdaptationSpeedToDark: + m_OverrideState: 0 + m_Value: 0.2 + eyeAdaptationMeteringMode: + m_OverrideState: 0 + m_Value: 0 + eyeAdaptationMinCameraDistance: + m_OverrideState: 0 + m_Value: 0 + eyeAdaptationMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + purkinje: + m_OverrideState: 0 + m_Value: 0 + purkinjeAmount: + m_OverrideState: 0 + m_Value: 1 + purkinjeLuminanceThreshold: + m_OverrideState: 0 + m_Value: 0.15 + vignettingOuterRing: + m_OverrideState: 0 + m_Value: 0 + vignettingInnerRing: + m_OverrideState: 0 + m_Value: 0 + vignettingFade: + m_OverrideState: 0 + m_Value: 0 + vignettingCircularShape: + m_OverrideState: 0 + m_Value: 0 + vignettingCircularShapeFitMode: + m_OverrideState: 0 + m_Value: 0 + vignettingAspectRatio: + m_OverrideState: 0 + m_Value: 1 + vignettingBlink: + m_OverrideState: 0 + m_Value: 0 + vignettingBlinkStyle: + m_OverrideState: 0 + m_Value: 0 + vignettingCenter: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + vignettingColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + vignettingMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + outline: + m_OverrideState: 0 + m_Value: 0 + outlineColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 0.8} + outlineTechnique: + m_OverrideState: 0 + m_Value: 0 + outlineMinSeparation: + m_OverrideState: 0 + m_Value: 1 + outlineThreshold: + m_OverrideState: 0 + m_Value: 0.2 + outlineMinDepthThreshold: + m_OverrideState: 0 + m_Value: 0.0005 + outlineSaturationDiffThreshold: + m_OverrideState: 0 + m_Value: 0.015 + outlineCustomize: + m_OverrideState: 0 + m_Value: 0 + outlineLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 2 + m_Bits: 4294967295 + outlineStageParameter: + m_OverrideState: 0 + m_Value: 0 + outlineSpread: + m_OverrideState: 0 + m_Value: 1 + outlineBlurPassCount: + m_OverrideState: 0 + m_Value: 1 + outlineBlurDownscale: + m_OverrideState: 0 + m_Value: 0 + outlineIntensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + outlineDistanceFade: + m_OverrideState: 0 + m_Value: 0 + outlineUsesOptimizedShader: + m_OverrideState: 0 + m_Value: 0 + outlineLayerCutOff: + m_OverrideState: 0 + m_Value: 0 + nightVision: + m_OverrideState: 0 + m_Value: 0 + nightVisionColor: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 1, b: 0.5, a: 0.5} + nightVisionDepth: + m_OverrideState: 0 + m_Value: 100000 + nightVisionDepthFallOff: + m_OverrideState: 0 + m_Value: 1 + thermalVision: + m_OverrideState: 0 + m_Value: 0 + thermalVisionScanLines: + m_OverrideState: 0 + m_Value: 1 + thermalVisionDistortionAmount: + m_OverrideState: 0 + m_Value: 9 + ditherIntensity: + m_OverrideState: 0 + m_Value: 0 + frame: + m_OverrideState: 0 + m_Value: 0 + frameStyle: + m_OverrideState: 0 + m_Value: 0 + frameBandHorizontalSize: + m_OverrideState: 0 + m_Value: 0 + frameBandHorizontalSmoothness: + m_OverrideState: 0 + m_Value: 0 + frameBandVerticalSize: + m_OverrideState: 0 + m_Value: 0.1 + frameBandVerticalSmoothness: + m_OverrideState: 0 + m_Value: 0 + frameColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0.047} + frameMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + blurIntensity: + m_OverrideState: 0 + m_Value: 0 + blurMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + blurKeepSourceOnTop: + m_OverrideState: 0 + m_Value: 0 + blurSourceRect: + m_OverrideState: 0 + m_Value: {x: 0.1, y: 0.1, z: 0.8, w: 0.8} + blurSourceEdgeBlendWidth: + m_OverrideState: 0 + m_Value: 0 + blurSourceEdgeBlendStrength: + m_OverrideState: 0 + m_Value: 20 +--- !u!114 &-4175720902093087789 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf9669dd43d41362b826cb959e024e98, type: 3} + m_Name: TinyMotionComponent + m_EditorClassIdentifier: + active: 0 + blurMode: + m_OverrideState: 0 + m_Value: 1 + sampleCountMode: + m_OverrideState: 0 + m_Value: 1 + samples: + m_OverrideState: 0 + m_Value: 6 + minSampleCount: + m_OverrideState: 0 + m_Value: 2 + maxSampleCount: + m_OverrideState: 0 + m_Value: 6 + motionTextureQuality: + m_OverrideState: 0 + m_Value: 1 + downsample: + m_OverrideState: 0 + m_Value: 1 + noiseMode: + m_OverrideState: 0 + m_Value: 0 + animateNoise: + m_OverrideState: 0 + m_Value: 0 + skipSecondPass: + m_OverrideState: 0 + m_Value: 0 + intensity: + m_OverrideState: 1 + m_Value: 1 + intensityCamera: + m_OverrideState: 0 + m_Value: 0 + shutterSpeed: + m_OverrideState: 0 + m_Value: 250 + threshold: + m_OverrideState: 0 + m_Value: 0.001 + depthSeparationTreshold: + m_OverrideState: 0 + m_Value: 0 + depthSeparationBothWays: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocity: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocityTreshold: + m_OverrideState: 0 + m_Value: 0.25 + clampVelocity: + m_OverrideState: 0 + m_Value: 1 + viewInEditor: + m_OverrideState: 0 + m_Value: 0 + includeTransparentObjects: + m_OverrideState: 0 + m_Value: 0 + debugMode: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &-4008367110992087880 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f53d442396c644b198ad641a34212ce, type: 3} + m_Name: RadiantGlobalIllumination + m_EditorClassIdentifier: + active: 0 + indirectIntensity: + m_OverrideState: 1 + m_Value: 100 + indirectDistanceAttenuation: + m_OverrideState: 0 + m_Value: 0 + indirectMaxSourceBrightness: + m_OverrideState: 0 + m_Value: 8 + normalMapInfluence: + m_OverrideState: 0 + m_Value: 1 + rayBounce: + m_OverrideState: 0 + m_Value: 0 + lumaInfluence: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscurance: + m_OverrideState: 0 + m_Value: 0 + nearFieldObscuranceSpread: + m_OverrideState: 0 + m_Value: 0.2 + nearFieldObscuranceMaxCameraDistance: + m_OverrideState: 0 + m_Value: 125 + nearFieldObscuranceOccluderDistance: + m_OverrideState: 0 + m_Value: 0.825 + nearFieldObscuranceTintColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + virtualEmitters: + m_OverrideState: 0 + m_Value: 0 + organicLight: + m_OverrideState: 0 + m_Value: 0 + organicLightThreshold: + m_OverrideState: 0 + m_Value: 0.5 + organicLightSpread: + m_OverrideState: 0 + m_Value: 0.98 + organicLightNormalsInfluence: + m_OverrideState: 0 + m_Value: 0.95 + organicLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + organicLightAnimationSpeed: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + organicLightDistanceScaling: + m_OverrideState: 0 + m_Value: 0 + rayCount: + m_OverrideState: 0 + m_Value: 1 + rayMaxLength: + m_OverrideState: 0 + m_Value: 8 + rayMaxSamples: + m_OverrideState: 0 + m_Value: 32 + rayJitter: + m_OverrideState: 0 + m_Value: 0 + thickness: + m_OverrideState: 0 + m_Value: 1 + rayBinarySearch: + m_OverrideState: 0 + m_Value: 1 + fallbackReuseRays: + m_OverrideState: 0 + m_Value: 0 + rayReuse: + m_OverrideState: 0 + m_Value: 0 + fallbackReflectionProbes: + m_OverrideState: 0 + m_Value: 0 + probesIntensity: + m_OverrideState: 0 + m_Value: 1 + fallbackReflectiveShadowMap: + m_OverrideState: 0 + m_Value: 0 + reflectiveShadowMapIntensity: + m_OverrideState: 0 + m_Value: 0.8 + downsampling: + m_OverrideState: 0 + m_Value: 1 + raytracerAccuracy: + m_OverrideState: 0 + m_Value: 8 + smoothing: + m_OverrideState: 0 + m_Value: 3 + temporalReprojection: + m_OverrideState: 0 + m_Value: 1 + temporalResponseSpeed: + m_OverrideState: 0 + m_Value: 12 + temporalCameraTranslationResponse: + m_OverrideState: 0 + m_Value: 100 + temporalDepthRejection: + m_OverrideState: 0 + m_Value: 1 + temporalChromaThreshold: + m_OverrideState: 0 + m_Value: 0.2 + showInEditMode: + m_OverrideState: 0 + m_Value: 1 + showInSceneView: + m_OverrideState: 0 + m_Value: 1 + brightnessThreshold: + m_OverrideState: 0 + m_Value: 0 + brightnessMax: + m_OverrideState: 0 + m_Value: 8 + specularContribution: + m_OverrideState: 0 + m_Value: 0.75 + sourceBrightness: + m_OverrideState: 0 + m_Value: 1 + giWeight: + m_OverrideState: 0 + m_Value: 0 + nearCameraAttenuation: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 1 + limitToVolumeBounds: + m_OverrideState: 0 + m_Value: 0 + stencilCheck: + m_OverrideState: 0 + m_Value: 0 + stencilValue: + m_OverrideState: 0 + m_Value: 1 + stencilCompareFunction: + m_OverrideState: 0 + m_Value: 6 + aoInfluence: + m_OverrideState: 0 + m_Value: 0 + debugView: + m_OverrideState: 0 + m_Value: 0 + debugDepthMultiplier: + m_OverrideState: 0 + m_Value: 10 + compareMode: + m_OverrideState: 0 + m_Value: 0 + compareSameSide: + m_OverrideState: 0 + m_Value: 0 + comparePanning: + m_OverrideState: 0 + m_Value: 0.25 + compareLineAngle: + m_OverrideState: 0 + m_Value: 1.4 + compareLineWidth: + m_OverrideState: 0 + m_Value: 0.002 +--- !u!114 &-3973662611378603825 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e0b07a42ea8749b41bdca5f151c44d94, type: 3} + m_Name: NiloToonRenderingPerformanceControlVolume + m_EditorClassIdentifier: + active: 0 + overrideEnableDepthTextureRimLigthAndShadow: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &-1703029571481380811 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 853cfdf4b80146545b90713442d462cf, type: 3} + m_Name: NiloToonAdditionalLightStyleVolume + m_EditorClassIdentifier: + active: 1 + additionalLightInjectIntoMainLightColor_Strength: + m_OverrideState: 1 + m_Value: 0.25 + additionalLightInjectIntoMainLightDirection_Strength: + m_OverrideState: 1 + m_Value: 0 + additionalLightInjectIntoMainLightColor_Desaturate: + m_OverrideState: 1 + m_Value: 0.5 + additionalLightInjectIntoMainLightColor_AllowCloseLightOverBright: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-849540741217479451 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3} + m_Name: Tonemapping + m_EditorClassIdentifier: + active: 0 + mode: + m_OverrideState: 1 + m_Value: 2 + neutralHDRRangeReductionMode: + m_OverrideState: 0 + m_Value: 2 + acesPreset: + m_OverrideState: 0 + m_Value: 3 + hueShiftAmount: + m_OverrideState: 0 + m_Value: 0 + detectPaperWhite: + m_OverrideState: 0 + m_Value: 0 + paperWhite: + m_OverrideState: 0 + m_Value: 300 + detectBrightnessLimits: + m_OverrideState: 0 + m_Value: 1 + minNits: + m_OverrideState: 0 + m_Value: 0.005 + maxNits: + m_OverrideState: 0 + m_Value: 1000 +--- !u!114 &-598188741750761343 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d89c46e6b4f031541986f8d6bdbad145, type: 3} + m_Name: NiloToonCinematicRimLightVolume + m_EditorClassIdentifier: + active: 1 + strengthRimMask2D: + m_OverrideState: 1 + m_Value: 0.7 + strengthRimMask3D_ClassicStyle: + m_OverrideState: 1 + m_Value: 0.7 + strengthRimMask3D_DynmaicStyle: + m_OverrideState: 0 + m_Value: 0.7 + sharpnessRimMask3D_DynamicStyle: + m_OverrideState: 0 + m_Value: 0.375 + strengthRimMask3D_StableStyle: + m_OverrideState: 0 + m_Value: 0.7 + sharpnessRimMask3D_StableStyle: + m_OverrideState: 0 + m_Value: 0.5 + lightIntensityMultiplier: + m_OverrideState: 1 + m_Value: 20 + tintBaseMap: + m_OverrideState: 1 + m_Value: 0.5 + enableStyleSafeGuard: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-426318345093102539 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d89c46e6b4f031541986f8d6bdbad145, type: 3} + m_Name: NiloToonCinematicRimLightVolume + m_EditorClassIdentifier: + active: 1 + strengthRimMask2D: + m_OverrideState: 0 + m_Value: 1 + strengthRimMask3D_ClassicStyle: + m_OverrideState: 0 + m_Value: 1 + strengthRimMask3D_DynmaicStyle: + m_OverrideState: 0 + m_Value: 1 + sharpnessRimMask3D_DynamicStyle: + m_OverrideState: 0 + m_Value: 0.375 + strengthRimMask3D_StableStyle: + m_OverrideState: 1 + m_Value: 1 + sharpnessRimMask3D_StableStyle: + m_OverrideState: 1 + m_Value: 0 + lightIntensityMultiplier: + m_OverrideState: 1 + m_Value: 0.25 + tintBaseMap: + m_OverrideState: 0 + m_Value: 0.5 + enableStyleSafeGuard: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset) + m_EditorClassIdentifier: + components: + - {fileID: 5018692330182970109} + - {fileID: 8623061367897789741} + - {fileID: 4675053336608618770} + - {fileID: -6636676602098857160} + - {fileID: 7773777288705028284} + - {fileID: 1392042495390883562} + - {fileID: 744989890794951721} + - {fileID: -426318345093102539} + - {fileID: -5934634642679004759} + - {fileID: -849540741217479451} + - {fileID: -1703029571481380811} + - {fileID: 962140819579389808} + - {fileID: -3973662611378603825} + - {fileID: 411203215106509782} + - {fileID: 7888073279915774665} + - {fileID: -4008367110992087880} +--- !u!114 &411203215106509782 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} + m_Name: ColorAdjustments + m_EditorClassIdentifier: + active: 0 + postExposure: + m_OverrideState: 0 + m_Value: 0 + contrast: + m_OverrideState: 1 + m_Value: 10 + colorFilter: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + hueShift: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 1 + m_Value: 10 +--- !u!114 &744989890794951721 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 39dc1fe45bfcc1e4eaa9ae19ecefd49c, type: 3} + m_Name: NiloToonShadowControlVolume + m_EditorClassIdentifier: + active: 1 + characterOverallShadowTintColor: + m_OverrideState: 1 + m_Value: {r: 0.8301887, g: 0.7425865, b: 0.68529725, a: 1} + characterOverallShadowStrength: + m_OverrideState: 0 + m_Value: 1 + enableCharAverageShadow: + m_OverrideState: 0 + m_Value: 1 + charAverageShadowStrength: + m_OverrideState: 0 + m_Value: 1 + enableCharSelfShadow: + m_OverrideState: 0 + m_Value: 1 + charSelfShadowStrength: + m_OverrideState: 0 + m_Value: 1 + useMainLightAsCastShadowDirection: + m_OverrideState: 0 + m_Value: 1 + shadowAngle: + m_OverrideState: 0 + m_Value: 30 + shadowLRAngle: + m_OverrideState: 0 + m_Value: 0 + shadowRange: + m_OverrideState: 0 + m_Value: 10 + shadowMapSize: + m_OverrideState: 0 + m_Value: 4096 + depthBias: + m_OverrideState: 0 + m_Value: 1 + normalBias: + m_OverrideState: 0 + m_Value: 1 + receiveURPShadow: + m_OverrideState: 0 + m_Value: 0 + URPShadowIntensity: + m_OverrideState: 0 + m_Value: 1 + URPShadowAsDirectLightMultiplier: + m_OverrideState: 0 + m_Value: 1 + URPShadowAsDirectLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + URPShadowAsDirectLightTintIgnoreMaterialURPUsageSetting: + m_OverrideState: 0 + m_Value: 1 + URPShadowblurriness: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &962140819579389808 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ccf1aba9553839d41ae37dd52e9ebcce, type: 3} + m_Name: MotionBlur + m_EditorClassIdentifier: + active: 0 + mode: + m_OverrideState: 1 + m_Value: 1 + quality: + m_OverrideState: 1 + m_Value: 2 + intensity: + m_OverrideState: 1 + m_Value: 0.25 + clamp: + m_OverrideState: 1 + m_Value: 0.05 +--- !u!114 &1392042495390883562 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eecc32444ea4503479fa0394f277db7d, type: 3} + m_Name: NiloToonScreenSpaceOutlineControlVolume + m_EditorClassIdentifier: + active: 0 + intensity: + m_OverrideState: 1 + m_Value: 1 + intensityForCharacter: + m_OverrideState: 0 + m_Value: 1 + intensityForEnvironment: + m_OverrideState: 0 + m_Value: 1 + widthMultiplier: + m_OverrideState: 1 + m_Value: 0.4 + widthMultiplierForCharacter: + m_OverrideState: 0 + m_Value: 1 + widthMultiplierForEnvironment: + m_OverrideState: 0 + m_Value: 1 + extraWidthMultiplierForXR: + m_OverrideState: 0 + m_Value: 0.2 + normalsSensitivityOffset: + m_OverrideState: 0 + m_Value: 0 + normalsSensitivityOffsetForCharacter: + m_OverrideState: 0 + m_Value: 0 + normalsSensitivityOffsetForEnvironment: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffset: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffsetForCharacter: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityOffsetForEnvironment: + m_OverrideState: 0 + m_Value: 0 + depthSensitivityDistanceFadeoutStrength: + m_OverrideState: 0 + m_Value: 1 + depthSensitivityDistanceFadeoutStrengthForCharacter: + m_OverrideState: 0 + m_Value: 1 + depthSensitivityDistanceFadeoutStrengthForEnvironment: + m_OverrideState: 0 + m_Value: 1 + outlineTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + outlineTintColorForChar: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + outlineTintColorForEnvi: + m_OverrideState: 0 + m_Value: {r: 0.12, g: 0.12, b: 0.12, a: 1} +--- !u!114 &3331279558105876180 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf9669dd43d41362b826cb959e024e98, type: 3} + m_Name: TinyMotionComponent + m_EditorClassIdentifier: + active: 0 + blurMode: + m_OverrideState: 0 + m_Value: 1 + sampleCountMode: + m_OverrideState: 0 + m_Value: 1 + samples: + m_OverrideState: 0 + m_Value: 6 + minSampleCount: + m_OverrideState: 0 + m_Value: 2 + maxSampleCount: + m_OverrideState: 0 + m_Value: 6 + motionTextureQuality: + m_OverrideState: 0 + m_Value: 1 + downsample: + m_OverrideState: 0 + m_Value: 1 + noiseMode: + m_OverrideState: 0 + m_Value: 0 + animateNoise: + m_OverrideState: 0 + m_Value: 0 + skipSecondPass: + m_OverrideState: 0 + m_Value: 0 + intensity: + m_OverrideState: 1 + m_Value: 2 + intensityCamera: + m_OverrideState: 0 + m_Value: 0 + shutterSpeed: + m_OverrideState: 0 + m_Value: 250 + threshold: + m_OverrideState: 0 + m_Value: 0.001 + depthSeparationTreshold: + m_OverrideState: 0 + m_Value: 0 + depthSeparationBothWays: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocity: + m_OverrideState: 0 + m_Value: 0 + depthSeparationVelocityTreshold: + m_OverrideState: 0 + m_Value: 0.25 + clampVelocity: + m_OverrideState: 0 + m_Value: 1 + viewInEditor: + m_OverrideState: 0 + m_Value: 0 + includeTransparentObjects: + m_OverrideState: 0 + m_Value: 0 + debugMode: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &4675053336608618770 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5aa15fc7246432d4fb73e65893caaa4b, type: 3} + m_Name: NiloToonAnimePostProcessVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.5 + rotation: + m_OverrideState: 0 + m_Value: 0 + topLightEffectDrawHeight: + m_OverrideState: 0 + m_Value: 0.3 + topLightEffectIntensity: + m_OverrideState: 0 + m_Value: 1 + topLightMultiplyLightColor: + m_OverrideState: 0 + m_Value: 1 + topLightSunTintColor: + m_OverrideState: 1 + m_Value: {r: 0.24526887, g: 0.2759902, b: 0.319, a: 1} + topLightDesaturate: + m_OverrideState: 0 + m_Value: 0 + topLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + topLightExtraRotation: + m_OverrideState: 0 + m_Value: 0 + bottomDarkenEffectDrawHeight: + m_OverrideState: 0 + m_Value: 0.3 + bottomDarkenEffectIntensity: + m_OverrideState: 1 + m_Value: 0 + bottomDarkenExtraRotation: + m_OverrideState: 0 + m_Value: 0 + drawBeforePostProcess: + m_OverrideState: 1 + m_Value: 1 + affectedByCameraPostprocessToggle: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &5018692330182970109 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4a104dcd31bca784aaed640904c00a0b, type: 3} + m_Name: NiloToonCharRenderingControlVolume + m_EditorClassIdentifier: + active: 1 + charBaseColorMultiply: + m_OverrideState: 0 + m_Value: 1 + charBaseColorTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + charMulColorIntensity: + m_OverrideState: 0 + m_Value: 0.95 + charMulColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + charLerpColorUsage: + m_OverrideState: 0 + m_Value: 0 + charLerpColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charOcclusionUsage: + m_OverrideState: 0 + m_Value: 1 + charIndirectLightMultiplier: + m_OverrideState: 1 + m_Value: 0 + charIndirectLightMinColor: + m_OverrideState: 1 + m_Value: {r: 0.01, g: 0.01, b: 0.01, a: 0} + charIndirectLightMaxColor: + m_OverrideState: 1 + m_Value: {r: 0.01, g: 0.01, b: 0.01, a: 1} + mainDirectionalLightIntensityMultiplier: + m_OverrideState: 0 + m_Value: 0.7 + mainDirectionalLightIntensityMultiplierColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + addMainLightColor: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + mainDirectionalLightMaxContribution: + m_OverrideState: 0 + m_Value: 1 + mainDirectionalLightMaxContributionColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + overrideLightDirectionIntensity: + m_OverrideState: 1 + m_Value: 1 + overridedLightUpDownAngle: + m_OverrideState: 0 + m_Value: -45 + overridedLightLRAngle: + m_OverrideState: 0 + m_Value: -30 + lightColorOverrideStrength: + m_OverrideState: 0 + m_Value: 0 + overridedLightColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + desaturateLightColor: + m_OverrideState: 0 + m_Value: 0 + additionalLightIntensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + additionalLightIntensityMultiplierColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightIntensityMultiplierForFaceArea: + m_OverrideState: 1 + m_Value: 0 + additionalLightIntensityMultiplierColorForFaceArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightIntensityMultiplierForOutlineArea: + m_OverrideState: 0 + m_Value: 1 + additionalLightIntensityMultiplierColorForOutlineArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + additionalLightApplyRimMask: + m_OverrideState: 0 + m_Value: 1 + additionalLightRimMaskPower: + m_OverrideState: 0 + m_Value: 1 + additionalLightRimMaskSoftness: + m_OverrideState: 0 + m_Value: 1 + additionalLightMaxContribution: + m_OverrideState: 0 + m_Value: 1 + additionalLightMaxContributionColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + specularIntensityMultiplier: + m_OverrideState: 0 + m_Value: 20 + specularTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + specularInShadowMinIntensity: + m_OverrideState: 0 + m_Value: 0.25 + specularReactToLightDirectionChange: + m_OverrideState: 0 + m_Value: 0 + depthTextureRimLightAndShadowWidthMultiplier: + m_OverrideState: 1 + m_Value: 1 + charRimLightMultiplier: + m_OverrideState: 1 + m_Value: 8 + charRimLightTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charRimLightMultiplierForOutlineArea: + m_OverrideState: 0 + m_Value: 0 + charRimLightTintColorForOutlineArea: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + depthTexRimLightDepthDiffThresholdOffset: + m_OverrideState: 1 + m_Value: 0.25 + charRimLightCameraDistanceFadeoutStartDistance: + m_OverrideState: 0 + m_Value: 1000 + charRimLightCameraDistanceFadeoutEndDistance: + m_OverrideState: 0 + m_Value: 2000 + characterOverallShadowStrength: + m_OverrideState: 0 + m_Value: 1 + characterOverallShadowTintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 0} + charOutlineWidthMultiplier: + m_OverrideState: 0 + m_Value: 1 + charOutlineWidthExtraMultiplierForXR: + m_OverrideState: 0 + m_Value: 0.5 + charOutlineWidthAutoAdjustToCameraDistanceAndFOV: + m_OverrideState: 0 + m_Value: 1 + charOutlineMulColor: + m_OverrideState: 0 + m_Value: {r: 0.25, g: 0.25, b: 0.25, a: 1} +--- !u!114 &7773777288705028284 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3} + m_Name: Vignette + m_EditorClassIdentifier: + active: 1 + color: + m_OverrideState: 0 + m_Value: {r: 0, g: 0, b: 0, a: 1} + center: + m_OverrideState: 0 + m_Value: {x: 0.5, y: 0.5} + intensity: + m_OverrideState: 1 + m_Value: 0.207 + smoothness: + m_OverrideState: 0 + m_Value: 0.2 + rounded: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &7888073279915774665 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae2b217974b749d4b97b47bae772aee5, type: 3} + m_Name: NiloToonMotionBlurVolume + m_EditorClassIdentifier: + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 1 +--- !u!114 &8623061367897789741 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8a10bd7999fb5fe43ab7b08bda3fe53f, type: 3} + m_Name: NiloToonBloomVolume + m_EditorClassIdentifier: + active: 1 + threshold: + m_OverrideState: 1 + m_Value: 0.75 + intensity: + m_OverrideState: 1 + m_Value: 4 + scatter: + m_OverrideState: 1 + m_Value: 0.7 + tint: + m_OverrideState: 0 + m_Value: {r: 1, g: 0.9, b: 0.9, a: 1} + clamp: + m_OverrideState: 1 + m_Value: 500 + highQualityFiltering: + m_OverrideState: 1 + m_Value: 1 + downscale: + m_OverrideState: 0 + m_Value: 0 + maxIterations: + m_OverrideState: 0 + m_Value: 8 + dirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + dirtIntensity: + m_OverrideState: 0 + m_Value: 0 + characterBaseColorBrightness: + m_OverrideState: 0 + m_Value: 1 + characterBrightness: + m_OverrideState: 1 + m_Value: 0.65 + characterPreTonemapBrightness: + m_OverrideState: 0 + m_Value: 0.95 + characterAreaBloomEmitMultiplier: + m_OverrideState: 1 + m_Value: 1 + characterAreaOverridedThreshold: + m_OverrideState: 1 + m_Value: 0.5 + characterAreaOverridedIntensity: + m_OverrideState: 1 + m_Value: 1 + HueOffset: + m_OverrideState: 0 + m_Value: 0 + SaturationBoost: + m_OverrideState: 1 + m_Value: 0.25 + ValueMultiply: + m_OverrideState: 0 + m_Value: 1 + ApplyHSVToCharAreaOnly: + m_OverrideState: 0 + m_Value: 1 + renderTextureOverridedToFixedHeight: + m_OverrideState: 1 + m_Value: 2160 diff --git a/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta new file mode 100644 index 0000000..5520833 --- /dev/null +++ b/Assets/External/NiloToonURP/Runtime/VolumePresetPicker/VolumeProfilePresets/Nilo031-Concert008_StyleDark_ACES_AutoLightDir_MotionBlur(NiloToonVolumePreset).asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 619cf9ad7e2b4dc40bad034744267fe2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloOutlineUtil.hlsl b/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloOutlineUtil.hlsl index 9b01ca5..6a25ac2 100644 --- a/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloOutlineUtil.hlsl +++ b/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloOutlineUtil.hlsl @@ -33,6 +33,34 @@ float ApplyOutlineFadeOutOrthoCamera(float inputMulFix) // but here we are not remapping HDR color, we are remapping outline width return min(2,inputMulFix); } + +float SmoothClamp(float x, float max, float smoothness) +{ + // concert min(max,x) to a smooth curve + + // smoothness > 0, larger = smoother transition + // when smoothness = 1, basic smooth curve + // when smoothness = 0.2, reaches max faster + // when smoothness = 5, reaches max much later + return max * (1 - exp(-x/(max * smoothness))); +} +float SmoothClampB(float x, float cameraFov) +{ + float delayStart = 60.0 / cameraFov; + + if (x <= delayStart) + { + // Linear part for x between 0 and delayStart + return x; + } + + // Non-linear part for x > delayStart + // Using a modified logarithmic function for slower decay + float a = delayStart; // Value at x = delayStart + float b = 0.5; // Controls how quickly the curve flattens (smaller value for slower decay) + return a + log(1.0 + (x - delayStart) * b) / b; +} + float GetOutlineCameraFovAndDistanceFixMultiplier(float positionVS_Z, float cameraFOV, float applyPercentage) { float outlineWidthMulFix; @@ -66,6 +94,24 @@ float GetOutlineCameraFovAndDistanceFixMultiplier(float positionVS_Z, float came // allow user to select applying how much of this auto outline width adjustment(this function) outlineWidthMulFix = lerp(60,outlineWidthMulFix, saturate(applyPercentage)); + //---------------------------------------------------------------- + // Experimental method override + // The original method maybe weird and old, here is another attempt to improve it + // TODO: make it optional for user, expose smoothness + /* + float x = 1.0/abs(UNITY_MATRIX_P[1][1]) * 120; + if(IsPerspectiveProjection()) x *= abs(positionVS_Z); + outlineWidthMulFix = SmoothClamp(x, 120, 1); + */ + //---------------------------------------------------------------- + + //---------------------------------------------------------------- + // GGX example code + // https://game.watch.impress.co.jp/docs/kikaku/1617901.html + // https://game.watch.impress.co.jp/img/gmw/docs/1617/901/html/11_o.jpg.html + //outlineWidthMulFix = 1.0 / UNITY_MATRIX_P[0][0] * 60 * abs(positionVS_Z); // const width no matter distance or fov, unclamped. not sure if they want P[0][0] or P[1][1] + //---------------------------------------------------------------- + return outlineWidthMulFix * 0.00005; // mul a const to make return result = default normal expand amount WS } diff --git a/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloStrandSpecular.hlsl b/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloStrandSpecular.hlsl index b0bece7..6543690 100644 --- a/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloStrandSpecular.hlsl +++ b/Assets/External/NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloStrandSpecular.hlsl @@ -7,21 +7,22 @@ // doing this can make sure your .hlsl's user can include this .hlsl anywhere anytime without producing any multi include conflict #pragma once +// note: we have received bug report about random NaN pixel in 2025-2, so we force all StrandSpecular code to use float instead of half // reference: From mobile to high-end PC: Achieving high quality anime style rendering on Unity (https://youtu.be/egHSE0dpWRw?t=1222) -half3 ShiftTangent(half3 T, half3 N, half uvX, half frequency = 750, half shift = 0.015, half offset = 0) +float3 ShiftTangent(float3 T, float3 N, float uvValue, float frequency = 750, float shift = 0.015, float offset = 0) { //distort T without texture read - float ALU_shift = sin(uvX * frequency) * shift + offset; + float ALU_shift = sin(uvValue * frequency) * shift + offset; return normalize(T + ALU_shift * N); } // https://web.engr.oregonstate.edu/~mjb/cs519/Projects/Papers/HairRendering.pdf - page 10 & 11 -half StrandSpecular(half3 T, half3 H, half exponent) +float StrandSpecular(float3 T, float3 H, float exponent) { - half dotTH = dot(T,H); - half sinTH = sqrt(1-dotTH*dotTH); - half dirAtten = smoothstep(-1,0,dotTH); - return dirAtten *pow(sinTH,exponent); + float dotTH = dot(T,H); + float sinTH = SafeSqrt(1-dotTH*dotTH); + float dirAtten = smoothstep(-1.0,0.0,dotTH); + return dirAtten * SafePositivePow_float(sinTH,exponent); } ///////////////////////////////////////////////////////////////////////////////// // helper functions diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter.shader b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter.shader index 83c0f6e..3d4d507 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter.shader +++ b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter.shader @@ -99,6 +99,7 @@ because: - https://medium.com/@jasonbooth_86226/branching-on-a-gpu-18bfc83694f2 - https://medium.com/@jasonbooth_86226/stalling-a-gpu-7faac66b11b9 - https://forum.unity.com/threads/branching-in-shaders.1231695/ + - https://iquilezles.org/articles/gpuconditionals/ [TLDR] Just remember(even for mobile platform): @@ -232,7 +233,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // For URP Lit shader's naming convention, see URP's Lit.shader (search "Lit t:shader" in the project window, use "Search: In Packages") // [about HDR color picker] - // All color properties in this shader are HDR, because we don't want to limit user's creativity, even if HDR color makes no sense at all. + // Most color properties in this shader are HDR, because we don't want to limit user's creativity, even if HDR color makes no sense at all. // If user want to make a 100% non-sense color choice, for example, an emissive shadow, just let them do it! // because why not? It is NPR, unlike PBR, there is no right or wrong, everything is permitted and valid if it looks good. // *Adding [HDR] will force unity to treat the color as linear, be careful. @@ -452,7 +453,10 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Helpbox()] [Helpbox(Please set Depth Priming Mode to Disabled in Universal Renderer.)] - //[Title(_IsFaceGroup, Mask)] + [Title(_IsFaceGroup,Face Normal)] + [Sub(_IsFaceGroup)]_FixFaceNormalAmountPerMaterial("Face Normal fix", Range(0,1)) = 1 + + [Title(_IsFaceGroup, Mask)] [Tooltip(If this material contains face and other non face parts together,)] [Tooltip(you can enable this toggle to make this section masked by Mask Map.)] [SubToggle(_IsFaceGroup,_FACE_MASK_ON)]_UseFaceMaskMap("Enable Mask?", Float) = 0 @@ -520,7 +524,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(. Front . Renders the front face of your geometry and culls the back face. This is the default setting.)] [Tooltip(. Back . Renders the back face of your geometry and culls the front face.)] [Tooltip(. Both . Renders both faces of the geometry, this is good for flat objects with single face polygon, like cloth and hair, where you might want both sides visible.)] - [SubEnum(_RenderFaceGroup,Front,2,Back,1,Both,0)]_Cull(" Lit pass", Float) = 2 + [SubEnum(_RenderFaceGroup,Front,2,Back,1,Both,0)]_Cull(" Lit pass", Float) = 2.0 [Advanced] [Tooltip(Use this dropdown to determine which sides of the outline geometry to render.)] @@ -561,6 +565,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(Many realtime application and games use this classic outline method also (e.g. Guilty Gear Xrd, Genshin Impact, VRM MToon))] [Tooltip()] [Tooltip(NiloToon improve this outline method by using an auto generated smoothed normal for extrude direction instead of lighting normal, and adding outline Z Offset, which will produce a much better outline result.)] + [PassSwitch(NiloToonOutline)] [Main(_RENDER_OUTLINE,_)]_RenderOutline("Classic Outline", Float) = 1 [Helpbox(When enabled, this material will produce a classic outline by redrawing the mesh with inverted culling and a slight extrusion based on the outline width.)] @@ -593,11 +598,12 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(The width of outline, usually it is between 0 to 1.)] [Tooltip()] [Tooltip(If you convert a material from VRM MToon or lilToon to NiloToon, NiloToon will keep the outline width from previous shader here. Then you should keep this Width untouched, and edit the below Width(extra) instead. This way you can preserve the outline width from previous shader.)] - [Sub(_RENDER_OUTLINE)]_OutlineWidth("Width", Range(0,32)) = 0.6 + [Sub(_RENDER_OUTLINE)]_OutlineWidth("Width", Range(0,32)) = 0.5 // default 0.5, a conservative outline width for VTuber model [Tooltip(Just like the Width above, this width serves as an additional multiplier control for convenience.)] [Tooltip(Sometimes when you convert a material from another shader (e.g. VRM MToon) to NiloToon, the width from previous shader is stored in the above Width, then you can use this slider to do any extra width multiplier control without editing the above Width(_OutlineWidth).)] [Tooltip(. For VRM0.x MToon converted materials, 12 to 18 is a good starting point)] [Tooltip(. For VRM1.0 MToon converted materials, 512 is a good starting point)] + [Tooltip(. For lilToon converted materials, 4 is a good starting point)] [Sub(_RENDER_OUTLINE)]_OutlineWidthExtraMultiplier("Width(extra)", Range(0,2048)) = 1 [Title(_RENDER_OUTLINE, Width Mask(Texture))] @@ -758,13 +764,16 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Title(_DepthTextureRimLightAndShadowGroup, Width)] [Tooltip(This width slider will control the width of both Depth Texture rim light and shadow together)] - [AdvancedHeaderProperty][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightAndShadowWidthMultiplier("Width Multiplier", Range(0,4)) = 0.6 + [AdvancedHeaderProperty][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightAndShadowWidthMultiplier("Width Multiplier", Range(0,4)) = 0.5 [Tooltip(This width slider serves as an additional multiplier, same as the Width Multiplier above, but it is provided for convenience.)] [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightAndShadowWidthExtraMultiplier("Width Multiplier(extra)", Range(0,4)) = 1 [Tooltip(When pixel to camera distance is less than 1,)] [Tooltip(increase this value towards 1 to reduce the width of rim light and shadow more.)] [Tooltip(reduce this value towards 0 to not reduce the width of rim light and shadow.)] [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightAndShadowReduceWidthWhenCameraIsClose("Near Cam Reduce Width", Range(0,1)) = 1 + [Tooltip(When camera is closer than this distance, the width will become conservative and safe, not auto adjust anymore)] + [Tooltip(Increase this when you find that the width become too large when looking closeup, and you want to make it not that large when looking closeup.)] + [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightAndShadowSafeViewDistance("Safe View Distance(m)", Range(1,10)) = 1 [Title(_DepthTextureRimLightAndShadowGroup,Width Mask (Texture))] [Tooltip(Enable to multiply the width of rim light and shadow by a texture)] @@ -786,7 +795,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Title(_DepthTextureRimLightAndShadowGroup, Style)] [Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightIgnoreLightDir("360 Rim light", Range(0,1)) = 0 - [Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexShadowIgnoreLightDir("360 Shadow (experimental)", Range(0,1)) = 0 + [Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexShadowIgnoreLightDir("360 Shadow (deprecated)", Range(0,1)) = 0 [Title(_DepthTextureRimLightAndShadowGroup, Style (face))] [Tooltip(When set to 1, the face 2D shadow will be static on the face, ignoring light direction)] @@ -826,6 +835,13 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(. 1 means fully multiply BaseMap color into rim light color)] [Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightMixWithBaseMapColor(" Mix with Base Map", Range(0,1)) = 0.5 + [Title(_DepthTextureRimLightAndShadowGroup, . Rim Light 3D Rim mask)] + [Tooltip(Mask the rim light result by a classic 3D fresnel rim light mask.)] + [Tooltip(Enable this may produce better rim light result for small objects like finger or accessory.)] + [SubToggle(_DepthTextureRimLightAndShadowGroup,_)]_DepthTexRimLight3DRimMaskEnable(" Enable?", Float) = 0 + [Helpbox(Recommend to enable for small objects like finger or accessory)] + [Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLight3DRimMaskThreshold(" threshold", Range(0,1)) = 0.5 + [Title(_DepthTextureRimLightAndShadowGroup, Rim Light Area)] [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightBlockByShadow("Block by Shadow", Range(0,1)) = 0 [Tooltip(A positive bias will make 2D rim light occlude by nearby objects easier (removing more inner 2D rim light), great for producing a clean silhouette only rim light)] @@ -836,12 +852,6 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightThresholdOffset("Occlusion bias", Range(-1,1)) = 0 [Tooltip(Rim light will fadeout softly when a nearby occulder appears, you can control the fadeout softness.)] [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLightFadeoutRange("Fadeout Softness", Range(0.01,10)) = 1 - - [Title(_DepthTextureRimLightAndShadowGroup, Rim Light 3D Rim mask)] - [Tooltip(Mask the rim light result by a classic 3D fresnel rim light mask.)] - [Tooltip(Enable this may produce better rim light result for small objects like finger or accessory.)] - [Advanced][SubToggle(_DepthTextureRimLightAndShadowGroup,_)]_DepthTexRimLight3DRimMaskEnable("Enable?", Float) = 0 - [Advanced][Sub(_DepthTextureRimLightAndShadowGroup)]_DepthTexRimLight3DRimMaskThreshold(" threshold", Range(0,1)) = 0.5 [Title(_DepthTextureRimLightAndShadowGroup, Rim Light artifacts fix)] [Tooltip(. Turn on will remove most of the rim light artifacts, but it is much slower to render.)] @@ -1036,6 +1046,10 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Title(_LightingStyleGroup,Main Light Shadow remove)] [Tooltip(Increase this a bit can produce fake SSS, or fake indirect light.)] [Sub(_LightingStyleGroup)]_MainLightIgnoreCelShade("Remove Shadow", Range(0,1)) = 0 + + [Title(_LightingStyleGroup,Main Light Shading Normal)] + [Sub(_LightingStyleGroup)]_MainLightSkinDiffuseNormalMapStrength("NormalMap strength (Skin)", Range(0,1)) = 1 + [Sub(_LightingStyleGroup)]_MainLightNonSkinDiffuseNormalMapStrength("NormalMap strength (Non-Skin)", Range(0,1)) = 1 [Title(_LightingStyleGroup, ........................................................................................................................................................................................................................................................................................................................................................................)] @@ -1311,7 +1325,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(. One,Zero for Opaque.)] [Tooltip(. SrcAlpha,OneMinusSrcAlpha for Semi Transparency.)] [Tooltip(. One,One for Additive.)] - [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_SrcBlend(". Source Factor", Float) = 1 + [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_SrcBlend(". Source Factor", Float) = 1.0 // Destination Factor [Tooltip(In most cases, you do NOT need to edit this, since selecting a Surface Type Preset will handle this for you already.)] [Tooltip()] @@ -1322,9 +1336,17 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(. One,Zero for Opaque.)] [Tooltip(. SrcAlpha,OneMinusSrcAlpha for Semi Transparency.)] [Tooltip(. One,One for Additive.)] - [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_DstBlend(". Destination Factor", Float) = 0 + [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_DstBlend(". Destination Factor", Float) = 0.0 [SubToggle(_ColorRenderStatesGroup, _)]_PreMultiplyAlphaIntoRGBOutput(". Pre Multiply Alpha to RGB?", Float) = 0 + + [Title(_ColorRenderStatesGroup, Blend Op)] + [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendOp)]_BlendOp(". Blend Op", Float) = 0.0 + + [Title(_ColorRenderStatesGroup, Blend Setting Alpha)] + // Alpha Op set to "One OneMinusSrcAlpha" (or "OneMinusDstAlpha One" is also correct), so semi-transparent material can update RenderTarget's a correctly, see https://twitter.com/MuRo_CG/status/1511543317883863045 + [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_SrcBlendAlpha(". Source Factor", Float) = 1.0 + [SubEnumDrawer(_ColorRenderStatesGroup,UnityEngine.Rendering.BlendMode)]_DstBlendAlpha(". Destination Factor", Float) = 10.0 [Title(_ColorRenderStatesGroup,Color Mask)] // https://docs.unity3d.com/Manual/SL-ColorMask.html @@ -1364,7 +1386,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(. If disabled, this material does NOT write into the depth buffer.)] [Tooltip()] [Tooltip(Changing Surface Type Preset will turn this off if the selected preset is Transparent (without ZWrite).)] - [SubToggle(_DepthRenderStatesGroup,_)]_ZWrite("Write to depth buffer?", Float) = 1 + [SubToggle(_DepthRenderStatesGroup,_)]_ZWrite("Write to depth buffer?", Float) = 1.0 [Title(_DepthRenderStatesGroup,ZTest)] // https://docs.unity3d.com/Manual/SL-ZTest.html @@ -1434,6 +1456,13 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(Setting to 1 may prevent the problem of see through all hairs inside semi transparent front hair, while viewed at some non front camera angle.)] [Sub(_BaseMapAlphaOverrideGroup)]_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCamera("Is front hair? (see Tooltip)", Range(0.0, 1.0)) = 0 + [Advanced(Semi transparent front hair)] + [MinMaxSlider(_BaseMapAlphaOverrideGroup,_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapStart,_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapEnd)]_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapMinMaxSlider(" Remap", Range(0.0,1.0)) = 1.0 + [Advanced(Semi transparent front hair)] + [HideInInspector]_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapStart("", Range(0.0,1.0)) = 0.0 + [Advanced(Semi transparent front hair)] + [HideInInspector]_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapEnd("", Range(0.0,1.0)) = 1.0 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Alpha Clipping ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1442,7 +1471,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(Enable this will make your Material act like a Cutout Shader. Use this to create a transparent effect with hard edges between the opaque and transparent areas.)] [Tooltip()] [Tooltip(For example, adding lace holes or cutout to an Opaque cloth material.)] - [Main(_AlphaClippingGroup,_ALPHATEST_ON)]_AlphaClip("Alpha Clipping", Float) = 0 + [Main(_AlphaClippingGroup,_ALPHATEST_ON)]_AlphaClip("Alpha Clipping", Float) = 0.0 [Helpbox(Same as the Alpha Clipping of URP Lit shader.)] @@ -3207,7 +3236,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(You can use the Smoothness slider to control the spread of highlights on the surface. 0 gives a wide, rough highlight. 1 gives a small, sharp highlight like glass. Values in between produce semi glossy looks. For example, 0.5 produces a plastic like glossiness.)] [Tooltip()] [Tooltip(Smoothness equals One minus Roughness.)] - [Sub(_SmoothnessGroup)]_Smoothness("Smoothness", Range(0,1)) = 0.5 + [Sub(_SmoothnessGroup)]_Smoothness("Smoothness", Range(0.0,1.0)) = 0.5 [Title(_SmoothnessGroup, ........................................................................................................................................................................................................................................................................................................................................................................)] @@ -3409,6 +3438,13 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Title(_KAJIYAKAY_SPECULAR,. UV Tiling(XY) Offset(ZW))] [Sub(_KAJIYAKAY_SPECULAR)]_HairStrandSpecularTintMapTilingXyOffsetZw("", Vector) = (1,1,0,0) + [Title(_KAJIYAKAY_SPECULAR, ........................................................................................................................................................................................................................................................................................................................................................................)] + + [Title(_KAJIYAKAY_SPECULAR, UV option)] + [Tooltip(Select a target UV for hair specular calculation.)] + [SubEnum(_KAJIYAKAY_SPECULAR,UV0,0,UV1,1,UV2,2,UV3,3)]_HairStrandSpecularUVIndex("UV index", Float) = 0 + [SubEnum(_KAJIYAKAY_SPECULAR,X,0,Y,1)]_HairStrandSpecularUVDirection("UV Direction", Float) = 0 + [Title(_KAJIYAKAY_SPECULAR, ........................................................................................................................................................................................................................................................................................................................................................................)] [Title(_KAJIYAKAY_SPECULAR, Shape)] @@ -3701,6 +3737,23 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Main(_ClothDynamicsGroup,_NILOTOON_SUPPORT_CLOTHDYNAMICS)]_SupportClothDynamics("Support 'Cloth Dynamics'", Float) = 0 [Title(_ClothDynamicsGroup, No options for this group.)] + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + [Title(Decal)] + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + [ShowIf(_UIDisplayMode, GEqual, 200)] + [Tooltip(In most cases, you do NOT need to edit this section.)] + [Tooltip(But in some situations, you may want to disable decal of this material for visual reason.)] + [Main(_DecalGroup,_,off,off)]_DecalGroup("Decal", Float) = 0 + [Sub(_DecalGroup)]_DecalAlbedoApplyStrength("Albedo", Range(0,1)) = 1 + [Sub(_DecalGroup)]_DecalNormalApplyStrength("Normal", Range(0,1)) = 1 + [Sub(_DecalGroup)]_DecalOcclusionApplyStrength("Occlusion", Range(0,1)) = 1 + [Sub(_DecalGroup)]_DecalSmoothnessApplyStrength("Smoothness", Range(0,1)) = 1 + [Sub(_DecalGroup)]_DecalSpecularApplyStrength("Specular", Range(0,1)) = 1 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3717,28 +3770,82 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" [Tooltip(But in some situations, you may want to disable rendering a shader pass of this material for performance or visual reason.)] [Main(_PassOnOffGroup,_,off,off)]_PassOnOffGroup("Allowed Pass", Float) = 0 - [Title(_PassOnOffGroup, URP pass)] + [Helpbox(Disabling pass will reduce drawcall and GPU workload.)] + [Helpbox(The following passes will not reduce drawcall,)] + [Helpbox(. NiloToonExtraThickOutline)] + [Helpbox(. NiloToonCharacterAreaStencilBufferFill)] + [Helpbox(. NiloToonCharacterAreaColorFill)] + [Helpbox()] + [Helpbox(To disable NiloToonOutline pass, turn off Classic Outline group instead.)] + + [Title(_PassOnOffGroup, URP passes)] + + [Tooltip(Enable to allow drawing shader pass with LightMode UniversalForwardOnly.)] + [Tooltip()] + [Tooltip(If you turn this off, NiloToon will not draw surface color pass of this material into any URP color buffer.)] + [Tooltip(In that case, you should also disable Classic Outline group since outline relies on surface color pass, else you want have a wrong rendering classic outline shell.)] + [PassSwitch(UniversalForwardOnly)] + [SubToggle(_PassOnOffGroup,_)]_AllowRenderURPUniversalForwardOnlyPass("UniversalForwardOnly", Float) = 1 + + // Classic Outline's PassSwitch is located at "Classic Outline" group's _RenderOutline property + //[PassSwitch(NiloToonOutline)] + //... + [Tooltip(Enable to allow drawing shader pass with LightMode ShadowCaster.)] [Tooltip()] [Tooltip(If you turn this off, NiloToon will not draw this material into any URP shadowmaps.)] + [PassSwitch(ShadowCaster)] [SubToggle(_PassOnOffGroup,_)]_AllowRenderURPShadowCasterPass("ShadowCaster", Float) = 1 - [Tooltip(Enable to allow drawing shader pass with LightMode DepthOnly or DepthNormals.)] + + [Tooltip(Enable to allow drawing shader pass with LightMode DepthOnly or DepthNormalsOnly.)] [Tooltip()] - [Tooltip(If you turn this off, NiloToon will not draw this material into any URP _CameraDepthTexture or _CameraNormalTexture.)] - [SubToggle(_PassOnOffGroup,_)]_AllowRenderDepthOnlyOrDepthNormalsPass("DepthOnly/DepthNormals", Float) = 1 + [Tooltip(If you turn this off, NiloToon will not draw this material into any URP prepass _CameraDepthTexture or _CameraNormalTexture.)] + [PassSwitch(DepthOnly,DepthNormalsOnly)] + [SubToggle(_PassOnOffGroup,_)]_AllowRenderDepthOnlyOrDepthNormalsPass("DepthOnly / DepthNormalsOnly", Float) = 1 + + [Tooltip(Enable to allow drawing shader pass with LightMode MotionVectors or XRMotionVectors.)] + [Tooltip()] + [Tooltip(If you turn this off, NiloToon will not draw this material into any URP MotionVector RT.)] + [PassSwitch(MotionVectors,XRMotionVectors)] + [SubToggle(_PassOnOffGroup,_)]_AllowRenderMotionVectorsPass("MotionVectors / XRMotionVectors", Float) = 1 [Title(_PassOnOffGroup, ........................................................................................................................................................................................................................................................................................................................................................................)] - [Title(_PassOnOffGroup, NiloToon pass)] + [Title(_PassOnOffGroup, NiloToon passes)] + [Tooltip(Enable to allow drawing shader pass with LightMode NiloToonSelfShadowCaster.)] [Tooltip()] [Tooltip(If you turn this off, NiloToon will not draw this material into any NiloToon self shadowmaps.)] + [PassSwitch(NiloToonSelfShadowCaster)] [SubToggle(_PassOnOffGroup,_)]_AllowRenderNiloToonSelfShadowPass("NiloToonSelfShadowCaster", Float) = 1 + + [Tooltip(Enable to allow drawing shader pass with LightMode NiloToonPrepassBuffer.)] + [Tooltip()] + [Tooltip(If you turn this off, NiloToon will not draw this material into the NiloToon prepass buffer RT.)] + [PassSwitch(NiloToonPrepassBuffer)] + [SubToggle(_PassOnOffGroup,_)]_AllowRenderNiloToonPrepassBufferPass("NiloToonPrepassBuffer", Float) = 1 + [Tooltip(Enable to allow drawing shader pass with LightMode NiloToonExtraThickOutline.)] [Tooltip()] - [Tooltip(If you turn this off, NiloToon will not draw this material when drawing extra thick outline.)] + [Tooltip(If you turn this off, NiloToon will still draw this material when drawing extra thick outline.)] + [Tooltip(It will only discard all vertex when drawing, but not actually remove the drawcall.)] + // [PassSwitch(xxx)] // no pass switch is needed! Since the pass on/off is controlled by NiloToonPerCharacterRenderController script [SubToggle(_PassOnOffGroup,_)]_AllowRenderExtraThickOutlinePass("NiloToonExtraThickOutline", Float) = 1 - + + [Tooltip(Enable to allow drawing shader pass with LightMode NiloToonCharacterAreaStencilBufferFill.)] + [Tooltip()] + [Tooltip(If you turn this off, NiloToon will still draw this material when drawing NiloToonCharacterAreaStencilBufferFill.)] + [Tooltip(It will only discard all vertex when drawing, but not actually remove the drawcall.)] + // [PassSwitch(xxx)] // no pass switch is needed! Since the pass on/off is controlled by NiloToonPerCharacterRenderController script + [SubToggle(_PassOnOffGroup,_)]_AllowRenderNiloToonCharacterAreaStencilBufferFillPass("NiloToonCharacterAreaStencilBufferFill", Float) = 1 + + [Tooltip(Enable to allow drawing shader pass with LightMode NiloToonCharacterAreaColorFill.)] + [Tooltip()] + [Tooltip(If you turn this off, NiloToon will still draw this material when drawing NiloToonCharacterAreaColorFill.)] + [Tooltip(It will only discard all vertex when drawing, but not actually remove the drawcall.)] + // [PassSwitch(xxx)] // no pass switch is needed! Since the pass on/off is controlled by NiloToonPerCharacterRenderController script + [SubToggle(_PassOnOffGroup,_)]_AllowRenderNiloToonCharacterAreaColorFillPass("NiloToonCharacterAreaColorFill", Float) = 1 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Set by script ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3803,13 +3910,11 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // per char center [HideInInspector]_CharacterBoundCenterPosWS("_CharacterBoundCenterPosWS", Vector) = (0,0,0) [HideInInspector]_CharacterBoundRadius("_CharacterBoundRadius", Float) = 1.25 - - // EnableDepthTextureRimLightAndShadow - [HideInInspector]_NiloToonEnableDepthTextureRimLightAndShadow("_NiloToonEnableDepthTextureRimLightAndShadow", Float) = 0 // dither fadeout [HideInInspector]_DitherFadeoutAmount("_DitherFadeoutAmount", Range(0,1)) = 0 [HideInInspector]_DitherFadeoutNormalScaleFix("_DitherFadeoutNormalScaleFix", Range(0,16)) = 1 + // dissolve [HideInInspector]_DissolveAmount("_DissolveAmount", Range(0,1)) = 0 [HideInInspector]_DissolveMode("_DissolveMode", Integer) = 0 // if C# uses Material.SetInt(), then shader must use Integer instead of Float in shader @@ -3849,51 +3954,45 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // These lines are disabled, which means let these passes = default on, in order to make using these features in edit mode possible. - // But comes with a disadvantage of "always drawing these passes" in edit mode(non-material instanced mode) even user don't need it, - // disadvantages are: + // But comes with a disadvantage of "always drawing these passes" in edit mode(non-material instanced mode) even user don't need it. + // Disadvantages are: // - edit mode performance is slower due to drawing useless pass // - edit mode frame debugger is polluted by these passes due to drawing useless pass //[PassSwitch(NiloToonCharacterAreaStencilBufferFill)]_EnableNiloToonCharacterAreaStencilBufferFill("", Float) = 0 //[PassSwitch(NiloToonExtraThickOutline)]_EnableNiloToonExtraThickOutline("", Float) = 0 //[PassSwitch(NiloToonCharacterAreaColorFill)]_EnableNiloToonCharacterAreaColorFill("", Float) = 0 - + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // URP Complex Lit shader properties + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //[HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 // Not yet supported + [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 + [HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1.0 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Unsupported BRP properties ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// [HideInInspector]_MainTex("_MainTex", 2D) = "White" {} } SubShader - { - Tags + { + // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings + // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this + // material work with both Universal Render Pipeline and Builtin Unity Pipeline + Tags { + "RenderType" = "Opaque" + // SRP introduced a new "RenderPipeline" tag in Subshader. This allows you to create shaders // that can match multiple render pipelines. If a RenderPipeline tag is not set it will match // any render pipeline. In case you want your SubShader to only run in URP, set the tag to // "UniversalPipeline" - // Universal Pipeline tag is required. because we only want this shader to run in URP. - // If Universal render pipeline is not set in the graphics settings, this SubShader will fail. - - // One can add a SubShader below or fallback to Standard built-in to make this - // material work with both Universal Render Pipeline and Builtin Unity Pipeline - // The tag value is "UniversalPipeline", not "UniversalRenderPipeline", be careful! // see -> https://github.com/Unity-Technologies/Graphics/pull/1431/ "RenderPipeline" = "UniversalPipeline" - - // [need ShaderModel 4.5 because of SRP-batcher] - // URP's ComplexLit.shader also require ShaderModel 4.5 - // ShaderModel 4.5 = OpenGL ES 3.1 capabilities (DX11 SM5.0 on D3D platforms, just without tessellation shaders) - // Not supported on DX11 before SM5.0, OpenGL before 4.3 (i.e. Mac), OpenGL ES 2.0/3.0. - // Supported on DX11+ SM5.0, OpenGL 4.3+, OpenGL ES 3.1, Metal, Vulkan, PS4/XB1 consoles. - // Has compute shaders, random access texture writes, atomics and so on. No geometry or tessellation shaders. - // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - "ShaderModel"="4.5" - - // explicit SubShader tag to avoid confusion - "RenderType"="Opaque" - "UniversalMaterialType" = "ComplexLit" // "UniversalMaterialType" is only used in deferred rendering, where each type of material are marked by stencil. If this tag is not set in a Pass, Unity uses the Lit value. + "UniversalMaterialType" = "ComplexLit" // "UniversalMaterialType" is only used in deferred rendering, where each type of material are marked by stencil. If this tag is not set in a Pass, Unity uses the Lit value. "IgnoreProjector" = "True" "Queue"="Geometry" } @@ -3901,13 +4000,14 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // No LOD defined //LOD 300 + //============================================================================================================================================ // We can extract duplicated hlsl code from all passes into this HLSLINCLUDE section to reduce duplicated code. - // All Passes will use these keywords + // All Passes will use these keywords. HLSLINCLUDE // these can affact alpha, which affects alpha clipping result, so they are required by all passes #pragma shader_feature_local_fragment _ALPHAOVERRIDEMAP - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON // MotionVector pass need this in vertex shader, so we can't use shader_feature_local_fragment here #pragma shader_feature_local_fragment _BASEMAP_STACKING_LAYER1 #pragma shader_feature_local_fragment _BASEMAP_STACKING_LAYER2 @@ -3929,14 +4029,16 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #pragma shader_feature_local USE_BUFFERS // set by Unity AssetStore asset "ClothDynamics"'s GPUClothDynamics.cs script // [NVIDIA Nsight shader profiling] - // you can enable these 2 lines when you want to use shader profiler in NVIDIA Nsight Graphics - // WARNING: DO NOT enable these on any public release! Doing that will leak the hlsl source code completely + // you can enable these 2 lines when you want to use 'shader profiler' in NVIDIA Nsight Graphics + // WARNING: DO NOT enable these for any public release build! Doing that will leak the hlsl source code completely //#pragma enable_d3d11_debug_symbols //#pragma use_dxc ENDHLSL + //============================================================================================================================================ // [#0 Pass - ForwardLit] + // ------------------------------------------------------------------ // Forward only pass. // Acts also as an opaque forward fallback for deferred rendering. @@ -3944,29 +4046,34 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // Compared to the Builtin pipeline forward renderer, URP forward renderer will // render a scene with multiple lights(additional light) with fewer draw calls and less overdraw. Pass - { + { + // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with + // no LightMode tag are also rendered by Universal Render Pipeline Name "ForwardLit" Tags { - // "Lightmode" matches the "ShaderPassName" set in UniversalRenderPipeline.cs. - // SRPDefaultUnlit and passes with no LightMode tag are also rendered by Universal Render Pipeline - - // In this pass, - // -For Unity2020.3 or below(Support of Unity2020.3 was removed since NiloToon 0.12.1), "Lightmode" tag must be "UniversalForward" in order to render lit objects by URP's ForwardRenderer. - // -For Unity2021.3 or above, "Lightmode" tag must be "UniversalForwardOnly" in order to render lit objects by URP's ForwardRendering. - // see "ShaderLab Pass tags" in https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/rendering/deferred-rendering-path.html + // About "UniversalForwardOnly", see "ShaderLab Pass tags" in: + //- https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/rendering/deferred-rendering-path.html#shaderlab-pass-tags + //- https://docs.unity3d.com/6000.2/Documentation/Manual/urp/urp-shaders/urp-shaderlab-pass-tags.html + //- https://docs.unity3d.com/6000.2/Documentation/Manual/urp/rendering/make-shader-compatible-with-deferred.html "LightMode" = "UniversalForwardOnly" } - // Render state (URP's ComplexLit.shader) - Blend [_SrcBlend] [_DstBlend] , One OneMinusSrcAlpha // Alpha Op set to "One OneMinusSrcAlpha" (or "OneMinusDstAlpha One" is also correct), so semi-transparent material can update RenderTarget's a correctly, see https://twitter.com/MuRo_CG/status/1511543317883863045 - ZWrite [_ZWrite] - Cull [_Cull] + // ------------------------------------- + // Render State Commands + // ------------------------------------- + Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] + ZWrite[_ZWrite] + Cull[_Cull] + //AlphaToMask[_AlphaToMask] // NiloToon doesn't support. To make this work, see the 'Anti-aliased Alpha Test' note below - // Render state (NiloToon extra added) + // NiloToon added: + BlendOp [_BlendOp] ColorMask [_ColorMask] ZTest [_ZTest] + // [Anti-aliased Alpha Test note] + //-------------------------------------- // TODO: if you enabled MSAA, it is possible to have Anti-aliased Alpha Test result by using "Alpha To Coverage(AlphaToMask)" . // read "Anti-aliased Alpha Test: The Esoteric Alpha To Coverage" by Ben Golus // https://bgolus.medium.com/anti-aliased-alpha-test-the-esoteric-alpha-to-coverage-8b177335ae4f @@ -3986,9 +4093,10 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // 4. Order independent transparency - Approximation techniques like depth peeling that correctly sort overlapping transparent objects. Can be expensive. // 5. Temporal anti-aliasing (TAA) - A post-process effect that filters aliased edges over multiple frames. Works well but adds latency. // 6. Supersampling - Rendering at a higher resolution and downsampling can smooth aliased edges. Adds significant performance cost. + //-------------------------------------- // Let user fully control the 2nd-8th bit of stencil buffer per material, - // but leaving the 1st bit for NiloToon to write "Character or Classic Outline" area + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area // https://docs.unity3d.com/Manual/SL-Stencil.html Stencil { @@ -4000,21 +4108,25 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" } HLSLPROGRAM - - //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass - - // no need to target 4.5, all platforms will run the same Pass(including WebGL = maximum 3.5) + + // no need to target 2.0, all platforms will run the same Pass(including WebGL = maximum 3.5) // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - //#pragma target 4.5 + //#pragma target 2.0 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material Keywords (similar to URP's ComplexLit.shader's Material Keywords) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Shader Stages + // ------------------------------------- + #pragma vertex VertexShaderAllWork + #pragma fragment FragmentShaderAllWork + + // ------------------------------------- + // Material Keywords + // ------------------------------------- #pragma shader_feature_local _NORMALMAP // need TangentWS from vertex shader also, so shader_feature_local_fragment is not enough #pragma shader_feature_local _PARALLAXMAP // need TangentWS from vertex shader also, so shader_feature_local_fragment is not enough - #pragma shader_feature_local_fragment _RECEIVE_URP_SHADOW // URP ComplexLit.shader use _RECEIVE_SHADOWS_OFF to save a keyword, here we use an inverted keyword + #pragma shader_feature_local_fragment _RECEIVE_URP_SHADOW // URP ComplexLit.shader uses _RECEIVE_SHADOWS_OFF to save a keyword, here we use an inverted keyword - // URP ComplexLit.shader use _ _DETAIL_MULX2 _DETAIL_SCALED, here we simplify them into a single keyword _DETAIL to reduce variant. + // URP ComplexLit.shader uses _ _DETAIL_MULX2 _DETAIL_SCALED, here we simplify them into a single keyword _DETAIL to reduce variant. #pragma shader_feature_local _DETAIL // need TangentWS from vertex shader also, so shader_feature_local_fragment is not enough #pragma shader_feature_local_fragment _EMISSION @@ -4024,9 +4136,9 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_TEX_TINT #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS // URP ComplexLit.shader use _ENVIRONMENTREFLECTIONS_OFF to save a keyword, here we use an inverted keyword, here we use an inverted keyword since it is default off - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material keywords (NiloToon specific shader_feature) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // NiloToon keywords (shader_feature) + // ------------------------------------- #pragma shader_feature_local _ISFACE // can affect vertex shader, so shader_feature_local_fragment is not enough #pragma shader_feature_local _FACE_MASK_ON // can affect vertex shader, so shader_feature_local_fragment is not enough #pragma shader_feature_local_fragment _SKIN_MASK_ON @@ -4069,9 +4181,9 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #pragma shader_feature_local_fragment _FACE_SHADOW_GRADIENTMAP #pragma shader_feature_local_fragment _FACE_3D_RIMLIGHT_AND_SHADOW - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material keywords (NiloToon specific multi_compile) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // NiloToon keywords (multi_compile) + // ------------------------------------- #pragma multi_compile_fragment _ _NILOTOON_RECEIVE_URP_SHADOWMAPPING #pragma multi_compile_fragment _ _NILOTOON_RECEIVE_SELF_SHADOW #pragma multi_compile_local_fragment _ _NILOTOON_DITHER_FADEOUT @@ -4080,29 +4192,41 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #pragma multi_compile_fragment _ _NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE //#pragma multi_compile_fragment _ _NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE_V2 //WIP, temp disabled - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // NiloToon Material debug keywords (can strip when build) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // NiloToon keywords (debug only, can strip when build) + // ------------------------------------- #pragma multi_compile _ _NILOTOON_DEBUG_SHADING // multi_compile_fragment is not enough, because we need to transfer uv8 in vertex shader - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Universal Pipeline keywords (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Universal Pipeline keywords + // ------------------------------------- // These multi_compile variants are stripped from the build depending on: - // 1) Settings in the URP Asset assigned in the GraphicsSettings at build time - // e.g If you disabled AdditionalLights in the asset then all _ADDITIONA_LIGHTS variants + // 1) Settings in the URP Asset assigned in the GraphicsSettings & QualitySettings at build time + // For example, if you disabled AdditionalLights in the asset then all _ADDITIONA_LIGHTS variants // will be stripped from build - // 2) Invalid combinations are stripped. e.g variants with _MAIN_LIGHT_SHADOWS_CASCADE - // but not _MAIN_LIGHT_SHADOWS are invalid and therefore stripped. + // 2) Invalid combinations are stripped. + // For example, variants with _MAIN_LIGHT_SHADOWS_CASCADE but not _MAIN_LIGHT_SHADOWS are invalid and therefore stripped. // You can read URP's ShaderPreprocessor.cs (which implements interface IPreprocessShaders) to view URP's shader stripping logic - // [directly copied from URP14 ComplexLit.shader] + // [directly copied from Unity6.1 URP17 ComplexLit.shader] #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS - // #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX + //#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX + #pragma multi_compile _ _LIGHT_LAYERS + + // Starting from 6.1, _FORWARD_PLUS is replaced by _CLUSTER_LIGHT_LOOP + #if UNITY_VERSION >= 60000100 + #pragma multi_compile _ _CLUSTER_LIGHT_LOOP + #elif UNITY_VERSION >= 202220 + #pragma multi_compile _ _FORWARD_PLUS + #endif + #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #if UNITY_VERSION >= 60000100 + #pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS + #endif // [Hardcode define _SHADOWS_SOFT base on SHADER_API, instead of multi_compile, in order to reduce shader variant by 50%] // https://docs.unity3d.com/ScriptReference/Rendering.BuiltinShaderDefine.html @@ -4111,50 +4235,65 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #define _SHADOWS_SOFT 1 #endif - // [Character won't need lightmap related logic] - //#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // not sure if it is worth the compile time & memory, disabled now + //#pragma multi_compile_fragment _ _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH // TODO: not supported now, it may ruin visual style if we included SSAO in lighting, and will double the shader memory usage //#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION - // [directly copied from URP14 ComplexLit.shader] #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 - #pragma multi_compile_fragment _ _LIGHT_LAYERS #pragma multi_compile_fragment _ _LIGHT_COOKIES + #if UNITY_VERSION >= 202220 - #pragma multi_compile _ _FORWARD_PLUS + #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #endif - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Unity defined keywords (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Unity defined keywords + // ------------------------------------- // [Character won't need lightmap related logic] - //#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + //#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING //#pragma multi_compile _ SHADOWS_SHADOWMASK //#pragma multi_compile _ DIRLIGHTMAP_COMBINED //#pragma multi_compile _ LIGHTMAP_ON + //#pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING //#pragma multi_compile _ DYNAMICLIGHTMAP_ON + //#pragma multi_compile _ USE_LEGACY_LIGHTMAPS - //#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE // Not worth to support this since it cost 2x shader memory - #pragma multi_compile_fog + //#pragma multi_compile _ LOD_FADE_CROSSFADE // Not worth to support this since it cost 2x shader memory //#pragma multi_compile_fragment _ DEBUG_DISPLAY // NiloToon didn't implement URP's debug display - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // GPU Instancing (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // [fog] + // In NiloToon, we force dynamic_branch for fog if possible (dynamic_branch fog introduced in Unity6.1), + // - https://docs.unity3d.com/6000.2/Documentation/Manual/urp/shader-stripping-fog.html + // this trades a little bit GPU performance for cutting 50~75% memory usage and 2x~4x faster build time, which is worth it + #if UNITY_VERSION >= 60000100 + #pragma dynamic_branch _ FOG_LINEAR FOG_EXP FOG_EXP2 // NiloToon's choice, no shader variant + //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl" // URP's original code + #else + #pragma multi_compile_fog + #endif + + // for APV support + #if UNITY_VERSION >= 60000011 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" + #endif + + //-------------------------------------- + // GPU Instancing + //-------------------------------------- // to support GPU instancing and Single Pass Stereo rendering(VR), you should add the following section // but here we disabled them because they are not worth the increase of memory usage and build time, // and this shader didn't have the concept of instancing anyway - //------------------------------------------------------------------------------------------------------------------------------ + //#pragma multi_compile_instancing //#pragma instancing_options renderinglayer //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" - //------------------------------------------------------------------------------------------------------------------------------ - - #pragma vertex VertexShaderAllWork - #pragma fragment FragmentShaderAllWork + // ------------------------------------- + // Includes + // ------------------------------------- // because this pass is a ForwardLit pass // define "NiloToonForwardLitPass" to inject code into VertexShaderAllWork() #define NiloToonForwardLitPass 1 @@ -4165,10 +4304,40 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ENDHLSL } + // [Redraw a pass similar to "LightMode" = "UniversalForwardOnly"] + + // Usually for: + // - redraw semi-transparent hair + // - 2-pass transparent's opaque cutout prepass + // - Outline + + // Result: + // For each UniversalForwardOnly draw, URP will add an extra draw before it + + // Disadvantage: + // - Each extra draw will be in fixed order(just before each UniversalForwardOnly draw), which make SRP Batching useless (each SRP batch is 1 draw call) + + // In Unity2021.3, possible LightMode that can produce a redraw: + // - (O) SRPDefaultUnlit + // - (O) don't write any lightmode code (no lightmode = implicitely renamed as SRPDefaultUnlit) + // - (X) UniversalForwardOnly + // - (X) LightweightForward + + // Example use of this method in lilToon: + // 1. SRPDefaultUnlit is the surface color pass + // 2. UniversalForward is the outline pass / fur pass + + /* + Pass + { + Tags { "LightMode" = "SRPDefaultUnlit" } + } + */ + // [#1 Pass - Outline] // Very similar to the above "ForwardLit" pass, but: // -vertex position are pushed(extrude) out a bit base on lighting normal / smoothed normal direction - // -also color is tinted + // -also color is tinted by outline color // -Cull Front instead of Cull Back because Cull Front is a must for all extrude mesh outline method Pass { @@ -4197,17 +4366,20 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // If done correctly, URP will render your new Pass{} for your shader, in a SRP-batcher friendly way (usually in 1 big SRP batch that containing lots of draw call) } - // Render state (URP's ComplexLit.shader) + // ------------------------------------- + // Render State Commands + // ------------------------------------- Blend One Zero // TODO: should we expose the blending param for outline pass? are there any good use of a semi-transparent outline? ZWrite On Cull [_CullOutline] + //AlphaToMask[_AlphaToMask] // NiloToon doesn't support - // Render state (NiloToon extra added) + // NiloToon added: ColorMask [_ColorMask] ZTest [_ZTest] // Let user fully control the 2nd-8th bit of stencil buffer per material, - // but leaving the 1st bit for NiloToon to write "Character or Classic Outline" area + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area // https://docs.unity3d.com/Manual/SL-Stencil.html Stencil { @@ -4219,34 +4391,39 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" } HLSLPROGRAM - - //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass - - // no need to target 4.5, all platforms will run the same Pass(including WebGL = maximum 3.5) + + // no need to target 2.0, all platforms will run the same Pass(including WebGL = maximum 3.5) // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - //#pragma target 4.5 + //#pragma target 2.0 + + // ------------------------------------- + // Shader Stages + // ------------------------------------- + #pragma vertex VertexShaderAllWork + #pragma fragment FragmentShaderAllWork // [For shader_feature and multi_compile] - // it is similar but not the same when comparing to all keywords from the above "ForwardLit" pass, - // this outline pass will ignore some keywords if it is not that important for this outline pass, to reduce compiled shader variant count - // for notes, please see the above "ForwardLit" pass - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material Keywords (similar to URP's ComplexLit.shader's Material Keywords) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // It is similar but not the same when comparing to all keywords from the above "ForwardLit" pass, + // this outline pass will ignore some keywords if it is not that important for this outline pass, to reduce compiled shader variant count. + // For notes, please see the above "ForwardLit" pass + + // ------------------------------------- + // Material Keywords + // ------------------------------------- // Note: outline need to receive URP shadow, else outline is not correctly darken when character is within URP shadow #pragma shader_feature_local_fragment _RECEIVE_URP_SHADOW - + //#pragma shader_feature_local_fragment _EMISSION // TODO: do we need emission? #pragma shader_feature_local_fragment _OCCLUSIONMAP // needs to affect outline color - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- // Material keywords (NiloToon Outline pass specific) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- #pragma shader_feature_local_vertex _OUTLINEWIDTHMAP #pragma shader_feature_local_vertex _OUTLINEZOFFSETMAP - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- // Material keywords (NiloToon specific shader_feature) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- #pragma shader_feature_local _ISFACE #pragma shader_feature_local _FACE_MASK_ON #pragma shader_feature_local_fragment _SKIN_MASK_ON // _OutlineTintColorSkinAreaOverride need this @@ -4259,33 +4436,45 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #pragma shader_feature_local_fragment _OVERRIDE_OUTLINECOLOR_BY_TEXTURE - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- // Material keywords (NiloToon specific multi_compile) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- #pragma multi_compile_fragment _ _NILOTOON_RECEIVE_URP_SHADOWMAPPING #pragma multi_compile_local_fragment _ _NILOTOON_DITHER_FADEOUT #pragma multi_compile_local_fragment _ _NILOTOON_PERCHARACTER_BASEMAP_OVERRIDE - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- // NiloToon Material debug keywords (can strip when build) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- #pragma multi_compile _ _NILOTOON_DEBUG_SHADING - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Universal Pipeline keywords (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // [directly copied from URP14 ComplexLit.shader] + // ------------------------------------- + // Universal Pipeline keywords + // ------------------------------------- + // [directly copied from Unity6.1 URP17 ComplexLit.shader] #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS - // #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX + //#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX + #pragma multi_compile _ _LIGHT_LAYERS + + // Starting from 6.1, _FORWARD_PLUS is replaced by _CLUSTER_LIGHT_LOOP + #if UNITY_VERSION >= 60000100 + #pragma multi_compile _ _CLUSTER_LIGHT_LOOP + #elif UNITY_VERSION >= 202220 + #pragma multi_compile _ _FORWARD_PLUS + #endif + #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS // for outline pass, // 100% correct reflection is not that important for mobile, // we prefer smaller shader memory usage on mobile #ifndef SHADER_API_MOBILE - #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING - #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #if UNITY_VERSION >= 60000100 + #pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS + #endif #endif // [Hardcode define _SHADOWS_SOFT base on SHADER_API, instead of multi_compile, in order to reduce shader variant by 50%] @@ -4295,35 +4484,64 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" #define _SHADOWS_SOFT 1 #endif - // [Character won't need lightmap related logic] - //#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // not sure if it is worth the compile time & memory, disabled now + //#pragma multi_compile_fragment _ _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH // TODO: not supported now, it may ruin visual style if we included SSAO in lighting, and will double the shader memory usage //#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION - // [directly copied from URP14 ComplexLit.shader] #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 - #pragma multi_compile_fragment _ _LIGHT_LAYERS #pragma multi_compile_fragment _ _LIGHT_COOKIES + #if UNITY_VERSION >= 202220 - #pragma multi_compile _ _FORWARD_PLUS + #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #endif - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Unity defined keywords (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Unity defined keywords + // ------------------------------------- + //#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + //#pragma multi_compile _ SHADOWS_SHADOWMASK + //#pragma multi_compile _ DIRLIGHTMAP_COMBINED + //#pragma multi_compile _ LIGHTMAP_ON + //#pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING + //#pragma multi_compile _ DYNAMICLIGHTMAP_ON + //#pragma multi_compile _ USE_LEGACY_LIGHTMAPS + + //#pragma multi_compile _ LOD_FADE_CROSSFADE // Not worth to support this since it cost 2x shader memory + //#pragma multi_compile_fragment _ DEBUG_DISPLAY // NiloToon didn't implement URP's debug display + + // [fog] + // In NiloToon, we force dynamic_branch for fog if possible (dynamic_branch fog introduced in Unity6.1), + // - https://docs.unity3d.com/6000.2/Documentation/Manual/urp/shader-stripping-fog.html + // this trades a little bit GPU performance for cutting 50~75% memory usage and 2x~4x faster build time, which is worth it + #if UNITY_VERSION >= 60000100 + #pragma dynamic_branch _ FOG_LINEAR FOG_EXP FOG_EXP2 // NiloToon's choice, no shader variant + //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl" // URP's original code + #else #pragma multi_compile_fog - // (except fog, all others removed) - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // GPU Instancing (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // (all removed) - - #pragma vertex VertexShaderAllWork - #pragma fragment FragmentShaderAllWork + #endif + + // for APV support + #if UNITY_VERSION >= 60000011 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" + #endif + + //-------------------------------------- + // GPU Instancing + //-------------------------------------- + // to support GPU instancing and Single Pass Stereo rendering(VR), you should add the following section + // but here we disabled them because they are not worth the increase of memory usage and build time, + // and this shader didn't have the concept of instancing anyway + + //#pragma multi_compile_instancing + //#pragma instancing_options renderinglayer + //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + // ------------------------------------- + // Includes + // ------------------------------------- // because this is an Outline pass, // define "NiloToonSelfOutlinePass" to inject outline related code into both VertexShaderAllWork() and FragmentShaderAllWork() #define NiloToonSelfOutlinePass 1 @@ -4576,54 +4794,70 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ENDHLSL } - // ShadowCaster pass. Used for rendering URP's shadow maps (see URP ComplexLit.shader's "ShadowCaster" pass for reference) + // [ShadowCaster pass] + // Used for rendering URP's shadow maps (see URP ComplexLit.shader's "ShadowCaster" pass for reference) Pass { Name "ShadowCaster" - Tags{"LightMode" = "ShadowCaster"} + Tags + { + "LightMode" = "ShadowCaster" + } - // Explicit render state to avoid confusion + // ------------------------------------- + // Render State Commands + // ------------------------------------- ZWrite On // the only goal of this pass is to write depth (shadow map's light space depth)! ZTest LEqual // early exit at Early-Z stage if possible (only possible if clip() does not exist) ColorMask 0 // we don't care about color, we just want to write depth, ColorMask 0 will save some write bandwidth Cull [_Cull] HLSLPROGRAM - - //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass - - // no need to target 4.5, all platforms will run the same Pass(including WebGL = maximum 3.5) + + // no need to target 2.0, all platforms will run the same Pass(including WebGL = maximum 3.5) // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - //#pragma target 4.5 + //#pragma target 2.0 - // we need clip() related keywords in this pass, which is already defined inside the HLSLINCLUDE block in SubShader level - // ... + // ------------------------------------- + // Shader Stages + // ------------------------------------- + #pragma vertex VertexShaderAllWork + #pragma fragment BaseColorAlphaClipTest // we only need to do Clip(), we do not need rgba color result for shading + + // ------------------------------------- + // Material Keywords + // ------------------------------------- + // we need clip() related keywords in this pass, which are already defined inside the HLSLINCLUDE block in SubShader level + //#pragma shader_feature_local _ALPHATEST_ON + // ------------------------------------- + // NiloToon Keywords + // ------------------------------------- // let dither fadeout affect URP's shadowmap(depth from light's view), then let URP's softshadow filter to average the dither holes in shadowmap, // doing this can let character cast shadows that looks like "semi-transparent" shadow #pragma multi_compile_local_fragment _ _NILOTOON_DITHER_FADEOUT // ------------------------------------- - // Universal Pipeline keywords - // (X) - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // GPU Instancing (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // GPU Instancing + // ------------------------------------- // to support GPU instancing and Single Pass Stereo rendering(VR), you should add the following section // but here we disabled them because they are not worth the memory usage and build time increase, // and the shader didn't have the concept of instancing anyway - //------------------------------------------------------------------------------------------------------------------------------ + //#pragma multi_compile_instancing //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" - //------------------------------------------------------------------------------------------------------------------------------ + // ------------------------------------- + // Unity defined keywords + // ------------------------------------- + //#pragma multi_compile _ LOD_FADE_CROSSFADE // NilooToon doesn't support + // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW - #pragma vertex VertexShaderAllWork - #pragma fragment BaseColorAlphaClipTest // we only need to do Clip(), we do not need rgba color result for shading - + // ------------------------------------- + // Includes + // ------------------------------------- // because it is a ShadowCaster pass, define "NiloToonShadowCasterPass" to inject "remove shadow mapping artifact" code into VertexShaderAllWork(). // We don't want to do outline extrude here because if we do it, the whole mesh will always receive self shadow. #define NiloToonShadowCasterPass 1 @@ -4634,37 +4868,64 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ENDHLSL } - // (X)No GBuffer Pass, this shader is designed for forward lighting only. - // Even project is in deferred mode, the actually rendering of this shader is still in Forward. + // (X)No GBuffer Pass, this shader is designed for Forward/Forward+ lighting only. + // Even project is in deferred/deferred+ mode, the actually rendering of this shader is still in Forward/Forward+. // {...} - // DepthOnly pass. Used for rendering URP's offscreen depth prepass _CameraDepthTexture (you can search DepthOnlyPass.cs in URP package) + // [DepthOnly pass] + // Used for rendering URP's offscreen depth prepass _CameraDepthTexture (you can search DepthOnlyPass.cs in URP package) // When URP's depth texture is required, and if CopyDepthPass is not possible due to MSAA or renderer feature, // URP will perform this offscreen depth prepass for this shader to draw character depth into _CameraDepthTexture Pass { Name "DepthOnly" - Tags{"LightMode" = "DepthOnly"} + Tags + { + "LightMode" = "DepthOnly" + } - // Explicit render state to avoid confusion + // ------------------------------------- + // Render State Commands + // ------------------------------------- ZWrite On // the only goal of this pass is to write depth! - ZTest LEqual // early exit at Early-Z stage if possible (only possible if clip() does not exist) - ColorMask R // (URP13.1.8 or later changed from 0 to R, we will follow it) normally, we don't care about color, we just want to write depth, ColorMask 0 will save some write bandwidth + ColorMask R // URP13.1.8 or later changed from 0 to R, we will follow it Cull [_Cull] + // Let user fully control the 2nd-8th bit of stencil buffer per material, + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area + // https://docs.unity3d.com/Manual/SL-Stencil.html + Stencil + { + Ref [_StencilRef] // user fully control + ReadMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + WriteMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + Comp [_StencilComp] // user fully control + Pass [_StencilPass] // user fully control + } + HLSLPROGRAM - - //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass - - // no need to target 4.5, all platforms will run the same Pass(including WebGL = maximum 3.5) + + // no need to target 2.0, all platforms will run the same Pass(including WebGL = maximum 3.5) // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - //#pragma target 4.5 + //#pragma target 2.0 + // ------------------------------------- + // Shader Stages + // ------------------------------------- + #pragma vertex VertexShaderAllWork + #pragma fragment BaseColorAlphaClipTest // we only need to do Clip(), no need color shading + + // ------------------------------------- + // Material Keywords + // ------------------------------------- // we need clip() related keywords in this pass, which is already defined inside the HLSLINCLUDE block in SubShader level - // ... - + //#pragma shader_feature_local _ALPHATEST_ON + + // ------------------------------------- + // NiloToon Keywords + // ------------------------------------- #pragma shader_feature_local_vertex _OUTLINEWIDTHMAP - + // for push back zoffset depth write of face vertices, to hide face depth texture self shadow artifact #pragma shader_feature_local _ISFACE #pragma shader_feature_local _FACE_MASK_ON @@ -4672,20 +4933,24 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // DITHER_FADEOUT is needed for this pass, do not disable it #pragma multi_compile_local_fragment _ _NILOTOON_DITHER_FADEOUT - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // GPU Instancing (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Unity defined keywords + // ------------------------------------- + //#pragma multi_compile _ LOD_FADE_CROSSFADE // NilooToon doesn't support + + // ------------------------------------- + // GPU Instancing + // ------------------------------------- // to support GPU instancing and Single Pass Stereo rendering(VR), you should add the following section // but here we disabled them because they are not worth the memory usage and build time increase, // and the shader didn't have the concept of instancing anyway - //------------------------------------------------------------------------------------------------------------------------------ + //#pragma multi_compile_instancing //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" - //------------------------------------------------------------------------------------------------------------------------------ - - #pragma vertex VertexShaderAllWork - #pragma fragment BaseColorAlphaClipTest // we only need to do Clip(), no need color shading + // ------------------------------------- + // Includes + // ------------------------------------- // because Outline area should write to depth also, define "NiloToonDepthOnlyOrDepthNormalPass" to inject outline related code into VertexShaderAllWork() // if depth write is correct, outline area will process depth of field correctly also. #define NiloToonDepthOnlyOrDepthNormalPass 1 @@ -4696,55 +4961,89 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ENDHLSL } - // [This pass is used when drawing to _CameraNormalsTexture texture] + // [Extra DepthOnly pass for outline] + // Note: by default URP will only render the first "DepthOnly" pass inside a SubShader, and ignore all later "DepthOnly" passes, so we can't just add an extra "DepthOnly" pass here + // TODO: To render outline pass's depth into URP's _CameraDepthTexture or _CameraNormalsTexture also, we need to rely on a new renderer pass in Unity6 RenderGraph. (Same for DepthNormalsOnly & MotionVectors) + // see https://docs.unity3d.com/6000.0/Documentation/Manual/urp/render-graph-draw-objects-in-a-pass.html + /* + Pass + { + Name "DepthOnlyOutline" + Tags { "LightMode" = "DepthOnlyOutline" } + + Cull Front // for Classic Outline + ZWrite On + ColorMask R + + HLSLPROGRAM + //... + ENDHLSL + } + */ + + // [DepthNormalsOnly] // This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer. - // Starting from URP 10, URP can generate a normal texture called _CameraNormalsTexture when renderer feature(e.g. SSAO or NiloToon's screen space outline) requires it. - // To render to this texture in your custom shader in URP 12 or later, add a Pass{} with the name "DepthNormalsOnly" and "LightMode" = "DepthNormalsOnly". - // For example, see the implementation in URP's ComplexLit.shader - // *this pass is almost a direct copy of the above "DepthOnly" pass, but with the following changes: - // - Name changed to DepthNormalsOnly - // - LightMode changed to DepthNormalsOnly - // - removed ColorMask R, because we need color rgba output - // - #pragma fragment point to a function returning PackNormalOctRectEncode() - // - include _NORMALMAP keyword + // (e.g. SSAO or NiloToon's screen space outline requires _CameraNormalsTexture) + // See ComplexLit.shader's DepthNormalsOnly for reference. Pass { Name "DepthNormalsOnly" - // In this pass, - // For Unity2020.3 or below, "Lightmode" tag must be "DepthNormals" in order to render lit objects by URP's ForwardRenderer. - // For Unity2021.3 or above, "Lightmode" tag must be "DepthNormalsOnly" in order to render lit objects by URP's ForwardRendering. - // see "ShaderLab Pass tags" in https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/rendering/deferred-rendering-path.html - Tags{"LightMode" = "DepthNormalsOnly"} + // About "DepthNormalsOnly", see "ShaderLab Pass tags" in: + //- https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/rendering/deferred-rendering-path.html#shaderlab-pass-tags + //- https://docs.unity3d.com/6000.2/Documentation/Manual/urp/urp-shaders/urp-shaderlab-pass-tags.html + //- https://docs.unity3d.com/6000.2/Documentation/Manual/urp/rendering/make-shader-compatible-with-deferred.html + Tags + { + "LightMode" = "DepthNormalsOnly" + } - // Explicit render state to avoid confusion + // ------------------------------------- + // Render State Commands + // ------------------------------------- ZWrite On // one of the goal of this pass is to write depth into _CameraDepthTexture! - ZTest LEqual // early exit at Early-Z stage if possible (only possible if clip() does not exist) - //ColorMask R // we NEED to write PackNormalOctRectEncode()'s result rg color data into _CameraNormalTexture color buffer, so don't write ColorMask R Cull [_Cull] + + //ColorMask R // we NEED to write PackNormalOctRectEncode()'s result rg color data into _CameraNormalTexture color buffer, so don't write ColorMask R + // Let user fully control the 2nd-8th bit of stencil buffer per material, + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area + // https://docs.unity3d.com/Manual/SL-Stencil.html + Stencil + { + Ref [_StencilRef] // user fully control + ReadMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + WriteMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + Comp [_StencilComp] // user fully control + Pass [_StencilPass] // user fully control + } + HLSLPROGRAM - - //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass - - // no need to target 4.5, all platforms will run the same Pass(including WebGL = maximum 3.5) + + // no need to target 2.0, all platforms will run the same Pass(including WebGL = maximum 3.5) // https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html - //#pragma target 4.5 + //#pragma target 2.0 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material Keywords (similar to ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Shader Stages + // ------------------------------------- + #pragma vertex VertexShaderAllWork + #pragma fragment BaseColorAlphaClipTest_AndDepthNormalColorOutput // we need to do Clip(), and output normal as color + + // ------------------------------------- + // Material Keywords + // ------------------------------------- // these shader_feature will affect normal result, so we need to include them #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _PARALLAXMAP #pragma shader_feature_local _ _DETAIL // we need clip() related keywords in this pass, which is already defined inside the HLSLINCLUDE block in SubShader level - // ... + //#pragma shader_feature_local _ALPHATEST_ON - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Material Keywords (NiloToon specific) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // NiloToon Keywords + // ------------------------------------- #pragma shader_feature_local_vertex _OUTLINEWIDTHMAP // for push back zoffset depth write of face vertices, to hide face depth texture self shadow artifact @@ -4754,27 +5053,32 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" // DITHER_FADEOUT is needed for this pass, do not disable it #pragma multi_compile_local_fragment _ _NILOTOON_DITHER_FADEOUT - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Unity defined keywords - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------- + // Universal Pipeline keywords + // ------------------------------------- #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant #if UNITY_VERSION >= 202220 #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #endif - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // GPU Instancing (you can always reference this section from URP's ComplexLit.shader) - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // ------------------------------------- + // Unity defined keywords + // ------------------------------------- + //#pragma multi_compile _ LOD_FADE_CROSSFADE // NiloToon doesn't support + + //-------------------------------------- + // GPU Instancing + //-------------------------------------- // to support GPU instancing and Single Pass Stereo rendering(VR), you should add the following section // but here we disabled them because they are not worth the memory usage and build time increase, // and the shader didn't have the concept of instancing anyway - //------------------------------------------------------------------------------------------------------------------------------ + //#pragma multi_compile_instancing - //#pragma multi_compile _ DOTS_INSTANCING_ON - //------------------------------------------------------------------------------------------------------------------------------ - - #pragma vertex VertexShaderAllWork - #pragma fragment BaseColorAlphaClipTest_AndDepthNormalColorOutput // we need to do Clip(), and output normal as color - + //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + // ------------------------------------- // because Outline area should write to depth also, define "NiloToonDepthOnlyOrDepthNormalPass" to inject outline related code into VertexShaderAllWork() // if depth write is correct, outline area will process depth of field correctly also. #define NiloToonDepthOnlyOrDepthNormalPass 1 // currently we share DepthOnly pass's define using "NiloToonDepthOnlyOrDepthNormalPass", since these 2 passes are almost the same @@ -4784,14 +5088,20 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" ENDHLSL } - // Copy and edited of URP17(Unity6 = Unity2023.3)'s Unlit.shader's MotionVectors pass + // (X)No Meta Pass, this shader is designed for dynamic renderer only (not static/not lightmap) + // {...} + + // (X)No Universal2D Pass, this shader is designed for 3D only + // {...} + + // Copy and edited of URP17(Unity6.1)'s ComplexLit.shader's MotionVectors pass // https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@17.0/manual/features/motion-vectors.html - // TODO: we need to write an additional motion vector pass for "Classic Outline", else DLSS/TAA will have artifact on outline pixels + // TODO: we need to write an additional motion vector pass for "Classic Outline", else DLSS/TAA/STP will have artifact on outline pixels Pass { // [PackageRequirements] // Force this motion vector pass only to run in URP16(Unity2023.2) or later - // since URP versions before Unity2023.2 all have a default motion vector pass, + // since URP versions before Unity2023.2 have a default motion vector pass already, // although that default motion vector pass is not 100% correct with NiloToon(e.g., not matching to perspective removal/dither/dissolve) // we don't want to override it due to code complexity (each URP version has it's own unique motion vector pass) // https://docs.unity3d.com/Manual/SL-PackageRequirements.html @@ -4804,25 +5114,78 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" Tags { "LightMode" = "MotionVectors" } ColorMask RG - Cull [_Cull] + Cull [_Cull] // NiloToon added: _Cull doesn't exist in the offical ComplexLit.shader + // Let user fully control the 2nd-8th bit of stencil buffer per material, + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area + // https://docs.unity3d.com/Manual/SL-Stencil.html + Stencil + { + Ref [_StencilRef] // user fully control + ReadMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + WriteMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + Comp [_StencilComp] // user fully control + Pass [_StencilPass] // user fully control + } + HLSLPROGRAM //#pragma shader_feature_local _ALPHATEST_ON // already declared - //#pragma multi_compile _ LOD_FADE_CROSSFADE // not supported by design + //#pragma multi_compile _ LOD_FADE_CROSSFADE // NiloToon doesn't support #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY - //#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl" #include "NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl" #include_with_pragmas "NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl" ENDHLSL } - // (X)No Meta Pass, this shader is designed for dynamic renderer only (not static/not lightmap) - // {...} + // The motion vector pass for XR's space warp + Pass + { + // [PackageRequirements] + // Force this motion vector pass only to run in URP16(Unity2023.2) or later + // since URP versions before Unity2023.2 have a default motion vector pass already, + // although that default motion vector pass is not 100% correct with NiloToon(e.g., not matching to perspective removal/dither/dissolve) + // we don't want to override it due to code complexity (each URP version has it's own unique motion vector pass) + // https://docs.unity3d.com/Manual/SL-PackageRequirements.html + PackageRequirements + { + "com.unity.render-pipelines.universal": "16.0.0" + } + + Name "XRMotionVectors" + Tags { "LightMode" = "XRMotionVectors" } + ColorMask RGB - // (X)No Universal2D Pass, this shader is designed for 3D only - // {...} + Cull [_Cull] // NiloToon added: _Cull doesn't exist in the offical ComplexLit shader + + // NiloToon's Stencil removed, due to URP require the special Stencil setting for XR + //Stencil {...} + + // Stencil write for obj motion pixels + Stencil + { + WriteMask 1 + Ref 1 + Comp Always + Pass Replace + } + HLSLPROGRAM + //#pragma shader_feature_local _ALPHATEST_ON // already declared + //#pragma multi_compile _ LOD_FADE_CROSSFADE // NiloToon doesn't support + #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY + + #if UNITY_VERSION >= 60000100 + #define APPLICATION_SPACE_WARP_MOTION 1 // starting from Unity6.1, the 'APLICATION' typo is fixed, now the correct one is 'APPLICATION'. See Unity6.1's ComplexLit.shader's XRMotionVectors pass + #else + #define APLICATION_SPACE_WARP_MOTION 1 // this is the 'correct' typo (APLICATION) for Unity6.0 version. See Unity6.0's ComplexLit.shader's XRMotionVectors pass + #endif + + #include "NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl" + #include_with_pragmas "NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl" + ENDHLSL + } + // NiloToonSelfShadowCaster pass. Used for rendering NiloToon system's character self shadow map (not related to URP's shadow map system) Pass { @@ -4884,6 +5247,18 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character" //ColorMask 0 // we NEED to draw rgba data into color buffer, so don't write ColorMask 0! Cull [_Cull] + // Let user fully control the 2nd-8th bit of stencil buffer per material, + // but leaving the 1st bit for NiloToon to write "Character + Classic Outline" area + // https://docs.unity3d.com/Manual/SL-Stencil.html + Stencil + { + Ref [_StencilRef] // user fully control + ReadMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + WriteMask 127 // 01111111 (only allow 2nd-8th bit for user fully control) + Comp [_StencilComp] // user fully control + Pass [_StencilPass] // user fully control + } + HLSLPROGRAM //#pragma exclude_renderers gles gles3 glcore // no need to exclude any renderers, all platforms will run the same Pass diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_LightingEquation.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_LightingEquation.hlsl index c720401..f88d4dd 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_LightingEquation.hlsl +++ b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_LightingEquation.hlsl @@ -128,6 +128,7 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh half NoL = dot(N,L); // don't saturate(), because we will remap NoL by smoothstep() later half saturateNoL = saturate(NoL); + half RawNoL = dot(rawN,L); half NoV = saturate(dot(N,V)); half NoH = saturate(dot(N,H)); half LoH = saturate(dot(L,H)); @@ -155,7 +156,10 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh // simplest 1 line cel shade, you can always replace this line by your method, like a grayscale ramp texture. // celShadeResult: 0 is in shadow, 1 is in light half finalCelShadeMidPoint = _CelShadeMidPoint + celShadeMidPointOffset; - half smoothstepNoL = smoothstep(finalCelShadeMidPoint-_CelShadeSoftness,finalCelShadeMidPoint+_CelShadeSoftness, NoL); + half skinDiffuseNoL = lerp(RawNoL,NoL, _MainLightSkinDiffuseNormalMapStrength); + half nonSkinDiffuseNoL = lerp(RawNoL,NoL, _MainLightNonSkinDiffuseNormalMapStrength); + half diffuseFinalNoL = lerp(nonSkinDiffuseNoL,skinDiffuseNoL,lightingData.isSkinArea); + half smoothstepNoL = smoothstep(finalCelShadeMidPoint-_CelShadeSoftness,finalCelShadeMidPoint+_CelShadeSoftness, diffuseFinalNoL); // if you don't want direct lighting's NdotL cel shade effect looks too strong, set _MainLightIgnoreCelShade to a higher value half selfLightAttenuation = lerp(smoothstepNoL,1, _MainLightIgnoreCelShade); @@ -165,7 +169,7 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh #if _ISFACE // [calculate another set of selfLightAttenuation for face area] - half celShadeResultForFaceArea = smoothstep(_CelShadeMidPointForFaceArea-_CelShadeSoftnessForFaceArea,_CelShadeMidPointForFaceArea+_CelShadeSoftnessForFaceArea, NoL); + half celShadeResultForFaceArea = smoothstep(_CelShadeMidPointForFaceArea-_CelShadeSoftnessForFaceArea,_CelShadeMidPointForFaceArea+_CelShadeSoftnessForFaceArea, diffuseFinalNoL); half ignoreCelShadeForFaceArea = _MainLightIgnoreCelShadeForFaceArea; #if _FACE_SHADOW_GRADIENTMAP ignoreCelShadeForFaceArea = max(ignoreCelShadeForFaceArea,_IgnoreDefaultMainLightFaceShadow); @@ -196,7 +200,17 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh // fill in head space's basis vector x,y,z, similar to filling in a TBN matrix // since we only care rotation, 3x3 matrix is enough - half3x3 worldSpaceToHeadSpaceMatrix = half3x3(faceRightDirWS,faceUpwardDirection,faceForwardDirection); + half3x3 worldSpaceToHeadSpaceMatrix = half3x3(faceRightDirWS,faceUpwardDirection,faceForwardDirection); + + // For world to head space with rotation and translation, we need the inverse transform + /* + float4x4 worldToHeadMatrix = float4x4( + faceRightDirWS.x, faceRightDirWS.y, faceRightDirWS.z, -dot(faceRightDirWS, headCenterWS), + faceUpwardDirection.x, faceUpwardDirection.y, faceUpwardDirection.z, -dot(faceUpwardDirection, headCenterWS), + faceForwardDirection.x, faceForwardDirection.y, faceForwardDirection.z, -dot(faceForwardDirection, headCenterWS), + 0, 0, 0, 1 + ); + */ // [transform all directions to head space] // after a "rotation only" matrix mul, unit vector is still unit vector, no normalize() is needed @@ -357,7 +371,6 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh // Only when "character script && material && global" all allows depth texture rim light, then we can render depth texture rim light safely // - _DitherFadeout will destroy DepthTextureRimLightAndShadow's result since it rely on a correct depth texture, so when dither fadeout is active, we disabled DepthTextureRimLightAndShadow bool enableDepthTextureRimLightAndShadow = _PerMaterialEnableDepthTextureRimLightAndShadow && - (_ControlledByNiloToonPerCharacterRenderController ? _NiloToonEnableDepthTextureRimLightAndShadow : 1) && // _NiloToonEnableDepthTextureRimLightAndShadow is always 0 if NiloToonPerCharacterScript doesn't exist _GlobalEnableDepthTextureRimLigthAndShadow && _AllowRenderDepthOnlyOrDepthNormalsPass && !_GlobalShouldDisableNiloToonDepthTextureRimLightAndShadow && @@ -381,9 +394,12 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh float selfLinearEyeDepthWithoutZOffset = lightingData.selfLinearEyeDepth + lightingData.ZOffsetFinalSum; float eyeDepthRCP = rcp(selfLinearEyeDepthWithoutZOffset); // w=1/d, this method will make rim light width ALWAYS constant (width relative to character) - float flatLineExit = lerp(2, 1, selfLinearEyeDepthWithoutZOffset); // w=-d+2, this method will reduce rim light width when camera is too close(width relative to character) - // Note: for flatlineExit, it is also possible to simply flatLineExit = 1, it can prevent rim light width too large on closeup, but we believe it is too conservation, it will make rim width too small - float cameraDistanceFix_perspective = selfLinearEyeDepthWithoutZOffset > 1 ? eyeDepthRCP : lerp(eyeDepthRCP, flatLineExit, _DepthTexRimLightAndShadowReduceWidthWhenCameraIsClose); + + float flatLineExitStartDistance = _DepthTexRimLightAndShadowSafeViewDistance; // exposed as slider, 1~10, default 1 because 1 is not breaking change + float flatLineExit = 2.0/flatLineExitStartDistance - 1.0/(flatLineExitStartDistance*flatLineExitStartDistance) * selfLinearEyeDepthWithoutZOffset; //w = 2/c - 1/(c^2) * d, where c is flatLineExitStartDistance (see graph: https://www.desmos.com/calculator/rqssgc4ol7) + + // Note: for flatlineExit, it is also possible to simply flatLineExit = 1, it can prevent rim light width too large on closeup, but we believe it is too conservative, it will make rim width too small + float cameraDistanceFix_perspective = selfLinearEyeDepthWithoutZOffset > flatLineExitStartDistance ? eyeDepthRCP : lerp(eyeDepthRCP, flatLineExit, _DepthTexRimLightAndShadowReduceWidthWhenCameraIsClose); float cameraDistanceFix = IsPerspectiveProjection() ? cameraDistanceFix_perspective : 0.875; // no need to care orthographicCameraAmount, this line is already correct // [calculate finalDepthTexRimLightAndShadowWidthMultiplier] @@ -984,10 +1000,12 @@ half4 ShadeMainLight(inout ToonSurfaceData surfaceData, Varyings input, ToonLigh //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #if _KAJIYAKAY_SPECULAR half3 kajiyaSpecularAdd = 0; - half3 shiftedT = ShiftTangent(lightingData.TBN_WS[1], lightingData.normalWS, lightingData.uv.x,_HairStrandSpecularShapeFrequency,_HairStrandSpecularShapeShift,_HairStrandSpecularShapePositionOffset); - half3 HforStrandSpecular = normalize(_NiloToonGlobalPerCharFaceUpwardDirWSArray[_CharacterID] + V); // L+V, where L = _FaceUpDirection because it looks more stable - kajiyaSpecularAdd += ((StrandSpecular(shiftedT, HforStrandSpecular,_HairStrandSpecularMainExponent))) * _HairStrandSpecularMainColor * _HairStrandSpecularMainIntensity; //sharp - kajiyaSpecularAdd += ((StrandSpecular(shiftedT, HforStrandSpecular,_HairStrandSpecularSecondExponent))) * _HairStrandSpecularSecondColor * _HairStrandSpecularSecondIntensity; //soft + float2 targetUV = GetUV(input, _HairStrandSpecularUVIndex); + float shiftValue = _HairStrandSpecularUVDirection == 0 ? targetUV.x : targetUV.y; + float3 shiftedT = ShiftTangent(lightingData.TBN_WS[1], lightingData.normalWS, shiftValue,_HairStrandSpecularShapeFrequency,_HairStrandSpecularShapeShift,_HairStrandSpecularShapePositionOffset); + float3 HforStrandSpecular = normalize(_NiloToonGlobalPerCharFaceUpwardDirWSArray[_CharacterID] + V); // L+V, where L = _FaceUpDirection because it looks more stable + kajiyaSpecularAdd += StrandSpecular(shiftedT, HforStrandSpecular,_HairStrandSpecularMainExponent) * _HairStrandSpecularMainColor * _HairStrandSpecularMainIntensity; //sharp + kajiyaSpecularAdd += StrandSpecular(shiftedT, HforStrandSpecular,_HairStrandSpecularSecondExponent) * _HairStrandSpecularSecondColor * _HairStrandSpecularSecondIntensity; //soft kajiyaSpecularAdd *= 0.02 * _HairStrandSpecularOverallIntensity; // * 0.02 to allow _HairStrandSpecularMainColor & _HairStrandSpecularSecondColor's default value is white kajiyaSpecularAdd *= lerp(1, surfaceData.albedo, _HairStrandSpecularMixWithBaseMapColor); #if _KAJIYAKAY_SPECULAR_TEX_TINT @@ -1135,7 +1153,9 @@ half3 CalculateAdditiveSingleAdditionalLight(Light light, ToonLightingData light // similar to PBR's DFG's Fresnel term ^2 if(_GlobalCinematic3DRimMaskStrength_StableStyle > 0) { - half F = pow(saturate(1.0-dot(V,H)),_GlobalCinematic3DRimMaskSharpness_StableStyle); // sharpness = default 10 + // Fresnel reflection(F) = F0 + (1-Fo) * (1-costheta)^5, where costheta is dot(N,V) + // Here, dot(V,H)'s H is important to produce a soft and back light only rim effect + half F = pow(saturate(1.0-dot(V,H)),_GlobalCinematic3DRimMaskSharpness_StableStyle); // sharpness = default 10. Allow 5~15 half width = 0.02; half midPoint = 0.02; //lightAttenuation *= lerp(1,smoothstep(midPoint-width,midPoint+width,F * NdotL)* (5.0 * 5.0), _GlobalCinematic3DRimMaskStrength_StableStyle); // can replace NdotL with editedNdotL diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl index 145a564..7f7aab7 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl +++ b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_ObjectMotionVectors.hlsl @@ -28,9 +28,6 @@ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl" -// ------------------------------------- -//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl" - // ------------------------------------- // Structs struct MotionVectorAttributes @@ -58,42 +55,54 @@ struct MotionVectorVaryings UNITY_VERTEX_OUTPUT_STEREO }; -// ------------------------------------- -//TEXTURE2D(_BaseMap); -//SAMPLER(sampler_BaseMap); -//float4 _BaseMap_TexelSize; +float4 TransformPositionCSByNiloFunctions(float4 inputPositionCS, float3 positionWS) +{ + // if we should not render this material, + // execute "disable rendering" + if(ShouldDisableRendering()) + { + // see [a trick to "delete" any vertex] below to understand what this line does + inputPositionCS.w = 0; + return inputPositionCS; + } + + // zoffset + inputPositionCS = NiloGetNewClipPosWithZOffsetVS(inputPositionCS, -(_ZOffset+_PerCharZOffset)); -// ------------------------------------- -// Nilo Removed: We use our own CBuffer, to ensure the CBuffer is the same with other passes = correctly SRP batching -/* -CBUFFER_START(UnityPerMaterial) - float4 _BaseMap_ST; - half4 _BaseColor; - half _Cutoff; - //half _Surface; - //UNITY_TEXTURE_STREAMING_DEBUG_VARS; -CBUFFER_END -*/ + // perspective removal + inputPositionCS = NiloDoPerspectiveRemoval(inputPositionCS,positionWS,_NiloToonGlobalPerCharHeadBonePosWSArray[_CharacterID],_PerspectiveRemovalRadius,_PerspectiveRemovalAmount, _PerspectiveRemovalStartHeight, _PerspectiveRemovalEndHeight); + + return inputPositionCS; +} // ------------------------------------- // Vertex MotionVectorVaryings vert(MotionVectorAttributes input) { MotionVectorVaryings output = (MotionVectorVaryings)0; - - UNITY_SETUP_INSTANCE_ID(input); - UNITY_TRANSFER_INSTANCE_ID(input, output); - UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + // to support GPU instancing and Single Pass Stereo rendering(VR), add the following section + //------------------------------------------------------------------------------------------------------------------------------ + UNITY_SETUP_INSTANCE_ID(input); // will turn into this in non OpenGL / non PSSL -> UnitySetupInstanceID(input.instanceID); + UNITY_TRANSFER_INSTANCE_ID(input, output); // will turn into this in non OpenGL / non PSSL -> output.instanceID = input.instanceID; + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); // will turn into this in non OpenGL / non PSSL -> output.stereoTargetEyeIndexAsRTArrayIdx = unity_StereoEyeIndex; + //------------------------------------------------------------------------------------------------------------------------------ const VertexPositionInputs vertexInput = GetVertexPositionInputs(input.position.xyz); #if defined(_ALPHATEST_ON) output.uv = TRANSFORM_TEX(input.uv, _BaseMap); #endif - + +#if defined(APLICATION_SPACE_WARP_MOTION) + // We do not need jittered position in ASW + output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.position));; + output.positionCS = output.positionCSNoJitter; +#else // Jittered. Match the frame. output.positionCS = vertexInput.positionCS; output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.position)); +#endif float4 prevPos = (unity_MotionVectorsParams.x == 1) ? float4(input.positionOld, 1) : input.position; @@ -103,8 +112,16 @@ MotionVectorVaryings vert(MotionVectorAttributes input) output.previousPositionCSNoJitter = mul(_PrevViewProjMatrix, mul(UNITY_PREV_MATRIX_M, prevPos)); - ApplyMotionVectorZBias(output.positionCS); + // NiloToon added: edit all positionCS by NiloToon functions that affect motion vector pass + //--------------------------------------------------------------------------------- + // enabled due to final quality is much more stable, this is required when user use dither/dissolve/enable rendering, else character area(without character rendering) will be distorted + output.positionCS = TransformPositionCSByNiloFunctions(output.positionCS, vertexInput.positionWS); + // disabled due to final quality actually reduced, maybe it is not a good idea to edit "no jitter positionCS" + //output.positionCSNoJitter = TransformPositionCSByNiloFunctions(output.positionCSNoJitter, vertexInput.positionWS); + //output.previousPositionCSNoJitter = TransformPositionCSByNiloFunctions(output.previousPositionCSNoJitter, mul(UNITY_PREV_MATRIX_M, prevPos)); + //--------------------------------------------------------------------------------- + return output; } @@ -132,7 +149,11 @@ float4 frag(MotionVectorVaryings input) : SV_Target LODFadeCrossFade(input.positionCS); #endif - return float4(CalcNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 0, 0); + #if defined(APLICATION_SPACE_WARP_MOTION) + return float4(CalcAswNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 1); + #else + return float4(CalcNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 0, 0); + #endif } diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl index f2f3a19..ca684a8 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl +++ b/Assets/External/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_Shared.hlsl @@ -476,6 +476,8 @@ CBUFFER_START(UnityPerMaterial) half _AlphaOverrideTexValueScale; half _AlphaOverrideTexValueOffset; half _ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCamera; + half _ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapStart; + half _ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapEnd; half4 _AlphaOverrideTexChannelMask; // alpha test @@ -867,6 +869,8 @@ CBUFFER_START(UnityPerMaterial) half3 _HairStrandSpecularSecondColor; half _HairStrandSpecularMainExponent; half _HairStrandSpecularSecondExponent; + uint _HairStrandSpecularUVIndex; + uint _HairStrandSpecularUVDirection; // detail map float _DetailUseSecondUv; @@ -927,6 +931,8 @@ CBUFFER_START(UnityPerMaterial) half _CelShadeMidPoint; half _CelShadeSoftness; half _MainLightIgnoreCelShade; + half _MainLightSkinDiffuseNormalMapStrength; + half _MainLightNonSkinDiffuseNormalMapStrength; half _IndirectLightFlatten; half _AdditionalLightCelShadeMidPoint; half _AdditionalLightCelShadeSoftness; @@ -961,13 +967,13 @@ CBUFFER_START(UnityPerMaterial) // depth texture rim light and shadow float _PerMaterialEnableDepthTextureRimLightAndShadow; - float _NiloToonEnableDepthTextureRimLightAndShadow; float _DepthTexRimLightAndShadowWidthMultiplier; float _DepthTexRimLight3DRimMaskEnable; float _DepthTexRimLight3DRimMaskThreshold; float _DepthTexRimLightAndShadowWidthExtraMultiplier; float _DepthTexRimLightAndShadowReduceWidthWhenCameraIsClose; + float _DepthTexRimLightAndShadowSafeViewDistance; float _DepthTexRimLightIgnoreLightDir; float _DepthTexShadowIgnoreLightDir; @@ -1138,6 +1144,7 @@ CBUFFER_START(UnityPerMaterial) //half3 _FaceForwardDirection; // converted to global array //half3 _FaceUpDirection; // converted to global array half _FixFaceNormalAmount; + half _FixFaceNormalAmountPerMaterial; half _FixFaceNormalUseFlattenOrProxySphereMethod; // per char bounding sphere @@ -1191,11 +1198,21 @@ CBUFFER_START(UnityPerMaterial) // per character ZOffset float _PerCharZOffset; + // Decal + half _DecalAlbedoApplyStrength; + half _DecalNormalApplyStrength; + half _DecalOcclusionApplyStrength; + half _DecalSmoothnessApplyStrength; + half _DecalSpecularApplyStrength; + // Pass On/Off float _AllowRenderURPShadowCasterPass; + float _AllowRenderDepthOnlyOrDepthNormalsPass; + float _AllowRenderNiloToonSelfShadowPass; float _AllowRenderExtraThickOutlinePass; - float _AllowRenderDepthOnlyOrDepthNormalsPass; + float _AllowRenderNiloToonCharacterAreaStencilBufferFillPass; + float _AllowRenderNiloToonCharacterAreaColorFillPass; // Per character effect on/off float _AllowPerCharacterDissolve; @@ -1381,17 +1398,20 @@ struct UVData // index 6: ScreenSpaceUV float2 allUVs[7]; - // Performance warning: + // Performance warning of "dynamic index": // dynamic index accessing an array may force the compiler to store the element values in off-chip memory! // because you can't do dynamic indexing into registers. // if we want the element values store in register for quick read, we need to use compile time constant index. + // it means a "ifelse chain or switch case that looks stupid" may perform better than a clean code dynamic index array access..! // see: // - https://developer.nvidia.com/blog/identifying-shader-limiters-with-the-shader-profiler-in-nvidia-nsight-graphics/ // - https://www.reddit.com/r/opengl/comments/ryig28/struct_switchindexing_with_20_values_faster_than/ - // - float2 GetUV(uint index) { - // In mobile test (Adreno612,Adreno619,MaliG57MC2), UVsMethod 1 is the fastest (NiloToonSampleScene) + // In mobile test (Adreno612,Adreno619,MaliG57MC2): + // - UVsMethod 0 (constant index) is debug control, it is expected to be the fastest + // - UVsMethod 1/2 (ifelse chain / switch) is faster than UVsMethod 3 + // - UVsMethod 3 (dynamic index) is the worst (NiloToonSampleScene) // ------------------------------------- // NiloToon 0.16.16 (Method3, control): // - low = 60fps (adreno619), 60fps (MaliG57), 25fps(adreno612) @@ -1399,19 +1419,19 @@ struct UVData // - high = 25fps (adreno619), 44fps (MaliG57), 9fps(adreno612) // - highest = 8fps (adreno619), 15fps (MaliG57), 3fps(adreno612) // ------------------------------------- - // NiloToon 0.16.16 (Method2): + // NiloToon 0.16.16 (Method2, switch case): // - low = 60fps (adreno619), 60fps (MaliG57), 22fps(adreno612) // - mid = 35fps (adreno619), 60fps (MaliG57), 13fps(adreno612) // - high = 21fps (adreno619), 41fps (MaliG57), 7fps(adreno612) // - highest = 7fps (adreno619), 15fps (MaliG57), 3fps(adreno612) // ------------------------------------- - // NiloToon 0.16.16 (Method1): + // NiloToon 0.16.16 (Method1, ifelse chain): // - low = 60fps (adreno619), 60fps (MaliG57), 23fps(adreno612) // - mid = 35fps (adreno619), 60fps (MaliG57), 13fps(adreno612) // - high = 21fps (adreno619), 47fps (MaliG57), 7fps(adreno612) // - highest = 8fps (adreno619), 11fps (MaliG57), 3fps(adreno612) // ------------------------------------- - // NiloToon 0.16.16 (Method0): + // NiloToon 0.16.16 (Method0, dynamic index): // - low = 60fps (adreno619), 60fps (MaliG57), 22fps(adreno612) // - mid = 33fps (adreno619), 60fps (MaliG57), 12fps(adreno612) // - high = 17fps (adreno619), 46fps (MaliG57), 6fps(adreno612) @@ -1419,8 +1439,10 @@ struct UVData #define UVsMethod 1 #if UVsMethod == 0 + // dynamic index array access, clean code but slower return allUVs[index]; #elif UVsMethod == 1 + // ifelse chain if(index == 0) return allUVs[0]; if(index == 1) return allUVs[1]; if(index == 2) return allUVs[2]; @@ -1430,6 +1452,7 @@ struct UVData if(index == 6) return allUVs[6]; return 0; #elif UVsMethod == 2 + // switch case switch (index) { case 0: return allUVs[0]; @@ -1442,7 +1465,8 @@ struct UVData } return 0; #elif UVsMethod == 3 - return allUVs[0]; // debug (control) + // constant index array access (debug control) + return allUVs[0]; #endif } }; @@ -1523,7 +1547,7 @@ float2 GetUV(Varyings varyings, uint index) return 0; /* - // same as the above code, but should be faster + // same as the above code, but slower due to array assign and read float2 uvArray[4]; uvArray[0] = varyings.uv01.xy; uvArray[1] = varyings.uv01.zw; @@ -1633,7 +1657,7 @@ half4 GetLightingNormalWS_FaceArea(half3 normalWS, float3 positionWS, float2 uv) //fixedFaceNormalWS = proxySphereFixFaceNormalWS; //TODO: this line better for face area additional light - resultNormalWS = normalize(lerp(resultNormalWS, fixedFaceNormalWS, _FixFaceNormalAmount * isFaceArea * _ControlledByNiloToonPerCharacterRenderController)); // only normalize() once at final to improve performance + resultNormalWS = normalize(lerp(resultNormalWS, fixedFaceNormalWS, _FixFaceNormalAmount * _FixFaceNormalAmountPerMaterial * isFaceArea * _ControlledByNiloToonPerCharacterRenderController)); // only normalize() once at final to improve performance #endif return half4(resultNormalWS,isFaceArea); @@ -1710,23 +1734,8 @@ float ShouldRenderOutline() return _RenderOutline && _PerCharacterRenderOutline; } -// [All pass's vertex shader will share this function] -// - if "NiloToonIsAnyOutlinePass" is not defined = do regular MVP transform -// - if "NiloToonIsAnyOutlinePass" is defined = do regular MVP transform + outline extrude vertex + all outline related task -Varyings VertexShaderAllWork(Attributes input) +bool ShouldDisableRendering() { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // init Varyings struct - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // init output struct with all 0 bits just to avoid "struct not init" warning/error - // but even passing 0 from vertex to fragment via Varying struct still has Rasterisation/interpolation cost - // so make sure Varyings struct is as small as possible by using {#if #endif} to remove unneeded things inside Varying struct - Varyings output = (Varyings)0; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // disable rendering (early exit) - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // user can disable rendering per material bool shouldDisableRendering = !(_EnableRendering && _RenderCharacter); @@ -1741,19 +1750,17 @@ Varyings VertexShaderAllWork(Attributes input) // Be careful not to run this section in DepthOnly/DepthNormalsOnly pass, // in DepthOnly pass we only need to skip the outline position extrude, not invalid the vertex! // so here only #if NiloToonSelfOutlinePass is used instead of #if NiloToonIsAnyOutlinePass. - // --- - // Ideally you want to remove the outline pass completely and not using this trick if the material's _RenderOutline toggle is off for best performance, - // but it will require a custom material editor inspector, which may make things too complicated without gaining much, - // since only a small amount of material will want to NOT render outline, like eyeball,eyebrow,teeth.... #if NiloToonSelfOutlinePass shouldDisableRendering = shouldDisableRendering || !ShouldRenderOutline(); #endif // Materials's "Pass On/Off" section bool shouldRenderingExtraThickOutline = _AllowRenderExtraThickOutlinePass && _ExtraThickOutlineEnabled; - bool shouldRenderingCharacterAreaColorFill = _CharacterAreaColorFillEnabled; + bool shouldRenderingCharacterAreaColorFill = _AllowRenderNiloToonCharacterAreaColorFillPass && _CharacterAreaColorFillEnabled; + bool shouldRenderCharacterAreaStencilBufferFill = (shouldRenderingExtraThickOutline || shouldRenderingCharacterAreaColorFill) && _AllowRenderNiloToonCharacterAreaStencilBufferFillPass; + #if NiloToonCharacterAreaStencilBufferFillPass - shouldDisableRendering = shouldDisableRendering || (!shouldRenderingExtraThickOutline && !shouldRenderingCharacterAreaColorFill); + shouldDisableRendering = shouldDisableRendering || !shouldRenderCharacterAreaStencilBufferFill; #endif #if NiloToonExtraThickOutlinePass shouldDisableRendering = shouldDisableRendering || !shouldRenderingExtraThickOutline; @@ -1771,9 +1778,28 @@ Varyings VertexShaderAllWork(Attributes input) shouldDisableRendering = shouldDisableRendering || !_AllowRenderNiloToonSelfShadowPass; #endif + return shouldDisableRendering; +} +// [All pass's vertex shader will share this function] +// - if "NiloToonIsAnyOutlinePass" is not defined = do regular MVP transform +// - if "NiloToonIsAnyOutlinePass" is defined = do regular MVP transform + outline extrude vertex + all outline related task +Varyings VertexShaderAllWork(Attributes input) +{ + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // init Varyings struct + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // init output struct with all 0 bits just to avoid "struct not init" warning/error + // but even passing 0 from vertex to fragment via Varying struct still has Rasterisation/interpolation cost + // so make sure Varyings struct is as small as possible by using {#if #endif} to remove unneeded things inside Varying struct + Varyings output = (Varyings)0; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // disable rendering (early exit) + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // if we should not render this material, // execute "disable rendering" - if(shouldDisableRendering) + if(ShouldDisableRendering()) { // see [a trick to "delete" any vertex] below to understand what this line does output.positionCS.w = 0; @@ -2509,9 +2535,9 @@ half4 GetFinalBaseColor(Varyings input, UVData uvData, float facing) // copied from https://docs.unity3d.com/Packages/com.unity.shadergraph@12.1/manual/Camera-Node.html?q=camera%20node half3 cameraBackwardDir = mul(UNITY_MATRIX_M, float4(transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) [2].xyz,0)).xyz; - half faceForwardFadeoutControl = saturate(dot(_NiloToonGlobalPerCharFaceForwardDirWSArray[_CharacterID], cameraBackwardDir)); // find the angle between faceForward vector and cameraBackwardDir + half faceForwardFadeoutControl = invLerpClamp(_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapStart, _ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCameraRemapEnd,dot(_NiloToonGlobalPerCharFaceForwardDirWSArray[_CharacterID], cameraBackwardDir)); // find the angle between faceForward vector and cameraBackwardDir faceForwardFadeoutControl = pow(faceForwardFadeoutControl,4); // fadeout faster - faceForwardFadeoutControl = lerp(1,faceForwardFadeoutControl,_ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCamera); // allow user to control it + faceForwardFadeoutControl = lerp(1,faceForwardFadeoutControl, _ApplyAlphaOverrideOnlyWhenFaceForwardIsPointingToCamera); // allow user to control it alphaOverrideStrength *= faceForwardFadeoutControl; } half newAlpha = dot(tex2D(_AlphaOverrideTex, uvData.GetUV(_AlphaOverrideTexUVIndex)),_AlphaOverrideTexChannelMask); @@ -3290,12 +3316,24 @@ ToonLightingData InitializeLightingData(Varyings input, half3 normalTS, float fa //---------------------------------------------------------------- // 1. inject indirect light into main light + + // [sample APV and replace SH, if project enabled APV] + #if (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) + lightingData.SH = SAMPLE_GI(lightingData.SH, + GetAbsolutePositionWS(lightingData.positionWS), + lightingData.normalWS * (1-_IndirectLightFlatten), // do normal flatten for indirect light + lightingData.viewDirectionWS, + lightingData.SV_POSITIONxy, + 1, // probe occlusion, since this shader is for dynamic character, we use a constant 1 + 1); // shadowmask, since this shader is for dynamic character, we use a constant 1 + #endif + // [pick the highest between indirect and main directional light = max(direct light,indirect light)] // anime character artist usually don't want the concept of indirect + direct light // because it will ruin the final color easily, // what anime character artist want is: // - if direct lighting is bright enough -> keep character's result same as albedo texture that they draw - // - if in a dark environment -> switch to use light probe to make character blend into environment + // - if in a dark environment -> switch to use light probe/APV to make character blend into the environment color // *max() can prevent result completely black, if light probe was not baked and no direct light is active const half3 indirectLight = min(max(lightingData.SH,_GlobalIndirectLightMinColor),_GlobalIndirectLightMaxColor); mainLight.color = max(mainLight.color, indirectLight); @@ -3684,9 +3722,17 @@ void ApplyAlbedoPreLightingEditIfOutlinePass(inout ToonSurfaceData surfaceData) #endif } -void ApplyURPDecal(inout ToonSurfaceData surfaceData, Varyings varyings, ToonLightingData lightingData) +void ApplyURPDecal(inout ToonSurfaceData surfaceData, Varyings varyings, inout ToonLightingData lightingData) { #ifdef _DBUFFER + // cache + half3 originalAlbedo = surfaceData.albedo; + half3 originalNormalWS = lightingData.normalWS; + half originalOcclusion = surfaceData.occlusion; + half originalSmoothness = surfaceData.smoothness; + half3 originalSpecular = surfaceData.specular; + + // apply decal half tempMetallic = 0; // we don't use metallic for now ApplyDecal( varyings.positionCS, @@ -3697,6 +3743,13 @@ void ApplyURPDecal(inout ToonSurfaceData surfaceData, Varyings varyings, ToonLig surfaceData.occlusion, surfaceData.smoothness ); + + // control apply % + surfaceData.albedo = lerp(originalAlbedo, surfaceData.albedo, _DecalAlbedoApplyStrength); + lightingData.normalWS = lerp(originalNormalWS, lightingData.normalWS, _DecalNormalApplyStrength); + surfaceData.occlusion = lerp(originalOcclusion, surfaceData.occlusion, _DecalOcclusionApplyStrength); + surfaceData.smoothness = lerp(originalSmoothness, surfaceData.smoothness, _DecalSmoothnessApplyStrength); + surfaceData.specular = lerp(originalSpecular, surfaceData.specular, _DecalSpecularApplyStrength); #endif } @@ -4381,6 +4434,26 @@ void FragmentShaderAllWork(Varyings input, FRONT_FACE_TYPE IsFrontFace : FRONT_F ////////////////////////////////////////////////////////////////////////////////////////// ApplyOverrideOutputAlpha(surfaceData.alpha); + ////////////////////////////////////////////////////////////////////////////////////////// + // Inverse Tonemapping + ////////////////////////////////////////////////////////////////////////////////////////// + // we can apply inverse tonemap to color inorder to use URP's tonemapping, but it will make bloom extremely bright, so likely not a good idea + // see https://zhuanlan.zhihu.com/p/14603997646?utm_psn=1857106055890354177&fbclid=IwZXh0bgNhZW0CMTAAAR26OV4Aooye9-I3cRDhDAeokolYIMjF6jxR1G-qNzGE6UDxRJwUjdIWuRQ_aem_tTvZmD9FNdQYSqUf7pE2Kw + /* + // Inverse for Unity's official Neutral + float3 InvTonemap_Neutral4(float3 RGB) + { + float3 t = RGB*RGB; + return 5.2f*t*t - 3.0f*t*RGB + 0.7f*t + RGB; + } + // Inverse for Unity's official ACES + float3 InvTonemap_ACES(float3 RGB) + { + float3 t = RGB * RGB; + return (0.5f*RGB*t + 0.3f*t + 0.7f*RGB + 0.45f) * sqrt(RGB); + } + */ + ////////////////////////////////////////////////////////////////////////////////////////// // output ////////////////////////////////////////////////////////////////////////////////////////// @@ -4496,7 +4569,17 @@ float4 BaseColorAlphaClipTest_AndNiloToonPrepassBufferColorOutput(Varyings input // When the RT depth and MSAA format of _CameraDepthTexture match _NiloToonPrepassBufferRT, // we can perform precise depth comparisons to reject "scene blocked char pixels." - if(sceneLinearDepth < selfLinearDepth) + // but still, it is possible to have problems similar Shadow acne, so a very small depth bias may help + float depthBias; + // Bias should not be affected by platform, since platform difference (Z reverse) is handled inside Convert_SV_PositionZ_ToLinearViewSpaceDepth()'s LinearEyeDepth() + // DX11 = - correct , + wrong + // Vulkan = - correct , + wrong + // OPENGLES = - correct , + wrong + // -0.00003 is the minimum number to work for a 24bit depth texture + // no reasonable value works for 16bit depth texture (should we allow user to increase it? expose in renderer feature?) + depthBias = - 0.0001; // we use a "~3x larger than -0.00003" bias just in case + + if(sceneLinearDepth < selfLinearDepth + depthBias) return 0; // if character pixel is still visible(not blocked by scene), draw to _NiloToonPrepassBufferTex diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment.shader b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment.shader index 501a972..e2166f1 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment.shader +++ b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment.shader @@ -3,9 +3,9 @@ // For more information, visit -> https://github.com/ColinLeung-NiloCat/UnityURPToonLitShaderExample -// This shader is a direct copy of URP16.0.3's ComplexLit.shader, but with some edit. +// This shader is a direct copy of Unity6.1 URP17.0.3's ComplexLit.shader, but with some edit. // If you want to see what is the difference, all edited lines will have a [NiloToon] tag, you can search [NiloToon] in this file, -// or compare URP16.0.3's ComplexLit.shader with this file using tools like SourceGear DiffMerge. +// or compare URP17.0.3's ComplexLit.shader with this file using tools like SourceGear DiffMerge. // Complex Lit is superset of Lit, but provides // advanced material properties and is always forward rendered. @@ -130,6 +130,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0 [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 + [HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1.0 [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 // Editmode props @@ -207,31 +208,65 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" #if UNITY_VERSION >= 202220 #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX #endif + #pragma multi_compile _ _LIGHT_LAYERS + + // Starting from 6.1, _FORWARD_PLUS is replaced by _CLUSTER_LIGHT_LOOP + #if UNITY_VERSION >= 60000100 + #pragma multi_compile _ _CLUSTER_LIGHT_LOOP + #elif UNITY_VERSION >= 202220 + #pragma multi_compile _ _FORWARD_PLUS + #else + #pragma multi_compile _ _CLUSTERED_RENDERING + #endif + #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #if UNITY_VERSION >= 60000100 + #pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS + #endif + #pragma multi_compile_fragment _ _SHADOWS_SOFT + #if UNITY_VERSION >= 60000000 + #pragma multi_compile_fragment _ _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #endif #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 - #pragma multi_compile_fragment _ _LIGHT_LAYERS #pragma multi_compile_fragment _ _LIGHT_COOKIES #if UNITY_VERSION >= 202220 - #pragma multi_compile _ _FORWARD_PLUS + #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" -#else - #pragma multi_compile _ _CLUSTERED_RENDERING #endif + // ------------------------------------- // Unity defined keywords #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ LIGHTMAP_ON + #if UNITY_VERSION >= 60000100 + #pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING + #endif #pragma multi_compile _ DYNAMICLIGHTMAP_ON - #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE - #pragma multi_compile_fog + #pragma multi_compile _ USE_LEGACY_LIGHTMAPS + #pragma multi_compile _ LOD_FADE_CROSSFADE #pragma multi_compile_fragment _ DEBUG_DISPLAY + // [fog] + // In NiloToon, we force dynamic_branch for fog if possible (dynamic_branch fog introduced in Unity6.1), + // this trades a little bit GPU performance for cutting 50~75% memory usage and 2x~4x faster build time, which is worth it + #if UNITY_VERSION >= 60000100 + #pragma dynamic_branch _ FOG_LINEAR FOG_EXP FOG_EXP2 // NiloToon's choice, no shader variant + //#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl" // URP's original code + #else + #pragma multi_compile_fog + #endif + + // for APV support + #if UNITY_VERSION >= 60000011 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" + #endif + //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing @@ -291,7 +326,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" // ------------------------------------- // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A //-------------------------------------- @@ -305,7 +340,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" // ------------------------------------- // Unity defined keywords #if UNITY_VERSION >= 202220 - #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile _ LOD_FADE_CROSSFADE #endif // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias @@ -327,6 +362,96 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" ENDHLSL } + // NiloToon removed GBuffer pass + /* + Pass + { + // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with + // no LightMode tag are also rendered by Universal Render Pipeline + // + // Fill GBuffer data to prevent "holes", just in case someone wants to reuse GBuffer data. + // Deferred lighting is stenciled out for ComplexLit and rendered as forward. + Name "GBuffer" + Tags + { + "LightMode" = "UniversalGBuffer" + } + + // ------------------------------------- + // Render State Commands + ZWrite[_ZWrite] + ZTest LEqual + Cull[_Cull] + + HLSLPROGRAM + #pragma target 4.5 + + // Deferred Rendering Path does not support the OpenGL-based graphics API: + // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. + #pragma exclude_renderers gles3 glcore + + // ------------------------------------- + // Shader Stages + #pragma vertex LitGBufferPassVertex + #pragma fragment LitGBufferPassFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local_fragment _ALPHATEST_ON + //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local_fragment _EMISSION + #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma shader_feature_local_fragment _OCCLUSIONMAP + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + + #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local_fragment _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF + + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #pragma multi_compile_fragment _ _SHADOWS_SOFT + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED + #pragma multi_compile _ _CLUSTER_LIGHT_LOOP + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ USE_LEGACY_LIGHTMAPS + #pragma multi_compile _ LOD_FADE_CROSSFADE + #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl" + ENDHLSL + } + */ + Pass { Name "DepthOnly" @@ -351,13 +476,13 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" // ------------------------------------- // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A // ------------------------------------- // Unity defined keywords #if UNITY_VERSION >= 202220 - #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile _ LOD_FADE_CROSSFADE #endif //-------------------------------------- @@ -412,7 +537,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _PARALLAXMAP #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A // ------------------------------------- @@ -425,7 +550,7 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" // ------------------------------------- // Unity defined keywords #if UNITY_VERSION >= 202220 - #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile _ LOD_FADE_CROSSFADE #endif //-------------------------------------- @@ -561,10 +686,57 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Environment" HLSLPROGRAM #pragma shader_feature_local _ALPHATEST_ON - #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile _ LOD_FADE_CROSSFADE #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + //[NiloToon] remove: + //========================================================================================================== + //#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + //========================================================================================================== + + //[NiloToon] add: + //========================================================================================================== + #include "NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl" + //========================================================================================================== + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ObjectMotionVectors.hlsl" + ENDHLSL + } + + Pass + { + Name "XRMotionVectors" + Tags { "LightMode" = "XRMotionVectors" } + ColorMask RGB + + // Stencil write for obj motion pixels + Stencil + { + WriteMask 1 + Ref 1 + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma shader_feature_local _ALPHATEST_ON + #pragma multi_compile _ LOD_FADE_CROSSFADE + #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY + + #if UNITY_VERSION >= 60000100 + #define APPLICATION_SPACE_WARP_MOTION 1 // starting from Unity6.1, the 'APLICATION' typo is fixed, now the correct one is 'APPLICATION'. See Unity6.1's ComplexLit.shader's XRMotionVectors pass + #else + #define APLICATION_SPACE_WARP_MOTION 1 // this is the 'correct' typo (APLICATION) for Unity6.0 version. See Unity6.0's ComplexLit.shader's XRMotionVectors pass + #endif + + //[NiloToon] remove: + //========================================================================================================== + //#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + //========================================================================================================== + + //[NiloToon] add: + //========================================================================================================== + #include "NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl" + //========================================================================================================== #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ObjectMotionVectors.hlsl" ENDHLSL } diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitForwardPass.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitForwardPass.hlsl index a5dbb97..722bdc7 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitForwardPass.hlsl +++ b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitForwardPass.hlsl @@ -3,9 +3,9 @@ // For more information, visit -> https://github.com/ColinLeung-NiloCat/UnityURPToonLitShaderExample -// This shader is a direct copy of URP16.0.3's LitForwardPass.hlsl, but with some edit. +// This shader is a direct copy of Unity6.1 URP17.0.3's LitForwardPass.hlsl, but with some edit. // If you want to see what is the difference, all edited lines will have a [NiloToon] tag, you can search [NiloToon] in this file, -// or compare URP16.0.3's LitForwardPass.hlsl with this file using tools like SourceGear DiffMerge. +// or compare Unity6.1 URP17.0.3's LitForwardPass.hlsl with this file using tools like SourceGear DiffMerge. // #pragma once is a safeguard best practice in almost every .hlsl, // doing this can make sure your .hlsl's user can include this .hlsl anywhere anytime without producing any multi include conflict @@ -94,9 +94,13 @@ struct Varyings float2 dynamicLightmapUV : TEXCOORD9; // Dynamic lightmap UVs #endif +#ifdef USE_APV_PROBE_OCCLUSION + float4 probeOcclusion : TEXCOORD10; +#endif + // [NiloToon] add: //======================================================= - float4 screenPos : TEXCOORD10; + float4 screenPos : TEXCOORD11; //======================================================= float4 positionCS : SV_POSITION; @@ -112,6 +116,12 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData inputData.positionWS = input.positionWS; #endif +#if UNITY_VERSION >= 60000000 +#if defined(DEBUG_DISPLAY) + inputData.positionCS = input.positionCS; +#endif +#endif + half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); #if defined(_NORMALMAP) || defined(_DETAIL) float sgn = input.tangentWS.w; // should be either +1 or -1 @@ -143,6 +153,7 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactor); #endif +#if UNITY_VERSION < 60000000 #if defined(DYNAMICLIGHTMAP_ON) inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS); #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) @@ -153,10 +164,14 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData input.positionCS.xy); #else inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS); +#endif #endif inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); + +#if UNITY_VERSION < 60000000 inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); +#endif #if defined(DEBUG_DISPLAY) #if defined(DYNAMICLIGHTMAP_ON) @@ -167,9 +182,35 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData #else inputData.vertexSH = input.vertexSH; #endif + #if UNITY_VERSION >= 60000000 + #if defined(USE_APV_PROBE_OCCLUSION) + inputData.probeOcclusion = input.probeOcclusion; + #endif + #endif #endif } +#if UNITY_VERSION >= 60000000 +void InitializeBakedGIData(Varyings input, inout InputData inputData) +{ + #if defined(DYNAMICLIGHTMAP_ON) + inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS); + inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); + #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) + inputData.bakedGI = SAMPLE_GI(input.vertexSH, + GetAbsolutePositionWS(inputData.positionWS), + inputData.normalWS, + inputData.viewDirectionWS, + input.positionCS.xy, + input.probeOcclusion, + inputData.shadowMask); + #else + inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS); + inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); + #endif +} +#endif + // [NiloToon] add: //========================================================================================================================================================== // debug on off @@ -435,16 +476,20 @@ void LitPassFragment( InputData inputData; InitializeInputData(input, surfaceData.normalTS, inputData); -#if UNITY_VERSION >= 600000 - SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv); +#if UNITY_VERSION >= 60000000 + SETUP_DEBUG_TEXTURE_DATA(inputData, UNDO_TRANSFORM_TEX(input.uv, _BaseMap)); #else SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap); #endif -#ifdef _DBUFFER +#if defined(_DBUFFER) ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData); #endif +#if UNITY_VERSION >= 60000000 + InitializeBakedGIData(input, inputData); +#endif + //[NiloToon] add: //========================================================================================================================================================== // debug on off diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl index 4f5969a..2a1a955 100644 --- a/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl +++ b/Assets/External/NiloToonURP/Shaders/NiloToonEnvironment_HLSL/NiloToonEnvironment_LitInput.hlsl @@ -3,9 +3,9 @@ // For more information, visit -> https://github.com/ColinLeung-NiloCat/UnityURPToonLitShaderExample -// This shader is a direct copy of URP16.0.3's LitInput.hlsl, but with some edit. +// This shader is a direct copy of Unity6.1 URP17.0.3's LitInput.hlsl, but with some edit. // If you want to see what is the difference, all edited lines will have a [NiloToon] tag, you can search [NiloToon] in this file, -// or compare URP16.0.3's LitInput.hlsl with this file using tools like SourceGear DiffMerge. +// or compare Unity6.1 URP17.0.3's LitInput.hlsl with this file using tools like SourceGear DiffMerge. #ifndef UNIVERSAL_LIT_INPUT_INCLUDED #define UNIVERSAL_LIT_INPUT_INCLUDED @@ -15,6 +15,9 @@ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl" +#if UNITY_VERSION >= 60000000 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" +#endif #if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED) #define _DETAIL @@ -38,6 +41,9 @@ half _ClearCoatSmoothness; half _DetailAlbedoMapScale; half _DetailNormalMapScale; half _Surface; +#if UNITY_VERSION >= 60000000 +UNITY_TEXTURE_STREAMING_DEBUG_VARS; +#endif // NiloToon added: //======================================== @@ -104,7 +110,68 @@ UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata) UNITY_DOTS_INSTANCED_PROP(float , _Surface) UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata) -#if UNITY_VERSION >= 202220 +#if UNITY_VERSION >= 60000000 +// Here, we want to avoid overriding a property like e.g. _BaseColor with something like this: +// #define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor0) +// +// It would be simpler, but it can cause the compiler to regenerate the property loading code for each use of _BaseColor. +// +// To avoid this, the property loads are cached in some static values at the beginning of the shader. +// The properties such as _BaseColor are then overridden so that it expand directly to the static value like this: +// #define _BaseColor unity_DOTS_Sampled_BaseColor +// +// This simple fix happened to improve GPU performances by ~10% on Meta Quest 2 with URP on some scenes. +static float4 unity_DOTS_Sampled_BaseColor; +static float4 unity_DOTS_Sampled_SpecColor; +static float4 unity_DOTS_Sampled_EmissionColor; +static float unity_DOTS_Sampled_Cutoff; +static float unity_DOTS_Sampled_Smoothness; +static float unity_DOTS_Sampled_Metallic; +static float unity_DOTS_Sampled_BumpScale; +static float unity_DOTS_Sampled_Parallax; +static float unity_DOTS_Sampled_OcclusionStrength; +static float unity_DOTS_Sampled_ClearCoatMask; +static float unity_DOTS_Sampled_ClearCoatSmoothness; +static float unity_DOTS_Sampled_DetailAlbedoMapScale; +static float unity_DOTS_Sampled_DetailNormalMapScale; +static float unity_DOTS_Sampled_Surface; + +void SetupDOTSLitMaterialPropertyCaches() +{ + unity_DOTS_Sampled_BaseColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor); + unity_DOTS_Sampled_SpecColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _SpecColor); + unity_DOTS_Sampled_EmissionColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _EmissionColor); + unity_DOTS_Sampled_Cutoff = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Cutoff); + unity_DOTS_Sampled_Smoothness = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Smoothness); + unity_DOTS_Sampled_Metallic = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Metallic); + unity_DOTS_Sampled_BumpScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _BumpScale); + unity_DOTS_Sampled_Parallax = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Parallax); + unity_DOTS_Sampled_OcclusionStrength = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OcclusionStrength); + unity_DOTS_Sampled_ClearCoatMask = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ClearCoatMask); + unity_DOTS_Sampled_ClearCoatSmoothness = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ClearCoatSmoothness); + unity_DOTS_Sampled_DetailAlbedoMapScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _DetailAlbedoMapScale); + unity_DOTS_Sampled_DetailNormalMapScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _DetailNormalMapScale); + unity_DOTS_Sampled_Surface = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Surface); +} + +#undef UNITY_SETUP_DOTS_MATERIAL_PROPERTY_CACHES +#define UNITY_SETUP_DOTS_MATERIAL_PROPERTY_CACHES() SetupDOTSLitMaterialPropertyCaches() + +#define _BaseColor unity_DOTS_Sampled_BaseColor +#define _SpecColor unity_DOTS_Sampled_SpecColor +#define _EmissionColor unity_DOTS_Sampled_EmissionColor +#define _Cutoff unity_DOTS_Sampled_Cutoff +#define _Smoothness unity_DOTS_Sampled_Smoothness +#define _Metallic unity_DOTS_Sampled_Metallic +#define _BumpScale unity_DOTS_Sampled_BumpScale +#define _Parallax unity_DOTS_Sampled_Parallax +#define _OcclusionStrength unity_DOTS_Sampled_OcclusionStrength +#define _ClearCoatMask unity_DOTS_Sampled_ClearCoatMask +#define _ClearCoatSmoothness unity_DOTS_Sampled_ClearCoatSmoothness +#define _DetailAlbedoMapScale unity_DOTS_Sampled_DetailAlbedoMapScale +#define _DetailNormalMapScale unity_DOTS_Sampled_DetailNormalMapScale +#define _Surface unity_DOTS_Sampled_Surface +#elif UNITY_VERSION >= 202220 #define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _BaseColor) #define _SpecColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _SpecColor) #define _EmissionColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _EmissionColor) diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion.meta b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion.meta new file mode 100644 index 0000000..ab83347 --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f2508ca2460fbfb448b7c1999e98c05d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt new file mode 100644 index 0000000..573c053 --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa7959134513b4e505d5415529232cb935557fe5f0cce7e65508ce1b860e8fc8 +size 1080 diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt.meta b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt.meta new file mode 100644 index 0000000..d58a34f --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/LICENSE.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 14ec7a8ec61a5f54ebfcc9ed2410566a +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl new file mode 100644 index 0000000..20f4811 --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl @@ -0,0 +1,319 @@ +#ifndef __MOTION_BLUR__ +#define __MOTION_BLUR__ + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + +TEXTURE2D_X(_MainTex); +TEXTURE2D_X(_MotionVectorTexture); +TEXTURE2D_X(_CameraDepthTexture); + +#if UNITY_VERSION <= 202310 +SAMPLER(sampler_LinearClamp); +SAMPLER(sampler_PointClamp); +#endif + + +float4 _MainTex_TexelSize; +float4 _MotionVectorTexture_TexelSize; + +// Packed velocity texture (2/10/10/10) +TEXTURE2D_X(_VelocityTex); +float2 _VelocityTex_TexelSize; + +// NeighborMax texture +TEXTURE2D_X(_NeighborMaxTex); +float2 _NeighborMaxTex_TexelSize; + +// Velocity scale factor +float _VelocityScale; + +// TileMax filter parameters +int _TileMaxLoop; +float2 _TileMaxOffs; + +// Maximum blur radius (in pixels) +half _MaxBlurRadius; +float _RcpMaxBlurRadius; + +// Filter parameters/coefficients +half _LoopCount; + +struct AttributesDefault +{ + float4 vertex : POSITION; + float2 texcoord : TEXCOORD0; +}; +struct VaryingsDefault +{ + float4 positionHCS : SV_POSITION; + float2 uv : TEXCOORD0; +}; +VaryingsDefault VertDefault(AttributesDefault input) +{ + VaryingsDefault output; + output.positionHCS = TransformObjectToHClip(input.vertex.xyz); + output.uv = input.texcoord; + return output; +} +struct VaryingsMultitex +{ + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + float2 uv1 : TEXCOORD1; +}; + +VaryingsMultitex VertMultitex(AttributesDefault v) +{ + VaryingsMultitex o; + o.pos = TransformObjectToHClip(v.vertex.xyz); + o.uv0 = v.texcoord.xy; + o.uv1 = v.texcoord.xy; + +#if UNITY_UV_STARTS_AT_TOP + if (_MainTex_TexelSize.y < 0.0) + o.uv1.y = 1.0 - v.texcoord.y; +#endif + + return o; +} + +// ----------------------------------------------------------------------------- +// helper functions +#define UNITY_PI_2 (UNITY_PI * 2.0) + +inline half2 MaxV(half2 v1, half2 v2) { return dot(v1, v1) < dot(v2, v2) ? v2 : v1; } + +// Interleaved gradient function from Jimenez 2014 http://goo.gl/eomGso +float GradientNoise(float2 uv) +{ + uv = floor(uv * _ScreenParams.xy); + float f = dot(float2(0.06711056, 0.00583715), uv); + return frac(52.9829189 * frac(f)); +} + +// Z buffer depth to linear 0-1 depth +// Handles orthographic projection correctly +float LinearizeDepth(float z) +{ + float isOrtho = unity_OrthoParams.w; + float isPers = 1.0 - unity_OrthoParams.w; + z *= _ZBufferParams.x; + return (1.0 - isOrtho * z) / (isPers * z + _ZBufferParams.y); +} +// ----------------------------------------------------------------------------- +// Prefilter + +// Velocity texture setup +half4 FragVelocitySetup(VaryingsDefault i) : SV_Target +{ + // Sample the motion vector. + float2 v = SAMPLE_TEXTURE2D_X(_MotionVectorTexture, sampler_LinearClamp, i.uv).xy; + + // Apply the exposure time and convert to the pixel space. + v *= (_VelocityScale * 0.5) * _MotionVectorTexture_TexelSize.zw; + + // Clamp the vector with the maximum blur radius. + v /= max(1.0, length(v) * _RcpMaxBlurRadius); + + // Sample the depth of the pixel. + half d = LinearizeDepth(SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_PointClamp, i.uv).r); + + // Pack into 10/10/10/2 format. + return half4((v * _RcpMaxBlurRadius + 1.0) * 0.5, d, 0.0); +} + +// TileMax filter (2 pixel width with normalization) +half4 FragTileMax1(VaryingsDefault i) : SV_Target +{ + float4 d = _MainTex_TexelSize.xyxy * float4(-0.5, -0.5, 0.5, 0.5); + + half2 v1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xy).rg; + half2 v2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.zy).rg; + half2 v3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xw).rg; + half2 v4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.zw).rg; + + v1 = (v1 * 2.0 - 1.0) * _MaxBlurRadius; + v2 = (v2 * 2.0 - 1.0) * _MaxBlurRadius; + v3 = (v3 * 2.0 - 1.0) * _MaxBlurRadius; + v4 = (v4 * 2.0 - 1.0) * _MaxBlurRadius; + + return half4(MaxV(MaxV(MaxV(v1, v2), v3), v4), 0.0, 0.0); +} + +// TileMax filter (2 pixel width) +half4 FragTileMax2(VaryingsDefault i) : SV_Target +{ + float4 d = _MainTex_TexelSize.xyxy * float4(-0.5, -0.5, 0.5, 0.5); + + half2 v1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xy).rg; + half2 v2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.zy).rg; + half2 v3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xw).rg; + half2 v4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.zw).rg; + + return half4(MaxV(MaxV(MaxV(v1, v2), v3), v4), 0.0, 0.0); +} + +// TileMax filter (variable width) +half4 FragTileMaxV(VaryingsDefault i) : SV_Target +{ + float2 uv0 = i.uv + _MainTex_TexelSize.xy * _TileMaxOffs.xy; + + float2 du = float2(_MainTex_TexelSize.x, 0.0); + float2 dv = float2(0, _MainTex_TexelSize.y); + + half2 vo = 0; + + UNITY_LOOP + for (int ix = 0; ix < _TileMaxLoop; ix++) + { + UNITY_LOOP + for (int iy = 0; iy < _TileMaxLoop; iy++) + { + float2 uv = uv0 + du * ix + dv * iy; + vo = MaxV(vo, SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv).rg); + } + } + + return half4(vo, 0.0, 0.0); +} + +// NeighborMax filter +half4 FragNeighborMax(VaryingsDefault i) : SV_Target +{ + const half cw = 1.01; // Center weight tweak + + float4 d = _MainTex_TexelSize.xyxy * float4(1.0, 1.0, -1.0, 0.0); + + half2 v1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - d.xy).rg; + half2 v2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - d.wy).rg; + half2 v3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - d.zy).rg; + + half2 v4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - d.xw).rg; + half2 v5 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv).rg * cw; + half2 v6 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xw).rg; + + half2 v7 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.zy).rg; + half2 v8 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.wy).rg; + half2 v9 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + d.xy).rg; + + half2 va = MaxV(v1, MaxV(v2, v3)); + half2 vb = MaxV(v4, MaxV(v5, v6)); + half2 vc = MaxV(v7, MaxV(v8, v9)); + + return half4(MaxV(va, MaxV(vb, vc)) * (1.0 / cw), 0.0, 0.0); +} + +// ----------------------------------------------------------------------------- +// Reconstruction + +// Returns true or false with a given interval. +bool Interval(half phase, half interval) +{ + return frac(phase / interval) > 0.499; +} + +// Jitter function for tile lookup +float2 JitterTile(float2 uv) +{ + float rx, ry; + sincos(GradientNoise(uv + float2(2.0, 0.0)) * PI * 2.0, ry, rx); + return float2(rx, ry) * _NeighborMaxTex_TexelSize.xy * 0.25; +} + +// Velocity sampling function +half3 SampleVelocity(float2 uv) +{ + half3 v = SAMPLE_TEXTURE2D_X_LOD(_VelocityTex, sampler_LinearClamp, uv, 0).xyz; + return half3((v.xy * 2.0 - 1.0) * _MaxBlurRadius, v.z); +} + +// Reconstruction filter +half4 FragReconstruction(VaryingsMultitex i) : SV_Target +{ + // Color sample at the center point + const half4 c_p = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv0); + + // Velocity/Depth sample at the center point + const half3 vd_p = SampleVelocity(i.uv1); + const half l_v_p = max(length(vd_p.xy), 0.5); + const half rcp_d_p = 1.0 / vd_p.z; + + // NeighborMax vector sample at the center point + const half2 v_max = SAMPLE_TEXTURE2D_X(_NeighborMaxTex, sampler_LinearClamp, i.uv1 + JitterTile(i.uv1)).xy; + const half l_v_max = length(v_max); + const half rcp_l_v_max = 1.0 / l_v_max; + + // Escape early if the NeighborMax vector is small enough. + if (l_v_max < 2.0) return c_p; + + // Use V_p as a secondary sampling direction except when it's too small + // compared to V_max. This vector is rescaled to be the length of V_max. + const half2 v_alt = (l_v_p * 2.0 > l_v_max) ? vd_p.xy * (l_v_max / l_v_p) : v_max; + + // Determine the sample count. + const half sc = floor(min(_LoopCount, l_v_max * 0.5)); + + // Loop variables (starts from the outermost sample) + const half dt = 1.0 / sc; + const half t_offs = (GradientNoise(i.uv0) - 0.5) * dt; + half t = 1.0 - dt * 0.5; + half count = 0.0; + + // Background velocity + // This is used for tracking the maximum velocity in the background layer. + half l_v_bg = max(l_v_p, 1.0); + + // Color accumlation + half4 acc = 0.0; + + UNITY_LOOP while (t > dt * 0.25) + { + // Sampling direction (switched per every two samples) + const half2 v_s = Interval(count, 4.0) ? v_alt : v_max; + + // Sample position (inverted per every sample) + const half t_s = (Interval(count, 2.0) ? -t : t) + t_offs; + + // Distance to the sample position + const half l_t = l_v_max * abs(t_s); + + // UVs for the sample position + const float2 uv0 = i.uv0 + v_s * t_s * _MainTex_TexelSize.xy; + const float2 uv1 = i.uv1 + v_s * t_s * _VelocityTex_TexelSize.xy; + + // Color sample + const half3 c = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv0, 0).rgb; + + // Velocity/Depth sample + const half3 vd = SampleVelocity(uv1); + + // Background/Foreground separation + const half fg = saturate((vd_p.z - vd.z) * 20.0 * rcp_d_p); + + // Length of the velocity vector + const half l_v = lerp(l_v_bg, length(vd.xy), fg); + + // Sample weight + // (Distance test) * (Spreading out by motion) * (Triangular window) + const half w = saturate(l_v - l_t) / l_v * (1.2 - t); + + // Color accumulation + acc += half4(c, 1.0) * w; + + // Update the background velocity. + l_v_bg = max(l_v_bg, l_v); + + // Advance to the next sample. + t = Interval(count, 2.0) ? t - dt : t; + count += 1.0; + } + + // Add the center sample. + acc += half4(c_p.rgb, 1.0) * (1.2 / (l_v_bg * sc * 2.0)); + + return half4(acc.rgb / acc.a, c_p.a); +} + +#endif // __MOTION_BLUR__ diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl.meta b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl.meta new file mode 100644 index 0000000..b97c3e5 --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8f21afbd61eff0e469872563982c62a7 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader new file mode 100644 index 0000000..e3749cd --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader @@ -0,0 +1,91 @@ +Shader "Hidden/NiloToon/NiloToonKinoMotionBlur" +{ + HLSLINCLUDE + + #pragma target 3.0 + + ENDHLSL + + SubShader + { + // require Unity2022.3 or above + PackageRequirements + { + "com.unity.render-pipelines.universal": "14.0.0" + } + + Cull Off ZWrite Off ZTest Always + + // (0) Velocity texture setup + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertDefault + #pragma fragment FragVelocitySetup + + ENDHLSL + } + + // (1) TileMax filter (2 pixel width with normalization) + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertDefault + #pragma fragment FragTileMax1 + + ENDHLSL + } + + // (2) TileMax filter (2 pixel width) + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertDefault + #pragma fragment FragTileMax2 + + ENDHLSL + } + + // (3) TileMax filter (variable width) + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertDefault + #pragma fragment FragTileMaxV + + ENDHLSL + } + + // (4) NeighborMax filter + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertDefault + #pragma fragment FragNeighborMax + + ENDHLSL + } + + // (5) Reconstruction filter + Pass + { + HLSLPROGRAM + + #include "NiloToonKinoMotionBlur.hlsl" + #pragma vertex VertMultitex + #pragma fragment FragReconstruction + + ENDHLSL + } + } +} diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader.meta b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader.meta new file mode 100644 index 0000000..b545876 --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonKinoMotion/NiloToonKinoMotionBlur.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ee405eb0f8e81bb49ad26c71bc04b4ed +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader new file mode 100644 index 0000000..9f4be9e --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader @@ -0,0 +1,353 @@ + +Shader "Hidden/NiloToon/NiloToonMotionBlur" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + } + + SubShader + { + // require Unity2022.3 or above + PackageRequirements + { + "com.unity.render-pipelines.universal": "14.0.0" + } + + Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"} + ZWrite Off ZTest Always Blend Off Cull Off + + HLSLINCLUDE + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + + TEXTURE2D_X(_MainTex); + SAMPLER(sampler_MainTex); + TEXTURE2D_X(_TileMaxTex); + SAMPLER(sampler_TileMaxTex); + TEXTURE2D_X(_NeighborMaxTex); + SAMPLER(sampler_NeighborMaxTex_linear_clamp); + TEXTURE2D_X(_MotionVectorTexture); + SAMPLER(sampler_MotionVectorTexture); + TEXTURE2D_X(_CameraDepthTexture); + SAMPLER(sampler_CameraDepthTexture); +#if UNITY_VERSION <= 202310 + SAMPLER(sampler_LinearClamp); + SAMPLER(sampler_PointClamp); +#endif + + + TEXTURE2D_X(_CopyTex); + SAMPLER(sampler_CopyTex); + + //float4 _MainTex_TexelSize; + float _NumSamples; + float _TileSize; + float _Intensity; + float _SoftZExtent; + float4 _SourceMV_TexelSize; + float _MaxBlurRadius; + + struct Attributes + { + float4 positionOS : POSITION; + float2 texcoord : TEXCOORD0; + }; + + struct Varyings + { + float4 positionHCS : SV_POSITION; + float2 texcoord : TEXCOORD0; + }; + + Varyings Vert(Attributes input) + { + Varyings output; + output.positionHCS = TransformObjectToHClip(input.positionOS.xyz); + output.texcoord = input.texcoord; + return output; + } + + float2 GetMotionVector(float2 uv) + { + // Unity doc to sample URP's motion vector + // https://docs.unity3d.com/6000.0/Documentation/Manual/urp/features/motion-vectors-sample.html + return SAMPLE_TEXTURE2D_X(_MotionVectorTexture, sampler_LinearClamp, uv).xy; + } + + // return = is A at the back relative to B + float SoftDepthCompare(float depthA, float depthB) + { + // Soft depth comparison function + return saturate(1.0 - (depthA - depthB) / _SoftZExtent); + } + + float ConeWeight(float2 X, float2 Y, float2 v) + { + // Cone function: linear falloff based on distance along the motion vector + return saturate(1.0 - length(X - Y) / (length(v) + 1e-4)); + } + + float CylinderWeight(float2 X, float2 Y, float2 v) + { + // Cylinder function for simultaneous blurriness + float dist = length(X - Y); + float vLen = length(v) + 1e-4; + return saturate(1.0 - smoothstep(0.95 * vLen, 1.05 * vLen, dist)); + } + + float Random(float2 uv) + { + // Simple hash-based random function + return frac(sin(dot(uv , float2(12.9898,78.233))) * 43758.5453); + } + + // copied from URP's CameraMotionBLur.shader + float2 ClampVelocity(float2 velocity, float maxVelocity) + { + float len = length(velocity); + return (len > 0.0) ? min(len, maxVelocity) * (velocity * rcp(len)) : 0.0; + } + + float4 TileMaxFilter(Varyings input) : SV_Target + { + // Source texture dimensions + float sourceWidth = _SourceMV_TexelSize.z; + float sourceHeight = _SourceMV_TexelSize.w; + + // The size of the tile in pixels + int tileSize = _TileSize; + + // Compute number of tiles (ensure integer values) + float numTilesX = ceil(sourceWidth / tileSize); + float numTilesY = ceil(sourceHeight / tileSize); + + // Compute tile indices in TileMax RT + float2 tileCoord = input.texcoord * float2(numTilesX, numTilesY); + int2 tileIndex = int2(tileCoord); + + // Compute the origin of the tile in source texture pixel coordinates + float2 tileOrigin = float2(tileIndex) * tileSize; + + // Initialize variables + float2 maxVelocity = float2(0, 0); + float maxLength = 0; + + // Loop over the pixels in the tile + for (int y = 0; y < tileSize; y++) + { + int py = int(tileOrigin.y) + y; + //if (py >= sourceHeight) + // break; // Avoid accessing beyond texture height + + for (int x = 0; x < tileSize; x++) + { + int px = int(tileOrigin.x) + x; + //if (px >= sourceWidth) + // break; // Avoid accessing beyond texture width + + float2 pixelCoord = float2(px, py); + + // Convert pixel coordinates to UVs in the source texture + float2 uv = pixelCoord / float2(sourceWidth, sourceHeight); + uv = clamp(uv, 0.0, 1.0); // Ensure UVs are within [0,1] + + // Sample the motion vector at this UV + float2 velocity = GetMotionVector(uv); + + float velocityLength = length(velocity); + + if (velocityLength > maxLength) + { + maxVelocity = velocity; + maxLength = velocityLength; + } + } + } + + return float4(maxVelocity, 0, 1); + } + + float4 NeighborMaxFilter(Varyings input) : SV_Target + { + float2 maxVelocity = float2(0, 0); + float maxLength = 0; + + // Compute the texel size of TileMaxTex in UV space + float2 texelSize = _TileSize * _SourceMV_TexelSize.xy; // Equivalent to tile size in UVs + + for (int y = -1; y <= 1; y++) + { + for (int x = -1; x <= 1; x++) + { + float2 offset = float2(x, y) * texelSize; + float2 uv = input.texcoord + offset; + + // Clamp UVs to prevent sampling outside the texture + uv = clamp(uv, 0.0, 1.0); + + float2 velocity = SAMPLE_TEXTURE2D_X(_TileMaxTex, sampler_LinearClamp, uv).xy; + float velocityLength = length(velocity); + + if (velocityLength > maxLength) + { + maxVelocity = velocity; + maxLength = velocityLength; + } + } + } + + return float4(maxVelocity, 0, 1); + } + + float4 NaiveMotionBlur(Varyings input) : SV_TARGET + { + float2 velocity = GetMotionVector(input.texcoord); + + float4 color = 0; + for (int i = -32; i < 32; i++) + { + color += SAMPLE_TEXTURE2D_X(_CopyTex, sampler_LinearClamp, input.texcoord + velocity * i * 0.005); + } + + return color * (1.0/65.0); + } + float4 MotionBlur(Varyings input) : SV_Target + { + float _ExposureTime = (1000/60) * _Intensity; + float _SampleCount = 15; // atleast 3, better to be odd number + float _EarlyExitThreshold = 1e-4; + //--------------------------- + float2 uv = input.texcoord; + float2 pixelPos = uv * _ScaledScreenParams.xy; + + // Retrieve the dominant motion vector from NeighborMax texture + float2 vN = SAMPLE_TEXTURE2D_X(_NeighborMaxTex, sampler_LinearClamp, uv).xy; + vN *= _ExposureTime; + + vN = ClampVelocity(vN, _MaxBlurRadius); + + float vNLength = length(vN); + + float4 color = SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, uv); + + // Check for significant motion + if (vNLength <= _EarlyExitThreshold) + { + // No significant motion, return original color + return color; + } + + // Initialize accumulation variables + float weightSum = 0.5; + float3 colorSum = color.rgb * weightSum; + + // Get per-pixel motion vector + float2 velocity = SAMPLE_TEXTURE2D_X(_MotionVectorTexture, sampler_LinearClamp, uv).xy; + velocity *= _ExposureTime; + + // Clamp velocity + velocity = ClampVelocity(velocity, _MaxBlurRadius); + + // Get depth of current pixel + float depth = Linear01Depth(SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_CameraDepthTexture, uv).r,_ZBufferParams); // DX: 1 at near, 0 at far. Linear + + // Jitter to prevent ghosting + float jitter = Random(uv) - 0.5; + + //jitter *= 0.5; + + // Number of samples along motion vector + int S = _SampleCount; + + for (int i = 0; i < S; i++) + { + // Fraction along the motion vector (-0.5 to 0.5) + float t = (i + jitter) / S - 0.5; + + // Sample position along the motion vector + float2 sampleOffset = vN * t; + float2 sampleUv = uv + sampleOffset * _SourceMV_TexelSize.xy; + + // Ensure sampleUv is within texture bounds + sampleUv = saturate(sampleUv); + + // Retrieve sample color and depth + float3 sampleColor = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, sampleUv, 0).rgb; + float sampleDepth = Linear01Depth(SAMPLE_TEXTURE2D_X_LOD(_CameraDepthTexture, sampler_CameraDepthTexture, sampleUv, 0).r, _ZBufferParams); // DX: 1 at near, 0 at far. Linear + float2 sampleVelocity = GetMotionVector(sampleUv); + sampleVelocity *= _ExposureTime; + + // Clamp the length of velocity to _MaxBlurRadius + sampleVelocity = ClampVelocity(sampleVelocity, _MaxBlurRadius); + + // [copy directly according to McGuire12Blur paper] + // Fore- vs. background classification of Y relative to X + // f means front + // b means back + // depth input is 0~1 (we assume linear is better) + // Note: we swap f&b's value, it is different to paper's design, but it is the correct way in unity + float f = SoftDepthCompare(sampleDepth, depth); // f = is offseted pixel(Y) at the front of original pixel(X) + float b = SoftDepthCompare(depth, sampleDepth); // b = is offseted pixel(Y) at the back of original pixel(X) + float alphaY = 0.0; + + // [copy directly according to McGuire12Blur paper] + float2 X = pixelPos; // original pixel coord index + float2 Y = pixelPos + sampleOffset; // offseted pixel coord index + float2 VX = velocity; // original pixel velocity + float2 VY = sampleVelocity; // offseted pixel velocity + + // TODO: length(X-Y) and Velocity should be using the same unit + alphaY += f * ConeWeight(Y, X, VY); // case 1: Y contributes when Y is moving+blurry and passes in front of X + alphaY += b * ConeWeight(X, Y, VX); // case 2: X itself is moving+blurry so we should be able to see through + alphaY += CylinderWeight(Y, X, VY) * CylinderWeight(X, Y, VX) * 2.0; // case 3: 2 moving blur together + + // test + alphaY *= 1.0 / max(1,distance(X,Y)/_TileSize); + + // Accumulate color and weight + colorSum += sampleColor * alphaY; + weightSum += alphaY; + } + + // Normalize accumulated color + float3 finalColor = colorSum / max(weightSum, 1e-4); + + return float4(finalColor, 1.0); + } + + ENDHLSL + + Pass // Tile max + { + Name "Tile Max" + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment TileMaxFilter + ENDHLSL + } + + Pass // Neighbor max + { + Name "Neighbor Max" + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment NeighborMaxFilter + ENDHLSL + } + + Pass // Motion blur + { + Name "Motion Blur" + + HLSLPROGRAM + #pragma vertex Vert + //#pragma fragment NaiveMotionBlur + #pragma fragment MotionBlur + ENDHLSL + } + } +} \ No newline at end of file diff --git a/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader.meta b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader.meta new file mode 100644 index 0000000..a5b57df --- /dev/null +++ b/Assets/External/NiloToonURP/Shaders/NiloToonRendererFeatureShaders/Resources/NiloToonMotionBlur.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3a18c13b0e75e05419a59b8164aaff90 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/External/NiloToonURP/package.json b/Assets/External/NiloToonURP/package.json index 884a488..5488be6 100644 --- a/Assets/External/NiloToonURP/package.json +++ b/Assets/External/NiloToonURP/package.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ef7d649149bec65878f52db2807844e1d07e0640ee148bea98f551175556713 -size 813 +oid sha256:ef91d7c8db358b904f5e3128cdba5501725b371966d52553c9b03a834f280e77 +size 828