#T#PoiMatcapProperties
// First Matcap
//ifex _MatcapEnable==0
[HideInInspector] m_start_matcap ("Matcap 0--{reference_property:_MatcapEnable,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/matcap},hover:Documentation}}", Float) = 0
[HideInInspector][ThryToggle(POI_MATCAP0)]_MatcapEnable ("Enable Matcap", Float) = 0
[ThryWideEnum(UTS Style, 0, Top Pinch, 1, Double Sided, 2)] _MatcapUVMode ("UV Mode", Int) = 1
_MatcapColor ("Color--{reference_property:_MatcapColorThemeIndex}", Color) = (1, 1, 1, 1)
_MatcapBaseColorMix ("Base Color Mix", Range(0, 1)) = 0
[HideInInspector][ThryWideEnum(Off, 0, Theme Color 0, 1, Theme Color 1, 2, Theme Color 2, 3, Theme Color 3, 4, ColorChord 0, 5, ColorChord 1, 6, ColorChord 2, 7, ColorChord 3, 8, AL Theme 0, 9, AL Theme 1, 10, AL Theme 2, 11, AL Theme 3, 12)] _MatcapColorThemeIndex ("", Int) = 0
[sRGBWarning(true)]_Matcap ("Matcap--{reference_properties:[_MatcapUVToBlend, _MatCapBlendUV1]}", 2D) = "white" { }
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _MatcapUVToBlend ("UV To Blend", Int) = 1
[HideInInspector][VectorToSliders(Blend UV X, 0.0, 1.0, Blend UV Y, 0.0, 1.0)]_MatCapBlendUV1 ("UV Blend", Vector) = (0, 0, 0, 0)
_MatcapBorder ("Border", Range(0, 5)) = 0.43
_MatcapRotation ("Rotation", Range(-1, 1)) = 0
[sRGBWarning][ThryRGBAPacker(R Mask, G Nothing, B Nothing, A Smoothness)]_MatcapMask ("Mask--{reference_properties:[_MatcapMaskPan, _MatcapMaskUV, _MatcapMaskChannel, _MatcapMaskInvert]}", 2D) = "white" { }
[HideInInspector][Vector2]_MatcapMaskPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _MatcapMaskUV ("UV", Int) = 0
[HideInInspector][Enum(R, 0, G, 1, B, 2, A, 3)]_MatcapMaskChannel ("Channel", Float) = 0
[HideInInspector][ToggleUI]_MatcapMaskInvert ("Invert", Float) = 0
[ThryWideEnum(Off, 0, 1R, 1, 1G, 2, 1B, 3, 1A, 4, 2R, 5, 2G, 6, 2B, 7, 2A, 8, 3R, 9, 3G, 10, 3B, 11, 3A, 12, 4R, 13, 4G, 14, 4B, 15, 4A, 16)] _MatcapMaskGlobalMask ("Global Mask--{reference_property:_MatcapMaskGlobalMaskBlendType}", Int) = 0
[HideInInspector][ThryWideEnum(Replace, 0, Darken, 1, Multiply, 2, Color Burn, 3, Linear Burn, 4, Lighten, 5, Screen, 6, Color Dodge, 7, Linear Dodge(Add), 8, Overlay, 9, Soft Lighten, 10, Hard Light, 11, Vivid Light, 12, Linear Light, 13, Pin Light, 14, Hard Mix, 15, Difference, 16, Exclusion, 17, Subtract, 18, Divide, 19)]_MatcapMaskGlobalMaskBlendType ("Blending", Range(0, 1)) = 2
_MatcapEmissionStrength ("Emission Strength", Range(0, 20)) = 0
_MatcapIntensity ("Intensity", Range(0, 5)) = 1
_MatcapLightMask ("Hide in Shadow", Range(0, 1)) = 0
_MatcapReplace ("Replace Blend", Range(0, 1)) = 1
_MatcapMultiply ("Multiply Blend", Range(0, 1)) = 0
_MatcapAdd ("Add Blend", Range(0, 1)) = 0
_MatcapMixed ("Mixed Blend", Range(0, 1)) = 0
_MatcapScreen ("Screen Blend", Range(0, 1)) = 0
_MatcapAddToLight ("Add To Light", Range(0, 1)) = 0
_MatcapAlphaOverride ("Override Alpha", Range(0, 1)) = 0
[Enum(Vertex, 0, Pixel, 1)] _MatcapNormal ("Normal to use", Int) = 1
[ThryToggle(POI_MATCAP0_CUSTOM_NORMAL, true)] _Matcap0CustomNormal ("<size=13><b>  Custom Normal</b></size>", Float) = 0
[Normal]_Matcap0NormalMap ("Normal Map--{reference_properties:[_Matcap0NormalMapPan, _Matcap0NormalMapUV, _Matcap0NormalMapScale], condition_showS:(_Matcap0CustomNormal==1)}", 2D) = "bump" { }
[HideInInspector][Vector2]_Matcap0NormalMapPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap0NormalMapUV ("UV", Int) = 0
[HideInInspector]_Matcap0NormalMapScale ("Intensity", Range(0, 10)) = 1
[ThryToggleUI(true)] _MatcapHueShiftEnabled ("<size=13><b>  Hue Shift</b></size>", Float) = 0
_MatcapHueShiftSpeed ("Shift Speed--{condition_showS:(_MatcapHueShiftEnabled==1)}", Float) = 0
_MatcapHueShift ("Hue Shift--{condition_showS:(_MatcapHueShiftEnabled==1)}", Range(0, 1)) = 0
[ThryToggleUI(true)] _MatcapSmoothnessEnabled ("<size=13><b>  Blur</b></size>", Float) = 0
_MatcapSmoothness ("Smoothness--{condition_showS:(_MatcapSmoothnessEnabled==1)}", Range(0, 1)) = 1
[ToggleUI]_MatcapMaskSmoothnessApply ("Apply Mask for Smoothness--{condition_showS:(_MatcapSmoothnessEnabled==1)}", Float) = 0
[Enum(R, 0, G, 1, B, 2, A, 3)]_MatcapMaskSmoothnessChannel ("Mask Channel for Smoothness--{condition_showS:(_MatcapSmoothnessEnabled==1)}", Int) = 3
[HideInInspector] g_start_MatcapTPSMaskGroup ("--{condition_showS:(_TPSPenetratorEnabled==1)}", Float) = 0
[ThryToggleUI(true)] _MatcapTPSDepthEnabled ("<size=13><b>  TPS Depth Mask Enabled</b></size>", Float) = 0
_MatcapTPSMaskStrength ("TPS Mask Strength--{condition_showS:(_MatcapTPSDepthEnabled==1)}", Range(0, 1)) = 1
[HideInInspector] g_end_MatcapTPSMaskGroup ("", Float) = 0
[HideInInspector] m_end_matcap ("Matcap--{condition_showS:(_MatcapHueShiftEnabled==1)}", Float) = 0
//endex

// Second Matcap
//ifex _Matcap2Enable==0
[HideInInspector] m_start_Matcap2 ("Matcap 1--{reference_property:_Matcap2Enable,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/matcap},hover:Documentation}}", Float) = 0
[HideInInspector][ThryToggle(COLOR_GRADING_HDR_3D)]_Matcap2Enable ("Enable Matcap 2", Float) = 0
[ThryWideEnum(UTS Style, 0, Top Pinch, 1, Double Sided, 2)] _Matcap2UVMode ("UV Mode", Int) = 1
_Matcap2Color ("Color--{reference_property:_Matcap2ColorThemeIndex}", Color) = (1, 1, 1, 1)
_Matcap2BaseColorMix ("Base Color Mix", Range(0, 1)) = 0
[HideInInspector][ThryWideEnum(Off, 0, Theme Color 0, 1, Theme Color 1, 2, Theme Color 2, 3, Theme Color 3, 4, ColorChord 0, 5, ColorChord 1, 6, ColorChord 2, 7, ColorChord 3, 8, AL Theme 0, 9, AL Theme 1, 10, AL Theme 2, 11, AL Theme 3, 12)] _Matcap2ColorThemeIndex ("", Int) = 0
[sRGBWarning(true)]_Matcap2 ("Matcap--{reference_properties:[_Matcap2UVToBlend,_MatCap2ndBlendUV1]}", 2D) = "white" { }
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap2UVToBlend ("UV To Blend", Int) = 1
[HideInInspector][VectorToSliders(Blend UV X, 0.0, 1.0, Blend UV Y, 0.0, 1.0)]_MatCap2ndBlendUV1 ("UV Blend", Vector) = (0, 0, 0, 0)
_Matcap2Border ("Border", Range(0, 5)) = 0.43
_Matcap2Rotation ("Rotation", Range(-1, 1)) = 0
[sRGBWarning][ThryRGBAPacker(R Mask, G Nothing, B Nothing, A Smoothness)]_Matcap2Mask ("Mask--{reference_properties:[_Matcap2MaskPan, _Matcap2MaskUV, _Matcap2MaskChannel, _Matcap2MaskInvert]}", 2D) = "white" { }
[HideInInspector][Vector2]_Matcap2MaskPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap2MaskUV ("UV", Int) = 0
[HideInInspector][Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap2MaskChannel ("Channel", Float) = 0
[HideInInspector][ToggleUI]_Matcap2MaskInvert ("Invert", Float) = 0
[ThryWideEnum(Off, 0, 1R, 1, 1G, 2, 1B, 3, 1A, 4, 2R, 5, 2G, 6, 2B, 7, 2A, 8, 3R, 9, 3G, 10, 3B, 11, 3A, 12, 4R, 13, 4G, 14, 4B, 15, 4A, 16)] _Matcap2MaskGlobalMask ("Global Mask--{reference_property:_Matcap2MaskGlobalMaskBlendType}", Int) = 0
[HideInInspector][ThryWideEnum(Replace, 0, Darken, 1, Multiply, 2, Color Burn, 3, Linear Burn, 4, Lighten, 5, Screen, 6, Color Dodge, 7, Linear Dodge(Add), 8, Overlay, 9, Soft Lighten, 10, Hard Light, 11, Vivid Light, 12, Linear Light, 13, Pin Light, 14, Hard Mix, 15, Difference, 16, Exclusion, 17, Subtract, 18, Divide, 19)]_Matcap2MaskGlobalMaskBlendType ("Blending", Range(0, 1)) = 2
_Matcap2EmissionStrength ("Emission Strength", Range(0, 20)) = 0
_Matcap2Intensity ("Intensity", Range(0, 5)) = 1
_Matcap2LightMask ("Hide in Shadow", Range(0, 1)) = 0
_Matcap2Replace ("Replace Blend", Range(0, 1)) = 0
_Matcap2Multiply ("Multiply Blend", Range(0, 1)) = 0
_Matcap2Add ("Add Blend", Range(0, 1)) = 0
_Matcap2Mixed ("Mixed Blend", Range(0, 1)) = 0
_Matcap2Screen ("Screen Blend", Range(0, 1)) = 0
_Matcap2AddToLight ("Add To Light", Range(0, 1)) = 0
_Matcap2AlphaOverride ("Override Alpha", Range(0, 1)) = 0
[Enum(Vertex, 0, Pixel, 1)] _Matcap2Normal ("Normal to use", Int) = 1
[ThryToggle(POI_MATCAP1_CUSTOM_NORMAL, true)] _Matcap1CustomNormal ("<size=13><b>  Custom Normal</b></size>", Float) = 0
[ThryToggle()]_Matcap1CustomNormal ("Custom Normal", Float) = 0
[Normal]_Matcap1NormalMap ("Normal Map--{reference_properties:[_Matcap1NormalMapPan, _Matcap1NormalMapUV, _Matcap1NormalMapScale], condition_showS:(_Matcap1CustomNormal==1)}", 2D) = "bump" { }
[HideInInspector][Vector2]_Matcap1NormalMapPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap1NormalMapUV ("UV", Int) = 0
[HideInInspector]_Matcap1NormalMapScale ("Intensity", Range(0, 10)) = 1
[ThryToggleUI(true)] _Matcap2HueShiftEnabled ("<size=13><b>  Hue Shift</b></size>", Float) = 0
_Matcap2HueShiftSpeed ("Shift Speed--{condition_showS:(_Matcap2HueShiftEnabled==1)}", Float) = 0
_Matcap2HueShift ("Hue Shift--{condition_showS:(_Matcap2HueShiftEnabled==1)}", Range(0, 1)) = 0
[ThryToggleUI(true)] _Matcap2SmoothnessEnabled ("<size=13><b>  Blur</b></size>", Float) = 0
_Matcap2Smoothness ("Smoothness--{condition_showS:(_Matcap2SmoothnessEnabled==1)}", Range(0, 1)) = 1
[ToggleUI]_Matcap2MaskSmoothnessApply ("Apply Mask for Smoothness--{condition_showS:(_Matcap2SmoothnessEnabled==1)}", Float) = 0
[Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap2MaskSmoothnessChannel ("Mask Channel for Smoothness--{condition_showS:(_Matcap2SmoothnessEnabled==1)}", Int) = 3
[HideInInspector] g_start_Matcap2TPSMaskGroup ("--{condition_showS:(_TPSPenetratorEnabled==1)}", Float) = 0
[ThryToggleUI(true)] _Matcap2TPSDepthEnabled ("<size=13><b>  TPS Depth Mask Enabled</b></size>", Float) = 0
_Matcap2TPSMaskStrength ("TPS Mask Strength--{condition_showS:(_Matcap2TPSDepthEnabled==1)}", Range(0, 1)) = 1
[HideInInspector] g_end_Matcap2TPSMaskGroup ("", Float) = 0
[HideInInspector] m_end_Matcap2 ("Matcap 1--{condition_showS:(_Matcap2HueShiftEnabled==1)}", Float) = 0
//endex

// Third Matcap
//ifex _Matcap3Enable==0
[HideInInspector] m_start_Matcap3 ("Matcap 2--{reference_property:_Matcap3Enable,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/matcap},hover:Documentation}}", Float) = 0
[HideInInspector][ThryToggle(POI_MATCAP2)]_Matcap3Enable ("Enable Matcap 2", Float) = 0
[ThryWideEnum(UTS Style, 0, Top Pinch, 1, Double Sided, 2)] _Matcap3UVMode ("UV Mode", Int) = 1
_Matcap3Color ("Color--{reference_property:_Matcap3ColorThemeIndex}", Color) = (1, 1, 1, 1)
_Matcap3BaseColorMix ("Base Color Mix", Range(0, 1)) = 0
[HideInInspector][ThryWideEnum(Off, 0, Theme Color 0, 1, Theme Color 1, 2, Theme Color 2, 3, Theme Color 3, 4, ColorChord 0, 5, ColorChord 1, 6, ColorChord 2, 7, ColorChord 3, 8, AL Theme 0, 9, AL Theme 1, 10, AL Theme 2, 11, AL Theme 3, 12)] _Matcap3ColorThemeIndex ("", Int) = 0
[sRGBWarning(true)]_Matcap3 ("Matcap--{reference_properties:[_Matcap3UVToBlend, _MatCap3rdBlendUV1]}", 2D) = "white" { }
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap3UVToBlend ("UV To Blend", Int) = 1
[HideInInspector][VectorToSliders(Blend UV X, 0.0, 1.0, Blend UV Y, 0.0, 1.0)]_MatCap3rdBlendUV1 ("UV Blend", Vector) = (0, 0, 0, 0)
_Matcap3Border ("Border", Range(0, 5)) = 0.43
_Matcap3Rotation ("Rotation", Range(-1, 1)) = 0
[sRGBWarning][ThryRGBAPacker(R Mask, G Nothing, B Nothing, A Smoothness)]_Matcap3Mask ("Mask--{reference_properties:[_Matcap3MaskPan, _Matcap3MaskUV, _Matcap3MaskChannel, _Matcap3MaskInvert]}", 2D) = "white" { }
[HideInInspector][Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap3MaskChannel ("Channel", Float) = 0
[HideInInspector][Vector2]_Matcap3MaskPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap3MaskUV ("UV", Int) = 0
[HideInInspector][ToggleUI]_Matcap3MaskInvert ("Invert", Float) = 0
[ThryWideEnum(Off, 0, 1R, 1, 1G, 2, 1B, 3, 1A, 4, 2R, 5, 2G, 6, 2B, 7, 2A, 8, 3R, 9, 3G, 10, 3B, 11, 3A, 12, 4R, 13, 4G, 14, 4B, 15, 4A, 16)] _Matcap3MaskGlobalMask ("Global Mask--{reference_property:_Matcap3MaskGlobalMaskBlendType}", Int) = 0
[HideInInspector][ThryWideEnum(Replace, 0, Darken, 1, Multiply, 2, Color Burn, 3, Linear Burn, 4, Lighten, 5, Screen, 6, Color Dodge, 7, Linear Dodge(Add), 8, Overlay, 9, Soft Lighten, 10, Hard Light, 11, Vivid Light, 12, Linear Light, 13, Pin Light, 14, Hard Mix, 15, Difference, 16, Exclusion, 17, Subtract, 18, Divide, 19)]_Matcap3MaskGlobalMaskBlendType ("Blending", Range(0, 1)) = 2
_Matcap3EmissionStrength ("Emission Strength", Range(0, 20)) = 0
_Matcap3Intensity ("Intensity", Range(0, 5)) = 1
_Matcap3LightMask ("Hide in Shadow", Range(0, 1)) = 0
_Matcap3Replace ("Replace Blend", Range(0, 1)) = 0
_Matcap3Multiply ("Multiply Blend", Range(0, 1)) = 0
_Matcap3Add ("Add Blend", Range(0, 1)) = 0
_Matcap3Screen ("Screen Blend", Range(0, 1)) = 0
_Matcap3AddToLight ("Add To Light", Range(0, 1)) = 0
_Matcap3AlphaOverride ("Override Alpha", Range(0, 1)) = 0
[Enum(Vertex, 0, Pixel, 1)] _Matcap3Normal ("Normal to use", Int) = 1
[ThryToggle(POI_MATCAP2_CUSTOM_NORMAL, true)] _Matcap2CustomNormal ("<size=13><b>  Custom Normal</b></size>", Float) = 0
[ThryToggle()]_Matcap2CustomNormal ("Custom Normal", Float) = 0
[Normal]_Matcap2NormalMap ("Normal Map--{reference_properties:[_Matcap2NormalMapPan, _Matcap2NormalMapUV, _Matcap2NormalMapScale], condition_showS:(_Matcap2CustomNormal==1)}", 2D) = "bump" { }
[HideInInspector][Vector2]_Matcap2NormalMapPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap2NormalMapUV ("UV", Int) = 0
[HideInInspector]_Matcap2NormalMapScale ("Intensity", Range(0, 10)) = 1
[ThryToggleUI(true)] _Matcap3HueShiftEnabled ("<size=13><b>  Hue Shift</b></size>", Float) = 0
_Matcap3HueShiftSpeed ("Shift Speed--{condition_showS:(_Matcap3HueShiftEnabled==1)}", Float) = 0
_Matcap3HueShift ("Hue Shift--{condition_showS:(_Matcap3HueShiftEnabled==1)}", Range(0, 1)) = 0
[ThryToggleUI(true)] _Matcap3SmoothnessEnabled ("<size=13><b>  Blur</b></size>", Float) = 0
_Matcap3Smoothness ("Smoothness--{condition_showS:(_Matcap3SmoothnessEnabled==1)}", Range(0, 1)) = 1
[ToggleUI]_Matcap3MaskSmoothnessApply ("Apply Mask for Smoothness--{condition_showS:(_Matcap3SmoothnessEnabled==1)}", Float) = 0
[Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap3MaskSmoothnessChannel ("Mask Channel for Smoothness--{condition_showS:(_Matcap3SmoothnessEnabled==1)}", Int) = 3
[HideInInspector] g_start_Matcap3TPSMaskGroup ("--{condition_showS:(_TPSPenetratorEnabled==1)}", Float) = 0
[ThryToggleUI(true)] _Matcap3TPSDepthEnabled ("<size=13><b>  TPS Depth Mask Enabled</b></size>", Float) = 0
_Matcap3TPSMaskStrength ("TPS Mask Strength--{condition_showS:(_Matcap3TPSDepthEnabled==1)}", Range(0, 1)) = 1
[HideInInspector] g_end_Matcap3TPSMaskGroup ("", Float) = 0
[HideInInspector] m_end_Matcap3 ("Matcap 2--{condition_showS:(_Matcap3HueShiftEnabled==1)}", Float) = 0
//endex

// Fourth Matcap
//ifex _Matcap4Enable==0
[HideInInspector] m_start_Matcap4 ("Matcap 3--{reference_property:_Matcap4Enable,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/matcap},hover:Documentation}}", Float) = 0
[HideInInspector][ThryToggle(POI_MATCAP3)]_Matcap4Enable ("Enable Matcap 3", Float) = 0
[ThryWideEnum(UTS Style, 0, Top Pinch, 1, Double Sided, 2)] _Matcap4UVMode ("UV Mode", Int) = 1
_Matcap4Color ("Color--{reference_property:_Matcap4ColorThemeIndex}", Color) = (1, 1, 1, 1)
_Matcap4BaseColorMix ("Base Color Mix", Range(0, 1)) = 0
[HideInInspector][ThryWideEnum(Off, 0, Theme Color 0, 1, Theme Color 1, 2, Theme Color 2, 3, Theme Color 3, 4, ColorChord 0, 5, ColorChord 1, 6, ColorChord 2, 7, ColorChord 3, 8, AL Theme 0, 9, AL Theme 1, 10, AL Theme 2, 11, AL Theme 3, 12)] _Matcap4ColorThemeIndex ("", Int) = 0
[sRGBWarning(true)]_Matcap4 ("Matcap--{reference_properties:[_Matcap4UVToBlend,_MatCap4thBlendUV1]}", 2D) = "white" { }
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap4UVToBlend ("UV To Blend", Int) = 1
[HideInInspector][VectorToSliders(Blend UV X, 0.0, 1.0, Blend UV Y, 0.0, 1.0)]_MatCap4thBlendUV1 ("UV Blend", Vector) = (0, 0, 0, 0)
_Matcap4Border ("Border", Range(0, .5)) = 0.43
_Matcap4Rotation ("Rotation", Range(-1, 1)) = 0
[sRGBWarning][ThryRGBAPacker(R Mask, G Nothing, B Nothing, A Smoothness)]_Matcap4Mask ("Mask--{reference_properties:[_Matcap4MaskPan, _Matcap4MaskUV, _Matcap4MaskChannel, _Matcap4MaskInvert]}", 2D) = "white" { }
[HideInInspector][Vector2]_Matcap4MaskPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap4MaskUV ("UV", Int) = 0
[HideInInspector][Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap4MaskChannel ("Channel", Float) = 0
[HideInInspector][ToggleUI]_Matcap4MaskInvert ("Invert", Float) = 0
[ThryWideEnum(Off, 0, 1R, 1, 1G, 2, 1B, 3, 1A, 4, 2R, 5, 2G, 6, 2B, 7, 2A, 8, 3R, 9, 3G, 10, 3B, 11, 3A, 12, 4R, 13, 4G, 14, 4B, 15, 4A, 16)] _Matcap4MaskGlobalMask ("Global Mask--{reference_property:_Matcap4MaskGlobalMaskBlendType}", Int) = 0
[HideInInspector][ThryWideEnum(Replace, 0, Darken, 1, Multiply, 2, Color Burn, 3, Linear Burn, 4, Lighten, 5, Screen, 6, Color Dodge, 7, Linear Dodge(Add), 8, Overlay, 9, Soft Lighten, 10, Hard Light, 11, Vivid Light, 12, Linear Light, 13, Pin Light, 14, Hard Mix, 15, Difference, 16, Exclusion, 17, Subtract, 18, Divide, 19)]_Matcap4MaskGlobalMaskBlendType ("Blending", Range(0, 1)) = 2
_Matcap4EmissionStrength ("Emission Strength", Range(0, 20)) = 0
_Matcap4Intensity ("Intensity", Range(0, 5)) = 1
_Matcap4LightMask ("Hide in Shadow", Range(0, 1)) = 0
_Matcap4Replace ("Replace Blend", Range(0, 1)) = 0
_Matcap4Multiply ("Multiply Blend", Range(0, 1)) = 0
_Matcap4Add ("Add Blend", Range(0, 1)) = 0
_Matcap4Screen ("Screen Blend", Range(0, 1)) = 0
_Matcap4AddToLight ("Add To Light", Range(0, 1)) = 0
_Matcap4AlphaOverride ("Override Alpha", Range(0, 1)) = 0
[Enum(Vertex, 0, Pixel, 1)] _Matcap4Normal ("Normal to use", Int) = 1
[ThryToggle(POI_MATCAP3_CUSTOM_NORMAL, true)] _Matcap3CustomNormal ("<size=13><b>  Custom Normal</b></size>", Float) = 0
[ThryToggle()]_Matcap3CustomNormal ("Custom Normal", Float) = 0
[Normal]_Matcap3NormalMap ("Normal Map--{reference_properties:[_Matcap3NormalMapPan, _Matcap3NormalMapUV, _Matcap3NormalMapScale], condition_showS:(_Matcap3CustomNormal==1)}", 2D) = "bump" { }
[HideInInspector][Vector2]_Matcap3NormalMapPan ("Panning", Vector) = (0, 0, 0, 0)
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _Matcap3NormalMapUV ("UV", Int) = 0
[HideInInspector]_Matcap3NormalMapScale ("Intensity", Range(0, 10)) = 1
[ThryToggleUI(true)] _Matcap4HueShiftEnabled ("<size=13><b>  Hue Shift</b></size>", Float) = 0
_Matcap4HueShiftSpeed ("Shift Speed--{condition_showS:(_Matcap4HueShiftEnabled==1)}", Float) = 0
_Matcap4HueShift ("Hue Shift--{condition_showS:(_Matcap4HueShiftEnabled==1)}", Range(0, 1)) = 0
[ThryToggleUI(true)] _Matcap4SmoothnessEnabled ("<size=13><b>  Blur</b></size>", Float) = 0
_Matcap4Smoothness ("Smoothness--{condition_showS:(_Matcap4SmoothnessEnabled==1)}", Range(0, 1)) = 1
[ToggleUI]_Matcap4MaskSmoothnessApply ("Apply Mask for Smoothness--{condition_showS:(_Matcap4SmoothnessEnabled==1)}", Float) = 0
[Enum(R, 0, G, 1, B, 2, A, 3)]_Matcap4MaskSmoothnessChannel ("Mask Channel for Smoothness--{condition_showS:(_Matcap4SmoothnessEnabled==1)}", Int) = 3
[HideInInspector] g_start_Matcap4TPSMaskGroup ("--{condition_showS:(_TPSPenetratorEnabled==1)}", Float) = 0
[ThryToggleUI(true)] _Matcap4TPSDepthEnabled ("<size=13><b>  TPS Depth Mask Enabled</b></size>", Float) = 0
_Matcap4TPSMaskStrength ("TPS Mask Strength--{condition_showS:(_Matcap4TPSDepthEnabled==1)}", Range(0, 1)) = 1
[HideInInspector] g_end_Matcap4TPSMaskGroup ("", Float) = 0
[HideInInspector] m_end_Matcap4 ("Matcap 3--{condition_showS:(_Matcap4HueShiftEnabled==1)}", Float) = 0
//endex

#T#PoiMatcapKeywords
//ifex _MatcapEnable==0
#pragma shader_feature_local POI_MATCAP0
#pragma shader_feature_local POI_MATCAP0_CUSTOM_NORMAL
//endex
//ifex _Matcap2Enable==0
#pragma shader_feature COLOR_GRADING_HDR_3D
#pragma shader_feature_local POI_MATCAP1_CUSTOM_NORMAL
//endex
//ifex _Matcap3Enable==0
#pragma shader_feature_local POI_MATCAP2
#pragma shader_feature_local POI_MATCAP2_CUSTOM_NORMAL
//endex
//ifex _Matcap4Enable==0
#pragma shader_feature_local POI_MATCAP3
#pragma shader_feature_local POI_MATCAP3_CUSTOM_NORMAL
//endex

#T#PoiMatcapVariables
//ifex _MatcapEnable==0
#ifdef POI_MATCAP0
	#if defined(PROP_MATCAP) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap;
		float4 _Matcap_ST;
		float4 _Matcap_TexelSize;
		float2 _MatcapPan;
		float _MatcapUV;
	#endif
	#if defined(PROP_MATCAPMASK) || !defined(OPTIMIZER_ENABLED)
		Texture2D _MatcapMask;
		float4 _MatcapMask_ST;
		float2 _MatcapMaskPan;
		float _MatcapMaskUV;
		float _MatcapMaskChannel;
	#endif
	#ifdef POI_MATCAP0_CUSTOM_NORMAL
		#if defined(PROP_MATCAP0NORMALMAP) || !defined(OPTIMIZER_ENABLED)
			Texture2D _Matcap0NormalMap;
		#endif
		float4 _Matcap0NormalMap_ST;
		float2 _Matcap0NormalMapPan;
		float _Matcap0NormalMapUV;
		float _Matcap0NormalMapScale;
	#endif
	float _MatcapUVToBlend;
	float4 _MatCapBlendUV1;
	float _MatcapUVMode;
	float _MatcapMaskInvert;
	float _MatcapMaskGlobalMask;
	float _MatcapMaskGlobalMaskBlendType;
	float _MatcapBorder;
	float _MatcapRotation;
	float _MatcapSmoothnessEnabled;
	float _MatcapSmoothness;
	float _MatcapMaskSmoothnessChannel;
	float _MatcapMaskSmoothnessApply;
	float4 _MatcapColor;
	float _MatcapBaseColorMix;
	float _MatcapColorThemeIndex;
	float _MatcapIntensity;
	float _MatcapReplace;
	float _MatcapMultiply;
	float _MatcapAdd;
	float _MatcapAddToLight;
	float _MatcapMixed;
	float _MatcapScreen;
	float _MatcapAlphaOverride;
	float _MatcapEnable;
	float _MatcapLightMask;
	float _MatcapEmissionStrength;
	float _MatcapNormal;
	float _MatcapHueShiftEnabled;
	float _MatcapHueShiftSpeed;
	float _MatcapHueShift;
	float _MatcapTPSDepthEnabled;
	float _MatcapTPSMaskStrength;
#endif
//endex
//ifex _Matcap2Enable==0
#ifdef COLOR_GRADING_HDR_3D
	#if defined(PROP_MATCAP2) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap2;
		float4 _Matcap2_ST;
		float4 _Matcap2_TexelSize;
		float2 _Matcap2Pan;
		float _Matcap2UV;
	#endif
	#if defined(PROP_MATCAP2MASK) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap2Mask;
		float4 _Matcap2Mask_ST;
		float2 _Matcap2MaskPan;
		float _Matcap2MaskUV;
		float _Matcap2MaskChannel;
	#endif
	#ifdef POI_MATCAP1_CUSTOM_NORMAL
		#if defined(PROP_MATCAP1NORMALMAP) || !defined(OPTIMIZER_ENABLED)
			Texture2D _Matcap1NormalMap;
		#endif
		float4 _Matcap1NormalMap_ST;
		float2 _Matcap1NormalMapPan;
		float _Matcap1NormalMapUV;
		float _Matcap1NormalMapScale;
	#endif
	float _Matcap2UVToBlend;
	float4 _MatCap2ndBlendUV1;
	float _Matcap2UVMode;
	float _Matcap2MaskInvert;
	float _Matcap2MaskGlobalMask;
	float _Matcap2MaskGlobalMaskBlendType;
	float _Matcap2Border;
	float _Matcap2Rotation;
	float _Matcap2SmoothnessEnabled;
	float _Matcap2Smoothness;
	float _Matcap2MaskSmoothnessChannel;
	float _Matcap2MaskSmoothnessApply;
	float4 _Matcap2Color;
	float _Matcap2BaseColorMix;
	float _Matcap2ColorThemeIndex;
	float _Matcap2Intensity;
	float _Matcap2Replace;
	float _Matcap2Multiply;
	float _Matcap2Add;
	float _Matcap2AddToLight;
	float _Matcap2Mixed;
	float _Matcap2Screen;
	float _Matcap2AlphaOverride;
	float _Matcap2Enable;
	float _Matcap2LightMask;
	float _Matcap2EmissionStrength;
	float _Matcap2Normal;
	float _Matcap2HueShiftEnabled;
	float _Matcap2HueShiftSpeed;
	float _Matcap2HueShift;
	float _Matcap2TPSDepthEnabled;
	float _Matcap2TPSMaskStrength;
#endif
//endex

//ifex _Matcap3Enable==0
#ifdef POI_MATCAP2
	#if defined(PROP_MATCAP3) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap3;
		float4 _Matcap3_ST;
		float4 _Matcap3_TexelSize;
		float2 _Matcap3Pan;
		float _Matcap3UV;
	#endif
	#if defined(PROP_MATCAP3MASK) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap3Mask;
		float4 _Matcap3Mask_ST;
		float2 _Matcap3MaskPan;
		float _Matcap3MaskUV;
		float _Matcap3MaskChannel;
	#endif
	#ifdef POI_MATCAP2_CUSTOM_NORMAL
		#if defined(PROP_MATCAP2NORMALMAP) || !defined(OPTIMIZER_ENABLED)
			Texture2D _Matcap2NormalMap;
		#endif
		float4 _Matcap2NormalMap_ST;
		float2 _Matcap2NormalMapPan;
		float _Matcap2NormalMapUV;
		float _Matcap2NormalMapScale;
	#endif
	float _Matcap3UVToBlend;
	float4 _MatCap3rdBlendUV1;
	float _Matcap3UVMode;
	float _Matcap3MaskInvert;
	float _Matcap3MaskGlobalMask;
	float _Matcap3MaskGlobalMaskBlendType;
	float _Matcap3Border;
	float _Matcap3Rotation;
	float _Matcap3SmoothnessEnabled;
	float _Matcap3Smoothness;
	float _Matcap3MaskSmoothnessChannel;
	float _Matcap3MaskSmoothnessApply;
	float4 _Matcap3Color;
	float _Matcap3BaseColorMix;
	float _Matcap3ColorThemeIndex;
	float _Matcap3Intensity;
	float _Matcap3Replace;
	float _Matcap3Multiply;
	float _Matcap3Add;
	float _Matcap3AddToLight;
	float _Matcap3Mixed;
	float _Matcap3Screen;
	float _Matcap3AlphaOverride;
	float _Matcap3Enable;
	float _Matcap3LightMask;
	float _Matcap3EmissionStrength;
	float _Matcap3Normal;
	float _Matcap3HueShiftEnabled;
	float _Matcap3HueShiftSpeed;
	float _Matcap3HueShift;
	float _Matcap3TPSDepthEnabled;
	float _Matcap3TPSMaskStrength;
#endif
//endex

//ifex _Matcap4Enable==0
#ifdef POI_MATCAP3
	#if defined(PROP_MATCAP4) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap4;
		float4 _Matcap4_ST;
		float4 _Matcap4_TexelSize;
		float2 _Matcap4Pan;
		float _Matcap4UV;
	#endif
	#if defined(PROP_MATCAP4MASK) || !defined(OPTIMIZER_ENABLED)
		Texture2D _Matcap4Mask;
		float4 _Matcap4Mask_ST;
		float2 _Matcap4MaskPan;
		float _Matcap4MaskUV;
		float _Matcap4MaskChannel;
	#endif
	#ifdef POI_MATCAP3_CUSTOM_NORMAL
		#if defined(PROP_MATCAP3NORMALMAP) || !defined(OPTIMIZER_ENABLED)
			Texture2D _Matcap3NormalMap;
		#endif
		float4 _Matcap3NormalMap_ST;
		float2 _Matcap3NormalMapPan;
		float _Matcap3NormalMapUV;
		float _Matcap3NormalMapScale;
	#endif
	float _Matcap4UVToBlend;
	float4 _MatCap4thBlendUV1;
	float _Matcap4UVMode;
	float _Matcap4MaskInvert;
	float _Matcap4MaskGlobalMask;
	float _Matcap4MaskGlobalMaskBlendType;
	float _Matcap4Border;
	float _Matcap4Rotation;
	float _Matcap4SmoothnessEnabled;
	float _Matcap4Smoothness;
	float _Matcap4MaskSmoothnessChannel;
	float _Matcap4MaskSmoothnessApply;
	float4 _Matcap4Color;
	float _Matcap4BaseColorMix;
	float _Matcap4ColorThemeIndex;
	float _Matcap4Intensity;
	float _Matcap4Replace;
	float _Matcap4Multiply;
	float _Matcap4Add;
	float _Matcap4AddToLight;
	float _Matcap4Mixed;
	float _Matcap4Screen;
	float _Matcap4AlphaOverride;
	float _Matcap4Enable;
	float _Matcap4LightMask;
	float _Matcap4EmissionStrength;
	float _Matcap4Normal;
	float _Matcap4HueShiftEnabled;
	float _Matcap4HueShiftSpeed;
	float _Matcap4HueShift;
	float _Matcap4TPSDepthEnabled;
	float _Matcap4TPSMaskStrength;
#endif
//endex

#T#PoiMatcapFunctions
//ifex _MatcapEnable==0 && _Matcap2Enable==0 && _Matcap3Enable==0 && _Matcap4Enable==0
void blendMatcap(inout PoiLight poiLight, inout PoiFragData poiFragData, in PoiMods poiMods, float add, float lightAdd, float multiply, float replace, float mixed, float screen, float4 matcapColor, float matcapMask, float emissionStrength, float matcapLightMask, uint globalMaskIndex, float globalMaskBlendType)
{
	if (matcapLightMask)
	{
		matcapMask *= lerp(1, poiLight.rampedLightMap, matcapLightMask);
	}
	if (globalMaskIndex > 0)
	{
		matcapMask = customBlend(matcapMask, poiMods.globalMask[globalMaskIndex - 1], globalMaskBlendType);
	}
	
	poiFragData.baseColor.rgb = lerp(poiFragData.baseColor.rgb, matcapColor.rgb, replace * matcapMask * matcapColor.a * .999999);
	poiFragData.baseColor.rgb *= lerp(1, matcapColor.rgb, multiply * matcapMask * matcapColor.a);
	poiFragData.baseColor.rgb += matcapColor.rgb * add * matcapMask * matcapColor.a;
	poiFragData.baseColor.rgb = lerp(poiFragData.baseColor.rgb, blendScreen(poiFragData.baseColor.rgb, matcapColor.rgb), screen * matcapMask * matcapColor.a);
	poiLight.finalLightAdd += matcapColor.rgb * lightAdd * matcapMask * matcapColor.a;
	poiFragData.baseColor.rgb = lerp(poiFragData.baseColor.rgb, poiFragData.baseColor.rgb + poiFragData.baseColor.rgb * matcapColor.rgb, mixed * matcapMask * matcapColor.a);
	poiFragData.emission += matcapColor.rgb * emissionStrength * matcapMask * matcapColor.a;
}
//endex
//ifex _MatcapEnable==0 && _Matcap2Enable==0 && _Matcap3Enable==0 && _Matcap4Enable==0
#if defined(POI_MATCAP0) || defined(COLOR_GRADING_HDR_3D) || defined(POI_MATCAP2) || defined(POI_MATCAP3)
	void applyMatcap(inout PoiFragData poiFragData, in PoiCam poiCam, in PoiMesh poiMesh, inout PoiLight poiLight, in PoiMods poiMods)
	{
		float4 matcap = 0;
		float matcapMask = 0;
		float4 matcap2 = 0;
		float matcap2Mask = 0;
		float4 matcap3 = 0;
		float matcap3Mask = 0;
		float4 matcap4 = 0;
		float matcap4Mask = 0;
		float2 matcapUV = 0;
		//endex
		
		//ifex _MatcapEnable==0
		// Matcap 1
		#ifdef POI_MATCAP0
			float3 normal0 = poiMesh.normals[_MatcapNormal];
			#ifdef POI_MATCAP0_CUSTOM_NORMAL
				#if defined(PROP_MATCAP0NORMALMAP) || !defined(OPTIMIZER_ENABLED)
					normal0 = calculateNormal(poiMesh.normals[_MatcapNormal], poiMesh, _Matcap0NormalMap, _Matcap0NormalMap_ST, _Matcap0NormalMapPan, _Matcap0NormalMapUV, _Matcap0NormalMapScale);
				#endif
			#endif
			
			switch(_MatcapUVMode)
			{
				// Normal / UTS
				case 0:
					{
						float3 viewNormal = (mul(UNITY_MATRIX_V, float4(normal0, 0))).rgb;
						float3 NormalBlend_MatCapUV_Detail = viewNormal.rgb * float3(-1, -1, 1);
						float3 NormalBlend_MatCapUV_Base = (mul(UNITY_MATRIX_V, float4(poiCam.viewDir, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1);
						float3 noSknewViewNormal = NormalBlend_MatCapUV_Base * dot(NormalBlend_MatCapUV_Base, NormalBlend_MatCapUV_Detail) / NormalBlend_MatCapUV_Base.b - NormalBlend_MatCapUV_Detail;
						
						matcapUV = noSknewViewNormal.rg * _MatcapBorder + 0.5;
						break;
				}
				// Top Pinch
				case 1:
					{
						float3 worldViewUp = normalize(float3(0, 1, 0) - poiCam.viewDir * dot(poiCam.viewDir, float3(0, 1, 0)));
						float3 worldViewRight = normalize(cross(poiCam.viewDir, worldViewUp));
						matcapUV = float2(dot(worldViewRight, normal0), dot(worldViewUp, normal0)) * _MatcapBorder + 0.5;
						break;
				}
				// Custom Double Sided
				case 2:
					{
						float3 reflection = reflect(-poiCam.viewDir, normal0);
						float2 uv = float2(dot(reflection, float3(1, 0, 0)), dot(reflection, float3(0, 1, 0)));
						matcapUV = uv * _MatcapBorder + 0.5;
						break;
				}
			}
			matcapUV = lerp(matcapUV, poiMesh.uv[_MatcapUVToBlend], _MatCapBlendUV1.xy);
			matcapUV = RotateUV(matcapUV, _MatcapRotation * PI, float2(.5, .5), 1.0f);
			
			if (IsInMirror())
			{
				matcapUV.x = 1 - matcapUV.x;
			}
			
			float matcapSmoothness;
			float mipCount0 = 9;
			if (_MatcapSmoothnessEnabled)
			{
				if (_Matcap_TexelSize.z == 8192) mipCount0 = 13;
				if (_Matcap_TexelSize.z == 4096) mipCount0 = 12;
				if (_Matcap_TexelSize.z == 2048) mipCount0 = 11;
				if (_Matcap_TexelSize.z == 1024) mipCount0 = 10;
				if (_Matcap_TexelSize.z == 512) mipCount0 = 9;
				if (_Matcap_TexelSize.z == 256) mipCount0 = 8;
				if (_Matcap_TexelSize.z == 128) mipCount0 = 7;
				if (_Matcap_TexelSize.z == 64) mipCount0 = 6;
				if (_Matcap_TexelSize.z == 32) mipCount0 = 5;
				
				matcapSmoothness = _MatcapSmoothness;
				
				if (_MatcapMaskSmoothnessApply)
				{
					#if defined(PROP_MATCAPMASK) || !defined(OPTIMIZER_ENABLED)
						matcapSmoothness *= POI2D_SAMPLER_PAN(_MatcapMask, _MainTex, poiUV(poiMesh.uv[_MatcapMaskUV], _MatcapMask_ST), _MatcapMaskPan)[_MatcapMaskSmoothnessChannel];
					#endif
				}
				matcapSmoothness = (1 - matcapSmoothness) * mipCount0;
			}
			
			#if defined(PROP_MATCAP) || !defined(OPTIMIZER_ENABLED)
				if (_MatcapSmoothnessEnabled)
				{
					matcap = UNITY_SAMPLE_TEX2D_SAMPLER_LOD(_Matcap, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap), matcapSmoothness) * float4(poiThemeColor(poiMods, _MatcapColor.rgb, _MatcapColorThemeIndex), _MatcapColor.a);
				}
				else
				{
					matcap = UNITY_SAMPLE_TEX2D_SAMPLER(_Matcap, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap)) * float4(poiThemeColor(poiMods, _MatcapColor.rgb, _MatcapColorThemeIndex), _MatcapColor.a);
				}
			#else
				matcap = float4(poiThemeColor(poiMods, _MatcapColor.rgb, _MatcapColorThemeIndex), _MatcapColor.a);
			#endif
			
			matcap.rgb *= _MatcapIntensity;
			matcap.rgb = lerp(matcap.rgb, matcap.rgb * poiFragData.baseColor.rgb, _MatcapBaseColorMix);
			
			#if defined(PROP_MATCAPMASK) || !defined(OPTIMIZER_ENABLED)
				matcapMask = POI2D_SAMPLER_PAN(_MatcapMask, _MainTex, poiUV(poiMesh.uv[_MatcapMaskUV], _MatcapMask_ST), _MatcapMaskPan)[_MatcapMaskChannel];
			#else
				matcapMask = 1;
			#endif
			
			if (_MatcapMaskInvert)
			{
				matcapMask = 1 - matcapMask;
			}
			
			#ifdef TPS_Penetrator
				if (_MatcapTPSDepthEnabled)
				{
					matcapMask = lerp(0, matcapMask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), _MatcapTPSMaskStrength);
				}
			#endif
			
			poiFragData.alpha *= lerp(1, matcap.a, matcapMask * _MatcapAlphaOverride);
			
			//UNITY_BRANCH
			if (_MatcapHueShiftEnabled)
			{
				matcap.rgb = hueShift(matcap.rgb, _MatcapHueShift + _Time.x * _MatcapHueShiftSpeed);
			}
			
			blendMatcap(poiLight, poiFragData, poiMods, _MatcapAdd, _MatcapAddToLight, _MatcapMultiply, _MatcapReplace, _MatcapMixed, _MatcapScreen, matcap, matcapMask, _MatcapEmissionStrength, _MatcapLightMask, _MatcapMaskGlobalMask, _MatcapMaskGlobalMaskBlendType);
		#endif
		//endex
		//ifex _Matcap2Enable==0
		// Matcap 2
		#ifdef COLOR_GRADING_HDR_3D
			
			float3 normal1 = poiMesh.normals[_Matcap2Normal];
			#ifdef POI_MATCAP1_CUSTOM_NORMAL
				#if defined(PROP_MATCAP1NORMALMAP) || !defined(OPTIMIZER_ENABLED)
					normal1 = calculateNormal(poiMesh.normals[_Matcap2Normal], poiMesh, _Matcap1NormalMap, _Matcap1NormalMap_ST, _Matcap1NormalMapPan, _Matcap1NormalMapUV, _Matcap1NormalMapScale);
				#endif
			#endif
			
			matcapUV = 0;
			
			switch(_Matcap2UVMode)
			{
				// Normal / UTS
				case 0:
					{
						float3 viewNormal = (mul(UNITY_MATRIX_V, float4(normal1, 0))).rgb;
						float3 NormalBlend_MatCapUV_Detail = viewNormal.rgb * float3(-1, -1, 1);
						float3 NormalBlend_MatCapUV_Base = (mul(UNITY_MATRIX_V, float4(poiCam.viewDir, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1);
						float3 noSknewViewNormal = NormalBlend_MatCapUV_Base * dot(NormalBlend_MatCapUV_Base, NormalBlend_MatCapUV_Detail) / NormalBlend_MatCapUV_Base.b - NormalBlend_MatCapUV_Detail;
						
						matcapUV = noSknewViewNormal.rg * _Matcap2Border + 0.5;
						break;
				}
				// Top Pinch
				case 1:
					{
						float3 worldViewUp = normalize(float3(0, 1, 0) - poiCam.viewDir * dot(poiCam.viewDir, float3(0, 1, 0)));
						float3 worldViewRight = normalize(cross(poiCam.viewDir, worldViewUp));
						matcapUV = float2(dot(worldViewRight, normal1), dot(worldViewUp, normal1)) * _Matcap2Border + 0.5;
						break;
				}
				// Custom Double Sided
				case 2:
					{
						float3 reflection = reflect(-poiCam.viewDir, normal1);
						float2 uv = float2(dot(reflection, float3(1, 0, 0)), dot(reflection, float3(0, 1, 0)));
						matcapUV = uv * _Matcap2Border + 0.5;
						break;
				}
			}
			matcapUV = lerp(matcapUV, poiMesh.uv[_Matcap2UVToBlend], _MatCap2ndBlendUV1.xy);
			matcapUV = RotateUV(matcapUV, _Matcap2Rotation * PI, float2(.5, .5), 1.0f);
			
			if (IsInMirror())
			{
				matcapUV.x = 1 - matcapUV.x;
			}
			
			float matcap2Smoothness;
			float mipCount2 = 9;
			if (_Matcap2SmoothnessEnabled)
			{
				if (_Matcap2_TexelSize.z == 8192) mipCount2 = 13;
				if (_Matcap2_TexelSize.z == 4096) mipCount2 = 12;
				if (_Matcap2_TexelSize.z == 2048) mipCount2 = 11;
				if (_Matcap2_TexelSize.z == 1024) mipCount2 = 10;
				if (_Matcap2_TexelSize.z == 512) mipCount2 = 9;
				if (_Matcap2_TexelSize.z == 256) mipCount2 = 8;
				if (_Matcap2_TexelSize.z == 128) mipCount2 = 7;
				if (_Matcap2_TexelSize.z == 64) mipCount2 = 6;
				if (_Matcap2_TexelSize.z == 32) mipCount2 = 5;
				
				matcap2Smoothness = _Matcap2Smoothness;
				
				if (_Matcap2MaskSmoothnessApply)
				{
					#if defined(PROP_MATCAP2MASK) || !defined(OPTIMIZER_ENABLED)
						matcap2Smoothness *= POI2D_SAMPLER_PAN(_Matcap2Mask, _MainTex, poiUV(poiMesh.uv[_Matcap2MaskUV], _Matcap2Mask_ST), _Matcap2MaskPan)[_Matcap2MaskSmoothnessChannel];
					#endif
				}
				matcap2Smoothness = (1 - matcap2Smoothness) * mipCount2;
			}
			
			#if defined(PROP_MATCAP2) || !defined(OPTIMIZER_ENABLED)
				if (_Matcap2SmoothnessEnabled)
				{
					matcap2 = UNITY_SAMPLE_TEX2D_SAMPLER_LOD(_Matcap2, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap2), matcap2Smoothness) * float4(poiThemeColor(poiMods, _Matcap2Color.rgb, _Matcap2ColorThemeIndex), _Matcap2Color.a);
				}
				else
				{
					matcap2 = UNITY_SAMPLE_TEX2D_SAMPLER(_Matcap2, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap2)) * float4(poiThemeColor(poiMods, _Matcap2Color.rgb, _Matcap2ColorThemeIndex), _Matcap2Color.a);
				}
			#else
				matcap2 = float4(poiThemeColor(poiMods, _Matcap2Color.rgb, _Matcap2ColorThemeIndex), _Matcap2Color.a);
			#endif
			
			matcap2.rgb *= _Matcap2Intensity;
			matcap2.rgb = lerp(matcap2.rgb, matcap2.rgb * poiFragData.baseColor.rgb, _Matcap2BaseColorMix);
			
			#if defined(PROP_MATCAP2MASK) || !defined(OPTIMIZER_ENABLED)
				matcap2Mask = POI2D_SAMPLER_PAN(_Matcap2Mask, _MainTex, poiUV(poiMesh.uv[_Matcap2MaskUV], _Matcap2Mask_ST), _Matcap2MaskPan)[_Matcap2MaskChannel];
			#else
				matcap2Mask = 1;
			#endif
			if (_Matcap2MaskInvert)
			{
				matcap2Mask = 1 - matcap2Mask;
			}
			
			#ifdef TPS_Penetrator
				if (_Matcap2TPSDepthEnabled)
				{
					matcap2Mask = lerp(0, matcap2Mask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), _Matcap2TPSMaskStrength);
				}
			#endif
			
			poiFragData.alpha *= lerp(1, matcap2.a, matcap2Mask * _Matcap2AlphaOverride);
			
			//UNITY_BRANCH
			if (_Matcap2HueShiftEnabled)
			{
				matcap2.rgb = hueShift(matcap2.rgb, _Matcap2HueShift + _Time.x * _Matcap2HueShiftSpeed);
			}
			
			blendMatcap(poiLight, poiFragData, poiMods, _Matcap2Add, _Matcap2AddToLight, _Matcap2Multiply, _Matcap2Replace, _Matcap2Mixed, _Matcap2Screen, matcap2, matcap2Mask, _Matcap2EmissionStrength, _Matcap2LightMask, _Matcap2MaskGlobalMask, _Matcap2MaskGlobalMaskBlendType);
		#endif
		//endex
		//ifex _Matcap3Enable==0
		// Matcap 3
		#ifdef POI_MATCAP2
			
			float3 normal2 = poiMesh.normals[_Matcap3Normal];
			#ifdef POI_MATCAP2_CUSTOM_NORMAL
				#if defined(PROP_MATCAP2NORMALMAP) || !defined(OPTIMIZER_ENABLED)
					normal2 = calculateNormal(poiMesh.normals[_Matcap3Normal], poiMesh, _Matcap2NormalMap, _Matcap2NormalMap_ST, _Matcap2NormalMapPan, _Matcap2NormalMapUV, _Matcap2NormalMapScale);
				#endif
			#endif
			
			matcapUV = 0;
			
			switch(_Matcap3UVMode)
			{
				// Normal / UTS
				case 0:
					{
						float3 viewNormal = (mul(UNITY_MATRIX_V, float4(normal2, 0))).rgb;
						float3 NormalBlend_MatCapUV_Detail = viewNormal.rgb * float3(-1, -1, 1);
						float3 NormalBlend_MatCapUV_Base = (mul(UNITY_MATRIX_V, float4(poiCam.viewDir, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1);
						float3 noSknewViewNormal = NormalBlend_MatCapUV_Base * dot(NormalBlend_MatCapUV_Base, NormalBlend_MatCapUV_Detail) / NormalBlend_MatCapUV_Base.b - NormalBlend_MatCapUV_Detail;
						
						matcapUV = noSknewViewNormal.rg * _Matcap3Border + 0.5;
						break;
				}
				// Top Pinch
				case 1:
					{
						float3 worldViewUp = normalize(float3(0, 1, 0) - poiCam.viewDir * dot(poiCam.viewDir, float3(0, 1, 0)));
						float3 worldViewRight = normalize(cross(poiCam.viewDir, worldViewUp));
						matcapUV = float2(dot(worldViewRight, normal2), dot(worldViewUp, normal2)) * _Matcap3Border + 0.5;
						break;
				}
				// Custom Double Sided
				case 2:
					{
						float3 reflection = reflect(-poiCam.viewDir, normal2);
						float2 uv = float2(dot(reflection, float3(1, 0, 0)), dot(reflection, float3(0, 1, 0)));
						matcapUV = uv * _Matcap3Border + 0.5;
						break;
				}
			}
			matcapUV = lerp(matcapUV, poiMesh.uv[_Matcap3UVToBlend], _MatCap3rdBlendUV1.xy);
			matcapUV = RotateUV(matcapUV, _Matcap3Rotation * PI, float2(.5, .5), 1.0f);
			
			if (IsInMirror())
			{
				matcapUV.x = 1 - matcapUV.x;
			}
			
			float matcap3Smoothness;
			float mipCount3 = 9;
			if (_Matcap3SmoothnessEnabled)
			{
				if (_Matcap3_TexelSize.z == 8192) mipCount3 = 13;
				if (_Matcap3_TexelSize.z == 4096) mipCount3 = 12;
				if (_Matcap3_TexelSize.z == 2048) mipCount3 = 11;
				if (_Matcap3_TexelSize.z == 1024) mipCount3 = 10;
				if (_Matcap3_TexelSize.z == 512) mipCount3 = 9;
				if (_Matcap3_TexelSize.z == 256) mipCount3 = 8;
				if (_Matcap3_TexelSize.z == 128) mipCount3 = 7;
				if (_Matcap3_TexelSize.z == 64) mipCount3 = 6;
				if (_Matcap3_TexelSize.z == 32) mipCount3 = 5;
				
				matcap3Smoothness = _Matcap3Smoothness;
				
				if (_Matcap3MaskSmoothnessApply)
				{
					#if defined(PROP_MATCAP3MASK) || !defined(OPTIMIZER_ENABLED)
						matcap3Smoothness *= POI2D_SAMPLER_PAN(_Matcap3Mask, _MainTex, poiUV(poiMesh.uv[_Matcap3MaskUV], _Matcap3Mask_ST), _Matcap3MaskPan)[_Matcap3MaskSmoothnessChannel];
					#endif
				}
				matcap3Smoothness = (1 - matcap3Smoothness) * mipCount3;
			}
			
			#if defined(PROP_MATCAP3) || !defined(OPTIMIZER_ENABLED)
				if (_Matcap3SmoothnessEnabled)
				{
					matcap3 = UNITY_SAMPLE_TEX2D_SAMPLER_LOD(_Matcap3, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap3), matcap3Smoothness) * float4(poiThemeColor(poiMods, _Matcap3Color.rgb, _Matcap3ColorThemeIndex), _Matcap3Color.a);
				}
				else
				{
					matcap3 = UNITY_SAMPLE_TEX2D_SAMPLER(_Matcap3, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap3)) * float4(poiThemeColor(poiMods, _Matcap3Color.rgb, _Matcap3ColorThemeIndex), _Matcap3Color.a);
				}
			#else
				matcap3 = float4(poiThemeColor(poiMods, _Matcap3Color.rgb, _Matcap3ColorThemeIndex), _Matcap3Color.a);
			#endif
			
			matcap3.rgb *= _Matcap3Intensity;
			matcap3.rgb = lerp(matcap3.rgb, matcap3.rgb * poiFragData.baseColor.rgb, _Matcap3BaseColorMix);
			
			#if defined(PROP_MATCAP3MASK) || !defined(OPTIMIZER_ENABLED)
				matcap3Mask = POI2D_SAMPLER_PAN(_Matcap3Mask, _MainTex, poiUV(poiMesh.uv[_Matcap3MaskUV], _Matcap3Mask_ST), _Matcap3MaskPan)[_Matcap3MaskChannel];
			#else
				matcap3Mask = 1;
			#endif
			if (_Matcap3MaskInvert)
			{
				matcap3Mask = 1 - matcap3Mask;
			}
			
			#ifdef TPS_Penetrator
				if (_Matcap3TPSDepthEnabled)
				{
					matcap3Mask = lerp(0, matcap3Mask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), _Matcap3TPSMaskStrength);
				}
			#endif
			
			poiFragData.alpha *= lerp(1, matcap3.a, matcap3Mask * _Matcap3AlphaOverride);
			
			//UNITY_BRANCH
			if (_Matcap3HueShiftEnabled)
			{
				matcap3.rgb = hueShift(matcap3.rgb, _Matcap3HueShift + _Time.x * _Matcap3HueShiftSpeed);
			}
			
			blendMatcap(poiLight, poiFragData, poiMods, _Matcap3Add, _Matcap3AddToLight, _Matcap3Multiply, _Matcap3Replace, _Matcap3Mixed, _Matcap3Screen, matcap3, matcap3Mask, _Matcap3EmissionStrength, _Matcap3LightMask, _Matcap3MaskGlobalMask, _Matcap3MaskGlobalMaskBlendType);
		#endif
		//endex
		//ifex _Matcap4Enable==0
		// Matcap 4
		#ifdef POI_MATCAP3
			
			float3 normal3 = poiMesh.normals[_Matcap4Normal];
			#ifdef POI_MATCAP3_CUSTOM_NORMAL
				#if defined(PROP_MATCAP3NORMALMAP) || !defined(OPTIMIZER_ENABLED)
					normal3 = calculateNormal(poiMesh.normals[_Matcap4Normal], poiMesh, _Matcap3NormalMap, _Matcap3NormalMap_ST, _Matcap3NormalMapPan, _Matcap3NormalMapUV, _Matcap3NormalMapScale);
				#endif
			#endif
			
			matcapUV = 0;
			
			switch(_Matcap4UVMode)
			{
				// Normal / UTS
				case 0:
					{
						float3 viewNormal = (mul(UNITY_MATRIX_V, float4(normal3, 0))).rgb;
						float3 NormalBlend_MatCapUV_Detail = viewNormal.rgb * float3(-1, -1, 1);
						float3 NormalBlend_MatCapUV_Base = (mul(UNITY_MATRIX_V, float4(poiCam.viewDir, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1);
						float3 noSknewViewNormal = NormalBlend_MatCapUV_Base * dot(NormalBlend_MatCapUV_Base, NormalBlend_MatCapUV_Detail) / NormalBlend_MatCapUV_Base.b - NormalBlend_MatCapUV_Detail;
						
						matcapUV = noSknewViewNormal.rg * _Matcap4Border + 0.5;
						break;
				}
				// Top Pinch
				case 1:
					{
						float3 worldViewUp = normalize(float3(0, 1, 0) - poiCam.viewDir * dot(poiCam.viewDir, float3(0, 1, 0)));
						float3 worldViewRight = normalize(cross(poiCam.viewDir, worldViewUp));
						matcapUV = float2(dot(worldViewRight, normal3), dot(worldViewUp, normal3)) * _Matcap4Border + 0.5;
						break;
				}
				// Custom Double Sided
				case 2:
					{
						float3 reflection = reflect(-poiCam.viewDir, normal3);
						float2 uv = float2(dot(reflection, float3(1, 0, 0)), dot(reflection, float3(0, 1, 0)));
						matcapUV = uv * _Matcap4Border + 0.5;
						break;
				}
			}
			matcapUV = lerp(matcapUV, poiMesh.uv[_Matcap4UVToBlend], _MatCap4thBlendUV1.xy);
			matcapUV = RotateUV(matcapUV, _Matcap4Rotation * PI, float2(.5, .5), 1.0f);
			
			if (IsInMirror())
			{
				matcapUV.x = 1 - matcapUV.x;
			}
			
			float matcap4Smoothness;
			float mipCount4 = 9;
			if (_Matcap4SmoothnessEnabled)
			{
				if (_Matcap4_TexelSize.z == 8192) mipCount4 = 13;
				if (_Matcap4_TexelSize.z == 4096) mipCount4 = 12;
				if (_Matcap4_TexelSize.z == 2048) mipCount4 = 11;
				if (_Matcap4_TexelSize.z == 1024) mipCount4 = 10;
				if (_Matcap4_TexelSize.z == 512) mipCount4 = 9;
				if (_Matcap4_TexelSize.z == 256) mipCount4 = 8;
				if (_Matcap4_TexelSize.z == 128) mipCount4 = 7;
				if (_Matcap4_TexelSize.z == 64) mipCount4 = 6;
				if (_Matcap4_TexelSize.z == 32) mipCount4 = 5;
				
				matcap4Smoothness = _Matcap4Smoothness;
				
				if (_Matcap4MaskSmoothnessApply)
				{
					#if defined(PROP_MATCAP4MASK) || !defined(OPTIMIZER_ENABLED)
						matcap4Smoothness *= POI2D_SAMPLER_PAN(_Matcap4Mask, _MainTex, poiUV(poiMesh.uv[_Matcap4MaskUV], _Matcap4Mask_ST), _Matcap4MaskPan)[_Matcap4MaskSmoothnessChannel];
					#endif
				}
				matcap4Smoothness = (1 - matcap4Smoothness) * mipCount4;
			}
			
			#if defined(PROP_MATCAP4) || !defined(OPTIMIZER_ENABLED)
				if (_Matcap4SmoothnessEnabled)
				{
					matcap4 = UNITY_SAMPLE_TEX2D_SAMPLER_LOD(_Matcap4, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap4), matcap4Smoothness) * float4(poiThemeColor(poiMods, _Matcap4Color.rgb, _Matcap4ColorThemeIndex), _Matcap4Color.a);
				}
				else
				{
					matcap4 = UNITY_SAMPLE_TEX2D_SAMPLER(_Matcap4, _MainTex, TRANSFORM_TEX(matcapUV, _Matcap4)) * float4(poiThemeColor(poiMods, _Matcap4Color.rgb, _Matcap4ColorThemeIndex), _Matcap4Color.a);
				}
			#else
				matcap4 = float4(poiThemeColor(poiMods, _Matcap4Color.rgb, _Matcap4ColorThemeIndex), _Matcap4Color.a);
			#endif
			
			matcap4.rgb *= _Matcap4Intensity;
			matcap4.rgb = lerp(matcap4.rgb, matcap4.rgb * poiFragData.baseColor.rgb, _Matcap4BaseColorMix);
			
			#if defined(PROP_MATCAP4MASK) || !defined(OPTIMIZER_ENABLED)
				matcap4Mask = POI2D_SAMPLER_PAN(_Matcap4Mask, _MainTex, poiUV(poiMesh.uv[_Matcap4MaskUV], _Matcap4Mask_ST), _Matcap4MaskPan)[_Matcap4MaskChannel];
			#else
				matcap4Mask = 1;
			#endif
			if (_Matcap4MaskInvert)
			{
				matcap4Mask = 1 - matcap4Mask;
			}
			
			#ifdef TPS_Penetrator
				if (_Matcap4TPSDepthEnabled)
				{
					matcap4Mask = lerp(0, matcap4Mask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), _Matcap4TPSMaskStrength);
				}
			#endif
			
			poiFragData.alpha *= lerp(1, matcap4.a, matcap4Mask * _Matcap4AlphaOverride);
			
			//UNITY_BRANCH
			if (_Matcap4HueShiftEnabled)
			{
				matcap4.rgb = hueShift(matcap4.rgb, _Matcap4HueShift + _Time.x * _Matcap4HueShiftSpeed);
			}
			
			blendMatcap(poiLight, poiFragData, poiMods, _Matcap4Add, _Matcap4AddToLight, _Matcap4Multiply, _Matcap4Replace, _Matcap4Mixed, _Matcap4Screen, matcap4, matcap4Mask, _Matcap4EmissionStrength, _Matcap4LightMask, _Matcap4MaskGlobalMask, _Matcap4MaskGlobalMaskBlendType);
		#endif
		//endex
		//ifex _MatcapEnable==0 && _Matcap2Enable==0 && _Matcap3Enable==0 && _Matcap4Enable==0

	}
#endif
//endex
#T#PoiMatcapFunctionCalls
//ifex _MatcapEnable==0 && _Matcap2Enable==0 && _Matcap3Enable==0 && _Matcap4Enable==0
#if defined(POI_MATCAP0) || defined(COLOR_GRADING_HDR_3D) || defined(POI_MATCAP2) || defined(POI_MATCAP3)
	applyMatcap(poiFragData, poiCam, poiMesh, poiLight, poiMods);
#endif
//endex