From 1f5994685bbaa1e94dd4e96287337a1613395a72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 22 Oct 2025 05:43:29 +0000 Subject: [PATCH 1/3] ga: update README (executed by update_readme.yml) [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6200dd9..fb49528d 100644 --- a/README.md +++ b/README.md @@ -94,4 +94,4 @@ git config --global core.symlinks true -*Auto-generated on Wed Oct 15 14:06:35 UTC 2025* +*Auto-generated on Wed Oct 22 05:43:29 UTC 2025* From 9f4377b586b133292b43dfbdbf47391ece8dbb9c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Oct 2025 05:56:38 +0000 Subject: [PATCH 2/3] Refactor: Consolidate shader properties and generate files This commit introduces a shader generator tool that consolidates shared properties into CommonProperties.txt and TessellationProperties.txt. This ensures consistency between UnityToon.shader and UnityToonTessellation.shader, making them easier to maintain. The tool generates the shader files, preserving existing non-property content and creating backups of original files. Co-authored-by: sindharta.tanuwijaya --- UnityToon_Generated_Test.shader | 1534 ++++++++++++++ .../Editor/README_ShaderGenerator.md | 78 + .../Editor/ShaderGenerator.cs | 248 +++ .../Editor/ShaderGeneratorTest.cs | 109 + .../Integrated/Shaders/CommonProperties.txt | 474 +++++ .../Shaders/TessellationProperties.txt | 20 + .../Integrated/Shaders/UnityToon.shader | 145 +- .../Shaders/UnityToon.shader.backup | 1675 +++++++++++++++ .../Shaders/UnityToonTessellation.shader | 182 +- .../UnityToonTessellation.shader.backup | 1790 +++++++++++++++++ generate_shaders.bat | 20 + generate_shaders.py | 152 ++ generate_shaders.sh | 20 + test_generation.py | 110 + test_shader_generation.cs | 130 ++ 15 files changed, 6371 insertions(+), 316 deletions(-) create mode 100644 UnityToon_Generated_Test.shader create mode 100644 com.unity.toonshader/Editor/README_ShaderGenerator.md create mode 100644 com.unity.toonshader/Editor/ShaderGenerator.cs create mode 100644 com.unity.toonshader/Editor/ShaderGeneratorTest.cs create mode 100644 com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt create mode 100644 com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt create mode 100644 com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup create mode 100644 com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup create mode 100644 generate_shaders.bat create mode 100644 generate_shaders.py create mode 100755 generate_shaders.sh create mode 100644 test_generation.py create mode 100644 test_shader_generation.cs diff --git a/UnityToon_Generated_Test.shader b/UnityToon_Generated_Test.shader new file mode 100644 index 00000000..8c69159b --- /dev/null +++ b/UnityToon_Generated_Test.shader @@ -0,0 +1,1534 @@ +//Unity Toon Shader +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) + +Shader "Toon" { + Properties { + [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 + [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 + [HideInInspector] _utsVersionX("VersionX", Float) = 0 + [HideInInspector] _utsVersionY("VersionY", Float) = 11 + [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 + [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF + _AutoRenderQueue("Automatic Render Queue ", int) = 1 + [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + _StencilComp("Stencil Comparison", Float) = 8 + _StencilNo("Stencil No", Float) = 1 + _StencilOpPass("Stencil Operation", Float) = 0 + _StencilOpFail("Stencil Operation", Float) = 0 + [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON + [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON + _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + _ClippingMask("ClippingMask", 2D) = "white" {} + _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 + _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 + _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + _MainTex ("BaseMap", 2D) = "white" {} + _BaseMap ("BaseMap", 2D) = "white" {} + _BaseColor ("BaseColor", Color) = (1,1,1,1) + _Color ("Color", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 + _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 + _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + _NormalMap ("NormalMap", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 + _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 + _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 + _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 + _1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 + _1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 + _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 + _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 + [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} + _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} + _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 + _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + _HighColor ("HighColor", Color) = (0,0,0,1) + _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} + [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 + [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 + _HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 + [Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 + [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 + [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 + _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 + _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} + _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _RimLight ("RimLight", Float ) = 0 + _RimLightColor ("RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 + [Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 + _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 + _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 + [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 + [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 + _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 + [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 + _Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 + _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 + [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 + _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} + _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _MatCap ("MatCap", Float ) = 0 + _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 + _MatCapColor ("MatCapColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 + [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 + _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 + _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 + [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 + _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} + _BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 + _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 + _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 + _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} + _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + [Toggle(_)] _AngelRing("AngelRing", Float) = 0 + _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} + _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) + [Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 + _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 + _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 + [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 + _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} + [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) + _Base_Speed ("Base_Speed", Float ) = 0 + _Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 + _Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 + _Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 + [Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 + [Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 + [HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) + _ColorShift_Speed ("ColorShift_Speed", Float ) = 0 + [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 + [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) + [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 + _Outline_Width ("Outline_Width", Float ) = 0 + _Farthest_Distance ("Farthest_Distance", Float ) = 100 + _Nearest_Distance ("Nearest_Distance", Float ) = 0.5 + _Outline_Sampler ("Outline_Sampler", 2D) = "white" {} + _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) + [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 + [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 + _OutlineTex ("OutlineTex", 2D) = "white" {} + _Offset_Z ("Offset_Camera_Z", Float) = 0 + [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 + _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 + _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 + _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 + [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 + [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 + _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 + _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 + _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 + [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 + _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 + [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 + _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 + [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 + _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 + [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 + _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + [Toggle(_)] _ComposerMaskMode("", Float) = 0 + [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + _BaseColorMap("BaseColorMap", 2D) = "white" {} + [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + _Metallic("_Metallic", Range(0.0, 1.0)) = 0 + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _MaskMap("MaskMap", 2D) = "white" {} + _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 + _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 + _AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 + _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 + _AORemapMin("AORemapMin", Float) = 0.0 + _AORemapMax("AORemapMax", Float) = 1.0 + _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value + _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + _BentNormalMap("_BentNormalMap", 2D) = "bump" {} + _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + _HeightMap("HeightMap", 2D) = "black" {} + [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. + [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + _HeightOffset("Height Offset", Float) = 0 + _HeightMin("Heightmap Min", Float) = -1 + _HeightMax("Heightmap Max", Float) = 1 + _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters + _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + _DetailMap("DetailMap", 2D) = "linearGrey" {} + _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 + _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 + _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + _TangentMap("TangentMap", 2D) = "bump" {} + _TangentMapOS("TangentMapOS", 2D) = "white" {} + _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 + _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 + [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) + [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 + _SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 + _SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} + _TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 + _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 + _ThicknessMap("Thickness Map", 2D) = "white" {} + _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 + _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} + _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 + _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 + _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 + _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) + _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) + _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} + [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 + [HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 + [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 + _EmissiveIntensity("Emissive Intensity", Float) = 1 + _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} + [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 + [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 + [Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 + [HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 + [HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 + [HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 + _DistortionScale("Distortion Scale", Float) = 1 + _DistortionVectorScale("Distortion Vector Scale", Float) = 2 + _DistortionVectorBias("Distortion Vector Bias", Float) = -1 + _DistortionBlurScale("Distortion Blur Scale", Float) = 1 + _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 + _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 + [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 + _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 + [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 + [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 + _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 + [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 + _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 + _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 + _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) + _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} + _ATDistance("Transmittance Absorption Distance", Float) = 1.0 + [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing + [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 + [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 + [HideInInspector] _SrcBlend("__src", Float) = 1.0 + [HideInInspector] _DstBlend("__dst", Float) = 0.0 + [HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 + [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 + [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 + [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 + [HideInInspector] _CullMode("__cullmode", Float) = 2.0 + [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent + [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default + [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal + [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 + [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 + [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 + [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 + [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 + [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 + [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 + _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 + [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) + [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 + [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 + [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 + [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 + _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 + _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 + _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 + _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 + _PPDPrimitiveLength("Primitive length for POM", Float) = 1 + _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 + [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 + [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) + [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 + _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + _EmissionColor("Color", Color) = (1, 1, 1) + _Color("Color", Color) = (1,1,1,1) + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + } + + HLSLINCLUDE + + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS +// HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + ENDHLSL + + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight 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 _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // 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 _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" + + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" + + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #pragma multi_compile _IS_PASS_FWDBASE + + // + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + //v.2.0.4 + + #pragma multi_compile _IS_PASS_FWDDELTA + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW + +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #include "../../Legacy/Shaders/UCTS_ShadowCaster.cginc" + ENDCG + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/com.unity.toonshader/Editor/README_ShaderGenerator.md b/com.unity.toonshader/Editor/README_ShaderGenerator.md new file mode 100644 index 00000000..f909337c --- /dev/null +++ b/com.unity.toonshader/Editor/README_ShaderGenerator.md @@ -0,0 +1,78 @@ +# Unity Toon Shader Generator + +This tool helps maintain consistency between `UnityToon.shader` and `UnityToonTessellation.shader` by using a single source of truth for shared properties. + +## Files + +- **CommonProperties.txt**: Contains all shared properties between the two shader files +- **TessellationProperties.txt**: Contains tessellation-specific properties only present in the tessellation shader +- **ShaderGenerator.cs**: Unity Editor script that generates the shader files from the property files + +## How to Use + +1. **Open the Shader Generator Window**: + - In Unity, go to `Tools > Unity Toon Shader > Generate Shader Files` + - This opens the Shader Generator window + +2. **Edit Properties**: + - Click "Open Common Properties File" to edit shared properties + - Click "Open Tessellation Properties File" to edit tessellation-specific properties + - Make your changes to the property files + +3. **Generate Shader Files**: + - Click "Generate Shader Files" button + - The tool will automatically: + - Create backups of the original shader files (`.backup` extension) + - Replace the Properties blocks in both shader files + - Preserve all other shader content (HLSLINCLUDE, SubShaders, etc.) + +## Property File Format + +The property files use the same format as ShaderLab Properties blocks, but without the `Properties { }` wrapper: + +``` +// Comments are supported +[HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 +[Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 +_BaseColor ("BaseColor", Color) = (1,1,1,1) +``` + +## Benefits + +- **Single Source of Truth**: All shared properties are defined in one place +- **Consistency**: Ensures both shader files have identical shared properties +- **Maintainability**: Easy to add, remove, or modify properties across both shaders +- **Backup Safety**: Original files are automatically backed up before generation +- **Preservation**: All non-Properties content is preserved during generation + +## Manual Generation (Alternative) + +If you prefer to generate shaders manually or from command line, you can use the Python script: + +```bash +cd /workspace +python3 generate_shaders.py +``` + +This will generate both shader files from the property files. + +## Troubleshooting + +- **Properties block not found**: Ensure the shader files have a valid `Properties { }` block +- **File not found errors**: Check that the property files exist in the correct paths +- **Generation fails**: Check the Unity Console for detailed error messages +- **Restore from backup**: If generation fails, you can restore from the `.backup` files + +## File Structure + +``` +com.unity.toonshader/ +├── Editor/ +│ ├── ShaderGenerator.cs # Unity Editor script +│ └── README_ShaderGenerator.md # This file +└── Runtime/Integrated/Shaders/ + ├── CommonProperties.txt # Shared properties + ├── TessellationProperties.txt # Tessellation-specific properties + ├── UnityToon.shader # Generated shader (regular) + └── UnityToonTessellation.shader # Generated shader (tessellation) +``` \ No newline at end of file diff --git a/com.unity.toonshader/Editor/ShaderGenerator.cs b/com.unity.toonshader/Editor/ShaderGenerator.cs new file mode 100644 index 00000000..d6f4c8e8 --- /dev/null +++ b/com.unity.toonshader/Editor/ShaderGenerator.cs @@ -0,0 +1,248 @@ +using System; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +namespace UnityEditor.Rendering.Toon +{ + /// + /// Shader generator for Unity Toon Shader that creates shader files from common properties. + /// This helps maintain consistency between UnityToon.shader and UnityToonTessellation.shader + /// by using a single source of truth for shared properties. + /// + public class ShaderGenerator : EditorWindow + { + private const string COMMON_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt"; + private const string TESSELATION_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt"; + private const string UNITY_TOON_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader"; + private const string UNITY_TOON_TESSELATION_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader"; + + [MenuItem("Tools/Unity Toon Shader/Generate Shader Files")] + public static void ShowWindow() + { + GetWindow("Shader Generator"); + } + + private void OnGUI() + { + GUILayout.Label("Unity Toon Shader Generator", EditorStyles.boldLabel); + GUILayout.Space(10); + + GUILayout.Label("This tool generates UnityToon.shader and UnityToonTessellation.shader from common property files.", EditorStyles.helpBox); + GUILayout.Space(10); + + if (GUILayout.Button("Generate Shader Files", GUILayout.Height(30))) + { + GenerateShaderFiles(); + } + + GUILayout.Space(10); + + if (GUILayout.Button("Open Common Properties File")) + { + var asset = AssetDatabase.LoadAssetAtPath(COMMON_PROPERTIES_PATH); + if (asset != null) + { + Selection.activeObject = asset; + EditorGUIUtility.PingObject(asset); + } + } + + if (GUILayout.Button("Open Tessellation Properties File")) + { + var asset = AssetDatabase.LoadAssetAtPath(TESSELATION_PROPERTIES_PATH); + if (asset != null) + { + Selection.activeObject = asset; + EditorGUIUtility.PingObject(asset); + } + } + } + + private void GenerateShaderFiles() + { + try + { + // Read common properties + string commonProperties = ReadFile(COMMON_PROPERTIES_PATH); + if (string.IsNullOrEmpty(commonProperties)) + { + Debug.LogError($"Failed to read common properties from {COMMON_PROPERTIES_PATH}"); + return; + } + + // Read tessellation properties + string tessellationProperties = ReadFile(TESSELATION_PROPERTIES_PATH); + if (string.IsNullOrEmpty(tessellationProperties)) + { + Debug.LogError($"Failed to read tessellation properties from {TESSELATION_PROPERTIES_PATH}"); + return; + } + + // Generate UnityToon.shader + GenerateUnityToonShader(commonProperties); + + // Generate UnityToonTessellation.shader + GenerateUnityToonTessellationShader(commonProperties, tessellationProperties); + + AssetDatabase.Refresh(); + Debug.Log("Shader files generated successfully!"); + } + catch (Exception e) + { + Debug.LogError($"Error generating shader files: {e.Message}"); + } + } + + private void GenerateUnityToonShader(string commonProperties) + { + // Read the original shader file to preserve the rest of the content + string originalContent = ReadFile(UNITY_TOON_SHADER_PATH); + if (string.IsNullOrEmpty(originalContent)) + { + Debug.LogError($"Failed to read original shader from {UNITY_TOON_SHADER_PATH}"); + return; + } + + // Create backup + CreateBackup(UNITY_TOON_SHADER_PATH); + + // Replace the Properties block + string newContent = ReplacePropertiesBlock(originalContent, commonProperties, ""); + WriteFile(UNITY_TOON_SHADER_PATH, newContent); + } + + private void GenerateUnityToonTessellationShader(string commonProperties, string tessellationProperties) + { + // Read the original shader file to preserve the rest of the content + string originalContent = ReadFile(UNITY_TOON_TESSELATION_SHADER_PATH); + if (string.IsNullOrEmpty(originalContent)) + { + Debug.LogError($"Failed to read original tessellation shader from {UNITY_TOON_TESSELATION_SHADER_PATH}"); + return; + } + + // Create backup + CreateBackup(UNITY_TOON_TESSELATION_SHADER_PATH); + + // Replace the Properties block + string newContent = ReplacePropertiesBlock(originalContent, commonProperties, tessellationProperties); + WriteFile(UNITY_TOON_TESSELATION_SHADER_PATH, newContent); + } + + private string ReplacePropertiesBlock(string originalContent, string commonProperties, string tessellationProperties) + { + // Find the Properties block using a more robust regex that handles nested braces + string propertiesPattern = @"Properties\s*\{"; + Match startMatch = Regex.Match(originalContent, propertiesPattern); + + if (!startMatch.Success) + { + Debug.LogError("Could not find Properties block start in shader file"); + return originalContent; + } + + // Find the matching closing brace + int startIndex = startMatch.Index; + int braceCount = 0; + int endIndex = startIndex; + bool foundStart = false; + + for (int i = startIndex; i < originalContent.Length; i++) + { + if (originalContent[i] == '{') + { + braceCount++; + foundStart = true; + } + else if (originalContent[i] == '}') + { + braceCount--; + if (foundStart && braceCount == 0) + { + endIndex = i; + break; + } + } + } + + if (braceCount != 0) + { + Debug.LogError("Could not find matching closing brace for Properties block"); + return originalContent; + } + + // Build new Properties block + StringBuilder newProperties = new StringBuilder(); + newProperties.AppendLine(" Properties {"); + + // Add common properties + string[] commonLines = commonProperties.Split('\n'); + int propertyCount = 0; + foreach (string line in commonLines) + { + if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + { + newProperties.AppendLine($" {line.Trim()}"); + propertyCount++; + } + } + + // Add tessellation properties if provided + if (!string.IsNullOrEmpty(tessellationProperties)) + { + newProperties.AppendLine(); + newProperties.AppendLine(" // Tessellation-specific properties"); + string[] tessellationLines = tessellationProperties.Split('\n'); + foreach (string line in tessellationLines) + { + if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + { + newProperties.AppendLine($" {line.Trim()}"); + propertyCount++; + } + } + } + + newProperties.AppendLine(" }"); + + Debug.Log($"Generated Properties block with {propertyCount} properties"); + + // Replace the Properties block in the original content + return originalContent.Substring(0, startIndex) + newProperties.ToString() + originalContent.Substring(endIndex + 1); + } + + private void CreateBackup(string filePath) + { + string backupPath = filePath + ".backup"; + if (File.Exists(filePath)) + { + File.Copy(filePath, backupPath, true); + Debug.Log($"Created backup at {backupPath}"); + } + } + + private string ReadFile(string path) + { + if (File.Exists(path)) + { + return File.ReadAllText(path); + } + return null; + } + + private void WriteFile(string path, string content) + { + // Ensure directory exists + string directory = Path.GetDirectoryName(path); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + File.WriteAllText(path, content); + } + } +} \ No newline at end of file diff --git a/com.unity.toonshader/Editor/ShaderGeneratorTest.cs b/com.unity.toonshader/Editor/ShaderGeneratorTest.cs new file mode 100644 index 00000000..5133f28b --- /dev/null +++ b/com.unity.toonshader/Editor/ShaderGeneratorTest.cs @@ -0,0 +1,109 @@ +using System; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +namespace UnityEditor.Rendering.Toon +{ + /// + /// Test script to verify the shader generator works correctly + /// + public class ShaderGeneratorTest + { + [MenuItem("Tools/Unity Toon Shader/Test Shader Generation")] + public static void TestShaderGeneration() + { + try + { + // Test reading the common properties file + string commonPropertiesPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt"; + string commonProperties = File.ReadAllText(commonPropertiesPath); + + if (string.IsNullOrEmpty(commonProperties)) + { + Debug.LogError("Common properties file is empty or could not be read"); + return; + } + + Debug.Log($"Successfully read common properties file. Length: {commonProperties.Length} characters"); + + // Test reading the tessellation properties file + string tessellationPropertiesPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt"; + string tessellationProperties = File.ReadAllText(tessellationPropertiesPath); + + if (string.IsNullOrEmpty(tessellationProperties)) + { + Debug.LogError("Tessellation properties file is empty or could not be read"); + return; + } + + Debug.Log($"Successfully read tessellation properties file. Length: {tessellationProperties.Length} characters"); + + // Test reading the original shader files + string unityToonPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader"; + string unityToonContent = File.ReadAllText(unityToonPath); + + if (string.IsNullOrEmpty(unityToonContent)) + { + Debug.LogError("UnityToon.shader file is empty or could not be read"); + return; + } + + Debug.Log($"Successfully read UnityToon.shader. Length: {unityToonContent.Length} characters"); + + // Test the Properties block replacement + string propertiesPattern = @"Properties\s*\{[^}]*\}"; + Match match = Regex.Match(unityToonContent, propertiesPattern, RegexOptions.Singleline); + + if (match.Success) + { + Debug.Log($"Found Properties block at position {match.Index}, length {match.Length}"); + + // Test building new Properties block + StringBuilder newProperties = new StringBuilder(); + newProperties.AppendLine(" Properties {"); + + // Add common properties + string[] commonLines = commonProperties.Split('\n'); + int propertyCount = 0; + foreach (string line in commonLines) + { + if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + { + newProperties.AppendLine($" {line.Trim()}"); + propertyCount++; + } + } + + newProperties.AppendLine(" }"); + + Debug.Log($"Generated new Properties block with {propertyCount} properties. Length: {newProperties.Length} characters"); + + // Test the replacement + string newContent = unityToonContent.Substring(0, match.Index) + newProperties.ToString() + unityToonContent.Substring(match.Index + match.Length); + + Debug.Log($"Generated new shader content. Original length: {unityToonContent.Length}, New length: {newContent.Length}"); + + // Write test file + string testPath = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon_Generated_Test.shader"; + File.WriteAllText(testPath, newContent); + AssetDatabase.Refresh(); + + Debug.Log($"Test shader written to {testPath}"); + } + else + { + Debug.LogError("Could not find Properties block in UnityToon.shader"); + } + + Debug.Log("Shader generation test completed successfully!"); + } + catch (Exception e) + { + Debug.LogError($"Error during shader generation test: {e.Message}\n{e.StackTrace}"); + } + } + } +} \ No newline at end of file diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt b/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt new file mode 100644 index 00000000..eb957c76 --- /dev/null +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt @@ -0,0 +1,474 @@ +// Common Properties for Unity Toon Shader +// This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader + +// Basic UI and Version Properties +[HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 +[HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 +[HideInInspector] _utsVersionX("VersionX", Float) = 0 +[HideInInspector] _utsVersionY("VersionY", Float) = 11 +[HideInInspector] _utsVersionZ("VersionZ", Float) = 0 +[HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF +_AutoRenderQueue("Automatic Render Queue ", int) = 1 + +// Stencil Properties +[Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 +// these are set in UniversalToonGUI.cs in accordance with _StencilMode +_StencilComp("Stencil Comparison", Float) = 8 +_StencilNo("Stencil No", Float) = 1 +_StencilOpPass("Stencil Operation", Float) = 0 +_StencilOpFail("Stencil Operation", Float) = 0 +[Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + +// Clipping Properties +// DoubleShadeWithFeather +// 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE +// ShadingGradeMap +// 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON +[Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + +// Cull and ZWrite Properties +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK +[Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON +[Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON +_SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + +// ClippingMask parameters +_ClippingMask("ClippingMask", 2D) = "white" {} +_IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 +// +[Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 +_Clipping_Level("Clipping_Level", Range(0, 1)) = 0 +_Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + +// Base Color Properties +_MainTex ("BaseMap", 2D) = "white" {} +_BaseMap ("BaseMap", 2D) = "white" {} +_BaseColor ("BaseColor", Color) = (1,1,1,1) +//v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. +//If you want to go back the former SSAO results, comment out the below line. +_Color ("Color", Color) = (1,1,1,1) +// +[Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + +// 1st Shade Properties +_1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 +_1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + +// 2nd Shade Properties +_2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 +_2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + +// Normal Map Properties +_NormalMap ("NormalMap", 2D) = "bump" {} +_BumpScale ("Normal Scale", Range(0, 1)) = 1 +[Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 +//v.2.0.4.4 +[Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 +_Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + +// Shading Properties +//v.2.0.6 +_BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 +_BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 +_ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 +_1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 +_1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 +_1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +_2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 +_2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +//v.2.0.5 +_StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 +[Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + +// Shading Grade Map Properties +_Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} +_Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} +_ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} +//v.2.0.6 +_Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 +_BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + +// High Color Properties +_HighColor ("HighColor", Color) = (0,0,0,1) +//v.2.0.4 HighColor_Tex +_HighColor_Tex ("HighColor_Tex", 2D) = "white" {} +[Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 +[Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 +_HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 +[Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 +[Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 +[Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 +_TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 +//HiColorMask +_Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} +_Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + +// Rim Light Properties +[Toggle(_)] _RimLight ("RimLight", Float ) = 0 +_RimLightColor ("RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 +[Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 +_RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 +_RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 +[Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 +//RimLight +[Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 +_Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 +[Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 +_Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 +_Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 +[Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 +//RimLightMask +_Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} +_Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + +// MatCap Properties +[Toggle(_)] _MatCap ("MatCap", Float ) = 0 +_MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} +//v.2.0.6 +_BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 +_MatCapColor ("MatCapColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 +[Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 +_Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 +_Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 +//v.2.0.6 +[Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 +[Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 +_NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} +_BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 +_Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 +[Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 +_TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 +//MatcapMask +_Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} +_Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 +[Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + +// Angel Rings Properties +[Toggle(_)] _AngelRing("AngelRing", Float) = 0 +_AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} +_AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) +[Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 +_AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 +_AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 +[Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + +// Emissive Properties +//v.2.0.7 Emissive +[KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 +_Emissive_Tex ("Emissive_Tex", 2D) = "white" {} +[HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) +_Base_Speed ("Base_Speed", Float ) = 0 +_Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 +_Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 +_Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 +[Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 +[Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 +[HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) +_ColorShift_Speed ("ColorShift_Speed", Float ) = 0 +[Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 +[HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) +[Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + +// Outline Properties +[KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 +_Outline_Width ("Outline_Width", Float ) = 0 +_Farthest_Distance ("Farthest_Distance", Float ) = 100 +_Nearest_Distance ("Nearest_Distance", Float ) = 0.5 +_Outline_Sampler ("Outline_Sampler", 2D) = "white" {} +_Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) +[Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 +[Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 +//v.2.0.4 +[Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 +_OutlineTex ("OutlineTex", 2D) = "white" {} +//Offset parameter +_Offset_Z ("Offset_Camera_Z", Float) = 0 +//v.2.0.4.3 Baked Normal Texture for Outline +[Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 +_BakedNormal ("Baked Normal for Outline", 2D) = "white" {} +//GI Intensity +_GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 +//For VR Chat under No effective light objects +_Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 +//Built-in Light Direction +[Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 +_Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 +_Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 +[Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + +// HDRP Matte Properties +[Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 +[Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 +_BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + +[Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 +_FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + +[Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 +_SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + +[Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 +[Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 +_HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + +[Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 +[Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 +_AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + +[Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 +[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 +_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + +[Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 +[Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 +_OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + +[Toggle(_)] _ComposerMaskMode("", Float) = 0 +[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + +// Avoid HDRP srp batcher error +[HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + +// HDRP material default values +_BaseColorMap("BaseColorMap", 2D) = "white" {} +[HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + +_Metallic("_Metallic", Range(0.0, 1.0)) = 0 +_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 +_MaskMap("MaskMap", 2D) = "white" {} +_SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 +_SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 +_AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 +_AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 +_AORemapMin("AORemapMin", Float) = 0.0 +_AORemapMax("AORemapMax", Float) = 1.0 + +// Normal Maps +_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value +_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + +_BentNormalMap("_BentNormalMap", 2D) = "bump" {} +_BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + +// Height Maps +_HeightMap("HeightMap", 2D) = "black" {} +// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 +// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. +[HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. +[HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 +// These parameters are for vertex displacement/Tessellation +_HeightOffset("Height Offset", Float) = 0 +// MinMax mode +_HeightMin("Heightmap Min", Float) = -1 +_HeightMax("Heightmap Max", Float) = 1 +// Amplitude mode +_HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters +_HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +// These parameters are for pixel displacement +_HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + +// Detail Maps +_DetailMap("DetailMap", 2D) = "linearGrey" {} +_DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 +_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 +_DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + +// Tangent Maps +_TangentMap("TangentMap", 2D) = "bump" {} +_TangentMapOS("TangentMapOS", 2D) = "white" {} +_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 +_AnisotropyMap("AnisotropyMap", 2D) = "white" {} + +// Diffusion Profile +[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 +[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) +[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 +_SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 +_SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} +_TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 +_Thickness("Thickness", Range(0.0, 1.0)) = 1.0 +_ThicknessMap("Thickness Map", 2D) = "white" {} +_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + +// Iridescence +_IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 +_IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} +_IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) +_IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 +_IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + +// Coat +_CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 +_CoatMaskMap("CoatMaskMap", 2D) = "white" {} + +// Specular +[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 +_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) +_SpecularColorMap("SpecularColorMap", 2D) = "white" {} + +// Following options are for the GUI inspector and different from the input parameters above +// These option below will cause different compilation flag. +[Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + +// Emissive +[HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) +// Used only to serialize the LDR and HDR emissive color in the material UI, +// in the shader only the _EmissiveColor should be used +[HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) +_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} +[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 +[HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 +[ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 +_EmissiveIntensity("Emissive Intensity", Float) = 1 +_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + +// Distortion +_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} +[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 +[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 +[Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 +[HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 +[HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 +[HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 +_DistortionScale("Distortion Scale", Float) = 1 +_DistortionVectorScale("Distortion Vector Scale", Float) = 2 +_DistortionVectorBias("Distortion Vector Bias", Float) = -1 +_DistortionBlurScale("Distortion Blur Scale", Float) = 1 +_DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 +_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + +// Alpha and Transparency +[ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 +[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 +_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 +[ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 +[ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 +[ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 +_TransparentSortPriority("_TransparentSortPriority", Float) = 0 + +// Transparency +[Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 +[Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 +_Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 +_ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 +_TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) +_TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} +_ATDistance("Transmittance Absorption Distance", Float) = 1.0 +[ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + +// Stencil state +// Forward +[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting +// GBuffer +[HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting +// Depth prepass +[HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing +[HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR +// Motion vector pass +[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +// Distortion vector pass +[HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors +[HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + +// Blending state +[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 +[HideInInspector] _BlendMode("__blendmode", Float) = 0.0 +[HideInInspector] _SrcBlend("__src", Float) = 1.0 +[HideInInspector] _DstBlend("__dst", Float) = 0.0 +[HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 +[HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 +[HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 +[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 +[HideInInspector] _CullMode("__cullmode", Float) = 2.0 +[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent +[HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default +[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal +[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 +[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 +[Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + +[ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 +[ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + +[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 +[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 +[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 +[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 +_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 +[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) +[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + +// Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other +// so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature +// The only material feature flag that can be added in all cases is clear coat +[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard +[ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + +[Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 +[ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 +[ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 +[ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + +[ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 +_SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 +_SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + +_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 +_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 +_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 +_PPDPrimitiveLength("Primitive length for POM", Float) = 1 +_PPDPrimitiveWidth("Primitive width for POM", Float) = 1 +[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 +[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) +[ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + +[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 +_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + +// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" +// value that exist to identify if the GI emission need to be enabled. +// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. +// TODO: Fix the code in legacy unity so we can customize the beahvior for GI +_EmissionColor("Color", Color) = (1, 1, 1) + +// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. +_Color("Color", Color) = (1,1,1,1) +_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + +[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 +[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 +[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 \ No newline at end of file diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt b/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt new file mode 100644 index 00000000..c7acc8e9 --- /dev/null +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt @@ -0,0 +1,20 @@ +// Tessellation-specific Properties for Unity Toon Shader Tessellation +// These properties are only present in the tessellation shader + +// Tessellation specific +[Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 +_TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 +_TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 +_TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0 +_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 +_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong +_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 + +// HDRP material tessellation values +[Enum(None, 0, Tessellation displacement, 3)] _DisplacementMode("DisplacementMode", Int) = 3 + +// Legacy material tessellation values +//Tessellation +_TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 +_TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 +_TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 \ No newline at end of file diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader index fe4969f0..8c69159b 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader @@ -3,7 +3,7 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon" { - Properties { + Properties { [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,70 +11,41 @@ Shader "Toon" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 - [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 - // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 - - // DoubleShadeWithFeather - // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE - // ShadingGradeMap - // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 - - [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK - // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} - _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 - // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 - // ClippingMask paramaters to Here. - - - [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK - - - - - - _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) - //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. - //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) - // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 - //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 - //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -83,19 +54,14 @@ Shader "Toon" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 - //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 - // _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} - //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 - // _HighColor ("HighColor", Color) = (0,0,0,1) -//v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -104,7 +70,6 @@ Shader "Toon" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 -//HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _RimLight ("RimLight", Float ) = 0 @@ -114,7 +79,6 @@ Shader "Toon" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 -//RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -122,20 +86,16 @@ Shader "Toon" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 -//RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 -// [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} - //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 - //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -143,13 +103,10 @@ Shader "Toon" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 -//MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 - //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 - //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -157,8 +114,6 @@ Shader "Toon" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 - // - //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -173,8 +128,6 @@ Shader "Toon" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 - // -//Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -183,76 +136,44 @@ Shader "Toon" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 - //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} - //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 - //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} - //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 - //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 - //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 - //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) - [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) - [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) - [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) - [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) - [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) - [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) - [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// End of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP material default values. //////////////// - ////////////////////////////////////////////////////////////////////////////// - _BaseColorMap("BaseColorMap", 2D) = "white" {} + _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) - _Metallic("_Metallic", Range(0.0, 1.0)) = 0 _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 _MaskMap("MaskMap", 2D) = "white" {} @@ -262,43 +183,28 @@ Shader "Toon" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 - - //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 - _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} - _HeightMap("HeightMap", 2D) = "black" {} - // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 - // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 - // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 - // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 - // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - - // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters - _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 - _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} - [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -308,27 +214,18 @@ Shader "Toon" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) - _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} - _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} - [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} - - // Following options are for the GUI inspector and different from the input parameters above - // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 - [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) - // Used only to serialize the LDR and HDR emissive color in the material UI, - // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -336,7 +233,6 @@ Shader "Toon" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 - _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -352,7 +248,6 @@ Shader "Toon" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 - [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -363,8 +258,6 @@ Shader "Toon" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 - - // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -373,26 +266,16 @@ Shader "Toon" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 - - // Stencil state - - // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting - // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting - // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR - // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors - // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors - - // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -408,69 +291,45 @@ Shader "Toon" { [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal - [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 - [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 - - // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other - // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature - // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 - _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 _PPDPrimitiveLength("Primitive length for POM", Float) = 1 _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 - [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) - - // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" - // value that exist to identify if the GI emission need to be enabled. - // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. - // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) - - // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. - //////////// _MainTex("BaseMap", 2D) = "white" {} _Color("Color", Color) = (1,1,1,1) _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 - [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material default values. //////////////////// - ////////////////////////////////////////////////////////////////////////////// } HLSLINCLUDE diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup new file mode 100644 index 00000000..fe4969f0 --- /dev/null +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup @@ -0,0 +1,1675 @@ +//Unity Toon Shader +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) + +Shader "Toon" { + Properties { + [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 + [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 + [HideInInspector] _utsVersionX("VersionX", Float) = 0 + [HideInInspector] _utsVersionY("VersionY", Float) = 11 + [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 + [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF + _AutoRenderQueue("Automatic Render Queue ", int) = 1 + + [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode + _StencilComp("Stencil Comparison", Float) = 8 + _StencilNo("Stencil No", Float) = 1 + _StencilOpPass("Stencil Operation", Float) = 0 + _StencilOpFail("Stencil Operation", Float) = 0 + [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON + [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + + + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON + [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON + _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + // ClippingMask paramaters from Here. + _ClippingMask("ClippingMask", 2D) = "white" {} + + _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // + [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 + _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 + _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + + + [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + + + + + + + _MainTex ("BaseMap", 2D) = "white" {} + _BaseMap ("BaseMap", 2D) = "white" {} + _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. + _Color ("Color", Color) = (1,1,1,1) + // + [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 + _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 + _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + _NormalMap ("NormalMap", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 + [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 + _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + //v.2.0.6 + _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 + _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 + _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 + _1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 + _1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 + _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 + _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 + _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 + [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + // + _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} + _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} + _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 + _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 + _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + // + _HighColor ("HighColor", Color) = (0,0,0,1) +//v.2.0.4 HighColor_Tex + _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} + [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 + [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 + _HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 + [Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 + [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 + [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 + _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 +//HiColorMask + _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} + _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _RimLight ("RimLight", Float ) = 0 + _RimLightColor ("RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 + [Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 + _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 + _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 + [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 +//RimLight + [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 + _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 + [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 + _Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 + _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 + [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 +//RimLightMask + _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} + _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 +// + [Toggle(_)] _MatCap ("MatCap", Float ) = 0 + _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 + _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 + _MatCapColor ("MatCapColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 + [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 + _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 + _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 + [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 + [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 + _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} + _BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 + _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 + _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 +//MatcapMask + _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} + _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + //// Angel Rings + [Toggle(_)] _AngelRing("AngelRing", Float) = 0 + _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} + _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) + [Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 + _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 + _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 + [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + // + //v.2.0.7 Emissive + [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 + _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} + [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) + _Base_Speed ("Base_Speed", Float ) = 0 + _Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 + _Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 + _Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 + [Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 + [Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 + [HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) + _ColorShift_Speed ("ColorShift_Speed", Float ) = 0 + [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 + [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) + [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + // +//Outline + [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 + _Outline_Width ("Outline_Width", Float ) = 0 + _Farthest_Distance ("Farthest_Distance", Float ) = 100 + _Nearest_Distance ("Nearest_Distance", Float ) = 0.5 + _Outline_Sampler ("Outline_Sampler", 2D) = "white" {} + _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) + [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 + [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 + [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 + _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter + _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline + [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 + _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity + _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects + _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction + [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 + _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 + _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 + [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 + [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 + _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + + [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 + _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + + [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 + _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + + [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 + [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 + _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + + [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 + [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 + _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + + [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 + [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 + _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + + [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 + [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 + _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + + [Toggle(_)] _ComposerMaskMode("", Float) = 0 + [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// + _BaseColorMap("BaseColorMap", 2D) = "white" {} + [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + + _Metallic("_Metallic", Range(0.0, 1.0)) = 0 + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _MaskMap("MaskMap", 2D) = "white" {} + _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 + _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 + _AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 + _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 + _AORemapMin("AORemapMin", Float) = 0.0 + _AORemapMax("AORemapMax", Float) = 1.0 + + //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map + _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value + _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + + _BentNormalMap("_BentNormalMap", 2D) = "bump" {} + _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + + _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. + [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. + [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation + _HeightOffset("Height Offset", Float) = 0 + // MinMax mode + _HeightMin("Heightmap Min", Float) = -1 + _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode + _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters + _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + // These parameters are for pixel displacement + _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + + _DetailMap("DetailMap", 2D) = "linearGrey" {} + _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 + _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 + _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + + _TangentMap("TangentMap", 2D) = "bump" {} + _TangentMapOS("TangentMapOS", 2D) = "white" {} + _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 + _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + + [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 + [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) + [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 + _SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 + _SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} + _TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 + _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 + _ThicknessMap("Thickness Map", 2D) = "white" {} + _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + + _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 + _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} + _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 + _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + + _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 + _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + + [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 + _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) + _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. + [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + + [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used + [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) + _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} + [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 + [HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 + [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 + _EmissiveIntensity("Emissive Intensity", Float) = 1 + _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + + _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} + [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 + [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 + [Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 + [HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 + [HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 + [HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 + _DistortionScale("Distortion Scale", Float) = 1 + _DistortionVectorScale("Distortion Vector Scale", Float) = 2 + _DistortionVectorBias("Distortion Vector Bias", Float) = -1 + _DistortionBlurScale("Distortion Blur Scale", Float) = 1 + _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 + _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + + [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 + [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 + _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 + [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 + [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 + _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + + // Transparency + [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 + [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 + _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 + _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 + _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) + _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} + _ATDistance("Transmittance Absorption Distance", Float) = 1.0 + [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + + // Stencil state + + // Forward + [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer + [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass + [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing + [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass + [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass + [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + + // Blending state + [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 + [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 + [HideInInspector] _SrcBlend("__src", Float) = 1.0 + [HideInInspector] _DstBlend("__dst", Float) = 0.0 + [HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 + [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 + [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 + [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 + [HideInInspector] _CullMode("__cullmode", Float) = 2.0 + [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent + [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default + [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal + [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 + [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 + [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + + [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 + [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + + [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 + [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 + [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 + [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 + _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 + [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) + [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat + [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + + [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 + [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 + [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 + [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + + [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 + _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 + _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + + _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 + _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 + _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 + _PPDPrimitiveLength("Primitive length for POM", Float) = 1 + _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 + [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 + [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) + [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + + [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 + _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI + _EmissionColor("Color", Color) = (1, 1, 1) + + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + //////////// _MainTex("BaseMap", 2D) = "white" {} + _Color("Color", Color) = (1,1,1,1) + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// + } + + HLSLINCLUDE + + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS +// HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + ENDHLSL + + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight 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 _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // 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 _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" + + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" + + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #pragma multi_compile _IS_PASS_FWDBASE + + // + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + //v.2.0.4 + + #pragma multi_compile _IS_PASS_FWDDELTA + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW + +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #include "../../Legacy/Shaders/UCTS_ShadowCaster.cginc" + ENDCG + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader index cedc1155..095be40f 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader @@ -3,7 +3,7 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon(Tessellation)" { - Properties { + Properties { [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,70 +11,41 @@ Shader "Toon(Tessellation)" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 - [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 - // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 - - // DoubleShadeWithFeather - // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE - // ShadingGradeMap - // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 - - [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK - // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} - _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 - // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 - // ClippingMask paramaters to Here. - - - [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK - - - - - - _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) - //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. - //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) - // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 - //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 - //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -83,19 +54,14 @@ Shader "Toon(Tessellation)" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 - //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 - // _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} - //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 - // _HighColor ("HighColor", Color) = (0,0,0,1) -//v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -104,7 +70,6 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 -//HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _RimLight ("RimLight", Float ) = 0 @@ -114,7 +79,6 @@ Shader "Toon(Tessellation)" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 -//RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -122,20 +86,16 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 -//RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 -// [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} - //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 - //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -143,13 +103,10 @@ Shader "Toon(Tessellation)" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 -//MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 - //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 - //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -157,8 +114,6 @@ Shader "Toon(Tessellation)" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 - // - //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -173,8 +128,6 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 - // -//Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -183,77 +136,44 @@ Shader "Toon(Tessellation)" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 - //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} - //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 - //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} - //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 - //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 - //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 - //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) - [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) - [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) - [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) - [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) - [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) - [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) - [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// End of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP material default values. //////////////// - ////////////////////////////////////////////////////////////////////////////// - _BaseColorMap("BaseColorMap", 2D) = "white" {} + _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) - _Metallic("_Metallic", Range(0.0, 1.0)) = 0 _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 _MaskMap("MaskMap", 2D) = "white" {} @@ -263,43 +183,28 @@ Shader "Toon(Tessellation)" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 - - //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 - _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} - _HeightMap("HeightMap", 2D) = "black" {} - // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 - // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 - // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 - // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 - // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - - // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters - _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 - _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} - [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -309,27 +214,18 @@ Shader "Toon(Tessellation)" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) - _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} - _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} - [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} - - // Following options are for the GUI inspector and different from the input parameters above - // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 - [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) - // Used only to serialize the LDR and HDR emissive color in the material UI, - // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -337,7 +233,6 @@ Shader "Toon(Tessellation)" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 - _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -353,7 +248,6 @@ Shader "Toon(Tessellation)" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 - [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -364,8 +258,6 @@ Shader "Toon(Tessellation)" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 - - // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -374,26 +266,16 @@ Shader "Toon(Tessellation)" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 - - // Stencil state - - // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting - // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting - // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR - // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors - // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors - - // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -409,59 +291,47 @@ Shader "Toon(Tessellation)" { [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal - [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 - [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 - - // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other - // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature - // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - - [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 3 + [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 - _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 _PPDPrimitiveLength("Primitive length for POM", Float) = 1 _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 - [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) - - // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" - // value that exist to identify if the GI emission need to be enabled. - // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. - // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) + _Color("Color", Color) = (1,1,1,1) + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - // Tessellation specific + // Tessellation-specific properties [Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 @@ -469,44 +339,10 @@ Shader "Toon(Tessellation)" { _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong _TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 - // TODO: Handle culling mode for backface culling - // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. - //////////// _MainTex("BaseMap", 2D) = "white" {} - _Color("Color", Color) = (1,1,1,1) - _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 - - [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 - [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 - [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material default values. //////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////// - //////////////////// Start of HDRP material tessellation values. ///////////// - ////////////////////////////////////////////////////////////////////////////// - [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - [Enum(None, 0, Tessellation displacement, 3)] _DisplacementMode("DisplacementMode", Int) = 3 - [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 - [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 - [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material tessellation values. ///////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////// - //////////////////// Start of Legacy material tessellation values. /////////// - ////////////////////////////////////////////////////////////////////////////// - - //Tessellation _TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 _TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 _TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of Legacy material tessellation values. /////////// - ////////////////////////////////////////////////////////////////////////////// - } HLSLINCLUDE diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup new file mode 100644 index 00000000..cedc1155 --- /dev/null +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup @@ -0,0 +1,1790 @@ +//Unity Toon Shader +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) + +Shader "Toon(Tessellation)" { + Properties { + [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 + [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 + [HideInInspector] _utsVersionX("VersionX", Float) = 0 + [HideInInspector] _utsVersionY("VersionY", Float) = 11 + [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 + [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF + _AutoRenderQueue("Automatic Render Queue ", int) = 1 + + [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode + _StencilComp("Stencil Comparison", Float) = 8 + _StencilNo("Stencil No", Float) = 1 + _StencilOpPass("Stencil Operation", Float) = 0 + _StencilOpFail("Stencil Operation", Float) = 0 + [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON + [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + + + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON + [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON + _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + // ClippingMask paramaters from Here. + _ClippingMask("ClippingMask", 2D) = "white" {} + + _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // + [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 + _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 + _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + + + [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + + + + + + + _MainTex ("BaseMap", 2D) = "white" {} + _BaseMap ("BaseMap", 2D) = "white" {} + _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. + _Color ("Color", Color) = (1,1,1,1) + // + [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 + _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 + _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + _NormalMap ("NormalMap", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 + [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 + _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + //v.2.0.6 + _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 + _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 + _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 + _1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 + _1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 + _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 + _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 + _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 + [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + // + _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} + _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} + _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 + _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 + _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + // + _HighColor ("HighColor", Color) = (0,0,0,1) +//v.2.0.4 HighColor_Tex + _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} + [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 + [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 + _HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 + [Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 + [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 + [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 + _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 +//HiColorMask + _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} + _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _RimLight ("RimLight", Float ) = 0 + _RimLightColor ("RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 + [Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 + _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 + _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 + [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 +//RimLight + [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 + _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 + [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 + _Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 + _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 + [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 +//RimLightMask + _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} + _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 +// + [Toggle(_)] _MatCap ("MatCap", Float ) = 0 + _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 + _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 + _MatCapColor ("MatCapColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 + [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 + _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 + _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 + [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 + [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 + _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} + _BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 + _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 + _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 +//MatcapMask + _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} + _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + //// Angel Rings + [Toggle(_)] _AngelRing("AngelRing", Float) = 0 + _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} + _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) + [Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 + _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 + _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 + [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + // + //v.2.0.7 Emissive + [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 + _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} + [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) + _Base_Speed ("Base_Speed", Float ) = 0 + _Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 + _Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 + _Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 + [Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 + [Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 + [HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) + _ColorShift_Speed ("ColorShift_Speed", Float ) = 0 + [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 + [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) + [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + // +//Outline + [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 + _Outline_Width ("Outline_Width", Float ) = 0 + _Farthest_Distance ("Farthest_Distance", Float ) = 100 + _Nearest_Distance ("Nearest_Distance", Float ) = 0.5 + _Outline_Sampler ("Outline_Sampler", 2D) = "white" {} + _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) + [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 + [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 + [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 + _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter + _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline + [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 + _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity + _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects + _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction + [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 + _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 + _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 + [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 + [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 + _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + + [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 + _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + + [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 + _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + + [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 + [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 + _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + + [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 + [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 + _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + + [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 + [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 + _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + + [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 + [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 + _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + + [Toggle(_)] _ComposerMaskMode("", Float) = 0 + [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// + _BaseColorMap("BaseColorMap", 2D) = "white" {} + [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + + _Metallic("_Metallic", Range(0.0, 1.0)) = 0 + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _MaskMap("MaskMap", 2D) = "white" {} + _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 + _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 + _AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 + _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 + _AORemapMin("AORemapMin", Float) = 0.0 + _AORemapMax("AORemapMax", Float) = 1.0 + + //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map + _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value + _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + + _BentNormalMap("_BentNormalMap", 2D) = "bump" {} + _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + + _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. + [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. + [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation + _HeightOffset("Height Offset", Float) = 0 + // MinMax mode + _HeightMin("Heightmap Min", Float) = -1 + _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode + _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters + _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + // These parameters are for pixel displacement + _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + + _DetailMap("DetailMap", 2D) = "linearGrey" {} + _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 + _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 + _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + + _TangentMap("TangentMap", 2D) = "bump" {} + _TangentMapOS("TangentMapOS", 2D) = "white" {} + _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 + _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + + [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 + [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) + [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 + _SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 + _SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} + _TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 + _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 + _ThicknessMap("Thickness Map", 2D) = "white" {} + _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + + _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 + _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} + _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 + _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + + _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 + _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + + [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 + _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) + _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. + [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + + [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used + [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) + _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} + [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 + [HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 + [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 + _EmissiveIntensity("Emissive Intensity", Float) = 1 + _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + + _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} + [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 + [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 + [Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 + [HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 + [HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 + [HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 + _DistortionScale("Distortion Scale", Float) = 1 + _DistortionVectorScale("Distortion Vector Scale", Float) = 2 + _DistortionVectorBias("Distortion Vector Bias", Float) = -1 + _DistortionBlurScale("Distortion Blur Scale", Float) = 1 + _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 + _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + + [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 + [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 + _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 + [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 + [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 + _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + + // Transparency + [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 + [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 + _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 + _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 + _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) + _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} + _ATDistance("Transmittance Absorption Distance", Float) = 1.0 + [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + + // Stencil state + + // Forward + [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer + [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass + [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing + [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass + [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass + [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + + // Blending state + [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 + [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 + [HideInInspector] _SrcBlend("__src", Float) = 1.0 + [HideInInspector] _DstBlend("__dst", Float) = 0.0 + [HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 + [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 + [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 + [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 + [HideInInspector] _CullMode("__cullmode", Float) = 2.0 + [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent + [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default + [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal + [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 + [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 + [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + + [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 + [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + + [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 + [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 + [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 + [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 + _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 + [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) + [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat + [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + + [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 3 + [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 + [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 + [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + + [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 + _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 + _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + + _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 + _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 + _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 + _PPDPrimitiveLength("Primitive length for POM", Float) = 1 + _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 + [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 + [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) + [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + + [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 + _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI + _EmissionColor("Color", Color) = (1, 1, 1) + + // Tessellation specific + [Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 + _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 + _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 + _TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0 + _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 + _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong + _TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 + // TODO: Handle culling mode for backface culling + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + //////////// _MainTex("BaseMap", 2D) = "white" {} + _Color("Color", Color) = (1,1,1,1) + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////// + //////////////////// Start of HDRP material tessellation values. ///////////// + ////////////////////////////////////////////////////////////////////////////// + [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + + [Enum(None, 0, Tessellation displacement, 3)] _DisplacementMode("DisplacementMode", Int) = 3 + [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 + [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 + [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material tessellation values. ///////////// + ////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////// + //////////////////// Start of Legacy material tessellation values. /////////// + ////////////////////////////////////////////////////////////////////////////// + + //Tessellation + _TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 + _TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 + _TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of Legacy material tessellation values. /////////// + ////////////////////////////////////////////////////////////////////////////// + + } + + HLSLINCLUDE + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS + // HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _TESSELLATION_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + + //------------------------------------------------------------------------------------- + // Define + //------------------------------------------------------------------------------------- + #define TESSELLATION_ON + // This shader support vertex modification + #define HAVE_VERTEX_MODIFICATION + #define HAVE_TESSELLATION_MODIFICATION + + // If we use subsurface scattering, enable output split lighting (for forward pass) + #if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT) + #define OUTPUT_SPLIT_LIGHTING + #endif + + #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) + #define _WRITE_TRANSPARENT_MOTION_VECTOR + #endif + + ENDHLSL + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + // TODO: Tesselation can't work with velocity for now... + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight 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 _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // 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 _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + + // used in Shadow calculation + #pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + // ------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" +#ifndef VERSION_GREATER_EQUAL +#define VERSION_GREATER_EQUAL(x, y) 1 +#endif +#if (VERSION_GREATER_EQUAL(10, 0)) + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" +#endif + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + #pragma target 5.0 + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #pragma multi_compile _IS_PASS_FWDBASE + + // + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline_Tess.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + //v.2.0.4 + + #pragma multi_compile _IS_PASS_FWDDELTA + #pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW + +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + #include "../../Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc" + ENDCG + + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/generate_shaders.bat b/generate_shaders.bat new file mode 100644 index 00000000..3e747a34 --- /dev/null +++ b/generate_shaders.bat @@ -0,0 +1,20 @@ +@echo off +echo Unity Toon Shader Generator +echo ========================== +echo. + +echo Generating shader files from common properties... +python3 generate_shaders.py + +if %ERRORLEVEL% EQU 0 ( + echo. + echo Shader generation completed successfully! + echo Both UnityToon.shader and UnityToonTessellation.shader have been updated. + echo Original files have been backed up with .backup extension. +) else ( + echo. + echo Shader generation failed! + echo Check the error messages above. +) + +pause \ No newline at end of file diff --git a/generate_shaders.py b/generate_shaders.py new file mode 100644 index 00000000..2198d151 --- /dev/null +++ b/generate_shaders.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 + +import re +import os +import shutil + +def generate_shader_files(): + try: + # Read the common properties file + common_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt" + with open(common_properties_path, 'r') as f: + common_properties = f.read() + + if not common_properties: + print("ERROR: Common properties file is empty or could not be read") + return False + + print(f"Successfully read common properties file. Length: {len(common_properties)} characters") + + # Read the tessellation properties file + tessellation_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt" + with open(tessellation_properties_path, 'r') as f: + tessellation_properties = f.read() + + if not tessellation_properties: + print("ERROR: Tessellation properties file is empty or could not be read") + return False + + print(f"Successfully read tessellation properties file. Length: {len(tessellation_properties)} characters") + + # Generate UnityToon.shader + print("\nGenerating UnityToon.shader...") + success1 = generate_shader("com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader", + common_properties, "") + + # Generate UnityToonTessellation.shader + print("\nGenerating UnityToonTessellation.shader...") + success2 = generate_shader("com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader", + common_properties, tessellation_properties) + + if success1 and success2: + print("\nBoth shader files generated successfully!") + return True + else: + print("\nSome shader files failed to generate.") + return False + + except Exception as e: + print(f"ERROR: {e}") + import traceback + traceback.print_exc() + return False + +def generate_shader(shader_path, common_properties, tessellation_properties): + try: + # Read the original shader file + with open(shader_path, 'r') as f: + original_content = f.read() + + if not original_content: + print(f"ERROR: {shader_path} file is empty or could not be read") + return False + + print(f"Successfully read {shader_path}. Length: {len(original_content)} characters") + + # Find the Properties block + properties_pattern = r"Properties\s*\{" + start_match = re.search(properties_pattern, original_content) + + if not start_match: + print(f"ERROR: Could not find Properties block start in {shader_path}") + return False + + print(f"Found Properties block start at position {start_match.start()}") + + # Find the matching closing brace + start_index = start_match.start() + brace_count = 0 + end_index = start_index + found_start = False + + for i in range(start_index, len(original_content)): + if original_content[i] == '{': + brace_count += 1 + found_start = True + elif original_content[i] == '}': + brace_count -= 1 + if found_start and brace_count == 0: + end_index = i + break + + if brace_count != 0: + print(f"ERROR: Could not find matching closing brace for Properties block in {shader_path}") + return False + + print(f"Found Properties block end at position {end_index}") + + # Build new Properties block + new_properties = [] + new_properties.append(" Properties {") + + # Add common properties + common_lines = common_properties.split('\n') + property_count = 0 + for line in common_lines: + if line.strip() and not line.strip().startswith("//"): + new_properties.append(f" {line.strip()}") + property_count += 1 + + # Add tessellation properties if provided + if tessellation_properties: + new_properties.append("") + new_properties.append(" // Tessellation-specific properties") + tessellation_lines = tessellation_properties.split('\n') + for line in tessellation_lines: + if line.strip() and not line.strip().startswith("//"): + new_properties.append(f" {line.strip()}") + property_count += 1 + + new_properties.append(" }") + + new_properties_text = '\n'.join(new_properties) + + print(f"Generated new Properties block with {property_count} properties. Length: {len(new_properties_text)} characters") + + # Create backup of original file + backup_path = shader_path + ".backup" + shutil.copy2(shader_path, backup_path) + print(f"Created backup at {backup_path}") + + # Replace the Properties block + new_content = original_content[:start_index] + new_properties_text + original_content[end_index + 1:] + + print(f"Generated new shader content. Original length: {len(original_content)}, New length: {len(new_content)}") + + # Write the new shader file + with open(shader_path, 'w') as f: + f.write(new_content) + + print(f"Successfully wrote {shader_path}") + return True + + except Exception as e: + print(f"ERROR generating {shader_path}: {e}") + return False + +if __name__ == "__main__": + success = generate_shader_files() + if success: + print("\nAll shader files generated successfully!") + else: + print("\nShader generation failed!") \ No newline at end of file diff --git a/generate_shaders.sh b/generate_shaders.sh new file mode 100755 index 00000000..42f0ac60 --- /dev/null +++ b/generate_shaders.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +echo "Unity Toon Shader Generator" +echo "==========================" +echo + +echo "Generating shader files from common properties..." +python3 generate_shaders.py + +if [ $? -eq 0 ]; then + echo + echo "Shader generation completed successfully!" + echo "Both UnityToon.shader and UnityToonTessellation.shader have been updated." + echo "Original files have been backed up with .backup extension." +else + echo + echo "Shader generation failed!" + echo "Check the error messages above." + exit 1 +fi \ No newline at end of file diff --git a/test_generation.py b/test_generation.py new file mode 100644 index 00000000..49f23e97 --- /dev/null +++ b/test_generation.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 + +import re +import os + +def test_shader_generation(): + try: + # Test reading the common properties file + common_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt" + with open(common_properties_path, 'r') as f: + common_properties = f.read() + + if not common_properties: + print("ERROR: Common properties file is empty or could not be read") + return + + print(f"Successfully read common properties file. Length: {len(common_properties)} characters") + + # Test reading the tessellation properties file + tessellation_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt" + with open(tessellation_properties_path, 'r') as f: + tessellation_properties = f.read() + + if not tessellation_properties: + print("ERROR: Tessellation properties file is empty or could not be read") + return + + print(f"Successfully read tessellation properties file. Length: {len(tessellation_properties)} characters") + + # Test reading the original shader files + unity_toon_path = "com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader" + with open(unity_toon_path, 'r') as f: + unity_toon_content = f.read() + + if not unity_toon_content: + print("ERROR: UnityToon.shader file is empty or could not be read") + return + + print(f"Successfully read UnityToon.shader. Length: {len(unity_toon_content)} characters") + + # Test the Properties block replacement + properties_pattern = r"Properties\s*\{" + start_match = re.search(properties_pattern, unity_toon_content) + + if not start_match: + print("ERROR: Could not find Properties block start in shader file") + return + + print(f"Found Properties block start at position {start_match.start()}") + + # Find the matching closing brace + start_index = start_match.start() + brace_count = 0 + end_index = start_index + found_start = False + + for i in range(start_index, len(unity_toon_content)): + if unity_toon_content[i] == '{': + brace_count += 1 + found_start = True + elif unity_toon_content[i] == '}': + brace_count -= 1 + if found_start and brace_count == 0: + end_index = i + break + + if brace_count != 0: + print("ERROR: Could not find matching closing brace for Properties block") + return + + print(f"Found Properties block end at position {end_index}") + + # Test building new Properties block + new_properties = [] + new_properties.append(" Properties {") + + # Add common properties + common_lines = common_properties.split('\n') + property_count = 0 + for line in common_lines: + if line.strip() and not line.strip().startswith("//"): + new_properties.append(f" {line.strip()}") + property_count += 1 + + new_properties.append(" }") + + new_properties_text = '\n'.join(new_properties) + + print(f"Generated new Properties block with {property_count} properties. Length: {len(new_properties_text)} characters") + + # Test the replacement + new_content = unity_toon_content[:start_index] + new_properties_text + unity_toon_content[end_index + 1:] + + print(f"Generated new shader content. Original length: {len(unity_toon_content)}, New length: {len(new_content)}") + + # Write test file + test_path = "UnityToon_Generated_Test.shader" + with open(test_path, 'w') as f: + f.write(new_content) + + print(f"Test shader written to {test_path}") + print("Shader generation test completed successfully!") + + except Exception as e: + print(f"ERROR: {e}") + import traceback + traceback.print_exc() + +if __name__ == "__main__": + test_shader_generation() \ No newline at end of file diff --git a/test_shader_generation.cs b/test_shader_generation.cs new file mode 100644 index 00000000..102c2d8e --- /dev/null +++ b/test_shader_generation.cs @@ -0,0 +1,130 @@ +using System; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; + +class Program +{ + static void Main() + { + try + { + // Test reading the common properties file + string commonPropertiesPath = "com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt"; + string commonProperties = File.ReadAllText(commonPropertiesPath); + + if (string.IsNullOrEmpty(commonProperties)) + { + Console.WriteLine("ERROR: Common properties file is empty or could not be read"); + return; + } + + Console.WriteLine($"Successfully read common properties file. Length: {commonProperties.Length} characters"); + + // Test reading the tessellation properties file + string tessellationPropertiesPath = "com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt"; + string tessellationProperties = File.ReadAllText(tessellationPropertiesPath); + + if (string.IsNullOrEmpty(tessellationProperties)) + { + Console.WriteLine("ERROR: Tessellation properties file is empty or could not be read"); + return; + } + + Console.WriteLine($"Successfully read tessellation properties file. Length: {tessellationProperties.Length} characters"); + + // Test reading the original shader files + string unityToonPath = "com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader"; + string unityToonContent = File.ReadAllText(unityToonPath); + + if (string.IsNullOrEmpty(unityToonContent)) + { + Console.WriteLine("ERROR: UnityToon.shader file is empty or could not be read"); + return; + } + + Console.WriteLine($"Successfully read UnityToon.shader. Length: {unityToonContent.Length} characters"); + + // Test the Properties block replacement + string propertiesPattern = @"Properties\s*\{"; + Match startMatch = Regex.Match(unityToonContent, propertiesPattern); + + if (!startMatch.Success) + { + Console.WriteLine("ERROR: Could not find Properties block start in shader file"); + return; + } + + Console.WriteLine($"Found Properties block start at position {startMatch.Index}"); + + // Find the matching closing brace + int startIndex = startMatch.Index; + int braceCount = 0; + int endIndex = startIndex; + bool foundStart = false; + + for (int i = startIndex; i < unityToonContent.Length; i++) + { + if (unityToonContent[i] == '{') + { + braceCount++; + foundStart = true; + } + else if (unityToonContent[i] == '}') + { + braceCount--; + if (foundStart && braceCount == 0) + { + endIndex = i; + break; + } + } + } + + if (braceCount != 0) + { + Console.WriteLine("ERROR: Could not find matching closing brace for Properties block"); + return; + } + + Console.WriteLine($"Found Properties block end at position {endIndex}"); + + // Test building new Properties block + StringBuilder newProperties = new StringBuilder(); + newProperties.AppendLine(" Properties {"); + + // Add common properties + string[] commonLines = commonProperties.Split('\n'); + int propertyCount = 0; + foreach (string line in commonLines) + { + if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + { + newProperties.AppendLine($" {line.Trim()}"); + propertyCount++; + } + } + + newProperties.AppendLine(" }"); + + Console.WriteLine($"Generated new Properties block with {propertyCount} properties. Length: {newProperties.Length} characters"); + + // Test the replacement + string newContent = unityToonContent.Substring(0, startIndex) + newProperties.ToString() + unityToonContent.Substring(endIndex + 1); + + Console.WriteLine($"Generated new shader content. Original length: {unityToonContent.Length}, New length: {newContent.Length}"); + + // Write test file + string testPath = "UnityToon_Generated_Test.shader"; + File.WriteAllText(testPath, newContent); + + Console.WriteLine($"Test shader written to {testPath}"); + Console.WriteLine("Shader generation test completed successfully!"); + } + catch (Exception e) + { + Console.WriteLine($"ERROR: {e.Message}"); + Console.WriteLine(e.StackTrace); + } + } +} \ No newline at end of file From 21511b20ecd52c6bcffeb0ae139720005a0888d0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Oct 2025 06:12:55 +0000 Subject: [PATCH 3/3] Refactor: Preserve comments in shader properties Co-authored-by: sindharta.tanuwijaya --- .../Editor/README_ShaderGenerator.md | 15 +- .../Editor/ShaderGenerator.cs | 16 +- .../Shaders/CommonPropertiesWithComments.txt | 496 ++++++++++++++++++ .../Integrated/Shaders/UnityToon.shader | 113 +++- .../Shaders/UnityToon.shader.backup | 145 +---- .../Shaders/UnityToonTessellation.shader | 119 ++++- .../UnityToonTessellation.shader.backup | 182 +------ generate_shaders.py | 12 +- 8 files changed, 763 insertions(+), 335 deletions(-) create mode 100644 com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt diff --git a/com.unity.toonshader/Editor/README_ShaderGenerator.md b/com.unity.toonshader/Editor/README_ShaderGenerator.md index f909337c..6103ff64 100644 --- a/com.unity.toonshader/Editor/README_ShaderGenerator.md +++ b/com.unity.toonshader/Editor/README_ShaderGenerator.md @@ -4,7 +4,7 @@ This tool helps maintain consistency between `UnityToon.shader` and `UnityToonTe ## Files -- **CommonProperties.txt**: Contains all shared properties between the two shader files +- **CommonPropertiesWithComments.txt**: Contains all shared properties between the two shader files with original comments preserved - **TessellationProperties.txt**: Contains tessellation-specific properties only present in the tessellation shader - **ShaderGenerator.cs**: Unity Editor script that generates the shader files from the property files @@ -15,7 +15,7 @@ This tool helps maintain consistency between `UnityToon.shader` and `UnityToonTe - This opens the Shader Generator window 2. **Edit Properties**: - - Click "Open Common Properties File" to edit shared properties + - Click "Open Common Properties File" to edit shared properties (includes all original comments) - Click "Open Tessellation Properties File" to edit tessellation-specific properties - Make your changes to the property files @@ -43,7 +43,8 @@ _BaseColor ("BaseColor", Color) = (1,1,1,1) - **Consistency**: Ensures both shader files have identical shared properties - **Maintainability**: Easy to add, remove, or modify properties across both shaders - **Backup Safety**: Original files are automatically backed up before generation -- **Preservation**: All non-Properties content is preserved during generation +- **Preservation**: All non-Properties content and comments are preserved during generation +- **Comment Preservation**: All original comments from the Properties blocks are maintained ## Manual Generation (Alternative) @@ -71,8 +72,8 @@ com.unity.toonshader/ │ ├── ShaderGenerator.cs # Unity Editor script │ └── README_ShaderGenerator.md # This file └── Runtime/Integrated/Shaders/ - ├── CommonProperties.txt # Shared properties - ├── TessellationProperties.txt # Tessellation-specific properties - ├── UnityToon.shader # Generated shader (regular) - └── UnityToonTessellation.shader # Generated shader (tessellation) + ├── CommonPropertiesWithComments.txt # Shared properties with comments + ├── TessellationProperties.txt # Tessellation-specific properties + ├── UnityToon.shader # Generated shader (regular) + └── UnityToonTessellation.shader # Generated shader (tessellation) ``` \ No newline at end of file diff --git a/com.unity.toonshader/Editor/ShaderGenerator.cs b/com.unity.toonshader/Editor/ShaderGenerator.cs index d6f4c8e8..55e67ef5 100644 --- a/com.unity.toonshader/Editor/ShaderGenerator.cs +++ b/com.unity.toonshader/Editor/ShaderGenerator.cs @@ -14,7 +14,7 @@ namespace UnityEditor.Rendering.Toon /// public class ShaderGenerator : EditorWindow { - private const string COMMON_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt"; + private const string COMMON_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt"; private const string TESSELATION_PROPERTIES_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationProperties.txt"; private const string UNITY_TOON_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader"; private const string UNITY_TOON_TESSELATION_SHADER_PATH = "Assets/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader"; @@ -183,10 +183,13 @@ private string ReplacePropertiesBlock(string originalContent, string commonPrope int propertyCount = 0; foreach (string line in commonLines) { - if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + if (!string.IsNullOrWhiteSpace(line)) { newProperties.AppendLine($" {line.Trim()}"); - propertyCount++; + if (!line.TrimStart().StartsWith("//")) + { + propertyCount++; + } } } @@ -198,10 +201,13 @@ private string ReplacePropertiesBlock(string originalContent, string commonPrope string[] tessellationLines = tessellationProperties.Split('\n'); foreach (string line in tessellationLines) { - if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//")) + if (!string.IsNullOrWhiteSpace(line)) { newProperties.AppendLine($" {line.Trim()}"); - propertyCount++; + if (!line.TrimStart().StartsWith("//")) + { + propertyCount++; + } } } } diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt b/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt new file mode 100644 index 00000000..732032f6 --- /dev/null +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt @@ -0,0 +1,496 @@ +// Common Properties for Unity Toon Shader +// This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader +// with comments preserved from the original files + +// Basic UI and Version Properties +[HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 +[HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 +[HideInInspector] _utsVersionX("VersionX", Float) = 0 +[HideInInspector] _utsVersionY("VersionY", Float) = 11 +[HideInInspector] _utsVersionZ("VersionZ", Float) = 0 +[HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF +_AutoRenderQueue("Automatic Render Queue ", int) = 1 + +// Stencil Properties +[Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 +// these are set in UniversalToonGUI.cs in accordance with _StencilMode +_StencilComp("Stencil Comparison", Float) = 8 +_StencilNo("Stencil No", Float) = 1 +_StencilOpPass("Stencil Operation", Float) = 0 +_StencilOpFail("Stencil Operation", Float) = 0 +[Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + +// Clipping Properties +// DoubleShadeWithFeather +// 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE +// ShadingGradeMap +// 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON +[Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + +// Cull and ZWrite Properties +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK +[Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON +[Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON +_SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + +// ClippingMask parameters +// ClippingMask paramaters from Here. +_ClippingMask("ClippingMask", 2D) = "white" {} +_IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 +// +[Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 +_Clipping_Level("Clipping_Level", Range(0, 1)) = 0 +_Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 +// ClippingMask paramaters to Here. + +// Base Color Properties +_MainTex ("BaseMap", 2D) = "white" {} +_BaseMap ("BaseMap", 2D) = "white" {} +_BaseColor ("BaseColor", Color) = (1,1,1,1) +//v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. +//If you want to go back the former SSAO results, comment out the below line. +_Color ("Color", Color) = (1,1,1,1) +// +[Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + +// 1st Shade Properties +_1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 +_1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + +// 2nd Shade Properties +_2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 +_2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + +// Normal Map Properties +_NormalMap ("NormalMap", 2D) = "bump" {} +_BumpScale ("Normal Scale", Range(0, 1)) = 1 +[Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 +//v.2.0.4.4 +[Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 +_Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + +// Shading Properties +//v.2.0.6 +_BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 +_BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 +_ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 +_1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 +_1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 +_1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +_2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 +_2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +//v.2.0.5 +_StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 +[Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + +// Shading Grade Map Properties +_Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} +_Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} +_ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} +//v.2.0.6 +_Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 +_BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + +// High Color Properties +_HighColor ("HighColor", Color) = (0,0,0,1) +//v.2.0.4 HighColor_Tex +_HighColor_Tex ("HighColor_Tex", 2D) = "white" {} +[Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 +[Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 +_HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 +[Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 +[Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 +[Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 +_TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 +//HiColorMask +_Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} +_Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + +// Rim Light Properties +[Toggle(_)] _RimLight ("RimLight", Float ) = 0 +_RimLightColor ("RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 +[Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 +_RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 +_RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 +[Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 +//RimLight +[Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 +_Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 +[Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 +_Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 +_Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 +[Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 +//RimLightMask +_Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} +_Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + +// MatCap Properties +[Toggle(_)] _MatCap ("MatCap", Float ) = 0 +_MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} +//v.2.0.6 +_BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 +_MatCapColor ("MatCapColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 +[Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 +_Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 +_Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 +//v.2.0.6 +[Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 +[Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 +_NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} +_BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 +_Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 +[Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 +_TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 +//MatcapMask +_Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} +_Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 +[Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + +// Angel Rings Properties +//// Angel Rings +[Toggle(_)] _AngelRing("AngelRing", Float) = 0 +_AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} +_AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) +[Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 +_AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 +_AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 +[Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + +// Emissive Properties +//v.2.0.7 Emissive +[KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 +_Emissive_Tex ("Emissive_Tex", 2D) = "white" {} +[HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) +_Base_Speed ("Base_Speed", Float ) = 0 +_Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 +_Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 +_Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 +[Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 +[Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 +[HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) +_ColorShift_Speed ("ColorShift_Speed", Float ) = 0 +[Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 +[HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) +[Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + +// Outline Properties +//Outline +[KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 +_Outline_Width ("Outline_Width", Float ) = 0 +_Farthest_Distance ("Farthest_Distance", Float ) = 100 +_Nearest_Distance ("Nearest_Distance", Float ) = 0.5 +_Outline_Sampler ("Outline_Sampler", 2D) = "white" {} +_Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) +[Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 +[Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 +//v.2.0.4 +[Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 +_OutlineTex ("OutlineTex", 2D) = "white" {} +//Offset parameter +_Offset_Z ("Offset_Camera_Z", Float) = 0 +//v.2.0.4.3 Baked Normal Texture for Outline +[Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 +_BakedNormal ("Baked Normal for Outline", 2D) = "white" {} +//GI Intensity +_GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 +//For VR Chat under No effective light objects +_Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 +//Built-in Light Direction +[Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 +_Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 +_Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 +[Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + +// HDRP Matte Properties +////////////////////////////////////////////////////////////////////////////// +////////////////// Beginning of HDRP Matte. ////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +[Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 +[Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 +_BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + +[Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 +_FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + +[Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 +_SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + +[Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 +[Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 +_HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + +[Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 +[Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 +_AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + +[Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 +[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 +_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + +[Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 +[Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 +_OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + +[Toggle(_)] _ComposerMaskMode("", Float) = 0 +[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + +////////////////////////////////////////////////////////////////////////////// +////////////////// End of HDRP Matte. ////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Avoid HDRP srp batcher error +////////////////// Avoid HDRP srp batcher error /////////////////////////////// +[HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // +////////////////// Avoid HDRP srp batcher error /////////////////////////////// + +// HDRP material default values +////////////////////////////////////////////////////////////////////////////// +////////////////// Beginning of HDRP material default values. //////////////// +////////////////////////////////////////////////////////////////////////////// +_BaseColorMap("BaseColorMap", 2D) = "white" {} +[HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + +_Metallic("_Metallic", Range(0.0, 1.0)) = 0 +_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 +_MaskMap("MaskMap", 2D) = "white" {} +_SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 +_SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 +_AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 +_AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 +_AORemapMin("AORemapMin", Float) = 0.0 +_AORemapMax("AORemapMax", Float) = 1.0 + +// Normal Maps +////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map +_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value +_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + +_BentNormalMap("_BentNormalMap", 2D) = "bump" {} +_BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + +// Height Maps +_HeightMap("HeightMap", 2D) = "black" {} +// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 +// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. +[HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. +[HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 +// These parameters are for vertex displacement/Tessellation +_HeightOffset("Height Offset", Float) = 0 +// MinMax mode +_HeightMin("Heightmap Min", Float) = -1 +_HeightMax("Heightmap Max", Float) = 1 +// Amplitude mode +_HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters +_HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +// These parameters are for pixel displacement +_HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + +// Detail Maps +_DetailMap("DetailMap", 2D) = "linearGrey" {} +_DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 +_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 +_DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + +// Tangent Maps +_TangentMap("TangentMap", 2D) = "bump" {} +_TangentMapOS("TangentMapOS", 2D) = "white" {} +_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 +_AnisotropyMap("AnisotropyMap", 2D) = "white" {} + +// Diffusion Profile +[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 +[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) +[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 +_SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 +_SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} +_TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 +_Thickness("Thickness", Range(0.0, 1.0)) = 1.0 +_ThicknessMap("Thickness Map", 2D) = "white" {} +_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + +// Iridescence +_IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 +_IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} +_IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) +_IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 +_IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + +// Coat +_CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 +_CoatMaskMap("CoatMaskMap", 2D) = "white" {} + +// Specular +[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 +_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) +_SpecularColorMap("SpecularColorMap", 2D) = "white" {} + +// Following options are for the GUI inspector and different from the input parameters above +// These option below will cause different compilation flag. +[Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + +// Emissive +[HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) +// Used only to serialize the LDR and HDR emissive color in the material UI, +// in the shader only the _EmissiveColor should be used +[HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) +_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} +[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 +[HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 +[ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 +_EmissiveIntensity("Emissive Intensity", Float) = 1 +_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + +// Distortion +_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} +[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 +[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 +[Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 +[HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 +[HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 +[HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 +_DistortionScale("Distortion Scale", Float) = 1 +_DistortionVectorScale("Distortion Vector Scale", Float) = 2 +_DistortionVectorBias("Distortion Vector Bias", Float) = -1 +_DistortionBlurScale("Distortion Blur Scale", Float) = 1 +_DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 +_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + +// Alpha and Transparency +[ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 +[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 +_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 +[ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 +[ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 +[ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 +_TransparentSortPriority("_TransparentSortPriority", Float) = 0 + +// Transparency +[Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 +[Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 +_Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 +_ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 +_TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) +_TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} +_ATDistance("Transmittance Absorption Distance", Float) = 1.0 +[ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + +// Stencil state +// Forward +[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting +// GBuffer +[HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting +// Depth prepass +[HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing +[HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR +// Motion vector pass +[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +// Distortion vector pass +[HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors +[HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + +// Blending state +[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 +[HideInInspector] _BlendMode("__blendmode", Float) = 0.0 +[HideInInspector] _SrcBlend("__src", Float) = 1.0 +[HideInInspector] _DstBlend("__dst", Float) = 0.0 +[HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 +[HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 +[HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 +[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 +[HideInInspector] _CullMode("__cullmode", Float) = 2.0 +[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent +[HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default +[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal +[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 +[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 +[Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + +[ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 +[ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + +[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 +[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 +[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 +[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 +_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 +[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) +[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + +// Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other +// so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature +// The only material feature flag that can be added in all cases is clear coat +[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard +[ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 + +[Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 +[ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 +[ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 +[ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 + +[ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 +_SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 +_SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + +_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 +_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 +_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 +_PPDPrimitiveLength("Primitive length for POM", Float) = 1 +_PPDPrimitiveWidth("Primitive width for POM", Float) = 1 +[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 +[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) +[ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + +[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 +_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + +// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" +// value that exist to identify if the GI emission need to be enabled. +// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. +// TODO: Fix the code in legacy unity so we can customize the beahvior for GI +_EmissionColor("Color", Color) = (1, 1, 1) + +// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. +////////// _MainTex("BaseMap", 2D) = "white" {} +_Color("Color", Color) = (1,1,1,1) +_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + +[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 +[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 +[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 +////////////////////////////////////////////////////////////////////////////// +//////////////////// End of HDRP material default values. //////////////////// +////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader index 8c69159b..a00cb91e 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader @@ -3,7 +3,11 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon" { - Properties { + Properties { + // Common Properties for Unity Toon Shader + // This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader + // with comments preserved from the original files + // Basic UI and Version Properties [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,41 +15,65 @@ Shader "Toon" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 + // Stencil Properties [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + // Clipping Properties + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + // Cull and ZWrite Properties [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + // ClippingMask parameters + // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + // Base Color Properties _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) + // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + // 1st Shade Properties _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + // 2nd Shade Properties _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + // Normal Map Properties _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + // Shading Properties + //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -54,14 +82,19 @@ Shader "Toon" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + // Shading Grade Map Properties _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + // High Color Properties _HighColor ("HighColor", Color) = (0,0,0,1) + //v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -70,8 +103,10 @@ Shader "Toon" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 + //HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + // Rim Light Properties [Toggle(_)] _RimLight ("RimLight", Float ) = 0 _RimLightColor ("RimLightColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 @@ -79,6 +114,7 @@ Shader "Toon" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 + //RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -86,16 +122,20 @@ Shader "Toon" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 + //RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + // MatCap Properties [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -103,10 +143,14 @@ Shader "Toon" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 + //MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + // Angel Rings Properties + //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -114,6 +158,8 @@ Shader "Toon" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + // Emissive Properties + //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -128,6 +174,8 @@ Shader "Toon" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + // Outline Properties + //Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -136,18 +184,29 @@ Shader "Toon" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + // HDRP Matte Properties + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) @@ -171,7 +230,17 @@ Shader "Toon" { _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + // Avoid HDRP srp batcher error + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + // HDRP material default values + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) _Metallic("_Metallic", Range(0.0, 1.0)) = 0 @@ -183,28 +252,40 @@ Shader "Toon" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 + // Normal Maps + ////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + // Height Maps _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 + // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + // Detail Maps _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + // Tangent Maps _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + // Diffusion Profile [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -214,18 +295,26 @@ Shader "Toon" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + // Iridescence _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + // Coat _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + // Specular [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + // Emissive [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -233,6 +322,7 @@ Shader "Toon" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + // Distortion _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -248,6 +338,7 @@ Shader "Toon" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + // Alpha and Transparency [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -258,6 +349,7 @@ Shader "Toon" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -266,16 +358,23 @@ Shader "Toon" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + // Stencil state + // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -302,6 +401,9 @@ Shader "Toon" { [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 @@ -324,12 +426,21 @@ Shader "Toon" { [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + ////////// _MainTex("BaseMap", 2D) = "white" {} _Color("Color", Color) = (1,1,1,1) _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// } HLSLINCLUDE diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup index fe4969f0..982459b6 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader.backup @@ -3,7 +3,7 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon" { - Properties { + Properties { [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,70 +11,41 @@ Shader "Toon" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 - [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 - // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 - - // DoubleShadeWithFeather - // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE - // ShadingGradeMap - // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 - - [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK - // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} - _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 - // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 - // ClippingMask paramaters to Here. - - - [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK - - - - - - _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) - //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. - //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) - // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 - //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 - //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -83,19 +54,14 @@ Shader "Toon" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 - //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 - // _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} - //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 - // _HighColor ("HighColor", Color) = (0,0,0,1) -//v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -104,7 +70,6 @@ Shader "Toon" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 -//HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _RimLight ("RimLight", Float ) = 0 @@ -114,7 +79,6 @@ Shader "Toon" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 -//RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -122,20 +86,16 @@ Shader "Toon" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 -//RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 -// [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} - //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 - //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -143,13 +103,10 @@ Shader "Toon" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 -//MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 - //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 - //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -157,8 +114,6 @@ Shader "Toon" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 - // - //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -173,8 +128,6 @@ Shader "Toon" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 - // -//Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -183,76 +136,44 @@ Shader "Toon" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 - //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} - //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 - //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} - //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 - //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 - //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 - //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) - [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) - [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) - [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) - [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) - [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) - [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) - [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// End of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP material default values. //////////////// - ////////////////////////////////////////////////////////////////////////////// - _BaseColorMap("BaseColorMap", 2D) = "white" {} + _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) - _Metallic("_Metallic", Range(0.0, 1.0)) = 0 _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 _MaskMap("MaskMap", 2D) = "white" {} @@ -262,43 +183,28 @@ Shader "Toon" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 - - //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 - _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} - _HeightMap("HeightMap", 2D) = "black" {} - // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 - // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 - // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 - // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 - // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - - // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters - _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 - _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} - [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -308,27 +214,18 @@ Shader "Toon" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) - _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} - _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} - [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} - - // Following options are for the GUI inspector and different from the input parameters above - // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 - [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) - // Used only to serialize the LDR and HDR emissive color in the material UI, - // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -336,7 +233,6 @@ Shader "Toon" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 - _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -352,7 +248,6 @@ Shader "Toon" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 - [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -363,8 +258,6 @@ Shader "Toon" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 - - // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -373,26 +266,16 @@ Shader "Toon" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 - - // Stencil state - - // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting - // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting - // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR - // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors - // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors - - // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -408,69 +291,45 @@ Shader "Toon" { [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal - [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 - [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 - - // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other - // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature - // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 - _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 _PPDPrimitiveLength("Primitive length for POM", Float) = 1 _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 - [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) - - // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" - // value that exist to identify if the GI emission need to be enabled. - // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. - // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) - - // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. - //////////// _MainTex("BaseMap", 2D) = "white" {} _Color("Color", Color) = (1,1,1,1) _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 - [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material default values. //////////////////// - ////////////////////////////////////////////////////////////////////////////// } HLSLINCLUDE diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader index 095be40f..77b7103a 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader @@ -3,7 +3,11 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon(Tessellation)" { - Properties { + Properties { + // Common Properties for Unity Toon Shader + // This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader + // with comments preserved from the original files + // Basic UI and Version Properties [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,41 +15,65 @@ Shader "Toon(Tessellation)" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 + // Stencil Properties [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + // Clipping Properties + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + // Cull and ZWrite Properties [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + // ClippingMask parameters + // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + // Base Color Properties _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) + // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + // 1st Shade Properties _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + // 2nd Shade Properties _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + // Normal Map Properties _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + // Shading Properties + //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -54,14 +82,19 @@ Shader "Toon(Tessellation)" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + // Shading Grade Map Properties _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + // High Color Properties _HighColor ("HighColor", Color) = (0,0,0,1) + //v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -70,8 +103,10 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 + //HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + // Rim Light Properties [Toggle(_)] _RimLight ("RimLight", Float ) = 0 _RimLightColor ("RimLightColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 @@ -79,6 +114,7 @@ Shader "Toon(Tessellation)" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 + //RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -86,16 +122,20 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 + //RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + // MatCap Properties [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -103,10 +143,14 @@ Shader "Toon(Tessellation)" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 + //MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + // Angel Rings Properties + //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -114,6 +158,8 @@ Shader "Toon(Tessellation)" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + // Emissive Properties + //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -128,6 +174,8 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + // Outline Properties + //Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -136,18 +184,29 @@ Shader "Toon(Tessellation)" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + // HDRP Matte Properties + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) @@ -171,7 +230,17 @@ Shader "Toon(Tessellation)" { _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + // Avoid HDRP srp batcher error + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + // HDRP material default values + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) _Metallic("_Metallic", Range(0.0, 1.0)) = 0 @@ -183,28 +252,40 @@ Shader "Toon(Tessellation)" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 + // Normal Maps + ////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + // Height Maps _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 + // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + // Detail Maps _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + // Tangent Maps _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + // Diffusion Profile [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -214,18 +295,26 @@ Shader "Toon(Tessellation)" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + // Iridescence _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + // Coat _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + // Specular [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + // Emissive [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -233,6 +322,7 @@ Shader "Toon(Tessellation)" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + // Distortion _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -248,6 +338,7 @@ Shader "Toon(Tessellation)" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + // Alpha and Transparency [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -258,6 +349,7 @@ Shader "Toon(Tessellation)" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -266,16 +358,23 @@ Shader "Toon(Tessellation)" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + // Stencil state + // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -302,6 +401,9 @@ Shader "Toon(Tessellation)" { [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 @@ -324,14 +426,26 @@ Shader "Toon(Tessellation)" { [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + ////////// _MainTex("BaseMap", 2D) = "white" {} _Color("Color", Color) = (1,1,1,1) _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// // Tessellation-specific properties + // Tessellation-specific Properties for Unity Toon Shader Tessellation + // These properties are only present in the tessellation shader + // Tessellation specific [Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 @@ -339,7 +453,10 @@ Shader "Toon(Tessellation)" { _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong _TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 + // HDRP material tessellation values [Enum(None, 0, Tessellation displacement, 3)] _DisplacementMode("DisplacementMode", Int) = 3 + // Legacy material tessellation values + //Tessellation _TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 _TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 _TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 diff --git a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup index cedc1155..2f68d43d 100644 --- a/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup +++ b/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader.backup @@ -3,7 +3,7 @@ //toshiyuki@unity3d.com (Intengrated) Shader "Toon(Tessellation)" { - Properties { + Properties { [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 [HideInInspector][Enum(OFF, 0, ON, 1)] _isUnityToonshader("Material is touched by Unity Toon Shader", Int) = 1 [HideInInspector] _utsVersionX("VersionX", Float) = 0 @@ -11,70 +11,41 @@ Shader "Toon(Tessellation)" { [HideInInspector] _utsVersionZ("VersionZ", Float) = 0 [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF _AutoRenderQueue("Automatic Render Queue ", int) = 1 - [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 - // these are set in UniversalToonGUI.cs in accordance with _StencilMode _StencilComp("Stencil Comparison", Float) = 8 _StencilNo("Stencil No", Float) = 1 _StencilOpPass("Stencil Operation", Float) = 0 _StencilOpFail("Stencil Operation", Float) = 0 [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 - - // DoubleShadeWithFeather - // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE - // ShadingGradeMap - // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 - - [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK - // ClippingMask paramaters from Here. _ClippingMask("ClippingMask", 2D) = "white" {} - _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 - // [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 - // ClippingMask paramaters to Here. - - - [Enum(OFF,0,FRONT,1,BACK,2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK - - - - - - _MainTex ("BaseMap", 2D) = "white" {} _BaseMap ("BaseMap", 2D) = "white" {} _BaseColor ("BaseColor", Color) = (1,1,1,1) - //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. - //If you want to go back the former SSAO results, comment out the below line. _Color ("Color", Color) = (1,1,1,1) - // [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} - //v.2.0.5 [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 _NormalMap ("NormalMap", 2D) = "bump" {} _BumpScale ("Normal Scale", Range(0, 1)) = 1 [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 - //v.2.0.4.4 [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 - //v.2.0.6 _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 @@ -83,19 +54,14 @@ Shader "Toon(Tessellation)" { _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 - //v.2.0.5 _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 - // _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} - //v.2.0.6 _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 - // _HighColor ("HighColor", Color) = (0,0,0,1) -//v.2.0.4 HighColor_Tex _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 @@ -104,7 +70,6 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 -//HiColorMask _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _RimLight ("RimLight", Float ) = 0 @@ -114,7 +79,6 @@ Shader "Toon(Tessellation)" { _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 -//RimLight [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 @@ -122,20 +86,16 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 -//RimLightMask _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 -// [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} - //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 - //v.2.0.6 [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} @@ -143,13 +103,10 @@ Shader "Toon(Tessellation)" { _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 -//MatcapMask _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 - //v.2.0.5 [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 - //// Angel Rings [Toggle(_)] _AngelRing("AngelRing", Float) = 0 _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) @@ -157,8 +114,6 @@ Shader "Toon(Tessellation)" { _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 - // - //v.2.0.7 Emissive [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) @@ -173,8 +128,6 @@ Shader "Toon(Tessellation)" { [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 - // -//Outline [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 _Outline_Width ("Outline_Width", Float ) = 0 _Farthest_Distance ("Farthest_Distance", Float ) = 100 @@ -183,77 +136,44 @@ Shader "Toon(Tessellation)" { _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 - //v.2.0.4 [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 _OutlineTex ("OutlineTex", 2D) = "white" {} - //Offset parameter _Offset_Z ("Offset_Camera_Z", Float) = 0 - //v.2.0.4.3 Baked Normal Texture for Outline [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} - //GI Intensity _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 - //For VR Chat under No effective light objects _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 - //v.2.0.5 [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 - //Built-in Light Direction [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) - [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) - [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) - [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) - [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) - [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) - [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) - [Toggle(_)] _ComposerMaskMode("", Float) = 0 [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// End of HDRP Matte. ////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // - ////////////////// Avoid HDRP srp batcher error /////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////// - ////////////////// Beginning of HDRP material default values. //////////////// - ////////////////////////////////////////////////////////////////////////////// - _BaseColorMap("BaseColorMap", 2D) = "white" {} + _BaseColorMap("BaseColorMap", 2D) = "white" {} [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) - _Metallic("_Metallic", Range(0.0, 1.0)) = 0 _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 _MaskMap("MaskMap", 2D) = "white" {} @@ -263,43 +183,28 @@ Shader "Toon(Tessellation)" { _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 - - //////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 - _BentNormalMap("_BentNormalMap", 2D) = "bump" {} _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} - _HeightMap("HeightMap", 2D) = "black" {} - // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 - // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 - // These parameters are for vertex displacement/Tessellation _HeightOffset("Height Offset", Float) = 0 - // MinMax mode _HeightMin("Heightmap Min", Float) = -1 _HeightMax("Heightmap Max", Float) = 1 - // Amplitude mode _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space - - // These parameters are for pixel displacement _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters - _DetailMap("DetailMap", 2D) = "linearGrey" {} _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 - _TangentMap("TangentMap", 2D) = "bump" {} _TangentMapOS("TangentMapOS", 2D) = "white" {} _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 _AnisotropyMap("AnisotropyMap", 2D) = "white" {} - [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 @@ -309,27 +214,18 @@ Shader "Toon(Tessellation)" { _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 _ThicknessMap("Thickness Map", 2D) = "white" {} _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) - _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} - _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 _CoatMaskMap("CoatMaskMap", 2D) = "white" {} - [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) _SpecularColorMap("SpecularColorMap", 2D) = "white" {} - - // Following options are for the GUI inspector and different from the input parameters above - // These option below will cause different compilation flag. [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 - [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) - // Used only to serialize the LDR and HDR emissive color in the material UI, - // in the shader only the _EmissiveColor should be used [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 @@ -337,7 +233,6 @@ Shader "Toon(Tessellation)" { [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 _EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 - _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 @@ -353,7 +248,6 @@ Shader "Toon(Tessellation)" { _DistortionBlurScale("Distortion Blur Scale", Float) = 1 _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 - [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 @@ -364,8 +258,6 @@ Shader "Toon(Tessellation)" { [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 _TransparentSortPriority("_TransparentSortPriority", Float) = 0 - - // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 @@ -374,26 +266,16 @@ Shader "Toon(Tessellation)" { _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} _ATDistance("Transmittance Absorption Distance", Float) = 1.0 [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 - - // Stencil state - - // Forward [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting - // GBuffer [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting - // Depth prepass [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR - // Motion vector pass [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors - // Distortion vector pass [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors - - // Blending state [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 [HideInInspector] _SrcBlend("__src", Float) = 1.0 @@ -409,59 +291,47 @@ Shader "Toon(Tessellation)" { [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal - [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 - [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 - - // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other - // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature - // The only material feature flag that can be added in all cases is clear coat [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - - [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 3 + [Enum(None, 0, Vertex displacement, 1, Pixel displacement, 2)] _DisplacementMode("DisplacementMode", Int) = 0 [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 - _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 _PPDPrimitiveLength("Primitive length for POM", Float) = 1 _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) - [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 - [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) - - // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" - // value that exist to identify if the GI emission need to be enabled. - // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. - // TODO: Fix the code in legacy unity so we can customize the beahvior for GI _EmissionColor("Color", Color) = (1, 1, 1) + _Color("Color", Color) = (1,1,1,1) + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - // Tessellation specific + // Tessellation-specific properties [Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 @@ -469,44 +339,10 @@ Shader "Toon(Tessellation)" { _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong _TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 - // TODO: Handle culling mode for backface culling - // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. - //////////// _MainTex("BaseMap", 2D) = "white" {} - _Color("Color", Color) = (1,1,1,1) - _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 - - [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 - [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 - [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material default values. //////////////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////// - //////////////////// Start of HDRP material tessellation values. ///////////// - ////////////////////////////////////////////////////////////////////////////// - [ToggleUI] _TransmissionEnable("_TransmissionEnable", Float) = 1.0 - [Enum(None, 0, Tessellation displacement, 3)] _DisplacementMode("DisplacementMode", Int) = 3 - [ToggleUI] _DisplacementLockObjectScale("displacement lock object scale", Float) = 1.0 - [ToggleUI] _DisplacementLockTilingScale("displacement lock tiling scale", Float) = 1.0 - [ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of HDRP material tessellation values. ///////////// - ////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////// - //////////////////// Start of Legacy material tessellation values. /////////// - ////////////////////////////////////////////////////////////////////////////// - - //Tessellation _TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 _TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 _TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 - ////////////////////////////////////////////////////////////////////////////// - //////////////////// End of Legacy material tessellation values. /////////// - ////////////////////////////////////////////////////////////////////////////// - } HLSLINCLUDE diff --git a/generate_shaders.py b/generate_shaders.py index 2198d151..6298f5fa 100644 --- a/generate_shaders.py +++ b/generate_shaders.py @@ -7,7 +7,7 @@ def generate_shader_files(): try: # Read the common properties file - common_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/CommonProperties.txt" + common_properties_path = "com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesWithComments.txt" with open(common_properties_path, 'r') as f: common_properties = f.read() @@ -103,9 +103,10 @@ def generate_shader(shader_path, common_properties, tessellation_properties): common_lines = common_properties.split('\n') property_count = 0 for line in common_lines: - if line.strip() and not line.strip().startswith("//"): + if line.strip(): new_properties.append(f" {line.strip()}") - property_count += 1 + if not line.strip().startswith("//"): + property_count += 1 # Add tessellation properties if provided if tessellation_properties: @@ -113,9 +114,10 @@ def generate_shader(shader_path, common_properties, tessellation_properties): new_properties.append(" // Tessellation-specific properties") tessellation_lines = tessellation_properties.split('\n') for line in tessellation_lines: - if line.strip() and not line.strip().startswith("//"): + if line.strip(): new_properties.append(f" {line.strip()}") - property_count += 1 + if not line.strip().startswith("//"): + property_count += 1 new_properties.append(" }")