7631 lines
325 KiB
GLSL
Executable file
7631 lines
325 KiB
GLSL
Executable file
Shader "Hidden/Locked/.poiyomi/Poiyomi 8.0/Poiyomi Toon/6e937c73b499f8a44a3a958a3dbb222d"
|
|
{
|
|
Properties
|
|
{
|
|
[HideInInspector] shader_master_label ("<color=#E75898ff>Poiyomi 8.0.426</color>", Float) = 0
|
|
[HideInInspector] shader_is_using_thry_editor ("", Float) = 0
|
|
[HideInInspector] footer_youtube ("{texture:{name:icon-youtube,height:16},action:{type:URL,data:https://www.youtube.com/poiyomi},hover:YOUTUBE}", Float) = 0
|
|
[HideInInspector] footer_twitter ("{texture:{name:icon-twitter,height:16},action:{type:URL,data:https://twitter.com/poiyomi},hover:TWITTER}", Float) = 0
|
|
[HideInInspector] footer_patreon ("{texture:{name:icon-patreon,height:16},action:{type:URL,data:https://www.patreon.com/poiyomi},hover:PATREON}", Float) = 0
|
|
[HideInInspector] footer_discord ("{texture:{name:icon-discord,height:16},action:{type:URL,data:https://discord.gg/Ays52PY},hover:DISCORD}", Float) = 0
|
|
[HideInInspector] footer_github ("{texture:{name:icon-github,height:16},action:{type:URL,data:https://github.com/poiyomi/PoiyomiToonShader},hover:GITHUB}", Float) = 0
|
|
[HideInInspector] _ForgotToLockMaterial (";;YOU_FORGOT_TO_LOCK_THIS_MATERIAL;", Int) = 1
|
|
[ThryShaderOptimizerLockButton] _ShaderOptimizerEnabled ("", Int) = 1
|
|
[Helpbox(1)] _LockTooltip ("Animations don't work by default when locked in. Right click a property if you want to animate it. The shader will lock in automatically at upload time.", Int) = 0
|
|
[ThryWideEnum(Opaque, 0, Cutout, 1, TransClipping, 9, Fade, 2, Transparent, 3, Additive, 4, Soft Additive, 5, Multiplicative, 6, 2x Multiplicative, 7)]_Mode("Rendering Preset--{on_value_actions:[
|
|
{value:0,actions:[{type:SET_PROPERTY,data:render_queue=2000}, {type:SET_PROPERTY,data:render_type=Opaque}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=1}, {type:SET_PROPERTY,data:_DstBlend=0}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=1}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:1,actions:[{type:SET_PROPERTY,data:render_queue=2450}, {type:SET_PROPERTY,data:render_type=TransparentCutout}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=.5}, {type:SET_PROPERTY,data:_SrcBlend=1}, {type:SET_PROPERTY,data:_DstBlend=0}, {type:SET_PROPERTY,data:_AlphaToMask=1}, {type:SET_PROPERTY,data:_ZWrite=1}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:9,actions:[{type:SET_PROPERTY,data:render_queue=2450}, {type:SET_PROPERTY,data:render_type=TransparentCutout}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=5}, {type:SET_PROPERTY,data:_DstBlend=10}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=1}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:2,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:render_type=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=5}, {type:SET_PROPERTY,data:_DstBlend=10}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:3,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:render_type=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=1}, {type:SET_PROPERTY,data:_DstBlend=10}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=1}]},
|
|
{value:4,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:render_type=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=1}, {type:SET_PROPERTY,data:_DstBlend=1}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:5,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:RenderType=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=4}, {type:SET_PROPERTY,data:_DstBlend=1}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:6,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:render_type=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=2}, {type:SET_PROPERTY,data:_DstBlend=0}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]},
|
|
{value:7,actions:[{type:SET_PROPERTY,data:render_queue=3000}, {type:SET_PROPERTY,data:render_type=Transparent}, {type:SET_PROPERTY,data:_BlendOp=0}, {type:SET_PROPERTY,data:_BlendOpAlpha=0}, {type:SET_PROPERTY,data:_Cutoff=0}, {type:SET_PROPERTY,data:_SrcBlend=2}, {type:SET_PROPERTY,data:_DstBlend=3}, {type:SET_PROPERTY,data:_AlphaToMask=0}, {type:SET_PROPERTY,data:_ZWrite=0}, {type:SET_PROPERTY,data:_ZTest=4}, {type:SET_PROPERTY,data:_AlphaPremultiply=0}]}
|
|
}]}]}", Int) = 0
|
|
[HideInInspector] m_mainCategory ("Color & Normals--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/color-and-normals/main},hover:Documentation}}", Float) = 0
|
|
_Color ("Color & Alpha--{reference_property:_ColorThemeIndex}", Color) = (1, 1, 1, 1)
|
|
[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)] _ColorThemeIndex ("", Int) = 0
|
|
_MainTex ("Texture--{reference_properties:[_MainTexPan, _MainTexUV, _MainPixelMode]}", 2D) = "white" { }
|
|
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _MainTexUV ("UV", Int) = 0
|
|
[HideInInspector][Vector2]_MainTexPan ("Panning", Vector) = (0, 0, 0, 0)
|
|
[HideInInspector][ToggleUI]_MainPixelMode ("Pixel Mode", Float) = 0
|
|
[Normal]_BumpMap ("Normal Map--{reference_properties:[_BumpMapPan, _BumpMapUV, _BumpScale]}", 2D) = "bump" { }
|
|
[HideInInspector][Vector2]_BumpMapPan ("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)] _BumpMapUV ("UV", Int) = 0
|
|
[HideInInspector]_BumpScale ("Intensity", Range(0, 10)) = 1
|
|
_ClippingMask ("Alpha Map--{reference_properties:[_ClippingMaskPan, _ClippingMaskUV, _Inverse_Clipping]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_ClippingMaskPan ("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)] _ClippingMaskUV ("UV", Int) = 0
|
|
[HideInInspector][ToggleUI]_Inverse_Clipping ("Invert", Float) = 0
|
|
_Cutoff ("Alpha Cutoff", Range(0, 1.001)) = 0.5
|
|
[HideInInspector] m_start_Alpha ("Alpha Options--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/color-and-normals/alpha-options},hover:Documentation}}", Float) = 0
|
|
[ToggleUI]_AlphaForceOpaque ("Force Opaque", Float) = 0
|
|
_AlphaMod ("Alpha Mod", Range(-1, 1)) = 0.0
|
|
[ToggleUI]_AlphaPremultiply ("Alpha Premultiply", Float) = 0
|
|
_AlphaBoostFA ("Boost Transparency in ForwardAdd--{condition_showS:(_AddBlendOp==4)}", Range(1, 100)) = 10
|
|
[HideInInspector] m_end_Alpha ("Alpha Options", Float) = 0
|
|
[HideInInspector] m_start_DecalSection ("Decals--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/color-and-normals/decals},hover:YouTube}}", Float) = 0
|
|
[ThryRGBAPacker(Decal 0 Mask, Decal 1 Mask, Decal 2 Mask, Decal 3 Mask)]_DecalMask ("Decal RGBA Mask--{reference_properties:[_DecalMaskPan, _DecalMaskUV]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_DecalMaskPan ("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)] _DecalMaskUV ("UV", Int) = 0
|
|
[ThryToggleUI(true)] _DecalTPSDepthMaskEnabled ("<size=13><b> TPS Depth Enabled</b></size>", Float) = 0
|
|
_Decal0TPSMaskStrength ("Mask r Strength--{condition_showS:(_DecalTPSDepthMaskEnabled==1)}", Range(0, 1)) = 1
|
|
_Decal1TPSMaskStrength ("Mask g Strength--{condition_showS:(_DecalTPSDepthMaskEnabled==1)}", Range(0, 1)) = 1
|
|
_Decal2TPSMaskStrength ("Mask b Strength--{condition_showS:(_DecalTPSDepthMaskEnabled==1)}", Range(0, 1)) = 1
|
|
_Decal3TPSMaskStrength ("Mask a Strength--{condition_showS:(_DecalTPSDepthMaskEnabled==1)}", Range(0, 1)) = 1
|
|
[HideInInspector] m_end_DecalSection ("Decal", Float) = 0
|
|
[HideInInspector] m_start_GlobalThemes ("Global Themes--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/color-and-normals/global-themes},hover:Documentation}}", Float) = 0
|
|
[HDR]_GlobalThemeColor0 ("Color 0", Color) = (1, 1, 1, 1)
|
|
[HDR]_GlobalThemeColor1 ("Color 1", Color) = (1, 1, 1, 1)
|
|
[HDR]_GlobalThemeColor2 ("Color 2", Color) = (1, 1, 1, 1)
|
|
[HDR]_GlobalThemeColor3 ("Color 3", Color) = (1, 1, 1, 1)
|
|
[HideInInspector] m_end_GlobalThemes ("Global Themes", Float) = 0
|
|
[HideInInspector] m_lightingCategory ("Shading", Float) = 0
|
|
[HideInInspector] m_start_PoiLightData ("Light Data--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/light-data},hover:Documentation}}", Float) = 0
|
|
_LightingAOMaps ("AO Maps (expand)--{reference_properties:[_LightingAOMapsPan, _LightingAOMapsUV,_LightDataAOStrengthR,_LightDataAOStrengthG,_LightDataAOStrengthB,_LightDataAOStrengthA]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_LightingAOMapsPan ("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)] _LightingAOMapsUV ("UV", Int) = 0
|
|
[HideInInspector]_LightDataAOStrengthR ("R Strength", Range(0, 1)) = 1
|
|
[HideInInspector]_LightDataAOStrengthG ("G Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightDataAOStrengthB ("B Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightDataAOStrengthA ("A Strength", Range(0, 1)) = 0
|
|
_LightingDetailShadowMaps ("Detail Shadows (expand)--{reference_properties:[_LightingDetailShadowMapsPan, _LightingDetailShadowMapsUV,_LightingDetailShadowStrengthR,_LightingDetailShadowStrengthG,_LightingDetailShadowStrengthB,_LightingDetailShadowStrengthA,_LightingAddDetailShadowStrengthR,_LightingAddDetailShadowStrengthG,_LightingAddDetailShadowStrengthB,_LightingAddDetailShadowStrengthA]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_LightingDetailShadowMapsPan ("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)] _LightingDetailShadowMapsUV ("UV", Int) = 0
|
|
[HideInInspector]_LightingDetailShadowStrengthR ("R Strength", Range(0, 1)) = 1
|
|
[HideInInspector]_LightingDetailShadowStrengthG ("G Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingDetailShadowStrengthB ("B Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingDetailShadowStrengthA ("A Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingAddDetailShadowStrengthR ("Additive R Strength", Range(0, 1)) = 1
|
|
[HideInInspector]_LightingAddDetailShadowStrengthG ("Additive G Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingAddDetailShadowStrengthB ("Additive B Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingAddDetailShadowStrengthA ("Additive A Strength", Range(0, 1)) = 0
|
|
_LightingShadowMasks ("Shadow Masks (expand)--{reference_properties:[_LightingShadowMasksPan, _LightingShadowMasksUV,_LightingShadowMaskStrengthR,_LightingShadowMaskStrengthG,_LightingShadowMaskStrengthB,_LightingShadowMaskStrengthA]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_LightingShadowMasksPan ("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)] _LightingShadowMasksUV ("UV", Int) = 0
|
|
[HideInInspector]_LightingShadowMaskStrengthR ("R Strength", Range(0, 1)) = 1
|
|
[HideInInspector]_LightingShadowMaskStrengthG ("G Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingShadowMaskStrengthB ("B Strength", Range(0, 1)) = 0
|
|
[HideInInspector]_LightingShadowMaskStrengthA ("A Strength", Range(0, 1)) = 0
|
|
[Space(15)]
|
|
[ThryHeaderLabel(Base Pass Lighting, 13)]
|
|
[Space(4)]
|
|
[Enum(Poi Custom, 0, Standard, 1, UTS2, 2, OpenLit (lil toon), 3)] _LightingColorMode ("Light Color Mode", Int) = 0
|
|
[Enum(Poi Custom, 0, Normalized NDotL, 1, Saturated NDotL, 2)] _LightingMapMode ("Light Map Mode", Int) = 0
|
|
[Enum(Poi Custom, 0, Forced Local Direction, 1, Forced World Direction, 2, UTS2, 3, OpenLit (lil toon), 4)] _LightingDirectionMode ("Light Direction Mode", Int) = 0
|
|
[Vector3]_LightngForcedDirection ("Forced Direction--{condition_showS:(_LightingDirectionMode==1 || _LightingDirectionMode==2)}", Vector) = (0, 0, 0)
|
|
[ToggleUI]_LightingForceColorEnabled ("Force Light Color", Float) = 0
|
|
_LightingForcedColor ("Forced Color--{condition_showS:(_LightingForceColorEnabled==1), reference_property:_LightingForcedColorThemeIndex}", Color) = (1, 1, 1)
|
|
[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)] _LightingForcedColorThemeIndex ("", Int) = 0
|
|
_Unlit_Intensity ("Unlit_Intensity--{condition_showS:(_LightingColorMode==2)}", Range(0.001, 4)) = 1
|
|
[ToggleUI]_LightingCapEnabled ("Limit Brightness", Float) = 1
|
|
_LightingCap ("Max Brightness--{condition_showS:(_LightingCapEnabled==1)}", Range(0, 10)) = 1
|
|
_LightingMinLightBrightness ("Min Brightness", Range(0, 1)) = 0
|
|
_LightingIndirectUsesNormals ("Indirect Uses Normals--{condition_showS:(_LightingColorMode==0)}", Range(0, 1)) = 0
|
|
_LightingCastedShadows ("Receive Casted Shadows", Range(0, 1)) = 0
|
|
_LightingMonochromatic ("Grayscale Lighting?", Range(0, 1)) = 0
|
|
[Space(15)]
|
|
[ThryHeaderLabel(Add Pass Lighting, 13)]
|
|
[Space(4)]
|
|
[ThryToggle(POI_LIGHT_DATA_ADDITIVE_ENABLE)]_LightingAdditiveEnable ("Enable Additive", Float) = 1
|
|
[ThryToggle(POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE)]_DisableDirectionalInAdd ("Ignore Directional--{condition_showS:(_LightingAdditiveEnable==1)}", Float) = 1
|
|
[ToggleUI]_LightingAdditiveLimited ("Limit Brightness?--{condition_showS:(_LightingAdditiveEnable==1)}", Float) = 0
|
|
_LightingAdditiveLimit ("Max Brightness--{ condition_showS:(_LightingAdditiveLimited==1&&_LightingAdditiveEnable==1)}", Range(0, 10)) = 1
|
|
_LightingAdditiveMonochromatic ("Grayscale Lighting?", Range(0, 1)) = 0
|
|
_LightingAdditivePassthrough ("Point Light Passthrough--{condition_showS:(_LightingAdditiveEnable==1)}", Range(0, 1)) = .5
|
|
[Space(15)]
|
|
[ThryHeaderLabel(Vertex Lighting, 13)]
|
|
[Space(4)]
|
|
[ThryToggle(POI_VERTEXLIGHT_ON)]_LightingVertexLightingEnabled ("Enabled", Float) = 1
|
|
[Space(15)]
|
|
[ThryHeaderLabel(Debug Visualization, 13)]
|
|
[Space(4)]
|
|
[ThryToggle(POI_LIGHT_DATA_DEBUG)]_LightDataDebugEnabled ("Debug", Float) = 0
|
|
[ThryWideEnum(Direct Color, 0, Indirect Color, 1, Light Map, 2, Attenuation, 3, N Dot L, 4, Half Dir, 5, Direction, 6, Add Color, 7, Add Attenuation, 8, Add Shadow, 9, Add N Dot L, 10)] _LightingDebugVisualize ("Visualize--{condition_showS:(_LightDataDebugEnabled==1)}", Int) = 0
|
|
[HideInInspector] m_end_PoiLightData ("Light Data", Float) = 0
|
|
[HideInInspector] m_start_PoiShading (" Shading--{reference_property:_ShadingEnabled,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/main},hover:Documentation}}", Float) = 0
|
|
[HideInInspector][ThryToggle(VIGNETTE_MASKED)]_ShadingEnabled ("Enable Shading", Float) = 1
|
|
[ThryHeaderLabel(Base Pass Shading, 13)]
|
|
[Space(4)]
|
|
[KeywordEnum(TextureRamp, Multilayer Math, Wrapped, Skin, ShadeMap, Flat, Realistic, Cloth, SDF)] _LightingMode ("Lighting Type", Float) = 5
|
|
_LightingShadowColor ("Shadow Tint--{condition_showS:(_LightingMode!=4 && _LightingMode!=1 && _LightingMode!=5)}", Color) = (1, 1, 1)
|
|
[Gradient]_ToonRamp ("Lighting Ramp--{texture:{width:512,height:4,filterMode:Bilinear,wrapMode:Clamp},force_texture_options:true,condition_showS:(_LightingMode==0)}", 2D) = "white" { }
|
|
_ShadowOffset ("Ramp Offset--{condition_showS:(_LightingMode==0)}", Range(-1, 1)) = 0
|
|
_LightingWrappedWrap ("Wrap--{condition_showS:(_LightingMode==2)}", Range(0, 2)) = 0
|
|
_LightingWrappedNormalization ("Normalization--{condition_showS:(_LightingMode==2)}", Range(0, 1)) = 0
|
|
[ToggleUI]_LightingMulitlayerNonLinear ("Non Linear Edge--{condition_showS:(_LightingMode==1)}", Float) = 1
|
|
_ShadowColorTex ("Shadow Color--{reference_properties:[_ShadowColorTexPan, _ShadowColorTexUV], condition_showS:(_LightingMode==1)}", 2D) = "black" { }
|
|
[HideInInspector][Vector2]_ShadowColorTexPan ("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)] _ShadowColorTexUV ("UV", Int) = 0
|
|
_ShadowColor ("Shadow Color--{condition_showS:(_LightingMode==1)}", Color) = (0.7, 0.75, 0.85, 1.0)
|
|
_MultilayerMathBlurMap ("Blur Map--{reference_properties:[_MultilayerMathBlurMapPan, _MultilayerMathBlurMapUV], condition_showS:(_LightingMode==1)}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_MultilayerMathBlurMapPan ("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)] _MultilayerMathBlurMapUV ("UV", Int) = 0
|
|
_ShadowBorder ("Border--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.5
|
|
_ShadowBlur ("Blur--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.1
|
|
_Shadow2ndColorTex ("2nd Color--{reference_properties:[_Shadow2ndColorTexPan, _Shadow2ndColorTexUV], condition_showS:(_LightingMode==1)}", 2D) = "black" { }
|
|
[HideInInspector][Vector2]_Shadow2ndColorTexPan ("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)] _Shadow2ndColorTexUV ("UV", Int) = 0
|
|
_Shadow2ndColor ("2nd Color--{condition_showS:(_LightingMode==1)}", Color) = (0, 0, 0, 0)
|
|
_Shadow2ndBorder ("2nd Border--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.5
|
|
_Shadow2ndBlur ("2nd Blur--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.3
|
|
_Shadow3rdColorTex ("3rd Color--{reference_properties:[_Shadow3rdColorTexPan, _Shadow3rdColorTexUV], condition_showS:(_LightingMode==1)}", 2D) = "black" { }
|
|
[HideInInspector][Vector2]_Shadow3rdColorTexPan ("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)] _Shadow3rdColorTexUV ("UV", Int) = 0
|
|
_Shadow3rdColor ("3rd Color--{condition_showS:(_LightingMode==1)}", Color) = (0, 0, 0, 0)
|
|
_Shadow3rdBorder ("3rd Border--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.25
|
|
_Shadow3rdBlur ("3rd Blur--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0.1
|
|
_ShadowBorderColor ("Border Color--{condition_showS:(_LightingMode==1)}", Color) = (1, 0, 0, 1)
|
|
_ShadowBorderRange ("Border Range--{condition_showS:(_LightingMode==1)}", Range(0, 1)) = 0
|
|
_LightingGradientStart ("Gradient Start--{condition_showS:(_LightingMode==2)}", Range(0, 1)) = 0
|
|
_LightingGradientEnd ("Gradient End--{condition_showS:(_LightingMode==2)}", Range(0, 1)) = .5
|
|
_1st_ShadeColor ("1st ShadeColor--{condition_showS:(_LightingMode==4)}", Color) = (1, 1, 1)
|
|
_1st_ShadeMap ("1st ShadeMap--{reference_properties:[_1st_ShadeMapPan, _1st_ShadeMapUV, _Use_1stShadeMapAlpha_As_ShadowMask, _1stShadeMapMask_Inverse],condition_showS:(_LightingMode==4)}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_1st_ShadeMapPan ("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)] _1st_ShadeMapUV ("UV", Int) = 0
|
|
[HideInInspector][ToggleUI]_Use_1stShadeMapAlpha_As_ShadowMask ("1st ShadeMap.a As ShadowMask", Float) = 0
|
|
[HideInInspector][ToggleUI]_1stShadeMapMask_Inverse ("1st ShadeMapMask Inverse", Float) = 0
|
|
[ToggleUI] _Use_BaseAs1st ("Use BaseMap as 1st ShadeMap--{condition_showS:(_LightingMode==4)}", Float) = 0
|
|
_2nd_ShadeColor ("2nd ShadeColor--{condition_showS:(_LightingMode==4)}", Color) = (1, 1, 1, 1)
|
|
_2nd_ShadeMap ("2nd ShadeMap--{reference_properties:[_2nd_ShadeMapPan, _2nd_ShadeMapUV, _Use_2ndShadeMapAlpha_As_ShadowMask, _2ndShadeMapMask_Inverse],condition_showS:(_LightingMode==4)}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_2nd_ShadeMapPan ("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)] _2nd_ShadeMapUV ("UV", Int) = 0
|
|
[HideInInspector][ToggleUI]_Use_2ndShadeMapAlpha_As_ShadowMask ("2nd ShadeMap.a As ShadowMask", Float) = 0
|
|
[HideInInspector][ToggleUI]_2ndShadeMapMask_Inverse ("2nd ShadeMapMask Inverse", Float) = 0
|
|
[ToggleUI] _Use_1stAs2nd ("Use 1st ShadeMap as 2nd_ShadeMap--{condition_showS:(_LightingMode==4)}", Float) = 0
|
|
_BaseColor_Step ("BaseColor_Step--{condition_showS:(_LightingMode==4)}", Range(0.01, 1)) = 0.5
|
|
_BaseShade_Feather ("Base/Shade_Feather--{condition_showS:(_LightingMode==4)}", Range(0.0001, 1)) = 0.0001
|
|
_ShadeColor_Step ("ShadeColor_Step--{condition_showS:(_LightingMode==4)}", Range(0, 1)) = 0
|
|
_1st2nd_Shades_Feather ("1st/2nd_Shades_Feather--{condition_showS:(_LightingMode==4)}", Range(0.0001, 1)) = 0.0001
|
|
[Enum(Replace, 0, Multiply, 1)]_ShadingShadeMapBlendType ("Blend Mode--{condition_showS:(_LightingMode==4)}", Int) = 0
|
|
_SkinLUT ("LUT--{condition_showS:(_LightingMode==3)}", 2D) = "white" { }
|
|
_SssScale ("Scale--{condition_showS:(_LightingMode==3)}", Range(0, 1)) = 1
|
|
[HideInInspector]_SssBumpBlur ("Bump Blur--{condition_showS:(_LightingMode==3)}", Range(0, 1)) = 0.7
|
|
[HideInInspector][Vector3]_SssTransmissionAbsorption ("Absorption--{condition_showS:(_LightingMode==3)}", Vector) = (-8, -40, -64, 0)
|
|
[HideInInspector][Vector3]_SssColorBleedAoWeights ("AO Color Bleed--{condition_showS:(_LightingMode==3)}", Vector) = (0.4, 0.15, 0.13, 0)
|
|
[NonModifiableTextureData] [NoScaleOffset] _ClothDFG ("MultiScatter Cloth DFG--{condition_showS:(_LightingMode==7)}", 2D) = "black" { }
|
|
[ThryRGBAPacker(Metallic Map, Cloth Mask, Reflectance, Smoothness)]_ClothMetallicSmoothnessMap ("Maps (Expand)--{reference_properties:[_ClothMetallicSmoothnessMapPan, _ClothMetallicSmoothnessMapUV, _ClothMetallicSmoothnessMapInvert],condition_showS:(_LightingMode==7)}", 2D) = "white" { }
|
|
[HideInInspector][Vector2] _ClothMetallicSmoothnessMapPan ("Panning", Vector) = (0, 0, 0, 0)
|
|
[HideInInspector][ToggleUI] _ClothMetallicSmoothnessMapInvert ("Invert Smoothness", Float) = 0
|
|
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)] _ClothMetallicSmoothnessMapUV ("UV", Int) = 0
|
|
_ClothReflectance ("Reflectance--{condition_showS:(_LightingMode==7)}", Range(0.35, 1)) = 0.5
|
|
_ClothSmoothness ("Smoothness--{condition_showS:(_LightingMode==7)}", Range(0, 1)) = 0.5
|
|
_SDFShadingTexture ("SDF--{reference_properties:[_SDFShadingTexturePan, _SDFShadingTextureUV],condition_showS:(_LightingMode==8)}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_SDFShadingTexturePan ("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)] _SDFShadingTextureUV ("UV", Int) = 0
|
|
_SDFBlur ("Blur--{condition_showS:(_LightingMode==8)}", Range(0, 1)) = 0.1
|
|
[Vector3]_SDFForward ("Forward Direction--{condition_showS:(_LightingMode==8)}", Vector) = (0, 0, 1, 0)
|
|
[Vector3]_SDFLeft ("Left Direction--{condition_showS:(_LightingMode==8)}", Vector) = (-1, 0, 0, 0)
|
|
_ShadowStrength ("Shadow Strength--{condition_showS:(_LightingMode<=4 || _LightingMode==8)}", Range(0, 1)) = 1
|
|
_LightingIgnoreAmbientColor ("Ignore Indirect Shadow Color--{condition_showS:(_LightingMode<=3 || _LightingMode==8)}", Range(0, 1)) = 1
|
|
[Space(15)]
|
|
[ThryHeaderLabel(Add Pass Shading, 13)]
|
|
[Space(4)]
|
|
[Enum(Realistic, 0, Toon, 1)] _LightingAdditiveType ("Lighting Type", Int) = 1
|
|
_LightingAdditiveGradientStart ("Gradient Start--{condition_showS:(_LightingAdditiveType==1)}", Range(0, 1)) = 0
|
|
_LightingAdditiveGradientEnd ("Gradient End--{condition_showS:(_LightingAdditiveType==1)}", Range(0, 1)) = .5
|
|
[HideInInspector] m_end_PoiShading ("Shading", Float) = 0
|
|
[HideInInspector] m_start_brdf ("Reflections & Specular--{reference_property:_MochieBRDF,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/shading/reflections-and-specular},hover:Documentation}}", Float) = 0
|
|
[HideInInspector][ThryToggle(MOCHIE_PBR)]_MochieBRDF ("Enable", Float) = 0
|
|
_MochieReflectionStrength ("Reflection Strength", Range(0, 1)) = 1
|
|
_MochieSpecularStrength ("Specular Strength", Range(0, 1)) = 1
|
|
_MochieMetallicMultiplier ("Metallic", Range(0, 1)) = 0
|
|
_MochieRoughnessMultiplier ("Smoothness", Range(0, 1)) = 1
|
|
_MochieReflectionTint ("Reflection Tint--{reference_property:_MochieReflectionTintThemeIndex}", Color) = (1, 1, 1, 1)
|
|
[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)] _MochieReflectionTintThemeIndex ("", Int) = 0
|
|
_MochieSpecularTint ("Specular Tint--{reference_property:_MochieSpecularTintThemeIndex}", Color) = (1, 1, 1, 1)
|
|
[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)] _MochieSpecularTintThemeIndex ("", Int) = 0
|
|
[Space(8)]
|
|
[ThryRGBAPacker(R Metallic Map, G Smoothness Map, B Reflection Mask, A Specular Mask)]_MochieMetallicMaps ("Maps [Expand]--{reference_properties:[_MochieMetallicMapsPan, _MochieMetallicMapsUV, _MochieMetallicMapInvert, _MochieRoughnessMapInvert, _MochieReflectionMaskInvert, _MochieSpecularMaskInvert]}", 2D) = "white" { }
|
|
[HideInInspector][Vector2]_MochieMetallicMapsPan ("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)]_MochieMetallicMapsUV ("UV", Int) = 0
|
|
[HideInInspector][ToggleUI]_MochieMetallicMapInvert ("Invert Metallic", Float) = 0
|
|
[HideInInspector][ToggleUI]_MochieRoughnessMapInvert ("Invert Smoothness", Float) = 0
|
|
[HideInInspector][ToggleUI]_MochieReflectionMaskInvert ("Invert Reflection Mask", Float) = 0
|
|
[HideInInspector][ToggleUI]_MochieSpecularMaskInvert ("Invert Specular Mask", Float) = 0
|
|
[ThryToggleUI(true)]_PBRSplitMaskSample ("<size=13><b> Split Mask Sampling</b></size>", Float) = 0
|
|
_PBRMaskScaleTiling ("ScaleXY TileZW--{condition_showS:(_PBRSplitMaskSample==1)}", Vector) = (1, 1, 0, 0)
|
|
[ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)]_MochieMetallicMasksUV ("UV--{condition_showS:(_PBRSplitMaskSample==1)}", Int) = 0
|
|
[Vector2]_MochieMetallicMasksPan ("Panning--{condition_showS:(_PBRSplitMaskSample==1)}", Vector) = (0, 0, 0, 0)
|
|
[ThryToggleUI(true)]_Specular2ndLayer ("<size=13><b> 2nd Specular</b></size>", Float) = 0
|
|
_MochieSpecularStrength2 ("Strength--{condition_showS:(_Specular2ndLayer==1)}", Range(0, 1)) = 1
|
|
_MochieRoughnessMultiplier2 ("Smoothness--{condition_showS:(_Specular2ndLayer==1)}", Range(0, 1)) = 1
|
|
[ThryToggleUI(true)] _BRDFTPSDepthEnabled ("<size=13><b> TPS Depth Enabled</b></size>", Float) = 0
|
|
_BRDFTPSReflectionMaskStrength ("Reflection Mask Strength--{condition_showS:(_BRDFTPSDepthEnabled==1)}", Range(0, 1)) = 1
|
|
_BRDFTPSSpecularMaskStrength ("Specular Mask Strength--{condition_showS:(_BRDFTPSDepthEnabled==1)}", Range(0, 1)) = 1
|
|
[ToggleUI]_IgnoreCastedShadows ("Ignore Casted Shadows", Float) = 0
|
|
[Space(8)]
|
|
[ThryTexture][NoScaleOffset]_MochieReflCube ("Fallback Cubemap", Cube) = "" { }
|
|
[ToggleUI]_MochieForceFallback ("Force Fallback", Int) = 0
|
|
[ToggleUI]_MochieLitFallback ("Lit Fallback", Float) = 0
|
|
[ThryToggleUI(true)]_MochieGSAAEnabled ("<size=13><b> GSAA</b></size>", Float) = 1
|
|
_PoiGSAAVariance ("GSAA Variance", Range(0, 1)) = 0.15
|
|
_PoiGSAAThreshold ("GSAA Threshold", Range(0, 1)) = 0.1
|
|
_RefSpecFresnel ("Fresnel Reflection", Range(0, 1)) = 1
|
|
[HideInInspector] m_end_brdf ("", Float) = 0
|
|
[HideInInspector] m_specialFXCategory ("Special FX", Float) = 0
|
|
[HideInInspector] m_start_pathing ("Pathing--{reference_property: _EnablePathing,button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/special-fx/pathing},hover:Documentation}}", Float) = 0
|
|
[HideInInspector][ThryToggle(POI_PATHING)] _EnablePathing ("Enable Pathing", Float) = 0
|
|
[Enum(Split Channels, 0, Merged Channels, 1)]_PathGradientType ("Gradient Type", Float) = 0
|
|
[ToggleUI]_PathingOverrideAlpha ("Override alpha", Float) = 0
|
|
[ThryRGBAPacker(R Path, G Path, B Path, A Path)]_PathingMap ("RGBA Path Map--{reference_properties:[_PathingMapPan, _PathingMapUV]}", 2D) = "white" { }
|
|
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)]_PathingMapUV ("UV", Int) = 0
|
|
[HideInInspector][Vector2]_PathingMapPan ("Panning", Vector) = (0, 0, 0, 0)
|
|
[ThryRGBAPacker(1, RGB Color, A Mask, 1)]_PathingColorMap ("Color & Mask (Expand)--{reference_properties:[_PathingColorMapPan, _PathingColorMapUV]}", 2D) = "white" { }
|
|
[HideInInspector][ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5, Polar UV, 6, Distorted UV, 7)]_PathingColorMapUV ("UV", Int) = 0
|
|
[HideInInspector][Vector2]_PathingColorMapPan ("Panning", Vector) = (0, 0, 0, 0)
|
|
[Enum(Fill, 0, Path, 1, Loop, 2)]_PathTypeR ("R Path Type", Float) = 0
|
|
[Enum(Fill, 0, Path, 1, Loop, 2)]_PathTypeG ("G Path Type", Float) = 0
|
|
[Enum(Fill, 0, Path, 1, Loop, 2)]_PathTypeB ("B Path Type", Float) = 0
|
|
[Enum(Fill, 0, Path, 1, Loop, 2)]_PathTypeA ("A Path Type", Float) = 0
|
|
[HDR]_PathColorR ("R Color--{reference_property:_PathColorRThemeIndex}", Color) = (1, 1, 1)
|
|
[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)] _PathColorRThemeIndex ("", Int) = 0
|
|
[HDR]_PathColorG ("G Color--{reference_property:_PathColorGThemeIndex}", Color) = (1, 1, 1)
|
|
[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)] _PathColorGThemeIndex ("", Int) = 0
|
|
[HDR]_PathColorB ("B Color--{reference_property:_PathColorBThemeIndex}", Color) = (1, 1, 1)
|
|
[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)] _PathColorBThemeIndex ("", Int) = 0
|
|
[HDR]_PathColorA ("A Color--{reference_property:_PathColorAThemeIndex}", Color) = (1, 1, 1)
|
|
[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)] _PathColorAThemeIndex ("", Int) = 0
|
|
_PathEmissionStrength ("Emission Strength", Vector) = (0.0, 0.0, 0.0, 0.0)
|
|
_PathSoftness ("Softness", Vector) = (1, 1, 1, 1)
|
|
_PathSpeed ("Speed", Vector) = (1.0, 1.0, 1.0, 1.0)
|
|
_PathWidth ("Length", Vector) = (0.03, 0.03, 0.03, 0.03)
|
|
[Header(Timing Options)]
|
|
_PathTime ("Manual Timing", Vector) = (-999.0, -999.0, -999.0, -999.0)
|
|
_PathOffset ("Timing Offset", Vector) = (0.0, 0.0, 0.0, 0.0)
|
|
_PathSegments ("Path Segments", Vector) = (0.0, 0.0, 0.0, 0.0)
|
|
[HideInInspector] m_start_PathAudioLink ("Audio Link ♫--{ condition_showS:_EnableAudioLink==1}", Float) = 0
|
|
[ThryToggleUI(true)]_PathALTimeOffset ("<size=13><b> Time Offset</b></size>", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathTimeOffsetBandR ("Band R--{condition_showS:(_PathALTimeOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathTimeOffsetR ("Offset R--{condition_showS:(_PathALTimeOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathTimeOffsetBandG ("Band G--{condition_showS:(_PathALTimeOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathTimeOffsetG ("Offset G--{condition_showS:(_PathALTimeOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathTimeOffsetBandB ("Band B--{condition_showS:(_PathALTimeOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathTimeOffsetB ("Offset B--{condition_showS:(_PathALTimeOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathTimeOffsetBandA ("Band A--{condition_showS:(_PathALTimeOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathTimeOffsetA ("Offset A--{condition_showS:(_PathALTimeOffset==1)}", Vector) = (0, 0, 0)
|
|
[Space(4)]
|
|
[ThryToggleUI(true)]_PathALEmissionOffset ("<size=13><b> Emission Offset</b></size>", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathEmissionAddBandR ("Band R--{condition_showS:(_PathALEmissionOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathEmissionAddR ("Offset R--{condition_showS:(_PathALEmissionOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathEmissionAddBandG ("Band G--{condition_showS:(_PathALEmissionOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathEmissionAddG ("Offset G--{condition_showS:(_PathALEmissionOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathEmissionAddBandB ("Band B--{condition_showS:(_PathALEmissionOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathEmissionAddB ("Offset B--{condition_showS:(_PathALEmissionOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathEmissionAddBandA ("Band A--{condition_showS:(_PathALEmissionOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathEmissionAddA ("Offset A--{condition_showS:(_PathALEmissionOffset==1)}", Vector) = (0, 0, 0)
|
|
[Space(4)]
|
|
[ThryToggleUI(true)]_PathALWidthOffset ("<size=13><b> Width Offset</b></size>", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathWidthOffsetBandR ("Band R--{condition_showS:(_PathALWidthOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathWidthOffsetR ("Offset R--{condition_showS:(_PathALWidthOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathWidthOffsetBandG ("Band G--{condition_showS:(_PathALWidthOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathWidthOffsetG ("Offset G--{condition_showS:(_PathALWidthOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathWidthOffsetBandB ("Band B--{condition_showS:(_PathALWidthOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathWidthOffsetB ("Offset B--{condition_showS:(_PathALWidthOffset==1)}", Vector) = (0, 0, 0)
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _AudioLinkPathWidthOffsetBandA ("Band A--{condition_showS:(_PathALWidthOffset==1)}", Int) = 0
|
|
[Vector2]_AudioLinkPathWidthOffsetA ("Offset A--{condition_showS:(_PathALWidthOffset==1)}", Vector) = (0, 0, 0)
|
|
[Space(4)]
|
|
[ThryToggleUI(true)]_PathALHistory ("<size=13><b> History</b></size>", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathALHistoryBandR ("R Band--{condition_showS:(_PathALHistory==1)}", Int) = 0
|
|
[ToggleUI]_PathALHistoryR ("R History--{condition_showS:(_PathALHistory==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathALHistoryBandG ("G Band--{condition_showS:(_PathALHistory==1)}", Int) = 0
|
|
[ToggleUI]_PathALHistoryG ("G History--{condition_showS:(_PathALHistory==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathALHistoryBandB ("B Band--{condition_showS:(_PathALHistory==1)}", Int) = 0
|
|
[ToggleUI]_PathALHistoryB ("B History--{condition_showS:(_PathALHistory==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathALHistoryBandA ("A Band--{condition_showS:(_PathALHistory==1)}", Int) = 0
|
|
[ToggleUI]_PathALHistoryA ("A History--{condition_showS:(_PathALHistory==1)}", Float) = 0
|
|
[Space(4)]
|
|
[ThryToggleUI(true)]_PathALChrono ("<size=13><b> Chrono Time</b></size>", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathChronoBandR ("R Band--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
[ThryWideEnum(Motion increases as intensity of band increases, 0, Above but Smooth, 1, Motion moves back and forth as a function of intensity, 2, Above but Smoooth, 3, Fixed speed increase when the band is dark Stationary when light, 4, Above but Smooooth, 5, Fixed speed increase when the band is dark Fixed speed decrease when light, 6, Above but Smoooooth, 7)]_PathChronoTypeR ("R Motion Type--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
_PathChronoSpeedR ("R Speed--{condition_showS:(_PathALChrono==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathChronoBandG ("G Band--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
[ThryWideEnum(Motion increases as intensity of band increases, 0, Above but Smooth, 1, Motion moves back and forth as a function of intensity, 2, Above but Smoooth, 3, Fixed speed increase when the band is dark Stationary when light, 4, Above but Smooooth, 5, Fixed speed increase when the band is dark Fixed speed decrease when light, 6, Above but Smoooooth, 7)]_PathChronoTypeG ("G Motion Type--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
_PathChronoSpeedG ("G Speed--{condition_showS:(_PathALChrono==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathChronoBandB ("B Band--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
[ThryWideEnum(Motion increases as intensity of band increases, 0, Above but Smooth, 1, Motion moves back and forth as a function of intensity, 2, Above but Smoooth, 3, Fixed speed increase when the band is dark Stationary when light, 4, Above but Smooooth, 5, Fixed speed increase when the band is dark Fixed speed decrease when light, 6, Above but Smoooooth, 7)]_PathChronoTypeB ("B Motion Type--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
_PathChronoSpeedB ("B Speed--{condition_showS:(_PathALChrono==1)}", Float) = 0
|
|
[Enum(Bass, 0, Low Mid, 1, High Mid, 2, Treble, 3)] _PathChronoBandA ("A Band--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
[ThryWideEnum(Motion increases as intensity of band increases, 0, Above but Smooth, 1, Motion moves back and forth as a function of intensity, 2, Above but Smoooth, 3, Fixed speed increase when the band is dark Stationary when light, 4, Above but Smooooth, 5, Fixed speed increase when the band is dark Fixed speed decrease when light, 6, Above but Smoooooth, 7)]_PathChronoTypeA ("A Motion Type--{condition_showS:(_PathALChrono==1)}", Int) = 0
|
|
_PathChronoSpeedA ("A Speed--{condition_showS:(_PathALChrono==1)}", Float) = 0
|
|
[Space(4)]
|
|
[ThryToggleUI(true)]_PathALAutoCorrelator ("<size=13><b> Auto Correlator</b></size>", Float) = 0
|
|
[Enum(Off, 0, On, 1, Mirrored, 2)]_PathALAutoCorrelatorR ("R Type--{condition_showS:(_PathALAutoCorrelator==1)}", Int) = 0
|
|
[Enum(Off, 0, On, 1, Mirrored, 2)]_PathALAutoCorrelatorG ("G Type--{condition_showS:(_PathALAutoCorrelator==1)}", Int) = 0
|
|
[Enum(Off, 0, On, 1, Mirrored, 2)]_PathALAutoCorrelatorB ("B Type--{condition_showS:(_PathALAutoCorrelator==1)}", Int) = 0
|
|
[Enum(Off, 0, On, 1, Mirrored, 2)]_PathALAutoCorrelatorA ("A Type--{condition_showS:(_PathALAutoCorrelator==1)}", Int) = 0
|
|
[Space(4)]
|
|
[ToggleUI]_PathALCCR ("R Color Chord Strip", Float) = 0
|
|
[ToggleUI]_PathALCCG ("G Color Chord Strip", Float) = 0
|
|
[ToggleUI]_PathALCCB ("B Color Chord Strip", Float) = 0
|
|
[ToggleUI]_PathALCCA ("A Color Chord Strip", Float) = 0
|
|
[HideInInspector] m_end_PathAudioLink ("", Float) = 0
|
|
[HideInInspector] m_end_pathing ("", Float) = 0
|
|
[HideInInspector] m_AudioLinkCategory (" Audio Link--{reference_property:_EnableAudioLink}", Float) = 0
|
|
[HideInInspector] m_start_audioLink ("Audio Link", Float) = 0
|
|
[HideInInspector][ThryToggle(POI_AUDIOLINK)] _EnableAudioLink ("Enabled?", Float) = 0
|
|
[Helpbox(1)] _AudioLinkHelp ("This section houses the global controls for audio link. Controls for individual features are in their respective sections. (Emission, Dissolve, etc...)", Int) = 0
|
|
[ToggleUI] _AudioLinkAnimToggle ("Anim Toggle", Float) = 1
|
|
[HideInInspector] m_end_audioLink ("Audio Link", Float) = 0
|
|
[HideInInspector] m_modifierCategory ("Modifiers", Float) = 0
|
|
[HideInInspector] m_start_uvPanosphere ("Panosphere UV", Float) = 0
|
|
[ToggleUI] _StereoEnabled ("Stereo Enabled", Float) = 0
|
|
[ToggleUI] _PanoUseBothEyes ("Perspective Correct (VR)", Float) = 1
|
|
[HideInInspector] m_end_uvPanosphere ("Panosphere UV", Float) = 0
|
|
[HideInInspector] m_start_uvPolar ("Polar UV", Float) = 0
|
|
[ThryWideEnum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Panosphere, 4, World Pos XZ, 5)] _PolarUV ("UV", Int) = 0
|
|
[Vector2]_PolarCenter ("Center Coordinate", Vector) = (.5, .5, 0, 0)
|
|
_PolarRadialScale ("Radial Scale", Float) = 1
|
|
_PolarLengthScale ("Length Scale", Float) = 1
|
|
_PolarSpiralPower ("Spiral Power", Float) = 0
|
|
[HideInInspector] m_end_uvPolar ("Polar UV", Float) = 0
|
|
[HideInInspector] m_thirdpartyCategory ("Third Party", Float) = 0
|
|
[HideInInspector] m_postprocessing ("Post Processing", Float) = 0
|
|
[HideInInspector] m_start_PoiLightData ("PP Animations--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/post-processing/pp-animations},hover:Documentation}}", Float) = 0
|
|
[Helpbox(1)] _PPHelp ("This section meant for real time adjustments through animations and not to be changed in unity", Int) = 0
|
|
_PPLightingMultiplier ("Lighting Mulitplier", Float) = 1
|
|
_PPLightingAddition ("Lighting Add", Float) = 0
|
|
_PPEmissionMultiplier ("Emission Multiplier", Float) = 1
|
|
_PPFinalColorMultiplier ("Final Color Multiplier", Float) = 1
|
|
[HideInInspector] m_end_PoiLightData ("PP Animations ", Float) = 0
|
|
[HideInInspector] m_renderingCategory ("Rendering--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/rendering/main},hover:Documentation}}", Float) = 0
|
|
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 2
|
|
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest ("ZTest", Float) = 4
|
|
[Enum(Off, 0, On, 1)] _ZWrite ("ZWrite", Int) = 1
|
|
[Enum(Thry.ColorMask)] _ColorMask ("Color Mask", Int) = 15
|
|
_OffsetFactor ("Offset Factor", Float) = 0.0
|
|
_OffsetUnits ("Offset Units", Float) = 0.0
|
|
[ToggleUI]_RenderingReduceClipDistance ("Reduce Clip Distance", Float) = 0
|
|
[ToggleUI]_IgnoreFog ("Ignore Fog", Float) = 0
|
|
[HideInInspector] Instancing ("Instancing", Float) = 0 //add this property for instancing variants settings to be shown
|
|
[HideInInspector] m_start_blending ("Blending--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/rendering/blending},hover:Documentation}}", Float) = 0
|
|
[Enum(Thry.BlendOp)]_BlendOp ("RGB Blend Op", Int) = 0
|
|
[Enum(Thry.BlendOp)]_BlendOpAlpha ("Alpha Blend Op", Int) = 0
|
|
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Source Blend", Int) = 1
|
|
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Destination Blend", Int) = 0
|
|
[Space][ThryHeaderLabel(Additive Blending, 13)]
|
|
[Enum(Thry.BlendOp)]_AddBlendOp ("RGB Blend Op", Int) = 0
|
|
[Enum(Thry.BlendOp)]_AddBlendOpAlpha ("Alpha Blend Op", Int) = 0
|
|
[Enum(UnityEngine.Rendering.BlendMode)] _AddSrcBlend ("Source Blend", Int) = 1
|
|
[Enum(UnityEngine.Rendering.BlendMode)] _AddDstBlend ("Destination Blend", Int) = 1
|
|
[HideInInspector] m_end_blending ("Blending", Float) = 0
|
|
[HideInInspector] m_start_StencilPassOptions ("Stencil--{button_help:{text:Tutorial,action:{type:URL,data:https://www.poiyomi.com/rendering/stencil},hover:Documentation}}", Float) = 0
|
|
[ThryWideEnum(Simple, 0, Front Face vs Back Face, 1)] _StencilType ("Stencil Type", Float) = 0
|
|
[IntRange] _StencilRef ("Stencil Reference Value", Range(0, 255)) = 0
|
|
[IntRange] _StencilReadMask ("Stencil ReadMask Value", Range(0, 255)) = 255
|
|
[IntRange] _StencilWriteMask ("Stencil WriteMask Value", Range(0, 255)) = 255
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilPassOp ("Stencil Pass Op--{condition_showS:(_StencilType==0)}", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilFailOp ("Stencil Fail Op--{condition_showS:(_StencilType==0)}", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilZFailOp ("Stencil ZFail Op--{condition_showS:(_StencilType==0)}", Float) = 0
|
|
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilCompareFunction ("Stencil Compare Function--{condition_showS:(_StencilType==0)}", Float) = 8
|
|
[HideInInspector] m_start_StencilPassBackOptions("Back--{condition_showS:(_StencilType==1)}", Float) = 0
|
|
[Helpbox(1)] _FFBFStencilHelp0 ("Front Face and Back Face Stencils only work when locked in due to Unity's Stencil managment", Int) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilBackPassOp ("Back Pass Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilBackFailOp ("Back Fail Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilBackZFailOp ("Back ZFail Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilBackCompareFunction ("Back Compare Function", Float) = 8
|
|
[HideInInspector] m_end_StencilPassBackOptions("Back", Float) = 0
|
|
[HideInInspector] m_start_StencilPassFrontOptions("Front--{condition_showS:(_StencilType==1)}", Float) = 0
|
|
[Helpbox(1)] _FFBFStencilHelp1 ("Front Face and Back Face Stencils only work when locked in due to Unity's Stencil managment", Int) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilFrontPassOp ("Front Pass Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilFrontFailOp ("Front Fail Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.StencilOp)] _StencilFrontZFailOp ("Front ZFail Op", Float) = 0
|
|
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilFrontCompareFunction ("Front Compare Function", Float) = 8
|
|
[HideInInspector] m_end_StencilPassFrontOptions("Front", Float) = 0
|
|
[HideInInspector] m_end_StencilPassOptions ("Stencil", Float) = 0
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "Opaque" "Queue" = "Geometry" "VRCFallback" = "Standard" }
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "ForwardBase" }
|
|
Stencil
|
|
{
|
|
Ref [_StencilRef]
|
|
ReadMask [_StencilReadMask]
|
|
WriteMask [_StencilWriteMask]
|
|
Comp [_StencilCompareFunction]
|
|
Pass [_StencilPassOp]
|
|
Fail [_StencilFailOp]
|
|
ZFail [_StencilZFailOp]
|
|
}
|
|
ZWrite [_ZWrite]
|
|
Cull [_Cull]
|
|
AlphaToMask [_AlphaToCoverage]
|
|
ZTest [_ZTest]
|
|
ColorMask [_ColorMask]
|
|
Offset [_OffsetFactor], [_OffsetUnits]
|
|
BlendOp [_BlendOp], [_BlendOpAlpha]
|
|
Blend [_SrcBlend] [_DstBlend]
|
|
CGPROGRAM
|
|
#define MOCHIE_PBR
|
|
#define POI_AUDIOLINK
|
|
#define POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE
|
|
#define POI_LIGHT_DATA_ADDITIVE_ENABLE
|
|
#define POI_PATHING
|
|
#define POI_VERTEXLIGHT_ON
|
|
#define VIGNETTE_MASKED
|
|
#define _LIGHTINGMODE_REALISTIC
|
|
#define PROP_PATHINGMAP
|
|
#define PROP_PATHINGCOLORMAP
|
|
#define OPTIMIZER_ENABLED
|
|
#pragma target 5.0
|
|
#pragma skip_variants LIGHTMAP_ON DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK DIRLIGHTMAP_COMBINED _MIXED_LIGHTING_SUBTRACTIVE
|
|
#pragma multi_compile_fwdbase
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile_fog
|
|
#pragma multi_compile _ VERTEXLIGHT_ON
|
|
#define POI_PASS_BASE
|
|
#include "UnityCG.cginc"
|
|
#include "UnityStandardUtils.cginc"
|
|
#include "AutoLight.cginc"
|
|
#include "UnityLightingCommon.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#ifdef POI_PASS_META
|
|
#include "UnityMetaPass.cginc"
|
|
#endif
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#define DielectricSpec float4(0.04, 0.04, 0.04, 1.0 - 0.04)
|
|
#define PI float(3.14159265359)
|
|
#define POI2D_SAMPLER_PAN(tex, texSampler, uv, pan) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan))
|
|
#define POI2D_SAMPLER_PANGRAD(tex, texSampler, uv, pan, ddx, ddy) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan, ddx, ddy))
|
|
#define POI2D_SAMPLER(tex, texSampler, uv) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv))
|
|
#define POI2D_PAN(tex, uv, pan) (tex2D(tex, uv + _Time.x * pan))
|
|
#define POI2D(tex, uv) (tex2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D(tex, uv) (UNITY_SAMPLE_TEX2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D_PAN(tex, uv, pan) (UNITY_SAMPLE_TEX2D(tex, uv + _Time.x * pan))
|
|
#define POI2D_MAINTEX_SAMPLER_PAN_INLINED(tex, poiMesh) (POI2D_SAMPLER_PAN(tex, _MainTex, poiUV(poiMesh.uv[tex##UV], tex##_ST), tex##Pan))
|
|
#define POI_SAFE_RGB0 float4(mainTexture.rgb * .0001, 0)
|
|
#define POI_SAFE_RGB1 float4(mainTexture.rgb * .0001, 1)
|
|
#define POI_SAFE_RGBA mainTexture
|
|
#if defined(UNITY_COMPILER_HLSL)
|
|
#define PoiInitStruct(type, name) name = (type)0;
|
|
#else
|
|
#define PoiInitStruct(type, name)
|
|
#endif
|
|
#define POI_ERROR(poiMesh, gridSize) lerp(float3(1, 0, 1), float3(0, 0, 0), fmod(floor((poiMesh.worldPos.x) * gridSize) + floor((poiMesh.worldPos.y) * gridSize) + floor((poiMesh.worldPos.z) * gridSize), 2) == 0)
|
|
#define POI_MODE_OPAQUE 0
|
|
#define POI_MODE_CUTOUT 1
|
|
#define POI_MODE_FADE 2
|
|
#define POI_MODE_TRANSPARENT 3
|
|
#define POI_MODE_ADDITIVE 4
|
|
#define POI_MODE_SOFTADDITIVE 5
|
|
#define POI_MODE_MULTIPLICATIVE 6
|
|
#define POI_MODE_2XMULTIPLICATIVE 7
|
|
#define POI_MODE_TRANSCLIPPING 9
|
|
#define ALPASS_DFT uint2(0,4) //Size: 128, 2
|
|
#define ALPASS_WAVEFORM uint2(0,6) //Size: 128, 16
|
|
#define ALPASS_AUDIOLINK uint2(0,0) //Size: 128, 4
|
|
#define ALPASS_AUDIOBASS uint2(0,0) //Size: 128, 1
|
|
#define ALPASS_AUDIOLOWMIDS uint2(0,1) //Size: 128, 1
|
|
#define ALPASS_AUDIOHIGHMIDS uint2(0,2) //Size: 128, 1
|
|
#define ALPASS_AUDIOTREBLE uint2(0,3) //Size: 128, 1
|
|
#define ALPASS_AUDIOLINKHISTORY uint2(1,0) //Size: 127, 4
|
|
#define ALPASS_GENERALVU uint2(0,22) //Size: 12, 1
|
|
#define ALPASS_CCINTERNAL uint2(12,22) //Size: 12, 2
|
|
#define ALPASS_CCCOLORS uint2(25,22) //Size: 11, 1
|
|
#define ALPASS_CCSTRIP uint2(0,24) //Size: 128, 1
|
|
#define ALPASS_CCLIGHTS uint2(0,25) //Size: 128, 2
|
|
#define ALPASS_AUTOCORRELATOR uint2(0,27) //Size: 128, 1
|
|
#define ALPASS_GENERALVU_INSTANCE_TIME uint2(2,22)
|
|
#define ALPASS_GENERALVU_LOCAL_TIME uint2(3,22)
|
|
#define ALPASS_GENERALVU_NETWORK_TIME uint2(4,22)
|
|
#define ALPASS_GENERALVU_PLAYERINFO uint2(6,22)
|
|
#define ALPASS_FILTEREDAUDIOLINK uint2(0,28) //Size: 16, 4
|
|
#define ALPASS_CHRONOTENSITY uint2(16,28) //Size: 8, 4
|
|
#define ALPASS_THEME_COLOR0 uint2(0,23)
|
|
#define ALPASS_THEME_COLOR1 uint2(1,23)
|
|
#define ALPASS_THEME_COLOR2 uint2(2,23)
|
|
#define ALPASS_THEME_COLOR3 uint2(3,23)
|
|
#define ALPASS_FILTEREDVU uint2(24,28) //Size: 4, 4
|
|
#define ALPASS_FILTEREDVU_INTENSITY uint2(24,28) //Size: 4, 1
|
|
#define ALPASS_FILTEREDVU_MARKER uint2(24,29) //Size: 4, 1
|
|
#define AUDIOLINK_SAMPHIST 3069 // Internal use for algos, do not change.
|
|
#define AUDIOLINK_SAMPLEDATA24 2046
|
|
#define AUDIOLINK_EXPBINS 24
|
|
#define AUDIOLINK_EXPOCT 10
|
|
#define AUDIOLINK_ETOTALBINS (AUDIOLINK_EXPBINS * AUDIOLINK_EXPOCT)
|
|
#define AUDIOLINK_WIDTH 128
|
|
#define AUDIOLINK_SPS 48000 // Samples per second
|
|
#define AUDIOLINK_ROOTNOTE 0
|
|
#define AUDIOLINK_4BAND_FREQFLOOR 0.123
|
|
#define AUDIOLINK_4BAND_FREQCEILING 1
|
|
#define AUDIOLINK_BOTTOM_FREQUENCY 13.75
|
|
#define AUDIOLINK_BASE_AMPLITUDE 2.5
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MIN 0.3
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MAX 0.9
|
|
#define AUDIOLINK_DFT_Q 4.0
|
|
#define AUDIOLINK_TREBLE_CORRECTION 5.0
|
|
#define COLORCHORD_EMAXBIN 192
|
|
#define COLORCHORD_IIR_DECAY_1 0.90
|
|
#define COLORCHORD_IIR_DECAY_2 0.85
|
|
#define COLORCHORD_CONSTANT_DECAY_1 0.01
|
|
#define COLORCHORD_CONSTANT_DECAY_2 0.0
|
|
#define COLORCHORD_NOTE_CLOSEST 3.0
|
|
#define COLORCHORD_NEW_NOTE_GAIN 8.0
|
|
#define COLORCHORD_MAX_NOTES 10
|
|
#ifndef glsl_mod
|
|
#define glsl_mod(x, y) (((x) - (y) * floor((x) / (y))))
|
|
#endif
|
|
uniform float4 _AudioTexture_TexelSize;
|
|
#ifdef SHADER_TARGET_SURFACE_ANALYSIS
|
|
#define AUDIOLINK_STANDARD_INDEXING
|
|
#endif
|
|
#ifdef AUDIOLINK_STANDARD_INDEXING
|
|
sampler2D _AudioTexture;
|
|
#define AudioLinkData(xycoord) tex2Dlod(_AudioTexture, float4(uint2(xycoord) * _AudioTexture_TexelSize.xy, 0, 0))
|
|
#else
|
|
uniform Texture2D<float4> _AudioTexture;
|
|
SamplerState sampler_AudioTexture;
|
|
#define AudioLinkData(xycoord) _AudioTexture[uint2(xycoord)]
|
|
#endif
|
|
uniform sampler2D _Stored;
|
|
uniform float4 _Stored_TexelSize;
|
|
#define LumaData(x,y) tex2Dlod(_Stored, float4(x, y, 0, 0))
|
|
float _Mode;
|
|
float4 _GlobalThemeColor0;
|
|
float4 _GlobalThemeColor1;
|
|
float4 _GlobalThemeColor2;
|
|
float4 _GlobalThemeColor3;
|
|
float _StereoEnabled;
|
|
float _PolarUV;
|
|
float2 _PolarCenter;
|
|
float _PolarRadialScale;
|
|
float _PolarLengthScale;
|
|
float _PolarSpiralPower;
|
|
float _PanoUseBothEyes;
|
|
#ifdef POI_AUDIOLINK
|
|
float _AudioLinkDelay;
|
|
float _AudioLinkAnimToggle;
|
|
float _DebugWaveform;
|
|
float _DebugDFT;
|
|
float _DebugBass;
|
|
float _DebugLowMids;
|
|
float _DebugHighMids;
|
|
float _DebugTreble;
|
|
float _DebugCCColors;
|
|
float _DebugCCStrip;
|
|
float _DebugCCLights;
|
|
float _DebugAutocorrelator;
|
|
float _DebugChronotensity;
|
|
float _AudioLinkCCStripY;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGAOMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingAOMaps;
|
|
#endif
|
|
float4 _LightingAOMaps_ST;
|
|
float2 _LightingAOMapsPan;
|
|
float _LightingAOMapsUV;
|
|
float _LightDataAOStrengthR;
|
|
float _LightDataAOStrengthG;
|
|
float _LightDataAOStrengthB;
|
|
float _LightDataAOStrengthA;
|
|
#if defined(PROP_LIGHTINGDETAILSHADOWMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingDetailShadowMaps;
|
|
#endif
|
|
float4 _LightingDetailShadowMaps_ST;
|
|
float2 _LightingDetailShadowMapsPan;
|
|
float _LightingDetailShadowMapsUV;
|
|
float _LightingDetailShadowStrengthR;
|
|
float _LightingDetailShadowStrengthG;
|
|
float _LightingDetailShadowStrengthB;
|
|
float _LightingDetailShadowStrengthA;
|
|
float _LightingAddDetailShadowStrengthR;
|
|
float _LightingAddDetailShadowStrengthG;
|
|
float _LightingAddDetailShadowStrengthB;
|
|
float _LightingAddDetailShadowStrengthA;
|
|
#if defined(PROP_LIGHTINGSHADOWMASKS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingShadowMasks;
|
|
#endif
|
|
float4 _LightingShadowMasks_ST;
|
|
float2 _LightingShadowMasksPan;
|
|
float _LightingShadowMasksUV;
|
|
float _LightingShadowMaskStrengthR;
|
|
float _LightingShadowMaskStrengthG;
|
|
float _LightingShadowMaskStrengthB;
|
|
float _LightingShadowMaskStrengthA;
|
|
float _Unlit_Intensity;
|
|
float _LightingColorMode;
|
|
float _LightingMapMode;
|
|
float _LightingDirectionMode;
|
|
float3 _LightngForcedDirection;
|
|
float _LightingIndirectUsesNormals;
|
|
float _LightingCapEnabled;
|
|
float _LightingCap;
|
|
float _LightingForceColorEnabled;
|
|
float3 _LightingForcedColor;
|
|
float _LightingForcedColorThemeIndex;
|
|
float _LightingCastedShadows;
|
|
float _LightingMonochromatic;
|
|
float _LightingAdditiveMonochromatic;
|
|
float _LightingMinLightBrightness;
|
|
float _LightingAdditiveLimited;
|
|
float _LightingAdditiveLimit;
|
|
float _LightingAdditivePassthrough;
|
|
float _LightingDebugVisualize;
|
|
float _IgnoreFog;
|
|
float _RenderingReduceClipDistance;
|
|
float _AddBlendOp;
|
|
float4 _Color;
|
|
float _ColorThemeIndex;
|
|
UNITY_DECLARE_TEX2D(_MainTex);
|
|
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
|
float _MainPixelMode;
|
|
float4 _MainTex_ST;
|
|
float2 _MainTexPan;
|
|
float _MainTexUV;
|
|
float4 _MainTex_TexelSize;
|
|
Texture2D _BumpMap;
|
|
float4 _BumpMap_ST;
|
|
float2 _BumpMapPan;
|
|
float _BumpMapUV;
|
|
float _BumpScale;
|
|
Texture2D _ClippingMask;
|
|
float4 _ClippingMask_ST;
|
|
float2 _ClippingMaskPan;
|
|
float _ClippingMaskUV;
|
|
float _Inverse_Clipping;
|
|
float _Cutoff;
|
|
SamplerState sampler_linear_clamp;
|
|
SamplerState sampler_linear_repeat;
|
|
float _AlphaForceOpaque;
|
|
float _AlphaMod;
|
|
float _AlphaPremultiply;
|
|
float _AlphaBoostFA;
|
|
float _ShadowOffset;
|
|
float _ShadowStrength;
|
|
float _LightingIgnoreAmbientColor;
|
|
float _LightingGradientStart;
|
|
float _LightingGradientEnd;
|
|
float3 _LightingShadowColor;
|
|
float _LightingGradientStartWrap;
|
|
float _LightingGradientEndWrap;
|
|
sampler2D _SkinLUT;
|
|
float _SssScale;
|
|
float _SssBumpBlur;
|
|
float3 _SssTransmissionAbsorption;
|
|
float3 _SssColorBleedAoWeights;
|
|
float _LightingAdditiveType;
|
|
float _LightingAdditiveGradientStart;
|
|
float _LightingAdditiveGradientEnd;
|
|
float _LightingAdditiveDetailStrength;
|
|
float4 _MochieReflCube_HDR;
|
|
#ifdef MOCHIE_PBR
|
|
#if defined(PROP_MOCHIEMETALLICMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _MochieMetallicMaps;
|
|
#endif
|
|
float4 _MochieMetallicMaps_ST;
|
|
float2 _MochieMetallicMapsPan;
|
|
float _MochieMetallicMapsUV;
|
|
float _MochieMetallicMapInvert;
|
|
float _MochieRoughnessMapInvert;
|
|
float _MochieReflectionMaskInvert;
|
|
float _MochieSpecularMaskInvert;
|
|
float _MochieReflectionTintThemeIndex;
|
|
float _MochieSpecularTintThemeIndex;
|
|
float _MochieRoughnessMultiplier;
|
|
float _MochieMetallicMultiplier;
|
|
float _MochieReflectionStrength;
|
|
float _MochieSpecularStrength;
|
|
float4 _MochieSpecularTint;
|
|
float4 _MochieReflectionTint;
|
|
float _MochieLitFallback;
|
|
float _IgnoreCastedShadows;
|
|
float _PBRSplitMaskSample;
|
|
float4 _PBRMaskScaleTiling;
|
|
float _MochieMetallicMasksUV;
|
|
float4 _MochieMetallicMasksPan;
|
|
float _Specular2ndLayer;
|
|
float _MochieSpecularStrength2;
|
|
float _MochieRoughnessMultiplier2;
|
|
float _RefSpecFresnel;
|
|
samplerCUBE _MochieReflCube;
|
|
float _MochieForceFallback;
|
|
float _MochieGSAAEnabled;
|
|
float _PoiGSAAVariance;
|
|
float _PoiGSAAThreshold;
|
|
float _BRDFTPSReflectionMaskStrength;
|
|
float _BRDFTPSSpecularMaskStrength;
|
|
float _BRDFTPSDepthEnabled;
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _PathingMap;
|
|
SamplerState SmpRepeatPoint;
|
|
#endif
|
|
float4 _PathingMap_ST;
|
|
float2 _PathingMapPan;
|
|
float _PathingMapUV;
|
|
#if defined(PROP_PATHINGCOLORMAP) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _PathingColorMap;
|
|
#endif
|
|
float4 _PathingColorMap_ST;
|
|
float2 _PathingColorMapPan;
|
|
float _PathingColorMapUV;
|
|
float _PathingOverrideAlpha;
|
|
float _PathTypeR;
|
|
float _PathTypeG;
|
|
float _PathTypeB;
|
|
float _PathTypeA;
|
|
float _PathGradientType;
|
|
half4 _PathWidth;
|
|
float4 _PathTime;
|
|
float4 _PathOffset;
|
|
float4 _PathSpeed;
|
|
float4 _PathColorR;
|
|
float4 _PathColorG;
|
|
float4 _PathColorB;
|
|
float4 _PathColorA;
|
|
float4 _PathEmissionStrength;
|
|
float4 _PathSoftness;
|
|
float4 _PathSegments;
|
|
float _PathColorRThemeIndex;
|
|
float _PathColorGThemeIndex;
|
|
float _PathColorBThemeIndex;
|
|
float _PathColorAThemeIndex;
|
|
#ifdef POI_AUDIOLINK
|
|
float _PathALAutoCorrelator;
|
|
float _PathALAutoCorrelatorR;
|
|
float _PathALAutoCorrelatorG;
|
|
float _PathALAutoCorrelatorB;
|
|
float _PathALAutoCorrelatorA;
|
|
float _PathALHistory;
|
|
float _PathALHistoryBandR;
|
|
float _PathALHistoryR;
|
|
float _PathALHistoryBandG;
|
|
float _PathALHistoryG;
|
|
float _PathALHistoryBandB;
|
|
float _PathALHistoryB;
|
|
float _PathALHistoryBandA;
|
|
float _PathALHistoryA;
|
|
float _PathALCCR;
|
|
float _PathALCCG;
|
|
float _PathALCCB;
|
|
float _PathALCCA;
|
|
float _PathALTimeOffset;
|
|
half _AudioLinkPathTimeOffsetBandR;
|
|
half2 _AudioLinkPathTimeOffsetR;
|
|
half _AudioLinkPathTimeOffsetBandG;
|
|
half2 _AudioLinkPathTimeOffsetG;
|
|
half _AudioLinkPathTimeOffsetBandB;
|
|
half2 _AudioLinkPathTimeOffsetB;
|
|
half _AudioLinkPathTimeOffsetBandA;
|
|
half2 _AudioLinkPathTimeOffsetA;
|
|
float _PathALEmissionOffset;
|
|
half _AudioLinkPathEmissionAddBandR;
|
|
half2 _AudioLinkPathEmissionAddR;
|
|
half _AudioLinkPathEmissionAddBandG;
|
|
half2 _AudioLinkPathEmissionAddG;
|
|
half _AudioLinkPathEmissionAddBandB;
|
|
half2 _AudioLinkPathEmissionAddB;
|
|
half _AudioLinkPathEmissionAddBandA;
|
|
half2 _AudioLinkPathEmissionAddA;
|
|
float _PathALWidthOffset;
|
|
half _AudioLinkPathWidthOffsetBandR;
|
|
half2 _AudioLinkPathWidthOffsetR;
|
|
half _AudioLinkPathWidthOffsetBandG;
|
|
half2 _AudioLinkPathWidthOffsetG;
|
|
half _AudioLinkPathWidthOffsetBandB;
|
|
half2 _AudioLinkPathWidthOffsetB;
|
|
half _AudioLinkPathWidthOffsetBandA;
|
|
half2 _AudioLinkPathWidthOffsetA;
|
|
float _PathALChrono;
|
|
float _PathChronoBandR;
|
|
float _PathChronoTypeR;
|
|
float _PathChronoSpeedR;
|
|
float _PathChronoBandG;
|
|
float _PathChronoTypeG;
|
|
float _PathChronoSpeedG;
|
|
float _PathChronoBandB;
|
|
float _PathChronoTypeB;
|
|
float _PathChronoSpeedB;
|
|
float _PathChronoBandA;
|
|
float _PathChronoTypeA;
|
|
float _PathChronoSpeedA;
|
|
#endif
|
|
#endif
|
|
float _PPLightingMultiplier;
|
|
float _PPLightingAddition;
|
|
float _PPEmissionMultiplier;
|
|
float _PPFinalColorMultiplier;
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
float4 tangent : TANGENT;
|
|
float4 color : COLOR;
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv1 : TEXCOORD1;
|
|
float2 uv2 : TEXCOORD2;
|
|
float2 uv3 : TEXCOORD3;
|
|
uint vertexId : SV_VertexID;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float2 uv[4] : TEXCOORD0;
|
|
float3 objNormal : TEXCOORD4;
|
|
float3 normal : TEXCOORD5;
|
|
float3 tangent : TEXCOORD6;
|
|
float3 binormal : TEXCOORD7;
|
|
float4 worldPos : TEXCOORD8;
|
|
float4 localPos : TEXCOORD9;
|
|
float3 objectPos : TEXCOORD10;
|
|
float4 vertexColor : TEXCOORD11;
|
|
float4 lightmapUV : TEXCOORD12;
|
|
float4 grabPos: TEXCOORD13;
|
|
float4 worldDirection: TEXCOORD14;
|
|
UNITY_SHADOW_COORDS(15)
|
|
UNITY_FOG_COORDS(16)
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
struct PoiMesh
|
|
{
|
|
float3 normals[2];
|
|
float3 objNormal;
|
|
float3 tangentSpaceNormal;
|
|
float3 binormal;
|
|
float3 tangent;
|
|
float3 worldPos;
|
|
float3 localPos;
|
|
float3 objectPosition;
|
|
float isFrontFace;
|
|
float4 vertexColor;
|
|
float4 lightmapUV;
|
|
float2 uv[8];
|
|
float2 parallaxUV;
|
|
};
|
|
struct PoiCam
|
|
{
|
|
float3 viewDir;
|
|
float3 forwardDir;
|
|
float3 worldPos;
|
|
float distanceToVert;
|
|
float4 clipPos;
|
|
float3 reflectionDir;
|
|
float3 vertexReflectionDir;
|
|
float3 tangentViewDir;
|
|
float4 grabPos;
|
|
float2 screenUV;
|
|
float vDotN;
|
|
float4 worldDirection;
|
|
};
|
|
struct PoiMods
|
|
{
|
|
float4 Mask;
|
|
float4 audioLink;
|
|
float audioLinkAvailable;
|
|
float audioLinkVersion;
|
|
float4 audioLinkTexture;
|
|
float audioLinkViaLuma;
|
|
float2 detailMask;
|
|
float2 backFaceDetailIntensity;
|
|
float globalEmission;
|
|
float4 globalColorTheme[12];
|
|
float ALTime[8];
|
|
};
|
|
struct PoiLight
|
|
{
|
|
float3 direction;
|
|
float attenuation;
|
|
float attenuationStrength;
|
|
float3 directColor;
|
|
float3 indirectColor;
|
|
float occlusion;
|
|
float shadowMask;
|
|
float detailShadow;
|
|
float3 halfDir;
|
|
float lightMap;
|
|
float3 rampedLightMap;
|
|
float vertexNDotL;
|
|
float nDotL;
|
|
float nDotV;
|
|
float vertexNDotV;
|
|
float nDotH;
|
|
float vertexNDotH;
|
|
float lDotv;
|
|
float lDotH;
|
|
float nDotLSaturated;
|
|
float nDotLNormalized;
|
|
#ifdef POI_PASS_ADD
|
|
float additiveShadow;
|
|
#endif
|
|
float3 finalLighting;
|
|
float3 finalLightAdd;
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float4 vDotNL;
|
|
float4 vertexVDotNL;
|
|
float3 vColor[4];
|
|
float4 vCorrectedDotNL;
|
|
float4 vAttenuation;
|
|
float4 vAttenuationDotNL;
|
|
float3 vPosition[4];
|
|
float3 vDirection[4];
|
|
float3 vFinalLighting;
|
|
float3 vHalfDir[4];
|
|
half4 vDotNH;
|
|
half4 vertexVDotNH;
|
|
half4 vDotLH;
|
|
#endif
|
|
};
|
|
struct PoiVertexLights
|
|
{
|
|
float3 direction;
|
|
float3 color;
|
|
float attenuation;
|
|
};
|
|
struct PoiFragData
|
|
{
|
|
float3 baseColor;
|
|
float3 finalColor;
|
|
float alpha;
|
|
float3 emission;
|
|
};
|
|
float2 poiUV(float2 uv, float4 tex_st)
|
|
{
|
|
return uv * tex_st.xy + tex_st.zw;
|
|
}
|
|
float calculateluminance(float3 color)
|
|
{
|
|
return color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
|
|
}
|
|
bool IsInMirror()
|
|
{
|
|
return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f;
|
|
}
|
|
bool IsOrthographicCamera()
|
|
{
|
|
return unity_OrthoParams.w == 1 || UNITY_MATRIX_P[3][3] == 1;
|
|
}
|
|
float shEvaluateDiffuseL1Geomerics_local(float L0, float3 L1, float3 n)
|
|
{
|
|
float R0 = max(0, L0);
|
|
float3 R1 = 0.5f * L1;
|
|
float lenR1 = length(R1);
|
|
float q = dot(normalize(R1), n) * 0.5 + 0.5;
|
|
q = saturate(q); // Thanks to ScruffyRuffles for the bug identity.
|
|
float p = 1.0f + 2.0f * lenR1 / R0;
|
|
float a = (1.0f - lenR1 / R0) / (1.0f + lenR1 / R0);
|
|
return R0 * (a + (1.0f - a) * (p + 1.0f) * pow(q, p));
|
|
}
|
|
half3 BetterSH9(half4 normal)
|
|
{
|
|
float3 indirect;
|
|
float3 L0 = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0;
|
|
indirect.r = shEvaluateDiffuseL1Geomerics_local(L0.r, unity_SHAr.xyz, normal.xyz);
|
|
indirect.g = shEvaluateDiffuseL1Geomerics_local(L0.g, unity_SHAg.xyz, normal.xyz);
|
|
indirect.b = shEvaluateDiffuseL1Geomerics_local(L0.b, unity_SHAb.xyz, normal.xyz);
|
|
indirect = max(0, indirect);
|
|
indirect += SHEvalLinearL2(normal);
|
|
return indirect;
|
|
}
|
|
float3 getCameraForward()
|
|
{
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
float3 p1 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 1, 1));
|
|
float3 p2 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 0, 1));
|
|
#else
|
|
float3 p1 = mul(unity_CameraToWorld, float4(0, 0, 1, 1)).xyz;
|
|
float3 p2 = mul(unity_CameraToWorld, float4(0, 0, 0, 1)).xyz;
|
|
#endif
|
|
return normalize(p2 - p1);
|
|
}
|
|
half3 GetSHLength()
|
|
{
|
|
half3 x, x1;
|
|
x.r = length(unity_SHAr);
|
|
x.g = length(unity_SHAg);
|
|
x.b = length(unity_SHAb);
|
|
x1.r = length(unity_SHBr);
|
|
x1.g = length(unity_SHBg);
|
|
x1.b = length(unity_SHBb);
|
|
return x + x1;
|
|
}
|
|
float3 BoxProjection(float3 direction, float3 position, float4 cubemapPosition, float3 boxMin, float3 boxMax)
|
|
{
|
|
#if UNITY_SPECCUBE_BOX_PROJECTION
|
|
if (cubemapPosition.w > 0)
|
|
{
|
|
float3 factors = ((direction > 0 ? boxMax : boxMin) - position) / direction;
|
|
float scalar = min(min(factors.x, factors.y), factors.z);
|
|
direction = direction * scalar + (position - cubemapPosition.xyz);
|
|
}
|
|
#endif
|
|
return direction;
|
|
}
|
|
float poiMax(float2 i)
|
|
{
|
|
return max(i.x, i.y);
|
|
}
|
|
float poiMax(float3 i)
|
|
{
|
|
return max(max(i.x, i.y), i.z);
|
|
}
|
|
float poiMax(float4 i)
|
|
{
|
|
return max(max(max(i.x, i.y), i.z), i.w);
|
|
}
|
|
float3 calculateNormal(in float3 baseNormal, in PoiMesh poiMesh, in Texture2D normalTexture, in float4 normal_ST, in float2 normalPan, in float normalUV, in float normalIntensity)
|
|
{
|
|
float3 normal = UnpackScaleNormal(POI2D_SAMPLER_PAN(normalTexture, _MainTex, poiUV(poiMesh.uv[normalUV], normal_ST), normalPan), normalIntensity);
|
|
return normalize(
|
|
normal.x * poiMesh.tangent +
|
|
normal.y * poiMesh.binormal +
|
|
normal.z * baseNormal
|
|
);
|
|
}
|
|
float remap(float x, float minOld, float maxOld, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float2 remap(float2 x, float2 minOld, float2 maxOld, float2 minNew = 0, float2 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float3 remap(float3 x, float3 minOld, float3 maxOld, float3 minNew = 0, float3 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float4 remap(float4 x, float4 minOld, float4 maxOld, float4 minNew = 0, float4 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float remapClamped(float minOld, float maxOld, float x, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 remapClamped(float2 minOld, float2 maxOld, float2 x, float2 minNew, float2 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float3 remapClamped(float3 minOld, float3 maxOld, float3 x, float3 minNew, float3 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float4 remapClamped(float4 minOld, float4 maxOld, float4 x, float4 minNew, float4 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 calcParallax(in float height, in PoiCam poiCam)
|
|
{
|
|
return ((height * - 1) + 1) * (poiCam.tangentViewDir.xy / poiCam.tangentViewDir.z);
|
|
}
|
|
float4 poiBlend(const float sourceFactor, const float4 sourceColor, const float destinationFactor, const float4 destinationColor, const float4 blendFactor)
|
|
{
|
|
float4 sA = 1 - blendFactor;
|
|
const float4 blendData[11] = {
|
|
float4(0.0, 0.0, 0.0, 0.0),
|
|
float4(1.0, 1.0, 1.0, 1.0),
|
|
destinationColor,
|
|
sourceColor,
|
|
float4(1.0, 1.0, 1.0, 1.0) - destinationColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sourceColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sA,
|
|
saturate(sourceColor.aaaa),
|
|
1 - sA,
|
|
};
|
|
return lerp(blendData[sourceFactor] * sourceColor + blendData[destinationFactor] * destinationColor, sourceColor, sA);
|
|
}
|
|
float3 blendAverage(float3 base, float3 blend)
|
|
{
|
|
return (base + blend) / 2.0;
|
|
}
|
|
float blendColorBurn(float base, float blend)
|
|
{
|
|
return (blend == 0.0)?blend : max((1.0 - ((1.0 - base) / blend)), 0.0);
|
|
}
|
|
float3 blendColorBurn(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorBurn(base.r, blend.r), blendColorBurn(base.g, blend.g), blendColorBurn(base.b, blend.b));
|
|
}
|
|
float blendColorDodge(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendColorDodge(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorDodge(base.r, blend.r), blendColorDodge(base.g, blend.g), blendColorDodge(base.b, blend.b));
|
|
}
|
|
float blendDarken(float base, float blend)
|
|
{
|
|
return min(blend, base);
|
|
}
|
|
float3 blendDarken(float3 base, float3 blend)
|
|
{
|
|
return float3(blendDarken(base.r, blend.r), blendDarken(base.g, blend.g), blendDarken(base.b, blend.b));
|
|
}
|
|
float3 blendExclusion(float3 base, float3 blend)
|
|
{
|
|
return base + blend - 2.0 * base * blend;
|
|
}
|
|
float blendReflect(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base * base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendReflect(float3 base, float3 blend)
|
|
{
|
|
return float3(blendReflect(base.r, blend.r), blendReflect(base.g, blend.g), blendReflect(base.b, blend.b));
|
|
}
|
|
float3 blendGlow(float3 base, float3 blend)
|
|
{
|
|
return blendReflect(blend, base);
|
|
}
|
|
float blendOverlay(float base, float blend)
|
|
{
|
|
return base < 0.5?(2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendOverlay(float3 base, float3 blend)
|
|
{
|
|
return float3(blendOverlay(base.r, blend.r), blendOverlay(base.g, blend.g), blendOverlay(base.b, blend.b));
|
|
}
|
|
float3 blendHardLight(float3 base, float3 blend)
|
|
{
|
|
return blendOverlay(blend, base);
|
|
}
|
|
float blendVividLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendColorBurn(base, (2.0 * blend)) : blendColorDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendVividLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendVividLight(base.r, blend.r), blendVividLight(base.g, blend.g), blendVividLight(base.b, blend.b));
|
|
}
|
|
float blendHardMix(float base, float blend)
|
|
{
|
|
return (blendVividLight(base, blend) < 0.5)?0.0 : 1.0;
|
|
}
|
|
float3 blendHardMix(float3 base, float3 blend)
|
|
{
|
|
return float3(blendHardMix(base.r, blend.r), blendHardMix(base.g, blend.g), blendHardMix(base.b, blend.b));
|
|
}
|
|
float blendLighten(float base, float blend)
|
|
{
|
|
return max(blend, base);
|
|
}
|
|
float3 blendLighten(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLighten(base.r, blend.r), blendLighten(base.g, blend.g), blendLighten(base.b, blend.b));
|
|
}
|
|
float blendLinearBurn(float base, float blend)
|
|
{
|
|
return max(base + blend - 1.0, 0.0);
|
|
}
|
|
float3 blendLinearBurn(float3 base, float3 blend)
|
|
{
|
|
return max(base + blend - float3(1.0, 1.0, 1.0), float3(0.0, 0.0, 0.0));
|
|
}
|
|
float blendLinearDodge(float base, float blend)
|
|
{
|
|
return min(base + blend, 1.0);
|
|
}
|
|
float3 blendLinearDodge(float3 base, float3 blend)
|
|
{
|
|
return min(base + blend, float3(1.0, 1.0, 1.0));
|
|
}
|
|
float blendLinearLight(float base, float blend)
|
|
{
|
|
return blend < 0.5?blendLinearBurn(base, (2.0 * blend)) : blendLinearDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendLinearLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLinearLight(base.r, blend.r), blendLinearLight(base.g, blend.g), blendLinearLight(base.b, blend.b));
|
|
}
|
|
float3 blendMultiply(float3 base, float3 blend)
|
|
{
|
|
return base * blend;
|
|
}
|
|
float3 blendNegation(float3 base, float3 blend)
|
|
{
|
|
return float3(1.0, 1.0, 1.0) - abs(float3(1.0, 1.0, 1.0) - base - blend);
|
|
}
|
|
float3 blendNormal(float3 base, float3 blend)
|
|
{
|
|
return blend;
|
|
}
|
|
float3 blendPhoenix(float3 base, float3 blend)
|
|
{
|
|
return min(base, blend) - max(base, blend) + float3(1.0, 1.0, 1.0);
|
|
}
|
|
float blendPinLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendDarken(base, (2.0 * blend)) : blendLighten(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendPinLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendPinLight(base.r, blend.r), blendPinLight(base.g, blend.g), blendPinLight(base.b, blend.b));
|
|
}
|
|
float blendScreen(float base, float blend)
|
|
{
|
|
return 1.0 - ((1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendScreen(float3 base, float3 blend)
|
|
{
|
|
return float3(blendScreen(base.r, blend.r), blendScreen(base.g, blend.g), blendScreen(base.b, blend.b));
|
|
}
|
|
float blendSoftLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?(2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend));
|
|
}
|
|
float3 blendSoftLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendSoftLight(base.r, blend.r), blendSoftLight(base.g, blend.g), blendSoftLight(base.b, blend.b));
|
|
}
|
|
float blendSubtract(float base, float blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float3 blendSubtract(float3 base, float3 blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float blendDifference(float base, float blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float3 blendDifference(float3 base, float3 blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float blendDivide(float base, float blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 blendDivide(float3 base, float3 blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 customBlend(float3 base, float3 blend, float blendType)
|
|
{
|
|
float3 ret = 0;
|
|
switch(blendType)
|
|
{
|
|
case 0:
|
|
{
|
|
ret = blendNormal(base, blend);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ret = blendDarken(base, blend);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ret = blendMultiply(base, blend);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
ret = blendColorBurn(base, blend);
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
ret = blendLinearBurn(base, blend);
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
ret = blendLighten(base, blend);
|
|
break;
|
|
}
|
|
case 6:
|
|
{
|
|
ret = blendScreen(base, blend);
|
|
break;
|
|
}
|
|
case 7:
|
|
{
|
|
ret = blendColorDodge(base, blend);
|
|
break;
|
|
}
|
|
case 8:
|
|
{
|
|
ret = blendLinearDodge(base, blend);
|
|
break;
|
|
}
|
|
case 9:
|
|
{
|
|
ret = blendOverlay(base, blend);
|
|
break;
|
|
}
|
|
case 10:
|
|
{
|
|
ret = blendSoftLight(base, blend);
|
|
break;
|
|
}
|
|
case 11:
|
|
{
|
|
ret = blendHardLight(base, blend);
|
|
break;
|
|
}
|
|
case 12:
|
|
{
|
|
ret = blendVividLight(base, blend);
|
|
break;
|
|
}
|
|
case 13:
|
|
{
|
|
ret = blendLinearLight(base, blend);
|
|
break;
|
|
}
|
|
case 14:
|
|
{
|
|
ret = blendPinLight(base, blend);
|
|
break;
|
|
}
|
|
case 15:
|
|
{
|
|
ret = blendHardMix(base, blend);
|
|
break;
|
|
}
|
|
case 16:
|
|
{
|
|
ret = blendDifference(base, blend);
|
|
break;
|
|
}
|
|
case 17:
|
|
{
|
|
ret = blendExclusion(base, blend);
|
|
break;
|
|
}
|
|
case 18:
|
|
{
|
|
ret = blendSubtract(base, blend);
|
|
break;
|
|
}
|
|
case 19:
|
|
{
|
|
ret = blendDivide(base, blend);
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
float random(float2 p)
|
|
{
|
|
return frac(sin(dot(p, float2(12.9898, 78.2383))) * 43758.5453123);
|
|
}
|
|
float2 random2(float2 p)
|
|
{
|
|
return frac(sin(float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)))) * 43758.5453);
|
|
}
|
|
float3 random3(float3 p)
|
|
{
|
|
return frac(sin(float3(dot(p, float3(127.1, 311.7, 248.6)), dot(p, float3(269.5, 183.3, 423.3)), dot(p, float3(248.3, 315.9, 184.2)))) * 43758.5453);
|
|
}
|
|
float3 randomFloat3(float2 Seed, float maximum)
|
|
{
|
|
return (.5 + float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * .5) * (maximum);
|
|
}
|
|
float3 randomFloat3Range(float2 Seed, float Range)
|
|
{
|
|
return (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1) * Range;
|
|
}
|
|
float3 randomFloat3WiggleRange(float2 Seed, float Range, float wiggleSpeed)
|
|
{
|
|
float3 rando = (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1);
|
|
float speed = 1 + wiggleSpeed;
|
|
return float3(sin((_Time.x + rando.x * PI) * speed), sin((_Time.x + rando.y * PI) * speed), sin((_Time.x + rando.z * PI) * speed)) * Range;
|
|
}
|
|
void poiDither(float4 In, float4 ScreenPosition, out float4 Out)
|
|
{
|
|
float2 uv = ScreenPosition.xy * _ScreenParams.xy;
|
|
float DITHER_THRESHOLDS[16] = {
|
|
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
|
|
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
|
|
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
|
|
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
|
|
};
|
|
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
|
|
Out = In - DITHER_THRESHOLDS[index];
|
|
}
|
|
static const float Epsilon = 1e-10;
|
|
static const float3 HCYwts = float3(0.299, 0.587, 0.114);
|
|
static const float HCLgamma = 3;
|
|
static const float HCLy0 = 100;
|
|
static const float HCLmaxL = 0.530454533953517; // == exp(HCLgamma / HCLy0) - 0.5
|
|
static const float3 wref = float3(1.0, 1.0, 1.0);
|
|
#define TAU 6.28318531
|
|
float3 HUEtoRGB(in float H)
|
|
{
|
|
float R = abs(H * 6 - 3) - 1;
|
|
float G = 2 - abs(H * 6 - 2);
|
|
float B = 2 - abs(H * 6 - 4);
|
|
return saturate(float3(R, G, B));
|
|
}
|
|
float3 RGBtoHCV(in float3 RGB)
|
|
{
|
|
float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0 / 3.0) : float4(RGB.gb, 0.0, -1.0 / 3.0);
|
|
float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
|
|
float C = Q.x - min(Q.w, Q.y);
|
|
float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
|
|
return float3(H, C, Q.x);
|
|
}
|
|
float3 HSVtoRGB(in float3 HSV)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSV.x);
|
|
return ((RGB - 1) * HSV.y + 1) * HSV.z;
|
|
}
|
|
float3 RGBtoHSV(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float S = HCV.y / (HCV.z + Epsilon);
|
|
return float3(HCV.x, S, HCV.z);
|
|
}
|
|
float3 HSLtoRGB(in float3 HSL)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSL.x);
|
|
float C = (1 - abs(2 * HSL.z - 1)) * HSL.y;
|
|
return (RGB - 0.5) * C + HSL.z;
|
|
}
|
|
float3 RGBtoHSL(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float L = HCV.z - HCV.y * 0.5;
|
|
float S = HCV.y / (1 - abs(L * 2 - 1) + Epsilon);
|
|
return float3(HCV.x, S, L);
|
|
}
|
|
float3 hueShift(float3 color, float hueOffset)
|
|
{
|
|
color = RGBtoHSV(color);
|
|
color.x = frac(hueOffset +color.x);
|
|
return HSVtoRGB(color);
|
|
}
|
|
float xyzF(float t)
|
|
{
|
|
return lerp(pow(t, 1. / 3.), 7.787037 * t + 0.139731, step(t, 0.00885645));
|
|
}
|
|
float xyzR(float t)
|
|
{
|
|
return lerp(t * t * t, 0.1284185 * (t - 0.139731), step(t, 0.20689655));
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float x, float y, float z)
|
|
{
|
|
float angleX = radians(x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float3 angles)
|
|
{
|
|
float angleX = radians(angles.x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(angles.y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(angles.z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float3 getCameraPosition()
|
|
{
|
|
#ifdef USING_STEREO_MATRICES
|
|
return lerp(unity_StereoWorldSpaceCameraPos[0], unity_StereoWorldSpaceCameraPos[1], 0.5);
|
|
#endif
|
|
return _WorldSpaceCameraPos;
|
|
}
|
|
half2 calcScreenUVs(half4 grabPos)
|
|
{
|
|
half2 uv = grabPos.xy / (grabPos.w + 0.0000000001);
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
uv.xy *= half2(_ScreenParams.x * 2, _ScreenParams.y);
|
|
#else
|
|
uv.xy *= _ScreenParams.xy;
|
|
#endif
|
|
return uv;
|
|
}
|
|
float CalcMipLevel(float2 texture_coord)
|
|
{
|
|
float2 dx = ddx(texture_coord);
|
|
float2 dy = ddy(texture_coord);
|
|
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
|
|
return 0.5 * log2(delta_max_sqr);
|
|
}
|
|
float inverseLerp(float A, float B, float T)
|
|
{
|
|
return (T - A) / (B - A);
|
|
}
|
|
float inverseLerp2(float2 a, float2 b, float2 value)
|
|
{
|
|
float2 AB = b - a;
|
|
float2 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp3(float3 a, float3 b, float3 value)
|
|
{
|
|
float3 AB = b - a;
|
|
float3 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp4(float4 a, float4 b, float4 value)
|
|
{
|
|
float4 AB = b - a;
|
|
float4 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float4 quaternion_conjugate(float4 v)
|
|
{
|
|
return float4(
|
|
v.x, -v.yzw
|
|
);
|
|
}
|
|
float4 quaternion_mul(float4 v1, float4 v2)
|
|
{
|
|
float4 result1 = (v1.x * v2 + v1 * v2.x);
|
|
float4 result2 = float4(
|
|
- dot(v1.yzw, v2.yzw),
|
|
cross(v1.yzw, v2.yzw)
|
|
);
|
|
return float4(result1 + result2);
|
|
}
|
|
float4 get_quaternion_from_angle(float3 axis, float angle)
|
|
{
|
|
float sn = sin(angle * 0.5);
|
|
float cs = cos(angle * 0.5);
|
|
return float4(axis * sn, cs);
|
|
}
|
|
float4 quaternion_from_vector(float3 inVec)
|
|
{
|
|
return float4(0.0, inVec);
|
|
}
|
|
float degree_to_radius(float degree)
|
|
{
|
|
return (
|
|
degree / 180.0 * PI
|
|
);
|
|
}
|
|
float3 rotate_with_quaternion(float3 inVec, float3 rotation)
|
|
{
|
|
float4 qx = get_quaternion_from_angle(float3(1, 0, 0), radians(rotation.x));
|
|
float4 qy = get_quaternion_from_angle(float3(0, 1, 0), radians(rotation.y));
|
|
float4 qz = get_quaternion_from_angle(float3(0, 0, 1), radians(rotation.z));
|
|
#define MUL3(A, B, C) quaternion_mul(quaternion_mul((A), (B)), (C))
|
|
float4 quaternion = normalize(MUL3(qx, qy, qz));
|
|
float4 conjugate = quaternion_conjugate(quaternion);
|
|
float4 inVecQ = quaternion_from_vector(inVec);
|
|
float3 rotated = (
|
|
MUL3(quaternion, inVecQ, conjugate)
|
|
).yzw;
|
|
return rotated;
|
|
}
|
|
float4 transform(float4 input, float4 pos, float4 rotation, float4 scale)
|
|
{
|
|
input.rgb *= (scale.xyz * scale.w);
|
|
input = float4(rotate_with_quaternion(input.xyz, rotation.xyz * rotation.w) + (pos.xyz * pos.w), input.w);
|
|
return input;
|
|
}
|
|
float3 poiThemeColor(in PoiMods poiMods, in float3 srcColor, in float themeIndex)
|
|
{
|
|
if (themeIndex == 0) return srcColor;
|
|
themeIndex -= 1;
|
|
if (themeIndex <= 3)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#endif
|
|
return srcColor;
|
|
}
|
|
float lilIsIn0to1(float f)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, 1.0));
|
|
}
|
|
float lilIsIn0to1(float f, float nv)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, nv));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border)
|
|
{
|
|
return (value - border) / clamp(fwidth(value), 0.0001, 1.0);
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
return smoothstep(border - fwidthValue, border + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float poiEdgeLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float3 OpenLitLinearToSRGB(float3 col)
|
|
{
|
|
return LinearToGammaSpace(col);
|
|
}
|
|
float3 OpenLitSRGBToLinear(float3 col)
|
|
{
|
|
return GammaToLinearSpace(col);
|
|
}
|
|
float OpenLitLuminance(float3 rgb)
|
|
{
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
return dot(rgb, float3(0.22, 0.707, 0.071));
|
|
#else
|
|
return dot(rgb, float3(0.0396819152, 0.458021790, 0.00609653955));
|
|
#endif
|
|
}
|
|
float OpenLitGray(float3 rgb)
|
|
{
|
|
return dot(rgb, float3(1.0/3.0, 1.0/3.0, 1.0/3.0));
|
|
}
|
|
void OpenLitShadeSH9ToonDouble(float3 lightDirection, out float3 shMax, out float3 shMin)
|
|
{
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 N = lightDirection * 0.666666;
|
|
float4 vB = N.xyzz * N.yzzx;
|
|
float3 res = float3(unity_SHAr.w,unity_SHAg.w,unity_SHAb.w);
|
|
res.r += dot(unity_SHBr, vB);
|
|
res.g += dot(unity_SHBg, vB);
|
|
res.b += dot(unity_SHBb, vB);
|
|
res += unity_SHC.rgb * (N.x * N.x - N.y * N.y);
|
|
float3 l1;
|
|
l1.r = dot(unity_SHAr.rgb, N);
|
|
l1.g = dot(unity_SHAg.rgb, N);
|
|
l1.b = dot(unity_SHAb.rgb, N);
|
|
shMax = res + l1;
|
|
shMin = res - l1;
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
shMax = OpenLitLinearToSRGB(shMax);
|
|
shMin = OpenLitLinearToSRGB(shMin);
|
|
#endif
|
|
#else
|
|
shMax = 0.0;
|
|
shMin = 0.0;
|
|
#endif
|
|
}
|
|
float3 OpenLitComputeCustomLightDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 customDir = length(lightDirectionOverride.xyz) * normalize(mul((float3x3)unity_ObjectToWorld, lightDirectionOverride.xyz));
|
|
return lightDirectionOverride.w ? customDir : lightDirectionOverride.xyz; // .w isn't doc'd anywhere and is always 0 unless end user changes it
|
|
}
|
|
float3 OpenLitLightingDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 mainDir = _WorldSpaceLightPos0.xyz * OpenLitLuminance(_LightColor0.rgb);
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 sh9Dir = unity_SHAr.xyz * 0.333333 + unity_SHAg.xyz * 0.333333 + unity_SHAb.xyz * 0.333333;
|
|
float3 sh9DirAbs = float3(sh9Dir.x, abs(sh9Dir.y), sh9Dir.z);
|
|
#else
|
|
float3 sh9Dir = 0;
|
|
float3 sh9DirAbs = 0;
|
|
#endif
|
|
float3 customDir = OpenLitComputeCustomLightDirection(lightDirectionOverride);
|
|
return normalize(sh9DirAbs + mainDir + customDir);
|
|
}
|
|
float3 OpenLitLightingDirection()
|
|
{
|
|
float4 customDir = float4(0.001,0.002,0.001,0.0);
|
|
return OpenLitLightingDirection(customDir);
|
|
}
|
|
inline float4 CalculateFrustumCorrection()
|
|
{
|
|
float x1 = -UNITY_MATRIX_P._31 / (UNITY_MATRIX_P._11 * UNITY_MATRIX_P._34);
|
|
float x2 = -UNITY_MATRIX_P._32 / (UNITY_MATRIX_P._22 * UNITY_MATRIX_P._34);
|
|
return float4(x1, x2, 0, UNITY_MATRIX_P._33 / UNITY_MATRIX_P._34 + x1 * UNITY_MATRIX_P._13 + x2 * UNITY_MATRIX_P._23);
|
|
}
|
|
inline float CorrectedLinearEyeDepth(float z, float B)
|
|
{
|
|
return 1.0 / (z / UNITY_MATRIX_P._34 + B);
|
|
}
|
|
float2 sharpSample( float4 texelSize , float2 p )
|
|
{
|
|
p = p*texelSize.zw;
|
|
float2 c = max(0.0, fwidth(p));
|
|
p = floor(p) + saturate(frac(p) / c);
|
|
p = (p - 0.5)*texelSize.xy;
|
|
return p;
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
float4 AudioLinkDataMultiline(uint2 xycoord) { return AudioLinkData(uint2(xycoord.x % AUDIOLINK_WIDTH, xycoord.y + xycoord.x/AUDIOLINK_WIDTH)); }
|
|
float4 AudioLinkLerp(float2 xy) { return lerp( AudioLinkData(xy), AudioLinkData(xy+int2(1,0)), frac( xy.x ) ); }
|
|
float4 AudioLinkLerpMultiline(float2 xy) { return lerp(AudioLinkDataMultiline(xy), AudioLinkDataMultiline(xy+float2(1,0)), frac(xy.x)); }
|
|
bool AudioLinkIsAvailable()
|
|
{
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
int width, height;
|
|
_AudioTexture.GetDimensions(width, height);
|
|
return width > 16;
|
|
#else
|
|
return _AudioTexture_TexelSize.z > 16;
|
|
#endif
|
|
}
|
|
float AudioLinkGetVersion()
|
|
{
|
|
int2 dims;
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
_AudioTexture.GetDimensions(dims.x, dims.y);
|
|
#else
|
|
dims = _AudioTexture_TexelSize.zw;
|
|
#endif
|
|
if (dims.x >= 128)
|
|
return AudioLinkData(ALPASS_GENERALVU).x;
|
|
else if (dims.x > 16)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
#define AudioLinkGetSelfPixelData(xy) _SelfTexture2D[xy]
|
|
uint AudioLinkDecodeDataAsUInt(uint2 indexloc)
|
|
{
|
|
uint4 rpx = AudioLinkData(indexloc);
|
|
return rpx.r + rpx.g*1024 + rpx.b * 1048576 + rpx.a * 1073741824;
|
|
}
|
|
float AudioLinkDecodeDataAsSeconds(uint2 indexloc)
|
|
{
|
|
uint time = AudioLinkDecodeDataAsUInt(indexloc) & 0x7ffffff;
|
|
return float(time / 1000) + float( time % 1000 ) / 1000.;
|
|
}
|
|
#define ALDecodeDataAsSeconds( x ) AudioLinkDecodeDataAsSeconds( x )
|
|
#define ALDecodeDataAsUInt( x ) AudioLinkDecodeDataAsUInt( x )
|
|
float AudioLinkRemap(float t, float a, float b, float u, float v) { return ((t-a) / (b-a)) * (v-u) + u; }
|
|
float3 AudioLinkHSVtoRGB(float3 HSV)
|
|
{
|
|
float3 RGB = 0;
|
|
float C = HSV.z * HSV.y;
|
|
float H = HSV.x * 6;
|
|
float X = C * (1 - abs(fmod(H, 2) - 1));
|
|
if (HSV.y != 0)
|
|
{
|
|
float I = floor(H);
|
|
if (I == 0) { RGB = float3(C, X, 0); }
|
|
else if (I == 1) { RGB = float3(X, C, 0); }
|
|
else if (I == 2) { RGB = float3(0, C, X); }
|
|
else if (I == 3) { RGB = float3(0, X, C); }
|
|
else if (I == 4) { RGB = float3(X, 0, C); }
|
|
else { RGB = float3(C, 0, X); }
|
|
}
|
|
float M = HSV.z - C;
|
|
return RGB + M;
|
|
}
|
|
float3 AudioLinkCCtoRGB(float bin, float intensity, int rootNote)
|
|
{
|
|
float note = bin / AUDIOLINK_EXPBINS;
|
|
float hue = 0.0;
|
|
note *= 12.0;
|
|
note = glsl_mod(4. - note + rootNote, 12.0);
|
|
{
|
|
if(note < 4.0)
|
|
{
|
|
hue = (note) / 24.0;
|
|
}
|
|
else if(note < 8.0)
|
|
{
|
|
hue = (note-2.0) / 12.0;
|
|
}
|
|
else
|
|
{
|
|
hue = (note - 4.0) / 8.0;
|
|
}
|
|
}
|
|
float val = intensity - 0.1;
|
|
return AudioLinkHSVtoRGB(float3(fmod(hue, 1.0), 1.0, clamp(val, 0.0, 1.0)));
|
|
}
|
|
float4 AudioLinkGetAmplitudeAtFrequency(float hertz)
|
|
{
|
|
float note = AUDIOLINK_EXPBINS * log2(hertz / AUDIOLINK_BOTTOM_FREQUENCY);
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(note, 0));
|
|
}
|
|
float AudioLinkGetAmplitudeAtNote(float octave, float note)
|
|
{
|
|
float quarter = note * 2.0;
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(octave * AUDIOLINK_EXPBINS + quarter, 0));
|
|
}
|
|
float AudioLinkGetChronoTime(uint index, uint band)
|
|
{
|
|
return (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(index, band))) / 100000.0;
|
|
}
|
|
float AudioLinkGetChronoTimeNormalized(uint index, uint band, float speed)
|
|
{
|
|
return frac(AudioLinkGetChronoTime(index, band) * speed);
|
|
}
|
|
float AudioLinkGetChronoTimeInterval(uint index, uint band, float speed, float interval)
|
|
{
|
|
return AudioLinkGetChronoTimeNormalized(index, band, speed) * interval;
|
|
}
|
|
float getBandAtTime(float band, float time, float size = 1.0f)
|
|
{
|
|
return remapClamped(min(size,.9999), 1, AudioLinkData(ALPASS_AUDIOBASS + uint2(time * AUDIOLINK_WIDTH,band)).r);
|
|
}
|
|
fixed3 maximize(fixed3 c) {
|
|
if (c.x == 0 && c.y == 0 && c.z == 0)
|
|
return fixed3(1.0, 1.0, 1.0);
|
|
else
|
|
return c / max(c.r, max(c.g, c.b));
|
|
}
|
|
bool LumaIsAvailable()
|
|
{
|
|
return LumaData(0.629, 0.511).r > 0.9;
|
|
}
|
|
float3 getLumaGradient(uint index, float offset) {
|
|
return LumaData(0.57 + (index * 0.11) + lerp(0, 0.107, offset), 0.493);
|
|
}
|
|
void initPoiAudioLink(inout PoiMods poiMods)
|
|
{
|
|
if (!(1.0 /*_AudioLinkAnimToggle*/)) return;
|
|
if (AudioLinkIsAvailable())
|
|
{
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkVersion = AudioLinkGetVersion();
|
|
poiMods.audioLink.x = AudioLinkData(ALPASS_AUDIOBASS).r;
|
|
poiMods.audioLink.y = AudioLinkData(ALPASS_AUDIOLOWMIDS).r;
|
|
poiMods.audioLink.z = AudioLinkData(ALPASS_AUDIOHIGHMIDS).r;
|
|
poiMods.audioLink.w = AudioLinkData(ALPASS_AUDIOTREBLE).r;
|
|
poiMods.globalColorTheme[4] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(2, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[5] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(3, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[6] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(4, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[7] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(5, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[8] = AudioLinkData(ALPASS_THEME_COLOR0);
|
|
poiMods.globalColorTheme[9] = AudioLinkData(ALPASS_THEME_COLOR1);
|
|
poiMods.globalColorTheme[10] = AudioLinkData(ALPASS_THEME_COLOR2);
|
|
poiMods.globalColorTheme[11] = AudioLinkData(ALPASS_THEME_COLOR3);
|
|
return;
|
|
}
|
|
if (LumaIsAvailable())
|
|
{
|
|
float4 audioPixel = LumaData(0.578, 0.515);
|
|
float audioLows = audioPixel.r;
|
|
float audioHighs = audioPixel.g;
|
|
float4 zone1 = LumaData(0.856, 0.522);
|
|
float4 zone2 = LumaData(0.856, 0.507);
|
|
float4 zone3 = LumaData(0.864, 0.522);
|
|
float4 zone4 = LumaData(0.864, 0.507);
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkViaLuma = true;
|
|
poiMods.audioLink.xy = audioLows;
|
|
poiMods.audioLink.zw = audioHighs;
|
|
poiMods.globalColorTheme[8] = zone1;
|
|
poiMods.globalColorTheme[9] = zone2;
|
|
poiMods.globalColorTheme[10] = zone3;
|
|
poiMods.globalColorTheme[11] = zone4;
|
|
}
|
|
}
|
|
void DebugVisualizer(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiMods poiMods){
|
|
if (_DebugWaveform){
|
|
float waveform = AudioLinkLerpMultiline(ALPASS_WAVEFORM + float2( 500. * poiMesh.uv[0].x, 0)).r;
|
|
poiFragData.emission += clamp(1 - 50 * abs(waveform - poiMesh.uv[0].y * 2. + 1), 0, 1);
|
|
}
|
|
if (_DebugDFT){
|
|
poiFragData.emission += AudioLinkLerpMultiline(ALPASS_DFT + uint2(poiMesh.uv[0].x * AUDIOLINK_ETOTALBINS, 0)).rrr;
|
|
}
|
|
if (_DebugBass){
|
|
poiFragData.emission += poiMods.audioLink.x;
|
|
}
|
|
if (_DebugLowMids){
|
|
poiFragData.emission += poiMods.audioLink.y;
|
|
}
|
|
if (_DebugHighMids){
|
|
poiFragData.emission += poiMods.audioLink.z;
|
|
}
|
|
if (_DebugTreble){
|
|
poiFragData.emission += poiMods.audioLink.w;
|
|
}
|
|
if (_DebugCCColors){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCCOLORS + uint2(3 + 1, 0));
|
|
}
|
|
if (_DebugCCStrip){
|
|
poiFragData.emission += AudioLinkLerp(ALPASS_CCSTRIP + float2(poiMesh.uv[0].x * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if (_DebugCCLights){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCLIGHTS + uint2(uint(poiMesh.uv[0].x * 8) + uint(poiMesh.uv[0].y * 16) * 8, 0));
|
|
}
|
|
if (_DebugAutocorrelator){
|
|
poiFragData.emission += saturate(AudioLinkLerp(ALPASS_AUTOCORRELATOR + float2((abs(1. - poiMesh.uv[0].x * 2.)) * AUDIOLINK_WIDTH, 0)).rrr);
|
|
}
|
|
if (_DebugChronotensity){
|
|
poiFragData.emission += (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(1, 0)) % 1000000) / 1000000.0;
|
|
}
|
|
}
|
|
void SetupAudioLink(inout PoiFragData poiFragData, inout PoiMods poiMods, in PoiMesh poiMesh){
|
|
initPoiAudioLink(poiMods);
|
|
DebugVisualizer(poiFragData, poiMesh, poiMods);
|
|
if(_AudioLinkCCStripY)
|
|
{
|
|
poiFragData.emission += AudioLinkLerp( ALPASS_CCSTRIP + float2( poiMesh.uv[0].y * AUDIOLINK_WIDTH, 0 ) ).rgb * .5;
|
|
}
|
|
}
|
|
#endif
|
|
v2f vert(appdata v)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
PoiInitStruct(v2f, o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
o.objectPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz;
|
|
o.objNormal = v.normal;
|
|
o.normal = UnityObjectToWorldNormal(v.normal);
|
|
o.tangent = UnityObjectToWorldDir(v.tangent);
|
|
o.binormal = cross(o.normal, o.tangent) * (v.tangent.w * unity_WorldTransformParams.w);
|
|
o.vertexColor = v.color;
|
|
o.uv[0] = v.uv0;
|
|
o.uv[1] = v.uv1;
|
|
o.uv[2] = v.uv2;
|
|
o.uv[3] = v.uv3;
|
|
#if defined(LIGHTMAP_ON)
|
|
o.lightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.lightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
o.localPos = v.vertex;
|
|
o.worldPos = mul(unity_ObjectToWorld, o.localPos);
|
|
float3 localOffset = float3(0, 0, 0);
|
|
float3 worldOffset = float3(0, 0, 0);
|
|
o.localPos.rgb += localOffset;
|
|
o.worldPos.rgb += worldOffset;
|
|
o.pos = UnityObjectToClipPos(o.localPos);
|
|
#ifdef POI_PASS_OUTLINE
|
|
#if defined(UNITY_REVERSED_Z)
|
|
o.pos.z += _Offset_Z * - 0.01;
|
|
#else
|
|
o.pos.z += _Offset_Z * 0.01;
|
|
#endif
|
|
#endif
|
|
o.grabPos = ComputeGrabScreenPos(o.pos);
|
|
#ifndef FORWARD_META_PASS
|
|
#if !defined(UNITY_PASS_SHADOWCASTER)
|
|
UNITY_TRANSFER_SHADOW(o, o.uv[0].xy);
|
|
#else
|
|
TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos);
|
|
#endif
|
|
#endif
|
|
UNITY_TRANSFER_FOG(o, o.pos);
|
|
if ((0.0 /*_RenderingReduceClipDistance*/))
|
|
{
|
|
if (o.pos.w < _ProjectionParams.y * 1.01 && o.pos.w > 0)
|
|
{
|
|
o.pos.z = o.pos.z * 0.0001 + o.pos.w * 0.999;
|
|
}
|
|
}
|
|
#ifdef POI_PASS_META
|
|
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
|
#endif
|
|
#if defined(GRAIN)
|
|
float4 worldDirection;
|
|
worldDirection.xyz = o.worldPos.xyz - _WorldSpaceCameraPos;
|
|
worldDirection.w = dot(o.pos, CalculateFrustumCorrection());
|
|
o.worldDirection = worldDirection;
|
|
#endif
|
|
return o;
|
|
}
|
|
void calculateGlobalThemes(inout PoiMods poiMods)
|
|
{
|
|
poiMods.globalColorTheme[0] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[1] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[2] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[3] = float4(1,1,1,1);
|
|
}
|
|
float2 calculatePolarCoordinate(in PoiMesh poiMesh)
|
|
{
|
|
float2 delta = poiMesh.uv[(0.0 /*_PolarUV*/)] - float4(0.5,0.5,0,0);
|
|
float radius = length(delta) * 2 * (1.0 /*_PolarRadialScale*/);
|
|
float angle = atan2(delta.x, delta.y) * 1.0 / 6.28 * (1.0 /*_PolarLengthScale*/);
|
|
return float2(radius, angle + distance(poiMesh.uv[(0.0 /*_PolarUV*/)], float4(0.5,0.5,0,0)) * (0.0 /*_PolarSpiralPower*/));
|
|
}
|
|
float2 MonoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(1.0 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(1.0, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).zw;
|
|
}
|
|
float2 StereoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(0.5 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(0.5, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).zw;
|
|
}
|
|
float2 calculatePanosphereUV(in PoiMesh poiMesh)
|
|
{
|
|
float3 viewDirection = normalize(lerp(getCameraPosition().xyz, _WorldSpaceCameraPos.xyz, (1.0 /*_PanoUseBothEyes*/)) - poiMesh.worldPos.xyz) * - 1;
|
|
return lerp(MonoPanoProjection(viewDirection), StereoPanoProjection(viewDirection), (0.0 /*_StereoEnabled*/));
|
|
}
|
|
void applyAlphaOptions(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam, in PoiMods poiMods)
|
|
{
|
|
poiFragData.alpha = saturate(poiFragData.alpha + (0.0 /*_AlphaMod*/));
|
|
}
|
|
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_BRANCH_DETAIL) || defined(GEOM_TYPE_FROND) || defined(DEPTH_OF_FIELD_COC_VIEW)
|
|
float2 decalUV(float uvNumber, float4 uv_st, float2 position, half rotation, half rotationSpeed, half2 scale, float4 scaleOffset, float depth, in PoiMesh poiMesh, in PoiCam poiCam)
|
|
{
|
|
scaleOffset = float4(-scaleOffset.x, scaleOffset.y, -scaleOffset.z, scaleOffset.w);
|
|
float2 uv = poiUV(poiMesh.uv[uvNumber], uv_st) + calcParallax(depth + 1, poiCam);
|
|
float2 decalCenter = position;
|
|
float theta = radians(rotation + _Time.z * rotationSpeed);
|
|
float cs = cos(theta);
|
|
float sn = sin(theta);
|
|
uv = float2((uv.x - decalCenter.x) * cs - (uv.y - decalCenter.y) * sn + decalCenter.x, (uv.x - decalCenter.x) * sn + (uv.y - decalCenter.y) * cs + decalCenter.y);
|
|
uv = remap(uv, float2(0, 0) - scale / 2 + position + scaleOffset.xz, scale / 2 + position + scaleOffset.yw, float2(0, 0), float2(1, 1));
|
|
return uv;
|
|
}
|
|
inline float3 decalHueShift(float enabled, float3 color, float shift, float shiftSpeed)
|
|
{
|
|
if (enabled)
|
|
{
|
|
color = hueShift(color, shift + _Time.x * shiftSpeed);
|
|
}
|
|
return color;
|
|
}
|
|
inline float applyTilingClipping(float enabled, float2 uv)
|
|
{
|
|
float ret = 1;
|
|
if (!enabled)
|
|
{
|
|
if (uv.x > 1 || uv.y > 1 || uv.x < 0 || uv.y < 0)
|
|
{
|
|
ret = 0;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
void applyDecals(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam, in PoiMods poiMods, in PoiLight poiLight)
|
|
{
|
|
float decalAlpha = 1;
|
|
float alphaOverride = 0;
|
|
#if defined(PROP_DECALMASK) || !defined(OPTIMIZER_ENABLED)
|
|
float4 decalMask = POI2D_SAMPLER_PAN(_DecalMask, _MainTex, poiUV(poiMesh.uv[(0.0 /*_DecalMaskUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#else
|
|
float4 decalMask = 1;
|
|
#endif
|
|
#ifdef TPS_Penetrator
|
|
if ((0.0 /*_DecalTPSDepthMaskEnabled*/))
|
|
{
|
|
decalMask.r = lerp(0, decalMask.r * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal0TPSMaskStrength*/));
|
|
decalMask.g = lerp(0, decalMask.g * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal1TPSMaskStrength*/));
|
|
decalMask.b = lerp(0, decalMask.b * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal2TPSMaskStrength*/));
|
|
decalMask.a = lerp(0, decalMask.a * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal3TPSMaskStrength*/));
|
|
}
|
|
#endif
|
|
float4 decalColor = 1;
|
|
float2 uv = 0;
|
|
float2 decalScale = float2(1, 1);
|
|
float decalRotation = 0;
|
|
float2 ddxuv = 0;
|
|
float2 ddyuv = 0;
|
|
float4 sideMod = 0;
|
|
if (alphaOverride)
|
|
{
|
|
poiFragData.alpha *= decalAlpha;
|
|
}
|
|
poiFragData.baseColor = saturate(poiFragData.baseColor);
|
|
}
|
|
#endif
|
|
#ifdef VIGNETTE_MASKED
|
|
float _LightingWrappedWrap;
|
|
float _LightingWrappedNormalization;
|
|
float RTWrapFunc(in float dt, in float w, in float norm)
|
|
{
|
|
float cw = saturate(w);
|
|
float o = (dt + cw) / ((1.0 + cw) * (1.0 + cw * norm));
|
|
float flt = 1.0 - 0.85 * norm;
|
|
if (w > 1.0)
|
|
{
|
|
o = lerp(o, flt, w - 1.0);
|
|
}
|
|
return o;
|
|
}
|
|
float3 GreenWrapSH(float fA) // Greens unoptimized and non-normalized
|
|
{
|
|
float fAs = saturate(fA);
|
|
float4 t = float4(fA + 1, fAs - 1, fA - 2, fAs + 1); // DJL edit: allow wrapping to L0-only at w=2
|
|
return float3(t.x, -t.z * t.x / 3, 0.25 * t.y * t.y * t.w);
|
|
}
|
|
float3 GreenWrapSHOpt(float fW) // optimised and normalized https://blog.selfshadow.com/2012/01/07/righting-wrap-part-2/
|
|
{
|
|
const float4 t0 = float4(0.0, 1.0 / 4.0, -1.0 / 3.0, -1.0 / 2.0);
|
|
const float4 t1 = float4(1.0, 2.0 / 3.0, 1.0 / 4.0, 0.0);
|
|
float3 fWs = float3(fW, fW, saturate(fW)); // DJL edit: allow wrapping to L0-only at w=2
|
|
float3 r;
|
|
r.xyz = t0.xxy * fWs + t0.xzw;
|
|
r.xyz = r.xyz * fWs + t1.xyz;
|
|
return r;
|
|
}
|
|
float3 ShadeSH9_wrapped(float3 normal, float wrap)
|
|
{
|
|
float3 x0, x1, x2;
|
|
float3 conv = lerp(GreenWrapSH(wrap), GreenWrapSHOpt(wrap), (0.0 /*_LightingWrappedNormalization*/)); // Should try optimizing this...
|
|
conv *= float3(1, 1.5, 4); // Undo pre-applied cosine convolution by using the inverse
|
|
x0 = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);
|
|
float3 L2_0 = float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / - 3.0;
|
|
x0 -= L2_0;
|
|
x1.r = dot(unity_SHAr.xyz, normal);
|
|
x1.g = dot(unity_SHAg.xyz, normal);
|
|
x1.b = dot(unity_SHAb.xyz, normal);
|
|
float4 vB = normal.xyzz * normal.yzzx;
|
|
x2.r = dot(unity_SHBr, vB);
|
|
x2.g = dot(unity_SHBg, vB);
|
|
x2.b = dot(unity_SHBb, vB);
|
|
float vC = normal.x * normal.x - normal.y * normal.y;
|
|
x2 += unity_SHC.rgb * vC;
|
|
x2 += L2_0;
|
|
return x0 * conv.x + x1 * conv.y + x2 * conv.z;
|
|
}
|
|
float3 GetSHDirectionL1()
|
|
{
|
|
return Unity_SafeNormalize((unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz));
|
|
}
|
|
half3 GetSHMaxL1()
|
|
{
|
|
float3 maxDirection = GetSHDirectionL1();
|
|
return ShadeSH9_wrapped(maxDirection, 0);
|
|
}
|
|
void ApplySubtractiveLighting(inout UnityIndirect indirectLight)
|
|
{
|
|
#if SUBTRACTIVE_LIGHTING
|
|
poiLight.attenuation = FadeShadows(lerp(1, poiLight.attenuation, _AttenuationMultiplier));
|
|
float ndotl = saturate(dot(i.normal, _WorldSpaceLightPos0.xyz));
|
|
float3 shadowedLightEstimate = ndotl * (1 - poiLight.attenuation) * _LightColor0.rgb;
|
|
float3 subtractedLight = indirectLight.diffuse - shadowedLightEstimate;
|
|
subtractedLight = max(subtractedLight, unity_ShadowColor.rgb);
|
|
subtractedLight = lerp(subtractedLight, indirectLight.diffuse, _LightShadowData.x);
|
|
indirectLight.diffuse = min(subtractedLight, indirectLight.diffuse);
|
|
#endif
|
|
}
|
|
UnityIndirect CreateIndirectLight(in PoiMesh poiMesh, in PoiCam poiCam, in PoiLight poiLight)
|
|
{
|
|
UnityIndirect indirectLight;
|
|
indirectLight.diffuse = 0;
|
|
indirectLight.specular = 0;
|
|
#if defined(LIGHTMAP_ON)
|
|
indirectLight.diffuse = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, poiMesh.lightmapUV.xy));
|
|
#if defined(DIRLIGHTMAP_COMBINED)
|
|
float4 lightmapDirection = UNITY_SAMPLE_TEX2D_SAMPLER(
|
|
unity_LightmapInd, unity_Lightmap, poiMesh.lightmapUV.xy
|
|
);
|
|
indirectLight.diffuse = DecodeDirectionalLightmap(
|
|
indirectLight.diffuse, lightmapDirection, poiMesh.normals[1]
|
|
);
|
|
#endif
|
|
ApplySubtractiveLighting(indirectLight);
|
|
#endif
|
|
#if defined(DYNAMICLIGHTMAP_ON)
|
|
float3 dynamicLightDiffuse = DecodeRealtimeLightmap(
|
|
UNITY_SAMPLE_TEX2D(unity_DynamicLightmap, poiMesh.lightmapUV.zw)
|
|
);
|
|
#if defined(DIRLIGHTMAP_COMBINED)
|
|
float4 dynamicLightmapDirection = UNITY_SAMPLE_TEX2D_SAMPLER(
|
|
unity_DynamicDirectionality, unity_DynamicLightmap,
|
|
poiMesh.lightmapUV.zw
|
|
);
|
|
indirectLight.diffuse += DecodeDirectionalLightmap(
|
|
dynamicLightDiffuse, dynamicLightmapDirection, poiMesh.normals[1]
|
|
);
|
|
#else
|
|
indirectLight.diffuse += dynamicLightDiffuse;
|
|
#endif
|
|
#endif
|
|
#if !defined(LIGHTMAP_ON) && !defined(DYNAMICLIGHTMAP_ON)
|
|
#if UNITY_LIGHT_PROBE_PROXY_VOLUME
|
|
if (unity_ProbeVolumeParams.x == 1)
|
|
{
|
|
indirectLight.diffuse = SHEvalLinearL0L1_SampleProbeVolume(
|
|
float4(poiMesh.normals[1], 1), poiMesh.worldPos
|
|
);
|
|
indirectLight.diffuse = max(0, indirectLight.diffuse);
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
indirectLight.diffuse = LinearToGammaSpace(indirectLight.diffuse);
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
indirectLight.diffuse += max(0, ShadeSH9(float4(poiMesh.normals[1], 1)));
|
|
}
|
|
#else
|
|
indirectLight.diffuse += max(0, ShadeSH9(float4(poiMesh.normals[1], 1)));
|
|
#endif
|
|
#endif
|
|
indirectLight.diffuse *= poiLight.occlusion;
|
|
return indirectLight;
|
|
}
|
|
void calculateShading(inout PoiLight poiLight, inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam)
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
float shadowStrength = (1.0 /*_ShadowStrength*/) * poiLight.shadowMask;
|
|
#ifdef POI_PASS_OUTLINE
|
|
shadowStrength = lerp(0, shadowStrength, _OutlineShadowStrength);
|
|
#endif
|
|
#ifdef _LIGHTINGMODE_REALISTIC
|
|
UnityLight light;
|
|
light.dir = poiLight.direction;
|
|
light.color = saturate(_LightColor0.rgb * lerp(1, poiLight.attenuation, poiLight.attenuationStrength) * poiLight.detailShadow);
|
|
light.ndotl = poiLight.nDotLSaturated;
|
|
poiLight.rampedLightMap = poiLight.nDotLSaturated;
|
|
poiLight.finalLighting = max(UNITY_BRDF_PBS(1, 0, 0, 0, poiMesh.normals[1], poiCam.viewDir, light, CreateIndirectLight(poiMesh, poiCam, poiLight)).xyz, (0.0 /*_LightingMinLightBrightness*/));
|
|
#endif
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if ((0.0 /*_LightingAdditiveType*/) == 0)
|
|
{
|
|
poiLight.rampedLightMap = max(0, poiLight.nDotL);
|
|
poiLight.finalLighting = poiLight.directColor * poiLight.attenuation * max(0, poiLight.nDotL) * poiLight.detailShadow * poiLight.additiveShadow;
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 1)
|
|
{
|
|
#if defined(POINT_COOKIE) || defined(DIRECTIONAL_COOKIE)
|
|
float passthrough = 0;
|
|
#else
|
|
float passthrough = (0.5 /*_LightingAdditivePassthrough*/);
|
|
#endif
|
|
if ((0.5 /*_LightingAdditiveGradientEnd*/) == (0.0 /*_LightingAdditiveGradientStart*/)) (0.5 /*_LightingAdditiveGradientEnd*/) += 0.001;
|
|
poiLight.rampedLightMap = smoothstep((0.5 /*_LightingAdditiveGradientEnd*/), (0.0 /*_LightingAdditiveGradientStart*/), 1 - (.5 * poiLight.nDotL + .5));
|
|
#if defined(POINT) || defined(SPOT)
|
|
poiLight.finalLighting = lerp(poiLight.directColor * max(min(poiLight.additiveShadow, poiLight.detailShadow), passthrough), poiLight.indirectColor, smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), 1 - (.5 * poiLight.nDotL + .5))) * poiLight.attenuation;
|
|
#else
|
|
poiLight.finalLighting = lerp(poiLight.directColor * max(min(poiLight.attenuation, poiLight.detailShadow), passthrough), poiLight.indirectColor, smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), 1 - (.5 * poiLight.nDotL + .5)));
|
|
#endif
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 2)
|
|
{
|
|
}
|
|
#endif
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float3 vertexLighting = float3(0, 0, 0);
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
if ((0.0 /*_LightingAdditiveType*/) == 0)
|
|
{
|
|
vertexLighting += poiLight.vColor[index] * poiLight.vAttenuationDotNL[index] * poiLight.detailShadow; // Realistic
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 1) // Toon
|
|
{
|
|
vertexLighting += lerp(poiLight.vColor[index] * poiLight.vAttenuation[index], poiLight.vColor[index] * (0.5 /*_LightingAdditivePassthrough*/) * poiLight.vAttenuation[index], smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), .5 * poiLight.vDotNL[index] + .5)) * poiLight.detailShadow;
|
|
}
|
|
}
|
|
float3 mixedLight = poiLight.finalLighting;
|
|
poiLight.finalLighting = vertexLighting + poiLight.finalLighting;
|
|
#endif
|
|
}
|
|
#endif
|
|
#if defined(MOCHIE_PBR) || defined(POI_CLEARCOAT)
|
|
float GSAA_Filament(float3 worldNormal, float perceptualRoughness, float gsaaVariance, float gsaaThreshold)
|
|
{
|
|
float3 du = ddx(worldNormal);
|
|
float3 dv = ddy(worldNormal);
|
|
float variance = gsaaVariance * (dot(du, du) + dot(dv, dv));
|
|
float roughness = perceptualRoughness * perceptualRoughness;
|
|
float kernelRoughness = min(2.0 * variance, gsaaThreshold);
|
|
float squareRoughness = saturate(roughness * roughness + kernelRoughness);
|
|
return sqrt(sqrt(squareRoughness));
|
|
}
|
|
bool SceneHasReflections()
|
|
{
|
|
float width, height;
|
|
unity_SpecCube0.GetDimensions(width, height);
|
|
return !(width * height < 2);
|
|
}
|
|
float3 GetWorldReflections(float3 reflDir, float3 worldPos, float roughness)
|
|
{
|
|
float3 baseReflDir = reflDir;
|
|
reflDir = BoxProjection(reflDir, worldPos, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax);
|
|
float4 envSample0 = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
|
|
float3 p0 = DecodeHDR(envSample0, unity_SpecCube0_HDR);
|
|
float interpolator = unity_SpecCube0_BoxMin.w;
|
|
|
|
if (interpolator < 0.99999)
|
|
{
|
|
float3 refDirBlend = BoxProjection(baseReflDir, worldPos, unity_SpecCube1_ProbePosition, unity_SpecCube1_BoxMin, unity_SpecCube1_BoxMax);
|
|
float4 envSample1 = UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(unity_SpecCube1, unity_SpecCube0, refDirBlend, roughness * UNITY_SPECCUBE_LOD_STEPS);
|
|
float3 p1 = DecodeHDR(envSample1, unity_SpecCube1_HDR);
|
|
p0 = lerp(p1, p0, interpolator);
|
|
}
|
|
return p0;
|
|
}
|
|
float3 GetReflections(in PoiCam poiCam, in PoiLight pl, in PoiMesh poiMesh, float roughness, float ForceFallback, float LightFallback, samplerCUBE reflectionCube, float3 reflectionDir)
|
|
{
|
|
float3 reflections = 0;
|
|
float3 lighting = pl.finalLighting;
|
|
if (ForceFallback == 0)
|
|
{
|
|
|
|
if (SceneHasReflections())
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = GetWorldReflections(reflectionDir, poiMesh.worldPos.xyz, roughness);
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * lerp(1, pl.finalLighting, LightFallback);
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if (LightFallback)
|
|
{
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * pl.finalLighting;
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * lerp(1, pl.finalLighting, LightFallback);
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if (LightFallback)
|
|
{
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * pl.finalLighting;
|
|
}
|
|
#endif
|
|
}
|
|
reflections *= pl.occlusion;
|
|
return reflections;
|
|
}
|
|
float GetGGXTerm(float nDotL, float nDotV, float nDotH, float roughness)
|
|
{
|
|
float visibilityTerm = 0;
|
|
if (nDotL > 0)
|
|
{
|
|
float rough = roughness;
|
|
float rough2 = roughness * roughness;
|
|
float lambdaV = nDotL * (nDotV * (1 - rough) + rough);
|
|
float lambdaL = nDotV * (nDotL * (1 - rough) + rough);
|
|
visibilityTerm = 0.5f / (lambdaV + lambdaL + 1e-5f);
|
|
float d = (nDotH * rough2 - nDotH) * nDotH + 1.0f;
|
|
float dotTerm = UNITY_INV_PI * rough2 / (d * d + 1e-7f);
|
|
visibilityTerm *= dotTerm * UNITY_PI;
|
|
}
|
|
return visibilityTerm;
|
|
}
|
|
void GetSpecFresTerm(float nDotL, float nDotV, float nDotH, float lDotH, inout float3 specularTerm, inout float3 fresnelTerm, float3 specCol, float roughness)
|
|
{
|
|
specularTerm = GetGGXTerm(nDotL, nDotV, nDotH, roughness);
|
|
fresnelTerm = FresnelTerm(specCol, lDotH);
|
|
specularTerm = max(0, specularTerm * max(0.00001, nDotL));
|
|
}
|
|
float GetRoughness(float smoothness)
|
|
{
|
|
float rough = 1 - smoothness;
|
|
rough *= 1.7 - 0.7 * rough;
|
|
return rough;
|
|
}
|
|
#endif
|
|
#ifdef MOCHIE_PBR
|
|
void MochieBRDF(inout PoiFragData poiFragData, in PoiCam poiCam, inout PoiLight poiLight, in PoiMesh poiMesh, in PoiMods poiMods)
|
|
{
|
|
float smoothness = (0.4 /*_MochieRoughnessMultiplier*/);
|
|
float smoothness2 = (0.8 /*_MochieRoughnessMultiplier2*/);
|
|
float metallic = (0.0 /*_MochieMetallicMultiplier*/);
|
|
float specularMask = 1;
|
|
float reflectionMask = 1;
|
|
#if defined(PROP_MOCHIEMETALLICMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 PRBMaps = POI2D_SAMPLER_PAN(_MochieMetallicMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_MochieMetallicMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0).xy);
|
|
|
|
if ((0.0 /*_PBRSplitMaskSample*/))
|
|
{
|
|
PRBMaps.zw = POI2D_SAMPLER_PAN(_MochieMetallicMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_MochieMetallicMasksUV*/)], float4(1,1,0,0)), float4(0,0,0,0).xy).zw;
|
|
}
|
|
metallic *= PRBMaps.r;
|
|
smoothness = (smoothness * PRBMaps.g);
|
|
smoothness2 = (smoothness2 * PRBMaps.g);
|
|
reflectionMask *= PRBMaps.b;
|
|
specularMask *= PRBMaps.a;
|
|
#endif
|
|
reflectionMask *= (0.05 /*_MochieReflectionStrength*/);
|
|
specularMask *= (1.0 /*_MochieSpecularStrength*/);
|
|
if ((0.0 /*_MochieSpecularMaskInvert*/))
|
|
{
|
|
specularMask = 1 - specularMask;
|
|
}
|
|
if ((0.0 /*_MochieReflectionMaskInvert*/))
|
|
{
|
|
reflectionMask = 1 - reflectionMask;
|
|
}
|
|
#ifdef TPS_Penetrator
|
|
if ((0.0 /*_BRDFTPSDepthEnabled*/))
|
|
{
|
|
reflectionMask = lerp(0, reflectionMask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_BRDFTPSReflectionMaskStrength*/));
|
|
specularMask = lerp(0, specularMask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_BRDFTPSSpecularMaskStrength*/));
|
|
}
|
|
#endif
|
|
if ((0.0 /*_MochieRoughnessMapInvert*/))
|
|
{
|
|
smoothness = 1 - smoothness;
|
|
smoothness2 = 1 - smoothness2;
|
|
}
|
|
float roughness = GetRoughness(smoothness);
|
|
float roughness2 = GetRoughness(smoothness2);
|
|
if ((0.0 /*_MochieMetallicMapInvert*/))
|
|
{
|
|
metallic = 1 - metallic;
|
|
}
|
|
float3 specCol = lerp(unity_ColorSpaceDielectricSpec.rgb, poiFragData.baseColor, metallic);
|
|
float omr = unity_ColorSpaceDielectricSpec.a - metallic * unity_ColorSpaceDielectricSpec.a;
|
|
float percepRough = 1 - smoothness;
|
|
float percepRough2 = 1 - smoothness2;
|
|
|
|
if ((1.0 /*_MochieGSAAEnabled*/))
|
|
{
|
|
percepRough = GSAA_Filament(poiMesh.normals[1], percepRough, (0.15 /*_PoiGSAAVariance*/), (0.1 /*_PoiGSAAThreshold*/));
|
|
if ((1.0 /*_Specular2ndLayer*/) == 1 && (1.0 /*_MochieSpecularStrength2*/) > 0)
|
|
{
|
|
percepRough2 = GSAA_Filament(poiMesh.normals[1], percepRough2, (0.15 /*_PoiGSAAVariance*/), (0.1 /*_PoiGSAAThreshold*/));
|
|
}
|
|
}
|
|
float brdfRoughness = percepRough * percepRough;
|
|
brdfRoughness = max(brdfRoughness, 0.002);
|
|
float brdfRoughness2 = percepRough2 * percepRough2;
|
|
brdfRoughness2 = max(brdfRoughness2, 0.002);
|
|
float3 diffuse = poiFragData.baseColor;
|
|
float3 specular = 0;
|
|
float3 specular2 = 0;
|
|
float3 vSpecular = 0;
|
|
float3 vSpecular2 = 0;
|
|
float3 reflections = 0;
|
|
float3 environment = 0;
|
|
float attenuation = min(poiLight.nDotLSaturated, lerp(poiLight.attenuation, 1, (0.0 /*_IgnoreCastedShadows*/)));
|
|
float3 fresnelTerm = 1;
|
|
float3 specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.nDotL, poiLight.nDotV, poiLight.nDotH, poiLight.lDotH, specularTerm, fresnelTerm, specCol, brdfRoughness);
|
|
specular = poiLight.directColor * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * attenuation;
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
fresnelTerm = 1;
|
|
specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.vDotNL[index], poiLight.nDotV, poiLight.vDotNH[index], poiLight.vDotLH[index], specularTerm, fresnelTerm, specCol, brdfRoughness);
|
|
vSpecular += poiLight.vColor[index] * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * poiLight.vAttenuation[index];
|
|
}
|
|
#endif
|
|
if ((1.0 /*_Specular2ndLayer*/) == 1)
|
|
{
|
|
float3 fresnelTerm = 1;
|
|
float3 specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.nDotL, poiLight.nDotV, poiLight.nDotH, poiLight.lDotH, specularTerm, fresnelTerm, specCol, brdfRoughness2);
|
|
specular2 = poiLight.directColor * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * attenuation * (1.0 /*_MochieSpecularStrength2*/);
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
fresnelTerm = 1;
|
|
specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.vDotNL[index], poiLight.nDotV, poiLight.vDotNH[index], poiLight.vDotLH[index], specularTerm, fresnelTerm, specCol, brdfRoughness2);
|
|
vSpecular2 += poiLight.vColor[index] * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * poiLight.vAttenuation[index] * (1.0 /*_MochieSpecularStrength2*/);
|
|
}
|
|
#endif
|
|
}
|
|
float surfaceReduction = (1.0 / (brdfRoughness * brdfRoughness + 1.0));
|
|
float grazingTerm = saturate(smoothness + (1 - omr));
|
|
float3 reflCol = GetReflections(poiCam, poiLight, poiMesh, roughness, (0.0 /*_MochieForceFallback*/), (0.0 /*_MochieLitFallback*/), _MochieReflCube, poiCam.reflectionDir);
|
|
reflections = surfaceReduction * reflCol * lerp(1, FresnelLerp(specCol, grazingTerm, poiLight.nDotV), (1.0 /*_RefSpecFresnel*/));
|
|
reflections *= poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieReflectionTintThemeIndex*/));
|
|
reflections *= reflectionMask;
|
|
#ifdef POI_PASS_ADD
|
|
reflections *= poiLight.attenuation;
|
|
#endif
|
|
diffuse = lerp(diffuse, diffuse * omr, reflectionMask);
|
|
environment = max(specular + vSpecular, specular2 + vSpecular2);
|
|
environment += reflections;
|
|
diffuse *= poiLight.finalLighting;
|
|
poiFragData.finalColor = diffuse;
|
|
poiLight.finalLightAdd += environment;
|
|
}
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
void applyPathing(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiMods poiMods)
|
|
{
|
|
float3 albedo = poiFragData.baseColor;
|
|
float3 pathEmission;
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
float4 path = _PathingMap.Sample(SmpRepeatPoint, poiUV(poiMesh.uv[(0.0 /*_PathingMapUV*/)], float4(1,1,0,0)) + float4(0,0,0,0).xy * _Time.x);
|
|
#else
|
|
float4 path = float4(1, 1, 1, 1);
|
|
#endif
|
|
float4 PathColor[4];
|
|
half pathAudioLinkPathTimeOffsetBand[4] = {
|
|
0, 0, 0, 0
|
|
};
|
|
half2 pathAudioLinkTimeOffset[4] = {
|
|
half2(0, 0), half2(0, 0), half2(0, 0), half2(0, 0)
|
|
};
|
|
half pathAudioLinkPathWidthOffsetBand[4] = {
|
|
0, 0, 0, 0
|
|
};
|
|
half2 pathAudioLinkWidthOffset[4] = {
|
|
half2(0, 0), half2(0, 0), half2(0, 0), half2(0, 0)
|
|
};
|
|
PathColor[0] = float4(1.498039,0,0,0);
|
|
PathColor[1] = float4(0,1.498039,0,0);
|
|
PathColor[2] = float4(0,0,1.498039,0);
|
|
PathColor[3] = float4(1.498039,1.498039,1.498039,0);
|
|
if ((0.0 /*_PathGradientType*/) == 1)
|
|
{
|
|
path = (path.r + path.g + path.b + path.a) * .25;
|
|
}
|
|
#if defined(PROP_PATHINGCOLORMAP) || !defined(OPTIMIZER_ENABLED)
|
|
float4 pathColorMap = POI2D_SAMPLER_PAN(_PathingColorMap, _MainTex, poiUV(poiMesh.uv[(0.0 /*_PathingColorMapUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#else
|
|
float4 pathColorMap = float4(1, 1, 1, 1);
|
|
#endif
|
|
float4 pathAudioLinkEmission = 0;
|
|
float4 pathTime = 0;
|
|
float3 pathAlpha[4] = {
|
|
float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)
|
|
};
|
|
#ifdef POI_AUDIOLINK
|
|
float4 chronoType = float4((2.0 /*_PathChronoTypeR*/), (2.0 /*_PathChronoTypeG*/), (2.0 /*_PathChronoTypeB*/), (0.0 /*_PathChronoTypeA*/));
|
|
float4 chronoBand = float4((0.0 /*_PathChronoBandR*/), (1.0 /*_PathChronoBandG*/), (0.0 /*_PathChronoBandB*/), (0.0 /*_PathChronoBandA*/));
|
|
float4 chronoSpeed = float4((0.3 /*_PathChronoSpeedR*/), (0.4 /*_PathChronoSpeedG*/), (0.2 /*_PathChronoSpeedB*/), (0.0 /*_PathChronoSpeedA*/));
|
|
float4 autoCorrelator = float4((0.0 /*_PathALAutoCorrelatorR*/), (0.0 /*_PathALAutoCorrelatorG*/), (0.0 /*_PathALAutoCorrelatorB*/), (0.0 /*_PathALAutoCorrelatorA*/));
|
|
float2 history[4] = {
|
|
float2((1.0 /*_PathALHistoryR*/), (0.0 /*_PathALHistoryBandR*/)), float2((1.0 /*_PathALHistoryG*/), (0.0 /*_PathALHistoryBandG*/)), float2((1.0 /*_PathALHistoryB*/), (0.0 /*_PathALHistoryBandB*/)), float2((0.0 /*_PathALHistoryA*/), (0.0 /*_PathALHistoryBandA*/))
|
|
};
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALTimeOffset*/))
|
|
{
|
|
pathAudioLinkPathTimeOffsetBand[0] = (0.0 /*_AudioLinkPathTimeOffsetBandR*/);
|
|
pathAudioLinkPathTimeOffsetBand[1] = (1.0 /*_AudioLinkPathTimeOffsetBandG*/);
|
|
pathAudioLinkPathTimeOffsetBand[2] = (2.0 /*_AudioLinkPathTimeOffsetBandB*/);
|
|
pathAudioLinkPathTimeOffsetBand[3] = (0.0 /*_AudioLinkPathTimeOffsetBandA*/);
|
|
pathAudioLinkTimeOffset[0] = float4(0,0.7,0,1).xy;
|
|
pathAudioLinkTimeOffset[1] = float4(0,-0.6,0,1).xy;
|
|
pathAudioLinkTimeOffset[2] = float4(0,0.6,0,1).xy;
|
|
pathAudioLinkTimeOffset[3] = float4(0,0,0,1).xy;
|
|
}
|
|
if ((1.0 /*_PathALWidthOffset*/))
|
|
{
|
|
pathAudioLinkPathWidthOffsetBand[0] = (0.0 /*_AudioLinkPathWidthOffsetBandR*/);
|
|
pathAudioLinkPathWidthOffsetBand[1] = (1.0 /*_AudioLinkPathWidthOffsetBandG*/);
|
|
pathAudioLinkPathWidthOffsetBand[2] = (0.0 /*_AudioLinkPathWidthOffsetBandB*/);
|
|
pathAudioLinkPathWidthOffsetBand[3] = (0.0 /*_AudioLinkPathWidthOffsetBandA*/);
|
|
pathAudioLinkWidthOffset[0] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[1] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[2] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[3] = float4(0,0,0,1).xy;
|
|
}
|
|
if ((1.0 /*_PathALEmissionOffset*/))
|
|
{
|
|
pathAudioLinkEmission.r += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(2.0 /*_AudioLinkPathEmissionAddBandR*/)]);
|
|
pathAudioLinkEmission.g += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(1.0 /*_AudioLinkPathEmissionAddBandG*/)]);
|
|
pathAudioLinkEmission.b += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(2.0 /*_AudioLinkPathEmissionAddBandB*/)]);
|
|
pathAudioLinkEmission.a += lerp(float4(0,0,0,1).x, float4(0,0,0,1).y, poiMods.audioLink[(0.0 /*_AudioLinkPathEmissionAddBandA*/)]);
|
|
}
|
|
if ((0.0 /*_PathALCCR*/))
|
|
{
|
|
PathColor[0] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[0] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCG*/))
|
|
{
|
|
PathColor[1] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[1] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCB*/))
|
|
{
|
|
PathColor[2] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[2] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCA*/))
|
|
{
|
|
PathColor[3] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[3] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
}
|
|
#endif
|
|
[unroll]
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
float timeOffset = 0;
|
|
#ifdef POI_AUDIOLINK
|
|
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALTimeOffset*/))
|
|
{
|
|
timeOffset += lerp(pathAudioLinkTimeOffset[index].x, pathAudioLinkTimeOffset[index].y, poiMods.audioLink[pathAudioLinkPathTimeOffsetBand[index]]);
|
|
}
|
|
if ((0.0 /*_PathALChrono*/))
|
|
{
|
|
timeOffset += AudioLinkGetChronoTime(chronoType[index], chronoBand[index]) * chronoSpeed[index];
|
|
}
|
|
}
|
|
#endif
|
|
pathTime[index] = float4(-999,-999,-999,1)[index] != -999.0f ? frac(float4(-999,-999,-999,1)[index] + float4(0,0,0,1)[index] + timeOffset) : frac(_Time.x * float4(1,-2.5,4,1)[index] + float4(0,0,0,1)[index] + timeOffset);
|
|
if (float4(0,0,0,1)[index])
|
|
{
|
|
float pathSegments = abs(float4(0,0,0,1)[index]);
|
|
pathTime = (ceil(pathTime * pathSegments) - .5) / pathSegments;
|
|
}
|
|
if (path[index])
|
|
{
|
|
half pathWidth = float4(0.8,0.75,0.9,1)[index] * .5;
|
|
#ifdef POI_AUDIOLINK
|
|
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALWidthOffset*/))
|
|
{
|
|
pathWidth += lerp(pathAudioLinkWidthOffset[index].x, pathAudioLinkWidthOffset[index].y, poiMods.audioLink[pathAudioLinkPathWidthOffsetBand[index]]);
|
|
}
|
|
}
|
|
#endif
|
|
pathAlpha[index].x = pathTime[index] > path[index];
|
|
pathAlpha[index].y = saturate((1 - abs(lerp(-pathWidth, 1 + pathWidth, pathTime[index]) - path[index])) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index].z = saturate((1 - distance(pathTime[index], path[index])) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index].z += saturate(distance(pathTime[index], path[index]) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index] = smoothstep(0, float4(0.8,0.9,0.9,1)[index] + .00001, pathAlpha[index]);
|
|
#ifdef POI_AUDIOLINK
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((0.0 /*_PathALHistory*/) && history[index].x)
|
|
{
|
|
pathAlpha[index] *= AudioLinkLerp(ALPASS_AUDIOLINK + float2(path[index] * AUDIOLINK_WIDTH, history[index].y)).r;
|
|
}
|
|
if ((0.0 /*_PathALAutoCorrelator*/) && autoCorrelator[index] != 0)
|
|
{
|
|
float autoCorrelatorUV = path[index];
|
|
if (autoCorrelator[index] == 2)
|
|
{
|
|
autoCorrelatorUV = abs(1. - path[index] * 2.);
|
|
}
|
|
pathAlpha[index] *= AudioLinkLerp(ALPASS_AUTOCORRELATOR + float2(autoCorrelatorUV * AUDIOLINK_WIDTH, 0)).r;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
pathEmission = 0;
|
|
pathEmission += pathAlpha[0][(2.0 /*_PathTypeR*/)] * poiThemeColor(poiMods, PathColor[0].rgb, (0.0 /*_PathColorRThemeIndex*/)) * (float4(5,5,5,1)[0] + pathAudioLinkEmission.r);
|
|
pathEmission += pathAlpha[1][(2.0 /*_PathTypeG*/)] * poiThemeColor(poiMods, PathColor[1].rgb, (0.0 /*_PathColorGThemeIndex*/)) * (float4(5,5,5,1)[1] + pathAudioLinkEmission.g);
|
|
pathEmission += pathAlpha[2][(2.0 /*_PathTypeB*/)] * poiThemeColor(poiMods, PathColor[2].rgb, (0.0 /*_PathColorBThemeIndex*/)) * (float4(5,5,5,1)[2] + pathAudioLinkEmission.b);
|
|
pathEmission += pathAlpha[3][(0.0 /*_PathTypeA*/)] * poiThemeColor(poiMods, PathColor[3].rgb, (0.0 /*_PathColorAThemeIndex*/)) * (float4(5,5,5,1)[3] + pathAudioLinkEmission.a);
|
|
pathEmission *= pathColorMap.rgb * pathColorMap.a;
|
|
float3 colorReplace = 0;
|
|
colorReplace = pathAlpha[0][(2.0 /*_PathTypeR*/)] * poiThemeColor(poiMods, PathColor[0].rgb, (0.0 /*_PathColorRThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[0].a * pathAlpha[0][(2.0 /*_PathTypeR*/)]);
|
|
colorReplace = pathAlpha[1][(2.0 /*_PathTypeG*/)] * poiThemeColor(poiMods, PathColor[1].rgb, (0.0 /*_PathColorGThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[1].a * pathAlpha[1][(2.0 /*_PathTypeG*/)]);
|
|
colorReplace = pathAlpha[2][(2.0 /*_PathTypeB*/)] * poiThemeColor(poiMods, PathColor[2].rgb, (0.0 /*_PathColorBThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[2].a * pathAlpha[2][(2.0 /*_PathTypeB*/)]);
|
|
colorReplace = pathAlpha[3][(0.0 /*_PathTypeA*/)] * poiThemeColor(poiMods, PathColor[3].rgb, (0.0 /*_PathColorAThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[3].a * pathAlpha[3][(0.0 /*_PathTypeA*/)]);
|
|
float alpha = max(max(max(pathAlpha[0][(2.0 /*_PathTypeR*/)], pathAlpha[1][(2.0 /*_PathTypeG*/)]), pathAlpha[2][(2.0 /*_PathTypeB*/)]), pathAlpha[3][(0.0 /*_PathTypeA*/)]);
|
|
poiFragData.alpha *= lerp(1, alpha, (1.0 /*_PathingOverrideAlpha*/));
|
|
poiFragData.baseColor = albedo.rgb;
|
|
poiFragData.emission += pathEmission;
|
|
}
|
|
#endif
|
|
float4 frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(i);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
|
PoiMesh poiMesh;
|
|
PoiInitStruct(PoiMesh, poiMesh);
|
|
PoiLight poiLight;
|
|
PoiInitStruct(PoiLight, poiLight);
|
|
PoiVertexLights poiVertexLights;
|
|
PoiInitStruct(PoiVertexLights, poiVertexLights);
|
|
PoiCam poiCam;
|
|
PoiInitStruct(PoiCam, poiCam);
|
|
PoiMods poiMods;
|
|
PoiInitStruct(PoiMods, poiMods);
|
|
poiMods.globalEmission = 1;
|
|
PoiFragData poiFragData;
|
|
poiFragData.emission = 0;
|
|
poiFragData.baseColor = float3(0, 0, 0);
|
|
poiFragData.finalColor = float3(0, 0, 0);
|
|
poiFragData.alpha = 1;
|
|
#ifdef POI_UDIMDISCARD
|
|
applyUDIMDiscard(i);
|
|
#endif
|
|
poiMesh.objectPosition = i.objectPos;
|
|
poiMesh.objNormal = i.objNormal;
|
|
poiMesh.normals[0] = i.normal;
|
|
poiMesh.tangent = i.tangent;
|
|
poiMesh.binormal = i.binormal;
|
|
poiMesh.worldPos = i.worldPos.xyz;
|
|
poiMesh.localPos = i.localPos.xyz;
|
|
poiMesh.vertexColor = i.vertexColor;
|
|
poiMesh.isFrontFace = facing;
|
|
#ifndef POI_PASS_OUTLINE
|
|
if (!poiMesh.isFrontFace)
|
|
{
|
|
poiMesh.normals[0] *= -1;
|
|
poiMesh.tangent *= -1;
|
|
poiMesh.binormal *= -1;
|
|
}
|
|
#endif
|
|
poiCam.viewDir = !IsOrthographicCamera() ? normalize(_WorldSpaceCameraPos - i.worldPos.xyz) : normalize(UNITY_MATRIX_I_V._m02_m12_m22);
|
|
float3 tanToWorld0 = float3(i.tangent.x, i.binormal.x, i.normal.x);
|
|
float3 tanToWorld1 = float3(i.tangent.y, i.binormal.y, i.normal.y);
|
|
float3 tanToWorld2 = float3(i.tangent.z, i.binormal.z, i.normal.z);
|
|
float3 ase_tanViewDir = tanToWorld0 * poiCam.viewDir.x + tanToWorld1 * poiCam.viewDir.y + tanToWorld2 * poiCam.viewDir.z;
|
|
poiCam.tangentViewDir = normalize(ase_tanViewDir);
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
poiMesh.lightmapUV = i.lightmapUV;
|
|
#endif
|
|
poiMesh.parallaxUV = poiCam.tangentViewDir.xy / max(poiCam.tangentViewDir.z, 0.0001);
|
|
poiMesh.uv[0] = i.uv[0];
|
|
poiMesh.uv[1] = i.uv[1];
|
|
poiMesh.uv[2] = i.uv[2];
|
|
poiMesh.uv[3] = i.uv[3];
|
|
poiMesh.uv[4] = poiMesh.uv[0];
|
|
poiMesh.uv[5] = poiMesh.worldPos.xz;
|
|
poiMesh.uv[6] = poiMesh.uv[0];
|
|
poiMesh.uv[7] = poiMesh.uv[0];
|
|
poiMesh.uv[4] = calculatePanosphereUV(poiMesh);
|
|
poiMesh.uv[6] = calculatePolarCoordinate(poiMesh);
|
|
float2 mainUV = poiMesh.uv[(0.0 /*_MainTexUV*/)].xy;
|
|
if ((0.0 /*_MainPixelMode*/))
|
|
{
|
|
mainUV = sharpSample(float4(0.0002441406,0.0002441406,4096,4096), mainUV);
|
|
}
|
|
float4 mainTexture = UNITY_SAMPLE_TEX2D(_MainTex, poiUV(mainUV, float4(1,1,0,0)) + _Time.x * float4(0,0,0,0));
|
|
float3 mainNormal = UnpackScaleNormal(POI2D_SAMPLER_PAN(_BumpMap, _MainTex, poiUV(poiMesh.uv[(0.0 /*_BumpMapUV*/)], float4(1,1,0,0)), float4(0,0,0,0)), (1.0 /*_BumpScale*/));
|
|
poiMesh.tangentSpaceNormal = mainNormal;
|
|
poiMesh.normals[1] = normalize(
|
|
poiMesh.tangentSpaceNormal.x * poiMesh.tangent.xyz +
|
|
poiMesh.tangentSpaceNormal.y * poiMesh.binormal +
|
|
poiMesh.tangentSpaceNormal.z * poiMesh.normals[0]
|
|
);
|
|
float3 fancyNormal = UnpackNormal(float4(0.5, 0.5, 1, 1));
|
|
poiMesh.normals[0] = normalize(
|
|
fancyNormal.x * poiMesh.tangent.xyz +
|
|
fancyNormal.y * poiMesh.binormal +
|
|
fancyNormal.z * poiMesh.normals[0]
|
|
);
|
|
poiCam.forwardDir = getCameraForward();
|
|
poiCam.worldPos = _WorldSpaceCameraPos;
|
|
poiCam.reflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[1]);
|
|
poiCam.vertexReflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[0]);
|
|
poiCam.distanceToVert = distance(poiMesh.worldPos, poiCam.worldPos);
|
|
poiCam.grabPos = i.grabPos;
|
|
poiCam.screenUV = calcScreenUVs(i.grabPos);
|
|
poiCam.vDotN = abs(dot(poiCam.viewDir, poiMesh.normals[1]));
|
|
poiCam.clipPos = i.pos;
|
|
poiCam.worldDirection = i.worldDirection;
|
|
calculateGlobalThemes(poiMods);
|
|
#ifdef POI_AUDIOLINK
|
|
SetupAudioLink(poiFragData, poiMods, poiMesh);
|
|
#endif
|
|
poiLight.finalLightAdd = 0;
|
|
#if defined(PROP_LIGHTINGAOMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 AOMaps = POI2D_SAMPLER_PAN(_LightingAOMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingAOMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
poiLight.occlusion = lerp(1, AOMaps.r, (0.3333 /*_LightDataAOStrengthR*/)) * lerp(1, AOMaps.g, (0.3333 /*_LightDataAOStrengthG*/)) * lerp(1, AOMaps.b, (0.3333 /*_LightDataAOStrengthB*/)) * lerp(1, AOMaps.a, (0.0 /*_LightDataAOStrengthA*/));
|
|
#else
|
|
poiLight.occlusion = 1;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGDETAILSHADOWMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 DetailShadows = POI2D_SAMPLER_PAN(_LightingDetailShadowMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingDetailShadowMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#ifndef POI_PASS_ADD
|
|
poiLight.detailShadow = lerp(1, DetailShadows.r, (1.0 /*_LightingDetailShadowStrengthR*/)) * lerp(1, DetailShadows.g, (0.0 /*_LightingDetailShadowStrengthG*/)) * lerp(1, DetailShadows.b, (0.0 /*_LightingDetailShadowStrengthB*/)) * lerp(1, DetailShadows.a, (0.0 /*_LightingDetailShadowStrengthA*/));
|
|
#else
|
|
poiLight.detailShadow = lerp(1, DetailShadows.r, (1.0 /*_LightingAddDetailShadowStrengthR*/)) * lerp(1, DetailShadows.g, (0.0 /*_LightingAddDetailShadowStrengthG*/)) * lerp(1, DetailShadows.b, (0.0 /*_LightingAddDetailShadowStrengthB*/)) * lerp(1, DetailShadows.a, (0.0 /*_LightingAddDetailShadowStrengthA*/));
|
|
#endif
|
|
#else
|
|
poiLight.detailShadow = 1;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGSHADOWMASKS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 ShadowMasks = POI2D_SAMPLER_PAN(_LightingShadowMasks, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingShadowMasksUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
poiLight.shadowMask = lerp(1, ShadowMasks.r, (1.0 /*_LightingShadowMaskStrengthR*/)) * lerp(1, ShadowMasks.g, (0.0 /*_LightingShadowMaskStrengthG*/)) * lerp(1, ShadowMasks.b, (0.0 /*_LightingShadowMaskStrengthB*/)) * lerp(1, ShadowMasks.a, (0.0 /*_LightingShadowMaskStrengthA*/));
|
|
#else
|
|
poiLight.shadowMask = 1;
|
|
#endif
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
bool lightExists = false;
|
|
if (any(_LightColor0.rgb >= 0.002))
|
|
{
|
|
lightExists = true;
|
|
}
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float4 toLightX = unity_4LightPosX0 - i.worldPos.x;
|
|
float4 toLightY = unity_4LightPosY0 - i.worldPos.y;
|
|
float4 toLightZ = unity_4LightPosZ0 - i.worldPos.z;
|
|
float4 lengthSq = 0;
|
|
lengthSq += toLightX * toLightX;
|
|
lengthSq += toLightY * toLightY;
|
|
lengthSq += toLightZ * toLightZ;
|
|
float4 lightAttenSq = unity_4LightAtten0;
|
|
float4 atten = 1.0 / (1.0 + lengthSq * lightAttenSq);
|
|
float4 vLightWeight = saturate(1 - (lengthSq * lightAttenSq / 25));
|
|
poiLight.vAttenuation = min(atten, vLightWeight * vLightWeight);
|
|
poiLight.vDotNL = 0;
|
|
poiLight.vDotNL += toLightX * poiMesh.normals[1].x;
|
|
poiLight.vDotNL += toLightY * poiMesh.normals[1].y;
|
|
poiLight.vDotNL += toLightZ * poiMesh.normals[1].z;
|
|
float4 corr = rsqrt(lengthSq);
|
|
poiLight.vertexVDotNL = max(0, poiLight.vDotNL * corr);
|
|
poiLight.vertexVDotNL = 0;
|
|
poiLight.vertexVDotNL += toLightX * poiMesh.normals[0].x;
|
|
poiLight.vertexVDotNL += toLightY * poiMesh.normals[0].y;
|
|
poiLight.vertexVDotNL += toLightZ * poiMesh.normals[0].z;
|
|
poiLight.vertexVDotNL = max(0, poiLight.vDotNL * corr);
|
|
poiLight.vAttenuationDotNL = saturate(poiLight.vAttenuation * saturate(poiLight.vDotNL));
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
poiLight.vPosition[index] = float3(unity_4LightPosX0[index], unity_4LightPosY0[index], unity_4LightPosZ0[index]);
|
|
float3 vertexToLightSource = poiLight.vPosition[index] - poiMesh.worldPos;
|
|
poiLight.vDirection[index] = normalize(vertexToLightSource);
|
|
poiLight.vColor[index] = unity_LightColor[index].rgb;
|
|
poiLight.vHalfDir[index] = Unity_SafeNormalize(poiLight.vDirection[index] + poiCam.viewDir);
|
|
poiLight.vDotNL[index] = dot(poiMesh.normals[1], -poiLight.vDirection[index]);
|
|
poiLight.vCorrectedDotNL[index] = .5 * (poiLight.vDotNL[index] + 1);
|
|
poiLight.vDotLH[index] = saturate(dot(poiLight.vDirection[index], poiLight.vHalfDir[index]));
|
|
poiLight.vDotNH[index] = dot(poiMesh.normals[1], poiLight.vHalfDir[index]);
|
|
poiLight.vertexVDotNH[index] = saturate(dot(poiMesh.normals[0], poiLight.vHalfDir[index]));
|
|
}
|
|
#endif
|
|
if ((0.0 /*_LightingColorMode*/) == 0) // Poi Custom Light Color
|
|
{
|
|
float3 magic = max(BetterSH9(normalize(unity_SHAr + unity_SHAg + unity_SHAb)), 0);
|
|
float3 normalLight = _LightColor0.rgb + BetterSH9(float4(0, 0, 0, 1));
|
|
float magiLumi = calculateluminance(magic);
|
|
float normaLumi = calculateluminance(normalLight);
|
|
float maginormalumi = magiLumi + normaLumi;
|
|
float magiratio = magiLumi / maginormalumi;
|
|
float normaRatio = normaLumi / maginormalumi;
|
|
float target = calculateluminance(magic * magiratio + normalLight * normaRatio);
|
|
float3 properLightColor = magic + normalLight;
|
|
float properLuminance = calculateluminance(magic + normalLight);
|
|
poiLight.directColor = properLightColor * max(0.0001, (target / properLuminance));
|
|
poiLight.indirectColor = BetterSH9(float4(lerp(0, poiMesh.normals[1], (0.0 /*_LightingIndirectUsesNormals*/)), 1));
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 1) // More standard approach to light color
|
|
{
|
|
float3 indirectColor = BetterSH9(float4(poiMesh.normals[1], 1));
|
|
if (lightExists)
|
|
{
|
|
poiLight.directColor = _LightColor0.rgb;
|
|
poiLight.indirectColor = indirectColor;
|
|
}
|
|
else
|
|
{
|
|
poiLight.directColor = indirectColor * 0.6;
|
|
poiLight.indirectColor = indirectColor * 0.5;
|
|
}
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 2) // UTS style
|
|
{
|
|
poiLight.indirectColor = saturate(max(half3(0.05, 0.05, 0.05) * (1.0 /*_Unlit_Intensity*/), max(ShadeSH9(half4(0.0, 0.0, 0.0, 1.0)), ShadeSH9(half4(0.0, -1.0, 0.0, 1.0)).rgb) * (1.0 /*_Unlit_Intensity*/)));
|
|
poiLight.directColor = max(poiLight.indirectColor, _LightColor0.rgb);
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 3) // OpenLit
|
|
{
|
|
float3 lightDirectionForSH9 = OpenLitLightingDirection();
|
|
OpenLitShadeSH9ToonDouble(lightDirectionForSH9, poiLight.directColor, poiLight.indirectColor);
|
|
poiLight.directColor += _LightColor0.rgb;
|
|
}
|
|
float lightMapMode = (0.0 /*_LightingMapMode*/);
|
|
if ((0.0 /*_LightingDirectionMode*/) == 0)
|
|
{
|
|
poiLight.direction = _WorldSpaceLightPos0.xyz + unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 1 || (0.0 /*_LightingDirectionMode*/) == 2)
|
|
{
|
|
if ((0.0 /*_LightingDirectionMode*/) == 1)
|
|
{
|
|
poiLight.direction = mul(unity_ObjectToWorld, float4(0,0,0,1)).xyz;;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 2)
|
|
{
|
|
poiLight.direction = float4(0,0,0,1);
|
|
}
|
|
if (lightMapMode == 0)
|
|
{
|
|
lightMapMode == 1;
|
|
}
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 3) // UTS
|
|
{
|
|
float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz);
|
|
float3 lightDirection = normalize(lerp(defaultLightDirection, _WorldSpaceLightPos0.xyz, any(_WorldSpaceLightPos0.xyz)));
|
|
poiLight.direction = lightDirection;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 4) // OpenLit
|
|
{
|
|
poiLight.direction = OpenLitLightingDirection(); // float4 customDir = 0; // Do we want to give users to alter this (OpenLit always does!)?
|
|
}
|
|
if (!any(poiLight.direction))
|
|
{
|
|
poiLight.direction = float3(.4, 1, .4);
|
|
}
|
|
poiLight.direction = normalize(poiLight.direction);
|
|
poiLight.attenuationStrength = (0.0 /*_LightingCastedShadows*/);
|
|
poiLight.attenuation = 1;
|
|
if (!all(_LightColor0.rgb == 0.0))
|
|
{
|
|
UNITY_LIGHT_ATTENUATION(attenuation, i, poiMesh.worldPos)
|
|
poiLight.attenuation *= attenuation;
|
|
}
|
|
if (!any(poiLight.directColor) && !any(poiLight.indirectColor) && lightMapMode == 0)
|
|
{
|
|
lightMapMode = 1;
|
|
if ((0.0 /*_LightingDirectionMode*/) == 0)
|
|
{
|
|
poiLight.direction = normalize(float3(.4, 1, .4));
|
|
}
|
|
}
|
|
poiLight.halfDir = normalize(poiLight.direction + poiCam.viewDir);
|
|
poiLight.vertexNDotL = dot(poiMesh.normals[0], poiLight.direction);
|
|
poiLight.nDotL = dot(poiMesh.normals[1], poiLight.direction);
|
|
poiLight.nDotLSaturated = saturate(poiLight.nDotL);
|
|
poiLight.nDotLNormalized = (poiLight.nDotL + 1) * 0.5;
|
|
poiLight.nDotV = abs(dot(poiMesh.normals[1], poiCam.viewDir));
|
|
poiLight.vertexNDotV = abs(dot(poiMesh.normals[0], poiCam.viewDir));
|
|
poiLight.nDotH = dot(poiMesh.normals[1], poiLight.halfDir);
|
|
poiLight.vertexNDotH = max(0.00001, dot(poiMesh.normals[0], poiLight.halfDir));
|
|
poiLight.lDotv = dot(poiLight.direction, poiCam.viewDir);
|
|
poiLight.lDotH = max(0.00001, dot(poiLight.direction, poiLight.halfDir));
|
|
if (lightMapMode == 0)
|
|
{
|
|
float3 ShadeSH9Plus = GetSHLength();
|
|
float3 ShadeSH9Minus = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0;
|
|
float3 greyScaleVector = float3(.33333, .33333, .33333);
|
|
float bw_lightColor = dot(poiLight.directColor, greyScaleVector);
|
|
float bw_directLighting = (((poiLight.nDotL * 0.5 + 0.5) * bw_lightColor * lerp(1, poiLight.attenuation, poiLight.attenuationStrength)) + dot(ShadeSH9(float4(poiMesh.normals[1], 1)), greyScaleVector));
|
|
float bw_bottomIndirectLighting = dot(ShadeSH9Minus, greyScaleVector);
|
|
float bw_topIndirectLighting = dot(ShadeSH9Plus, greyScaleVector);
|
|
float lightDifference = ((bw_topIndirectLighting + bw_lightColor) - bw_bottomIndirectLighting);
|
|
poiLight.lightMap = smoothstep(0, lightDifference, bw_directLighting - bw_bottomIndirectLighting) * poiLight.detailShadow;
|
|
}
|
|
if (lightMapMode == 1)
|
|
{
|
|
poiLight.lightMap = poiLight.nDotLNormalized * lerp(1, poiLight.attenuation, poiLight.attenuationStrength);
|
|
}
|
|
if (lightMapMode == 2)
|
|
{
|
|
poiLight.lightMap = poiLight.nDotLSaturated * lerp(1, poiLight.attenuation, poiLight.attenuationStrength);
|
|
}
|
|
poiLight.directColor = max(poiLight.directColor, 0.0001);
|
|
poiLight.indirectColor = max(poiLight.indirectColor, 0.0001);
|
|
if ((0.0 /*_LightingColorMode*/) == 3)
|
|
{
|
|
poiLight.directColor = max(poiLight.directColor, (0.0 /*_LightingMinLightBrightness*/));
|
|
poiLight.indirectColor = max(poiLight.indirectColor, (0.0 /*_LightingMinLightBrightness*/));
|
|
}
|
|
else
|
|
{
|
|
poiLight.directColor = max(poiLight.directColor, poiLight.directColor / max(0.0001, (calculateluminance(poiLight.directColor) / (0.0 /*_LightingMinLightBrightness*/))));
|
|
poiLight.indirectColor = max(poiLight.indirectColor, poiLight.indirectColor / max(0.0001, (calculateluminance(poiLight.indirectColor) / (0.0 /*_LightingMinLightBrightness*/))));
|
|
}
|
|
poiLight.directColor = lerp(poiLight.directColor, dot(poiLight.directColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingMonochromatic*/));
|
|
poiLight.indirectColor = lerp(poiLight.indirectColor, dot(poiLight.indirectColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingMonochromatic*/));
|
|
if ((1.0 /*_LightingCapEnabled*/))
|
|
{
|
|
poiLight.directColor = min(poiLight.directColor, (1.0 /*_LightingCap*/));
|
|
poiLight.indirectColor = min(poiLight.indirectColor, (1.0 /*_LightingCap*/));
|
|
}
|
|
if ((0.0 /*_LightingForceColorEnabled*/))
|
|
{
|
|
poiLight.directColor = poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_LightingForcedColorThemeIndex*/));
|
|
}
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
poiLight.directColor = max(poiLight.directColor * (1.0 /*_PPLightingMultiplier*/), 0);
|
|
poiLight.directColor = max(poiLight.directColor + (0.0 /*_PPLightingAddition*/), 0);
|
|
poiLight.indirectColor = max(poiLight.indirectColor * (1.0 /*_PPLightingMultiplier*/), 0);
|
|
poiLight.indirectColor = max(poiLight.indirectColor + (0.0 /*_PPLightingAddition*/), 0);
|
|
#endif
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
#if defined(POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE) && defined(DIRECTIONAL)
|
|
return float4(mainTexture.rgb * .0001, 1);
|
|
#endif
|
|
#if defined(POINT) || defined(SPOT)
|
|
poiLight.direction = normalize(_WorldSpaceLightPos0.xyz - i.worldPos.xyz);
|
|
#ifdef POINT
|
|
poiLight.additiveShadow = UNITY_SHADOW_ATTENUATION(i, poiMesh.worldPos);
|
|
unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(poiMesh.worldPos, 1)).xyz;
|
|
poiLight.attenuation = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).r;
|
|
#endif
|
|
#ifdef SPOT
|
|
poiLight.additiveShadow = UNITY_SHADOW_ATTENUATION(i, poiMesh.worldPos);
|
|
unityShadowCoord4 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(poiMesh.worldPos, 1));
|
|
poiLight.attenuation = (lightCoord.z > 0) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate(lightCoord.xyz);
|
|
#endif
|
|
#else
|
|
poiLight.direction = _WorldSpaceLightPos0.xyz;
|
|
UNITY_LIGHT_ATTENUATION(attenuation, i, poiMesh.worldPos)
|
|
poiLight.additiveShadow == 0;
|
|
poiLight.attenuation = attenuation;
|
|
#endif
|
|
poiLight.directColor = (0.0 /*_LightingAdditiveLimited*/) ? min((1.0 /*_LightingAdditiveLimit*/), _LightColor0.rgb) : _LightColor0.rgb;
|
|
#if defined(POINT_COOKIE) || defined(DIRECTIONAL_COOKIE)
|
|
poiLight.indirectColor = 0;
|
|
#else
|
|
poiLight.indirectColor = lerp(0, poiLight.directColor, (0.5 /*_LightingAdditivePassthrough*/));
|
|
#endif
|
|
poiLight.directColor = lerp(poiLight.directColor, dot(poiLight.directColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingAdditiveMonochromatic*/));
|
|
poiLight.indirectColor = lerp(poiLight.indirectColor, dot(poiLight.indirectColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingAdditiveMonochromatic*/));
|
|
poiLight.halfDir = normalize(poiLight.direction + poiCam.viewDir);
|
|
poiLight.nDotL = dot(poiMesh.normals[1], poiLight.direction);
|
|
poiLight.nDotLSaturated = saturate(poiLight.nDotL);
|
|
poiLight.nDotLNormalized = (poiLight.nDotL + 1) * 0.5;
|
|
poiLight.nDotV = abs(dot(poiMesh.normals[1], poiCam.viewDir));
|
|
poiLight.nDotH = dot(poiMesh.normals[1], poiLight.halfDir);
|
|
poiLight.lDotv = dot(poiLight.direction, poiCam.viewDir);
|
|
poiLight.lDotH = dot(poiLight.direction, poiLight.halfDir);
|
|
poiLight.vertexNDotL = dot(poiMesh.normals[0], poiLight.direction);
|
|
poiLight.vertexNDotV = abs(dot(poiMesh.normals[0], poiCam.viewDir));
|
|
poiLight.vertexNDotH = max(0.00001, dot(poiMesh.normals[0], poiLight.halfDir));
|
|
poiLight.lightMap = 1;
|
|
#endif
|
|
poiFragData.baseColor = mainTexture.rgb * poiThemeColor(poiMods, float4(1,1,1,1).rgb, (0.0 /*_ColorThemeIndex*/));
|
|
poiFragData.alpha = mainTexture.a * float4(1,1,1,1).a;
|
|
#if defined(PROP_CLIPPINGMASK) || !defined(OPTIMIZER_ENABLED)
|
|
float alphaMask = POI2D_SAMPLER_PAN(_ClippingMask, _MainTex, poiUV(poiMesh.uv[(0.0 /*_ClippingMaskUV*/)], float4(1,1,0,0)), float4(0,0,0,0)).r;
|
|
if ((0.0 /*_Inverse_Clipping*/))
|
|
{
|
|
alphaMask = 1 - alphaMask;
|
|
}
|
|
#else
|
|
float alphaMask = 1;
|
|
#endif
|
|
poiFragData.alpha *= alphaMask;
|
|
applyAlphaOptions(poiFragData, poiMesh, poiCam, poiMods);
|
|
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_BRANCH_DETAIL) || defined(GEOM_TYPE_FROND) || defined(DEPTH_OF_FIELD_COC_VIEW)
|
|
applyDecals(poiFragData, poiMesh, poiCam, poiMods, poiLight);
|
|
#endif
|
|
#if defined(_LIGHTINGMODE_SHADEMAP) && defined(VIGNETTE_MASKED)
|
|
#ifndef POI_PASS_OUTLINE
|
|
#endif
|
|
#endif
|
|
#ifdef VIGNETTE_MASKED
|
|
#ifdef POI_PASS_OUTLINE
|
|
if (_OutlineLit)
|
|
{
|
|
calculateShading(poiLight, poiFragData, poiMesh, poiCam);
|
|
}
|
|
else
|
|
{
|
|
poiLight.finalLighting = 1;
|
|
}
|
|
#else
|
|
calculateShading(poiLight, poiFragData, poiMesh, poiCam);
|
|
#endif
|
|
#else
|
|
poiLight.finalLighting = 1;
|
|
poiLight.rampedLightMap = poiEdgeNonLinear(poiLight.nDotL, 0.1, .1);
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
applyPathing(poiFragData, poiMesh, poiMods);
|
|
#endif
|
|
#endif
|
|
|
|
if ((0.0 /*_AlphaPremultiply*/))
|
|
{
|
|
poiFragData.baseColor *= saturate(poiFragData.alpha);
|
|
}
|
|
poiFragData.finalColor = poiFragData.baseColor;
|
|
poiFragData.finalColor = poiFragData.baseColor * poiLight.finalLighting;
|
|
#ifdef MOCHIE_PBR
|
|
MochieBRDF(poiFragData, poiCam, poiLight, poiMesh, poiMods);
|
|
#endif
|
|
if ((0.0 /*_IgnoreFog*/) == 0)
|
|
{
|
|
UNITY_APPLY_FOG(i.fogCoord, poiFragData.finalColor);
|
|
}
|
|
poiFragData.alpha = (0.0 /*_AlphaForceOpaque*/) ? 1 : poiFragData.alpha;
|
|
poiFragData.finalColor += poiLight.finalLightAdd;
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
poiFragData.emission = max(poiFragData.emission * (1.0 /*_PPEmissionMultiplier*/), 0);
|
|
poiFragData.finalColor = max(poiFragData.finalColor * (1.0 /*_PPFinalColorMultiplier*/), 0);
|
|
#endif
|
|
if ((0.0 /*_Mode*/) == POI_MODE_OPAQUE)
|
|
{
|
|
poiFragData.alpha = 1;
|
|
}
|
|
clip(poiFragData.alpha - (0.5 /*_Cutoff*/));
|
|
return float4(poiFragData.finalColor + poiFragData.emission * poiMods.globalEmission, poiFragData.alpha) + POI_SAFE_RGB0;
|
|
}
|
|
ENDCG
|
|
}
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "ForwardAdd" }
|
|
Stencil
|
|
{
|
|
Ref [_StencilRef]
|
|
ReadMask [_StencilReadMask]
|
|
WriteMask [_StencilWriteMask]
|
|
Comp [_StencilCompareFunction]
|
|
Pass [_StencilPassOp]
|
|
Fail [_StencilFailOp]
|
|
ZFail [_StencilZFailOp]
|
|
}
|
|
ZWrite Off
|
|
Cull [_Cull]
|
|
AlphaToMask [_AlphaToCoverage]
|
|
ZTest [_ZTest]
|
|
ColorMask [_ColorMask]
|
|
Offset [_OffsetFactor], [_OffsetUnits]
|
|
BlendOp [_AddBlendOp], [_AddBlendOpAlpha]
|
|
Blend [_AddSrcBlend] [_AddDstBlend]
|
|
CGPROGRAM
|
|
#define MOCHIE_PBR
|
|
#define POI_AUDIOLINK
|
|
#define POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE
|
|
#define POI_LIGHT_DATA_ADDITIVE_ENABLE
|
|
#define POI_PATHING
|
|
#define POI_VERTEXLIGHT_ON
|
|
#define VIGNETTE_MASKED
|
|
#define _LIGHTINGMODE_REALISTIC
|
|
#define PROP_PATHINGMAP
|
|
#define PROP_PATHINGCOLORMAP
|
|
#define OPTIMIZER_ENABLED
|
|
#pragma target 5.0
|
|
#pragma skip_variants LIGHTMAP_ON DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK DIRLIGHTMAP_COMBINED _MIXED_LIGHTING_SUBTRACTIVE
|
|
#pragma multi_compile_fwdadd_fullshadows
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile_fog
|
|
#define POI_PASS_ADD
|
|
#include "UnityCG.cginc"
|
|
#include "UnityStandardUtils.cginc"
|
|
#include "AutoLight.cginc"
|
|
#include "UnityLightingCommon.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#ifdef POI_PASS_META
|
|
#include "UnityMetaPass.cginc"
|
|
#endif
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#define DielectricSpec float4(0.04, 0.04, 0.04, 1.0 - 0.04)
|
|
#define PI float(3.14159265359)
|
|
#define POI2D_SAMPLER_PAN(tex, texSampler, uv, pan) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan))
|
|
#define POI2D_SAMPLER_PANGRAD(tex, texSampler, uv, pan, ddx, ddy) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan, ddx, ddy))
|
|
#define POI2D_SAMPLER(tex, texSampler, uv) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv))
|
|
#define POI2D_PAN(tex, uv, pan) (tex2D(tex, uv + _Time.x * pan))
|
|
#define POI2D(tex, uv) (tex2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D(tex, uv) (UNITY_SAMPLE_TEX2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D_PAN(tex, uv, pan) (UNITY_SAMPLE_TEX2D(tex, uv + _Time.x * pan))
|
|
#define POI2D_MAINTEX_SAMPLER_PAN_INLINED(tex, poiMesh) (POI2D_SAMPLER_PAN(tex, _MainTex, poiUV(poiMesh.uv[tex##UV], tex##_ST), tex##Pan))
|
|
#define POI_SAFE_RGB0 float4(mainTexture.rgb * .0001, 0)
|
|
#define POI_SAFE_RGB1 float4(mainTexture.rgb * .0001, 1)
|
|
#define POI_SAFE_RGBA mainTexture
|
|
#if defined(UNITY_COMPILER_HLSL)
|
|
#define PoiInitStruct(type, name) name = (type)0;
|
|
#else
|
|
#define PoiInitStruct(type, name)
|
|
#endif
|
|
#define POI_ERROR(poiMesh, gridSize) lerp(float3(1, 0, 1), float3(0, 0, 0), fmod(floor((poiMesh.worldPos.x) * gridSize) + floor((poiMesh.worldPos.y) * gridSize) + floor((poiMesh.worldPos.z) * gridSize), 2) == 0)
|
|
#define POI_MODE_OPAQUE 0
|
|
#define POI_MODE_CUTOUT 1
|
|
#define POI_MODE_FADE 2
|
|
#define POI_MODE_TRANSPARENT 3
|
|
#define POI_MODE_ADDITIVE 4
|
|
#define POI_MODE_SOFTADDITIVE 5
|
|
#define POI_MODE_MULTIPLICATIVE 6
|
|
#define POI_MODE_2XMULTIPLICATIVE 7
|
|
#define POI_MODE_TRANSCLIPPING 9
|
|
#define ALPASS_DFT uint2(0,4) //Size: 128, 2
|
|
#define ALPASS_WAVEFORM uint2(0,6) //Size: 128, 16
|
|
#define ALPASS_AUDIOLINK uint2(0,0) //Size: 128, 4
|
|
#define ALPASS_AUDIOBASS uint2(0,0) //Size: 128, 1
|
|
#define ALPASS_AUDIOLOWMIDS uint2(0,1) //Size: 128, 1
|
|
#define ALPASS_AUDIOHIGHMIDS uint2(0,2) //Size: 128, 1
|
|
#define ALPASS_AUDIOTREBLE uint2(0,3) //Size: 128, 1
|
|
#define ALPASS_AUDIOLINKHISTORY uint2(1,0) //Size: 127, 4
|
|
#define ALPASS_GENERALVU uint2(0,22) //Size: 12, 1
|
|
#define ALPASS_CCINTERNAL uint2(12,22) //Size: 12, 2
|
|
#define ALPASS_CCCOLORS uint2(25,22) //Size: 11, 1
|
|
#define ALPASS_CCSTRIP uint2(0,24) //Size: 128, 1
|
|
#define ALPASS_CCLIGHTS uint2(0,25) //Size: 128, 2
|
|
#define ALPASS_AUTOCORRELATOR uint2(0,27) //Size: 128, 1
|
|
#define ALPASS_GENERALVU_INSTANCE_TIME uint2(2,22)
|
|
#define ALPASS_GENERALVU_LOCAL_TIME uint2(3,22)
|
|
#define ALPASS_GENERALVU_NETWORK_TIME uint2(4,22)
|
|
#define ALPASS_GENERALVU_PLAYERINFO uint2(6,22)
|
|
#define ALPASS_FILTEREDAUDIOLINK uint2(0,28) //Size: 16, 4
|
|
#define ALPASS_CHRONOTENSITY uint2(16,28) //Size: 8, 4
|
|
#define ALPASS_THEME_COLOR0 uint2(0,23)
|
|
#define ALPASS_THEME_COLOR1 uint2(1,23)
|
|
#define ALPASS_THEME_COLOR2 uint2(2,23)
|
|
#define ALPASS_THEME_COLOR3 uint2(3,23)
|
|
#define ALPASS_FILTEREDVU uint2(24,28) //Size: 4, 4
|
|
#define ALPASS_FILTEREDVU_INTENSITY uint2(24,28) //Size: 4, 1
|
|
#define ALPASS_FILTEREDVU_MARKER uint2(24,29) //Size: 4, 1
|
|
#define AUDIOLINK_SAMPHIST 3069 // Internal use for algos, do not change.
|
|
#define AUDIOLINK_SAMPLEDATA24 2046
|
|
#define AUDIOLINK_EXPBINS 24
|
|
#define AUDIOLINK_EXPOCT 10
|
|
#define AUDIOLINK_ETOTALBINS (AUDIOLINK_EXPBINS * AUDIOLINK_EXPOCT)
|
|
#define AUDIOLINK_WIDTH 128
|
|
#define AUDIOLINK_SPS 48000 // Samples per second
|
|
#define AUDIOLINK_ROOTNOTE 0
|
|
#define AUDIOLINK_4BAND_FREQFLOOR 0.123
|
|
#define AUDIOLINK_4BAND_FREQCEILING 1
|
|
#define AUDIOLINK_BOTTOM_FREQUENCY 13.75
|
|
#define AUDIOLINK_BASE_AMPLITUDE 2.5
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MIN 0.3
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MAX 0.9
|
|
#define AUDIOLINK_DFT_Q 4.0
|
|
#define AUDIOLINK_TREBLE_CORRECTION 5.0
|
|
#define COLORCHORD_EMAXBIN 192
|
|
#define COLORCHORD_IIR_DECAY_1 0.90
|
|
#define COLORCHORD_IIR_DECAY_2 0.85
|
|
#define COLORCHORD_CONSTANT_DECAY_1 0.01
|
|
#define COLORCHORD_CONSTANT_DECAY_2 0.0
|
|
#define COLORCHORD_NOTE_CLOSEST 3.0
|
|
#define COLORCHORD_NEW_NOTE_GAIN 8.0
|
|
#define COLORCHORD_MAX_NOTES 10
|
|
#ifndef glsl_mod
|
|
#define glsl_mod(x, y) (((x) - (y) * floor((x) / (y))))
|
|
#endif
|
|
uniform float4 _AudioTexture_TexelSize;
|
|
#ifdef SHADER_TARGET_SURFACE_ANALYSIS
|
|
#define AUDIOLINK_STANDARD_INDEXING
|
|
#endif
|
|
#ifdef AUDIOLINK_STANDARD_INDEXING
|
|
sampler2D _AudioTexture;
|
|
#define AudioLinkData(xycoord) tex2Dlod(_AudioTexture, float4(uint2(xycoord) * _AudioTexture_TexelSize.xy, 0, 0))
|
|
#else
|
|
uniform Texture2D<float4> _AudioTexture;
|
|
SamplerState sampler_AudioTexture;
|
|
#define AudioLinkData(xycoord) _AudioTexture[uint2(xycoord)]
|
|
#endif
|
|
uniform sampler2D _Stored;
|
|
uniform float4 _Stored_TexelSize;
|
|
#define LumaData(x,y) tex2Dlod(_Stored, float4(x, y, 0, 0))
|
|
float _Mode;
|
|
float4 _GlobalThemeColor0;
|
|
float4 _GlobalThemeColor1;
|
|
float4 _GlobalThemeColor2;
|
|
float4 _GlobalThemeColor3;
|
|
float _StereoEnabled;
|
|
float _PolarUV;
|
|
float2 _PolarCenter;
|
|
float _PolarRadialScale;
|
|
float _PolarLengthScale;
|
|
float _PolarSpiralPower;
|
|
float _PanoUseBothEyes;
|
|
#ifdef POI_AUDIOLINK
|
|
float _AudioLinkDelay;
|
|
float _AudioLinkAnimToggle;
|
|
float _DebugWaveform;
|
|
float _DebugDFT;
|
|
float _DebugBass;
|
|
float _DebugLowMids;
|
|
float _DebugHighMids;
|
|
float _DebugTreble;
|
|
float _DebugCCColors;
|
|
float _DebugCCStrip;
|
|
float _DebugCCLights;
|
|
float _DebugAutocorrelator;
|
|
float _DebugChronotensity;
|
|
float _AudioLinkCCStripY;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGAOMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingAOMaps;
|
|
#endif
|
|
float4 _LightingAOMaps_ST;
|
|
float2 _LightingAOMapsPan;
|
|
float _LightingAOMapsUV;
|
|
float _LightDataAOStrengthR;
|
|
float _LightDataAOStrengthG;
|
|
float _LightDataAOStrengthB;
|
|
float _LightDataAOStrengthA;
|
|
#if defined(PROP_LIGHTINGDETAILSHADOWMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingDetailShadowMaps;
|
|
#endif
|
|
float4 _LightingDetailShadowMaps_ST;
|
|
float2 _LightingDetailShadowMapsPan;
|
|
float _LightingDetailShadowMapsUV;
|
|
float _LightingDetailShadowStrengthR;
|
|
float _LightingDetailShadowStrengthG;
|
|
float _LightingDetailShadowStrengthB;
|
|
float _LightingDetailShadowStrengthA;
|
|
float _LightingAddDetailShadowStrengthR;
|
|
float _LightingAddDetailShadowStrengthG;
|
|
float _LightingAddDetailShadowStrengthB;
|
|
float _LightingAddDetailShadowStrengthA;
|
|
#if defined(PROP_LIGHTINGSHADOWMASKS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _LightingShadowMasks;
|
|
#endif
|
|
float4 _LightingShadowMasks_ST;
|
|
float2 _LightingShadowMasksPan;
|
|
float _LightingShadowMasksUV;
|
|
float _LightingShadowMaskStrengthR;
|
|
float _LightingShadowMaskStrengthG;
|
|
float _LightingShadowMaskStrengthB;
|
|
float _LightingShadowMaskStrengthA;
|
|
float _Unlit_Intensity;
|
|
float _LightingColorMode;
|
|
float _LightingMapMode;
|
|
float _LightingDirectionMode;
|
|
float3 _LightngForcedDirection;
|
|
float _LightingIndirectUsesNormals;
|
|
float _LightingCapEnabled;
|
|
float _LightingCap;
|
|
float _LightingForceColorEnabled;
|
|
float3 _LightingForcedColor;
|
|
float _LightingForcedColorThemeIndex;
|
|
float _LightingCastedShadows;
|
|
float _LightingMonochromatic;
|
|
float _LightingAdditiveMonochromatic;
|
|
float _LightingMinLightBrightness;
|
|
float _LightingAdditiveLimited;
|
|
float _LightingAdditiveLimit;
|
|
float _LightingAdditivePassthrough;
|
|
float _LightingDebugVisualize;
|
|
float _IgnoreFog;
|
|
float _RenderingReduceClipDistance;
|
|
float _AddBlendOp;
|
|
float4 _Color;
|
|
float _ColorThemeIndex;
|
|
UNITY_DECLARE_TEX2D(_MainTex);
|
|
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
|
float _MainPixelMode;
|
|
float4 _MainTex_ST;
|
|
float2 _MainTexPan;
|
|
float _MainTexUV;
|
|
float4 _MainTex_TexelSize;
|
|
Texture2D _BumpMap;
|
|
float4 _BumpMap_ST;
|
|
float2 _BumpMapPan;
|
|
float _BumpMapUV;
|
|
float _BumpScale;
|
|
Texture2D _ClippingMask;
|
|
float4 _ClippingMask_ST;
|
|
float2 _ClippingMaskPan;
|
|
float _ClippingMaskUV;
|
|
float _Inverse_Clipping;
|
|
float _Cutoff;
|
|
SamplerState sampler_linear_clamp;
|
|
SamplerState sampler_linear_repeat;
|
|
float _AlphaForceOpaque;
|
|
float _AlphaMod;
|
|
float _AlphaPremultiply;
|
|
float _AlphaBoostFA;
|
|
float _ShadowOffset;
|
|
float _ShadowStrength;
|
|
float _LightingIgnoreAmbientColor;
|
|
float _LightingGradientStart;
|
|
float _LightingGradientEnd;
|
|
float3 _LightingShadowColor;
|
|
float _LightingGradientStartWrap;
|
|
float _LightingGradientEndWrap;
|
|
sampler2D _SkinLUT;
|
|
float _SssScale;
|
|
float _SssBumpBlur;
|
|
float3 _SssTransmissionAbsorption;
|
|
float3 _SssColorBleedAoWeights;
|
|
float _LightingAdditiveType;
|
|
float _LightingAdditiveGradientStart;
|
|
float _LightingAdditiveGradientEnd;
|
|
float _LightingAdditiveDetailStrength;
|
|
float4 _MochieReflCube_HDR;
|
|
#ifdef MOCHIE_PBR
|
|
#if defined(PROP_MOCHIEMETALLICMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _MochieMetallicMaps;
|
|
#endif
|
|
float4 _MochieMetallicMaps_ST;
|
|
float2 _MochieMetallicMapsPan;
|
|
float _MochieMetallicMapsUV;
|
|
float _MochieMetallicMapInvert;
|
|
float _MochieRoughnessMapInvert;
|
|
float _MochieReflectionMaskInvert;
|
|
float _MochieSpecularMaskInvert;
|
|
float _MochieReflectionTintThemeIndex;
|
|
float _MochieSpecularTintThemeIndex;
|
|
float _MochieRoughnessMultiplier;
|
|
float _MochieMetallicMultiplier;
|
|
float _MochieReflectionStrength;
|
|
float _MochieSpecularStrength;
|
|
float4 _MochieSpecularTint;
|
|
float4 _MochieReflectionTint;
|
|
float _MochieLitFallback;
|
|
float _IgnoreCastedShadows;
|
|
float _PBRSplitMaskSample;
|
|
float4 _PBRMaskScaleTiling;
|
|
float _MochieMetallicMasksUV;
|
|
float4 _MochieMetallicMasksPan;
|
|
float _Specular2ndLayer;
|
|
float _MochieSpecularStrength2;
|
|
float _MochieRoughnessMultiplier2;
|
|
float _RefSpecFresnel;
|
|
samplerCUBE _MochieReflCube;
|
|
float _MochieForceFallback;
|
|
float _MochieGSAAEnabled;
|
|
float _PoiGSAAVariance;
|
|
float _PoiGSAAThreshold;
|
|
float _BRDFTPSReflectionMaskStrength;
|
|
float _BRDFTPSSpecularMaskStrength;
|
|
float _BRDFTPSDepthEnabled;
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _PathingMap;
|
|
SamplerState SmpRepeatPoint;
|
|
#endif
|
|
float4 _PathingMap_ST;
|
|
float2 _PathingMapPan;
|
|
float _PathingMapUV;
|
|
#if defined(PROP_PATHINGCOLORMAP) || !defined(OPTIMIZER_ENABLED)
|
|
Texture2D _PathingColorMap;
|
|
#endif
|
|
float4 _PathingColorMap_ST;
|
|
float2 _PathingColorMapPan;
|
|
float _PathingColorMapUV;
|
|
float _PathingOverrideAlpha;
|
|
float _PathTypeR;
|
|
float _PathTypeG;
|
|
float _PathTypeB;
|
|
float _PathTypeA;
|
|
float _PathGradientType;
|
|
half4 _PathWidth;
|
|
float4 _PathTime;
|
|
float4 _PathOffset;
|
|
float4 _PathSpeed;
|
|
float4 _PathColorR;
|
|
float4 _PathColorG;
|
|
float4 _PathColorB;
|
|
float4 _PathColorA;
|
|
float4 _PathEmissionStrength;
|
|
float4 _PathSoftness;
|
|
float4 _PathSegments;
|
|
float _PathColorRThemeIndex;
|
|
float _PathColorGThemeIndex;
|
|
float _PathColorBThemeIndex;
|
|
float _PathColorAThemeIndex;
|
|
#ifdef POI_AUDIOLINK
|
|
float _PathALAutoCorrelator;
|
|
float _PathALAutoCorrelatorR;
|
|
float _PathALAutoCorrelatorG;
|
|
float _PathALAutoCorrelatorB;
|
|
float _PathALAutoCorrelatorA;
|
|
float _PathALHistory;
|
|
float _PathALHistoryBandR;
|
|
float _PathALHistoryR;
|
|
float _PathALHistoryBandG;
|
|
float _PathALHistoryG;
|
|
float _PathALHistoryBandB;
|
|
float _PathALHistoryB;
|
|
float _PathALHistoryBandA;
|
|
float _PathALHistoryA;
|
|
float _PathALCCR;
|
|
float _PathALCCG;
|
|
float _PathALCCB;
|
|
float _PathALCCA;
|
|
float _PathALTimeOffset;
|
|
half _AudioLinkPathTimeOffsetBandR;
|
|
half2 _AudioLinkPathTimeOffsetR;
|
|
half _AudioLinkPathTimeOffsetBandG;
|
|
half2 _AudioLinkPathTimeOffsetG;
|
|
half _AudioLinkPathTimeOffsetBandB;
|
|
half2 _AudioLinkPathTimeOffsetB;
|
|
half _AudioLinkPathTimeOffsetBandA;
|
|
half2 _AudioLinkPathTimeOffsetA;
|
|
float _PathALEmissionOffset;
|
|
half _AudioLinkPathEmissionAddBandR;
|
|
half2 _AudioLinkPathEmissionAddR;
|
|
half _AudioLinkPathEmissionAddBandG;
|
|
half2 _AudioLinkPathEmissionAddG;
|
|
half _AudioLinkPathEmissionAddBandB;
|
|
half2 _AudioLinkPathEmissionAddB;
|
|
half _AudioLinkPathEmissionAddBandA;
|
|
half2 _AudioLinkPathEmissionAddA;
|
|
float _PathALWidthOffset;
|
|
half _AudioLinkPathWidthOffsetBandR;
|
|
half2 _AudioLinkPathWidthOffsetR;
|
|
half _AudioLinkPathWidthOffsetBandG;
|
|
half2 _AudioLinkPathWidthOffsetG;
|
|
half _AudioLinkPathWidthOffsetBandB;
|
|
half2 _AudioLinkPathWidthOffsetB;
|
|
half _AudioLinkPathWidthOffsetBandA;
|
|
half2 _AudioLinkPathWidthOffsetA;
|
|
float _PathALChrono;
|
|
float _PathChronoBandR;
|
|
float _PathChronoTypeR;
|
|
float _PathChronoSpeedR;
|
|
float _PathChronoBandG;
|
|
float _PathChronoTypeG;
|
|
float _PathChronoSpeedG;
|
|
float _PathChronoBandB;
|
|
float _PathChronoTypeB;
|
|
float _PathChronoSpeedB;
|
|
float _PathChronoBandA;
|
|
float _PathChronoTypeA;
|
|
float _PathChronoSpeedA;
|
|
#endif
|
|
#endif
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
float4 tangent : TANGENT;
|
|
float4 color : COLOR;
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv1 : TEXCOORD1;
|
|
float2 uv2 : TEXCOORD2;
|
|
float2 uv3 : TEXCOORD3;
|
|
uint vertexId : SV_VertexID;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float2 uv[4] : TEXCOORD0;
|
|
float3 objNormal : TEXCOORD4;
|
|
float3 normal : TEXCOORD5;
|
|
float3 tangent : TEXCOORD6;
|
|
float3 binormal : TEXCOORD7;
|
|
float4 worldPos : TEXCOORD8;
|
|
float4 localPos : TEXCOORD9;
|
|
float3 objectPos : TEXCOORD10;
|
|
float4 vertexColor : TEXCOORD11;
|
|
float4 lightmapUV : TEXCOORD12;
|
|
float4 grabPos: TEXCOORD13;
|
|
float4 worldDirection: TEXCOORD14;
|
|
UNITY_SHADOW_COORDS(15)
|
|
UNITY_FOG_COORDS(16)
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
struct PoiMesh
|
|
{
|
|
float3 normals[2];
|
|
float3 objNormal;
|
|
float3 tangentSpaceNormal;
|
|
float3 binormal;
|
|
float3 tangent;
|
|
float3 worldPos;
|
|
float3 localPos;
|
|
float3 objectPosition;
|
|
float isFrontFace;
|
|
float4 vertexColor;
|
|
float4 lightmapUV;
|
|
float2 uv[8];
|
|
float2 parallaxUV;
|
|
};
|
|
struct PoiCam
|
|
{
|
|
float3 viewDir;
|
|
float3 forwardDir;
|
|
float3 worldPos;
|
|
float distanceToVert;
|
|
float4 clipPos;
|
|
float3 reflectionDir;
|
|
float3 vertexReflectionDir;
|
|
float3 tangentViewDir;
|
|
float4 grabPos;
|
|
float2 screenUV;
|
|
float vDotN;
|
|
float4 worldDirection;
|
|
};
|
|
struct PoiMods
|
|
{
|
|
float4 Mask;
|
|
float4 audioLink;
|
|
float audioLinkAvailable;
|
|
float audioLinkVersion;
|
|
float4 audioLinkTexture;
|
|
float audioLinkViaLuma;
|
|
float2 detailMask;
|
|
float2 backFaceDetailIntensity;
|
|
float globalEmission;
|
|
float4 globalColorTheme[12];
|
|
float ALTime[8];
|
|
};
|
|
struct PoiLight
|
|
{
|
|
float3 direction;
|
|
float attenuation;
|
|
float attenuationStrength;
|
|
float3 directColor;
|
|
float3 indirectColor;
|
|
float occlusion;
|
|
float shadowMask;
|
|
float detailShadow;
|
|
float3 halfDir;
|
|
float lightMap;
|
|
float3 rampedLightMap;
|
|
float vertexNDotL;
|
|
float nDotL;
|
|
float nDotV;
|
|
float vertexNDotV;
|
|
float nDotH;
|
|
float vertexNDotH;
|
|
float lDotv;
|
|
float lDotH;
|
|
float nDotLSaturated;
|
|
float nDotLNormalized;
|
|
#ifdef POI_PASS_ADD
|
|
float additiveShadow;
|
|
#endif
|
|
float3 finalLighting;
|
|
float3 finalLightAdd;
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float4 vDotNL;
|
|
float4 vertexVDotNL;
|
|
float3 vColor[4];
|
|
float4 vCorrectedDotNL;
|
|
float4 vAttenuation;
|
|
float4 vAttenuationDotNL;
|
|
float3 vPosition[4];
|
|
float3 vDirection[4];
|
|
float3 vFinalLighting;
|
|
float3 vHalfDir[4];
|
|
half4 vDotNH;
|
|
half4 vertexVDotNH;
|
|
half4 vDotLH;
|
|
#endif
|
|
};
|
|
struct PoiVertexLights
|
|
{
|
|
float3 direction;
|
|
float3 color;
|
|
float attenuation;
|
|
};
|
|
struct PoiFragData
|
|
{
|
|
float3 baseColor;
|
|
float3 finalColor;
|
|
float alpha;
|
|
float3 emission;
|
|
};
|
|
float2 poiUV(float2 uv, float4 tex_st)
|
|
{
|
|
return uv * tex_st.xy + tex_st.zw;
|
|
}
|
|
float calculateluminance(float3 color)
|
|
{
|
|
return color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
|
|
}
|
|
bool IsInMirror()
|
|
{
|
|
return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f;
|
|
}
|
|
bool IsOrthographicCamera()
|
|
{
|
|
return unity_OrthoParams.w == 1 || UNITY_MATRIX_P[3][3] == 1;
|
|
}
|
|
float shEvaluateDiffuseL1Geomerics_local(float L0, float3 L1, float3 n)
|
|
{
|
|
float R0 = max(0, L0);
|
|
float3 R1 = 0.5f * L1;
|
|
float lenR1 = length(R1);
|
|
float q = dot(normalize(R1), n) * 0.5 + 0.5;
|
|
q = saturate(q); // Thanks to ScruffyRuffles for the bug identity.
|
|
float p = 1.0f + 2.0f * lenR1 / R0;
|
|
float a = (1.0f - lenR1 / R0) / (1.0f + lenR1 / R0);
|
|
return R0 * (a + (1.0f - a) * (p + 1.0f) * pow(q, p));
|
|
}
|
|
half3 BetterSH9(half4 normal)
|
|
{
|
|
float3 indirect;
|
|
float3 L0 = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0;
|
|
indirect.r = shEvaluateDiffuseL1Geomerics_local(L0.r, unity_SHAr.xyz, normal.xyz);
|
|
indirect.g = shEvaluateDiffuseL1Geomerics_local(L0.g, unity_SHAg.xyz, normal.xyz);
|
|
indirect.b = shEvaluateDiffuseL1Geomerics_local(L0.b, unity_SHAb.xyz, normal.xyz);
|
|
indirect = max(0, indirect);
|
|
indirect += SHEvalLinearL2(normal);
|
|
return indirect;
|
|
}
|
|
float3 getCameraForward()
|
|
{
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
float3 p1 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 1, 1));
|
|
float3 p2 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 0, 1));
|
|
#else
|
|
float3 p1 = mul(unity_CameraToWorld, float4(0, 0, 1, 1)).xyz;
|
|
float3 p2 = mul(unity_CameraToWorld, float4(0, 0, 0, 1)).xyz;
|
|
#endif
|
|
return normalize(p2 - p1);
|
|
}
|
|
half3 GetSHLength()
|
|
{
|
|
half3 x, x1;
|
|
x.r = length(unity_SHAr);
|
|
x.g = length(unity_SHAg);
|
|
x.b = length(unity_SHAb);
|
|
x1.r = length(unity_SHBr);
|
|
x1.g = length(unity_SHBg);
|
|
x1.b = length(unity_SHBb);
|
|
return x + x1;
|
|
}
|
|
float3 BoxProjection(float3 direction, float3 position, float4 cubemapPosition, float3 boxMin, float3 boxMax)
|
|
{
|
|
#if UNITY_SPECCUBE_BOX_PROJECTION
|
|
if (cubemapPosition.w > 0)
|
|
{
|
|
float3 factors = ((direction > 0 ? boxMax : boxMin) - position) / direction;
|
|
float scalar = min(min(factors.x, factors.y), factors.z);
|
|
direction = direction * scalar + (position - cubemapPosition.xyz);
|
|
}
|
|
#endif
|
|
return direction;
|
|
}
|
|
float poiMax(float2 i)
|
|
{
|
|
return max(i.x, i.y);
|
|
}
|
|
float poiMax(float3 i)
|
|
{
|
|
return max(max(i.x, i.y), i.z);
|
|
}
|
|
float poiMax(float4 i)
|
|
{
|
|
return max(max(max(i.x, i.y), i.z), i.w);
|
|
}
|
|
float3 calculateNormal(in float3 baseNormal, in PoiMesh poiMesh, in Texture2D normalTexture, in float4 normal_ST, in float2 normalPan, in float normalUV, in float normalIntensity)
|
|
{
|
|
float3 normal = UnpackScaleNormal(POI2D_SAMPLER_PAN(normalTexture, _MainTex, poiUV(poiMesh.uv[normalUV], normal_ST), normalPan), normalIntensity);
|
|
return normalize(
|
|
normal.x * poiMesh.tangent +
|
|
normal.y * poiMesh.binormal +
|
|
normal.z * baseNormal
|
|
);
|
|
}
|
|
float remap(float x, float minOld, float maxOld, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float2 remap(float2 x, float2 minOld, float2 maxOld, float2 minNew = 0, float2 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float3 remap(float3 x, float3 minOld, float3 maxOld, float3 minNew = 0, float3 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float4 remap(float4 x, float4 minOld, float4 maxOld, float4 minNew = 0, float4 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float remapClamped(float minOld, float maxOld, float x, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 remapClamped(float2 minOld, float2 maxOld, float2 x, float2 minNew, float2 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float3 remapClamped(float3 minOld, float3 maxOld, float3 x, float3 minNew, float3 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float4 remapClamped(float4 minOld, float4 maxOld, float4 x, float4 minNew, float4 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 calcParallax(in float height, in PoiCam poiCam)
|
|
{
|
|
return ((height * - 1) + 1) * (poiCam.tangentViewDir.xy / poiCam.tangentViewDir.z);
|
|
}
|
|
float4 poiBlend(const float sourceFactor, const float4 sourceColor, const float destinationFactor, const float4 destinationColor, const float4 blendFactor)
|
|
{
|
|
float4 sA = 1 - blendFactor;
|
|
const float4 blendData[11] = {
|
|
float4(0.0, 0.0, 0.0, 0.0),
|
|
float4(1.0, 1.0, 1.0, 1.0),
|
|
destinationColor,
|
|
sourceColor,
|
|
float4(1.0, 1.0, 1.0, 1.0) - destinationColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sourceColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sA,
|
|
saturate(sourceColor.aaaa),
|
|
1 - sA,
|
|
};
|
|
return lerp(blendData[sourceFactor] * sourceColor + blendData[destinationFactor] * destinationColor, sourceColor, sA);
|
|
}
|
|
float3 blendAverage(float3 base, float3 blend)
|
|
{
|
|
return (base + blend) / 2.0;
|
|
}
|
|
float blendColorBurn(float base, float blend)
|
|
{
|
|
return (blend == 0.0)?blend : max((1.0 - ((1.0 - base) / blend)), 0.0);
|
|
}
|
|
float3 blendColorBurn(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorBurn(base.r, blend.r), blendColorBurn(base.g, blend.g), blendColorBurn(base.b, blend.b));
|
|
}
|
|
float blendColorDodge(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendColorDodge(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorDodge(base.r, blend.r), blendColorDodge(base.g, blend.g), blendColorDodge(base.b, blend.b));
|
|
}
|
|
float blendDarken(float base, float blend)
|
|
{
|
|
return min(blend, base);
|
|
}
|
|
float3 blendDarken(float3 base, float3 blend)
|
|
{
|
|
return float3(blendDarken(base.r, blend.r), blendDarken(base.g, blend.g), blendDarken(base.b, blend.b));
|
|
}
|
|
float3 blendExclusion(float3 base, float3 blend)
|
|
{
|
|
return base + blend - 2.0 * base * blend;
|
|
}
|
|
float blendReflect(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base * base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendReflect(float3 base, float3 blend)
|
|
{
|
|
return float3(blendReflect(base.r, blend.r), blendReflect(base.g, blend.g), blendReflect(base.b, blend.b));
|
|
}
|
|
float3 blendGlow(float3 base, float3 blend)
|
|
{
|
|
return blendReflect(blend, base);
|
|
}
|
|
float blendOverlay(float base, float blend)
|
|
{
|
|
return base < 0.5?(2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendOverlay(float3 base, float3 blend)
|
|
{
|
|
return float3(blendOverlay(base.r, blend.r), blendOverlay(base.g, blend.g), blendOverlay(base.b, blend.b));
|
|
}
|
|
float3 blendHardLight(float3 base, float3 blend)
|
|
{
|
|
return blendOverlay(blend, base);
|
|
}
|
|
float blendVividLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendColorBurn(base, (2.0 * blend)) : blendColorDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendVividLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendVividLight(base.r, blend.r), blendVividLight(base.g, blend.g), blendVividLight(base.b, blend.b));
|
|
}
|
|
float blendHardMix(float base, float blend)
|
|
{
|
|
return (blendVividLight(base, blend) < 0.5)?0.0 : 1.0;
|
|
}
|
|
float3 blendHardMix(float3 base, float3 blend)
|
|
{
|
|
return float3(blendHardMix(base.r, blend.r), blendHardMix(base.g, blend.g), blendHardMix(base.b, blend.b));
|
|
}
|
|
float blendLighten(float base, float blend)
|
|
{
|
|
return max(blend, base);
|
|
}
|
|
float3 blendLighten(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLighten(base.r, blend.r), blendLighten(base.g, blend.g), blendLighten(base.b, blend.b));
|
|
}
|
|
float blendLinearBurn(float base, float blend)
|
|
{
|
|
return max(base + blend - 1.0, 0.0);
|
|
}
|
|
float3 blendLinearBurn(float3 base, float3 blend)
|
|
{
|
|
return max(base + blend - float3(1.0, 1.0, 1.0), float3(0.0, 0.0, 0.0));
|
|
}
|
|
float blendLinearDodge(float base, float blend)
|
|
{
|
|
return min(base + blend, 1.0);
|
|
}
|
|
float3 blendLinearDodge(float3 base, float3 blend)
|
|
{
|
|
return min(base + blend, float3(1.0, 1.0, 1.0));
|
|
}
|
|
float blendLinearLight(float base, float blend)
|
|
{
|
|
return blend < 0.5?blendLinearBurn(base, (2.0 * blend)) : blendLinearDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendLinearLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLinearLight(base.r, blend.r), blendLinearLight(base.g, blend.g), blendLinearLight(base.b, blend.b));
|
|
}
|
|
float3 blendMultiply(float3 base, float3 blend)
|
|
{
|
|
return base * blend;
|
|
}
|
|
float3 blendNegation(float3 base, float3 blend)
|
|
{
|
|
return float3(1.0, 1.0, 1.0) - abs(float3(1.0, 1.0, 1.0) - base - blend);
|
|
}
|
|
float3 blendNormal(float3 base, float3 blend)
|
|
{
|
|
return blend;
|
|
}
|
|
float3 blendPhoenix(float3 base, float3 blend)
|
|
{
|
|
return min(base, blend) - max(base, blend) + float3(1.0, 1.0, 1.0);
|
|
}
|
|
float blendPinLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendDarken(base, (2.0 * blend)) : blendLighten(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendPinLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendPinLight(base.r, blend.r), blendPinLight(base.g, blend.g), blendPinLight(base.b, blend.b));
|
|
}
|
|
float blendScreen(float base, float blend)
|
|
{
|
|
return 1.0 - ((1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendScreen(float3 base, float3 blend)
|
|
{
|
|
return float3(blendScreen(base.r, blend.r), blendScreen(base.g, blend.g), blendScreen(base.b, blend.b));
|
|
}
|
|
float blendSoftLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?(2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend));
|
|
}
|
|
float3 blendSoftLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendSoftLight(base.r, blend.r), blendSoftLight(base.g, blend.g), blendSoftLight(base.b, blend.b));
|
|
}
|
|
float blendSubtract(float base, float blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float3 blendSubtract(float3 base, float3 blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float blendDifference(float base, float blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float3 blendDifference(float3 base, float3 blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float blendDivide(float base, float blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 blendDivide(float3 base, float3 blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 customBlend(float3 base, float3 blend, float blendType)
|
|
{
|
|
float3 ret = 0;
|
|
switch(blendType)
|
|
{
|
|
case 0:
|
|
{
|
|
ret = blendNormal(base, blend);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ret = blendDarken(base, blend);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ret = blendMultiply(base, blend);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
ret = blendColorBurn(base, blend);
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
ret = blendLinearBurn(base, blend);
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
ret = blendLighten(base, blend);
|
|
break;
|
|
}
|
|
case 6:
|
|
{
|
|
ret = blendScreen(base, blend);
|
|
break;
|
|
}
|
|
case 7:
|
|
{
|
|
ret = blendColorDodge(base, blend);
|
|
break;
|
|
}
|
|
case 8:
|
|
{
|
|
ret = blendLinearDodge(base, blend);
|
|
break;
|
|
}
|
|
case 9:
|
|
{
|
|
ret = blendOverlay(base, blend);
|
|
break;
|
|
}
|
|
case 10:
|
|
{
|
|
ret = blendSoftLight(base, blend);
|
|
break;
|
|
}
|
|
case 11:
|
|
{
|
|
ret = blendHardLight(base, blend);
|
|
break;
|
|
}
|
|
case 12:
|
|
{
|
|
ret = blendVividLight(base, blend);
|
|
break;
|
|
}
|
|
case 13:
|
|
{
|
|
ret = blendLinearLight(base, blend);
|
|
break;
|
|
}
|
|
case 14:
|
|
{
|
|
ret = blendPinLight(base, blend);
|
|
break;
|
|
}
|
|
case 15:
|
|
{
|
|
ret = blendHardMix(base, blend);
|
|
break;
|
|
}
|
|
case 16:
|
|
{
|
|
ret = blendDifference(base, blend);
|
|
break;
|
|
}
|
|
case 17:
|
|
{
|
|
ret = blendExclusion(base, blend);
|
|
break;
|
|
}
|
|
case 18:
|
|
{
|
|
ret = blendSubtract(base, blend);
|
|
break;
|
|
}
|
|
case 19:
|
|
{
|
|
ret = blendDivide(base, blend);
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
float random(float2 p)
|
|
{
|
|
return frac(sin(dot(p, float2(12.9898, 78.2383))) * 43758.5453123);
|
|
}
|
|
float2 random2(float2 p)
|
|
{
|
|
return frac(sin(float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)))) * 43758.5453);
|
|
}
|
|
float3 random3(float3 p)
|
|
{
|
|
return frac(sin(float3(dot(p, float3(127.1, 311.7, 248.6)), dot(p, float3(269.5, 183.3, 423.3)), dot(p, float3(248.3, 315.9, 184.2)))) * 43758.5453);
|
|
}
|
|
float3 randomFloat3(float2 Seed, float maximum)
|
|
{
|
|
return (.5 + float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * .5) * (maximum);
|
|
}
|
|
float3 randomFloat3Range(float2 Seed, float Range)
|
|
{
|
|
return (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1) * Range;
|
|
}
|
|
float3 randomFloat3WiggleRange(float2 Seed, float Range, float wiggleSpeed)
|
|
{
|
|
float3 rando = (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1);
|
|
float speed = 1 + wiggleSpeed;
|
|
return float3(sin((_Time.x + rando.x * PI) * speed), sin((_Time.x + rando.y * PI) * speed), sin((_Time.x + rando.z * PI) * speed)) * Range;
|
|
}
|
|
void poiDither(float4 In, float4 ScreenPosition, out float4 Out)
|
|
{
|
|
float2 uv = ScreenPosition.xy * _ScreenParams.xy;
|
|
float DITHER_THRESHOLDS[16] = {
|
|
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
|
|
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
|
|
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
|
|
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
|
|
};
|
|
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
|
|
Out = In - DITHER_THRESHOLDS[index];
|
|
}
|
|
static const float Epsilon = 1e-10;
|
|
static const float3 HCYwts = float3(0.299, 0.587, 0.114);
|
|
static const float HCLgamma = 3;
|
|
static const float HCLy0 = 100;
|
|
static const float HCLmaxL = 0.530454533953517; // == exp(HCLgamma / HCLy0) - 0.5
|
|
static const float3 wref = float3(1.0, 1.0, 1.0);
|
|
#define TAU 6.28318531
|
|
float3 HUEtoRGB(in float H)
|
|
{
|
|
float R = abs(H * 6 - 3) - 1;
|
|
float G = 2 - abs(H * 6 - 2);
|
|
float B = 2 - abs(H * 6 - 4);
|
|
return saturate(float3(R, G, B));
|
|
}
|
|
float3 RGBtoHCV(in float3 RGB)
|
|
{
|
|
float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0 / 3.0) : float4(RGB.gb, 0.0, -1.0 / 3.0);
|
|
float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
|
|
float C = Q.x - min(Q.w, Q.y);
|
|
float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
|
|
return float3(H, C, Q.x);
|
|
}
|
|
float3 HSVtoRGB(in float3 HSV)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSV.x);
|
|
return ((RGB - 1) * HSV.y + 1) * HSV.z;
|
|
}
|
|
float3 RGBtoHSV(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float S = HCV.y / (HCV.z + Epsilon);
|
|
return float3(HCV.x, S, HCV.z);
|
|
}
|
|
float3 HSLtoRGB(in float3 HSL)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSL.x);
|
|
float C = (1 - abs(2 * HSL.z - 1)) * HSL.y;
|
|
return (RGB - 0.5) * C + HSL.z;
|
|
}
|
|
float3 RGBtoHSL(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float L = HCV.z - HCV.y * 0.5;
|
|
float S = HCV.y / (1 - abs(L * 2 - 1) + Epsilon);
|
|
return float3(HCV.x, S, L);
|
|
}
|
|
float3 hueShift(float3 color, float hueOffset)
|
|
{
|
|
color = RGBtoHSV(color);
|
|
color.x = frac(hueOffset +color.x);
|
|
return HSVtoRGB(color);
|
|
}
|
|
float xyzF(float t)
|
|
{
|
|
return lerp(pow(t, 1. / 3.), 7.787037 * t + 0.139731, step(t, 0.00885645));
|
|
}
|
|
float xyzR(float t)
|
|
{
|
|
return lerp(t * t * t, 0.1284185 * (t - 0.139731), step(t, 0.20689655));
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float x, float y, float z)
|
|
{
|
|
float angleX = radians(x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float3 angles)
|
|
{
|
|
float angleX = radians(angles.x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(angles.y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(angles.z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float3 getCameraPosition()
|
|
{
|
|
#ifdef USING_STEREO_MATRICES
|
|
return lerp(unity_StereoWorldSpaceCameraPos[0], unity_StereoWorldSpaceCameraPos[1], 0.5);
|
|
#endif
|
|
return _WorldSpaceCameraPos;
|
|
}
|
|
half2 calcScreenUVs(half4 grabPos)
|
|
{
|
|
half2 uv = grabPos.xy / (grabPos.w + 0.0000000001);
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
uv.xy *= half2(_ScreenParams.x * 2, _ScreenParams.y);
|
|
#else
|
|
uv.xy *= _ScreenParams.xy;
|
|
#endif
|
|
return uv;
|
|
}
|
|
float CalcMipLevel(float2 texture_coord)
|
|
{
|
|
float2 dx = ddx(texture_coord);
|
|
float2 dy = ddy(texture_coord);
|
|
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
|
|
return 0.5 * log2(delta_max_sqr);
|
|
}
|
|
float inverseLerp(float A, float B, float T)
|
|
{
|
|
return (T - A) / (B - A);
|
|
}
|
|
float inverseLerp2(float2 a, float2 b, float2 value)
|
|
{
|
|
float2 AB = b - a;
|
|
float2 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp3(float3 a, float3 b, float3 value)
|
|
{
|
|
float3 AB = b - a;
|
|
float3 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp4(float4 a, float4 b, float4 value)
|
|
{
|
|
float4 AB = b - a;
|
|
float4 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float4 quaternion_conjugate(float4 v)
|
|
{
|
|
return float4(
|
|
v.x, -v.yzw
|
|
);
|
|
}
|
|
float4 quaternion_mul(float4 v1, float4 v2)
|
|
{
|
|
float4 result1 = (v1.x * v2 + v1 * v2.x);
|
|
float4 result2 = float4(
|
|
- dot(v1.yzw, v2.yzw),
|
|
cross(v1.yzw, v2.yzw)
|
|
);
|
|
return float4(result1 + result2);
|
|
}
|
|
float4 get_quaternion_from_angle(float3 axis, float angle)
|
|
{
|
|
float sn = sin(angle * 0.5);
|
|
float cs = cos(angle * 0.5);
|
|
return float4(axis * sn, cs);
|
|
}
|
|
float4 quaternion_from_vector(float3 inVec)
|
|
{
|
|
return float4(0.0, inVec);
|
|
}
|
|
float degree_to_radius(float degree)
|
|
{
|
|
return (
|
|
degree / 180.0 * PI
|
|
);
|
|
}
|
|
float3 rotate_with_quaternion(float3 inVec, float3 rotation)
|
|
{
|
|
float4 qx = get_quaternion_from_angle(float3(1, 0, 0), radians(rotation.x));
|
|
float4 qy = get_quaternion_from_angle(float3(0, 1, 0), radians(rotation.y));
|
|
float4 qz = get_quaternion_from_angle(float3(0, 0, 1), radians(rotation.z));
|
|
#define MUL3(A, B, C) quaternion_mul(quaternion_mul((A), (B)), (C))
|
|
float4 quaternion = normalize(MUL3(qx, qy, qz));
|
|
float4 conjugate = quaternion_conjugate(quaternion);
|
|
float4 inVecQ = quaternion_from_vector(inVec);
|
|
float3 rotated = (
|
|
MUL3(quaternion, inVecQ, conjugate)
|
|
).yzw;
|
|
return rotated;
|
|
}
|
|
float4 transform(float4 input, float4 pos, float4 rotation, float4 scale)
|
|
{
|
|
input.rgb *= (scale.xyz * scale.w);
|
|
input = float4(rotate_with_quaternion(input.xyz, rotation.xyz * rotation.w) + (pos.xyz * pos.w), input.w);
|
|
return input;
|
|
}
|
|
float3 poiThemeColor(in PoiMods poiMods, in float3 srcColor, in float themeIndex)
|
|
{
|
|
if (themeIndex == 0) return srcColor;
|
|
themeIndex -= 1;
|
|
if (themeIndex <= 3)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#endif
|
|
return srcColor;
|
|
}
|
|
float lilIsIn0to1(float f)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, 1.0));
|
|
}
|
|
float lilIsIn0to1(float f, float nv)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, nv));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border)
|
|
{
|
|
return (value - border) / clamp(fwidth(value), 0.0001, 1.0);
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
return smoothstep(border - fwidthValue, border + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float poiEdgeLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float3 OpenLitLinearToSRGB(float3 col)
|
|
{
|
|
return LinearToGammaSpace(col);
|
|
}
|
|
float3 OpenLitSRGBToLinear(float3 col)
|
|
{
|
|
return GammaToLinearSpace(col);
|
|
}
|
|
float OpenLitLuminance(float3 rgb)
|
|
{
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
return dot(rgb, float3(0.22, 0.707, 0.071));
|
|
#else
|
|
return dot(rgb, float3(0.0396819152, 0.458021790, 0.00609653955));
|
|
#endif
|
|
}
|
|
float OpenLitGray(float3 rgb)
|
|
{
|
|
return dot(rgb, float3(1.0/3.0, 1.0/3.0, 1.0/3.0));
|
|
}
|
|
void OpenLitShadeSH9ToonDouble(float3 lightDirection, out float3 shMax, out float3 shMin)
|
|
{
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 N = lightDirection * 0.666666;
|
|
float4 vB = N.xyzz * N.yzzx;
|
|
float3 res = float3(unity_SHAr.w,unity_SHAg.w,unity_SHAb.w);
|
|
res.r += dot(unity_SHBr, vB);
|
|
res.g += dot(unity_SHBg, vB);
|
|
res.b += dot(unity_SHBb, vB);
|
|
res += unity_SHC.rgb * (N.x * N.x - N.y * N.y);
|
|
float3 l1;
|
|
l1.r = dot(unity_SHAr.rgb, N);
|
|
l1.g = dot(unity_SHAg.rgb, N);
|
|
l1.b = dot(unity_SHAb.rgb, N);
|
|
shMax = res + l1;
|
|
shMin = res - l1;
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
shMax = OpenLitLinearToSRGB(shMax);
|
|
shMin = OpenLitLinearToSRGB(shMin);
|
|
#endif
|
|
#else
|
|
shMax = 0.0;
|
|
shMin = 0.0;
|
|
#endif
|
|
}
|
|
float3 OpenLitComputeCustomLightDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 customDir = length(lightDirectionOverride.xyz) * normalize(mul((float3x3)unity_ObjectToWorld, lightDirectionOverride.xyz));
|
|
return lightDirectionOverride.w ? customDir : lightDirectionOverride.xyz; // .w isn't doc'd anywhere and is always 0 unless end user changes it
|
|
}
|
|
float3 OpenLitLightingDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 mainDir = _WorldSpaceLightPos0.xyz * OpenLitLuminance(_LightColor0.rgb);
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 sh9Dir = unity_SHAr.xyz * 0.333333 + unity_SHAg.xyz * 0.333333 + unity_SHAb.xyz * 0.333333;
|
|
float3 sh9DirAbs = float3(sh9Dir.x, abs(sh9Dir.y), sh9Dir.z);
|
|
#else
|
|
float3 sh9Dir = 0;
|
|
float3 sh9DirAbs = 0;
|
|
#endif
|
|
float3 customDir = OpenLitComputeCustomLightDirection(lightDirectionOverride);
|
|
return normalize(sh9DirAbs + mainDir + customDir);
|
|
}
|
|
float3 OpenLitLightingDirection()
|
|
{
|
|
float4 customDir = float4(0.001,0.002,0.001,0.0);
|
|
return OpenLitLightingDirection(customDir);
|
|
}
|
|
inline float4 CalculateFrustumCorrection()
|
|
{
|
|
float x1 = -UNITY_MATRIX_P._31 / (UNITY_MATRIX_P._11 * UNITY_MATRIX_P._34);
|
|
float x2 = -UNITY_MATRIX_P._32 / (UNITY_MATRIX_P._22 * UNITY_MATRIX_P._34);
|
|
return float4(x1, x2, 0, UNITY_MATRIX_P._33 / UNITY_MATRIX_P._34 + x1 * UNITY_MATRIX_P._13 + x2 * UNITY_MATRIX_P._23);
|
|
}
|
|
inline float CorrectedLinearEyeDepth(float z, float B)
|
|
{
|
|
return 1.0 / (z / UNITY_MATRIX_P._34 + B);
|
|
}
|
|
float2 sharpSample( float4 texelSize , float2 p )
|
|
{
|
|
p = p*texelSize.zw;
|
|
float2 c = max(0.0, fwidth(p));
|
|
p = floor(p) + saturate(frac(p) / c);
|
|
p = (p - 0.5)*texelSize.xy;
|
|
return p;
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
float4 AudioLinkDataMultiline(uint2 xycoord) { return AudioLinkData(uint2(xycoord.x % AUDIOLINK_WIDTH, xycoord.y + xycoord.x/AUDIOLINK_WIDTH)); }
|
|
float4 AudioLinkLerp(float2 xy) { return lerp( AudioLinkData(xy), AudioLinkData(xy+int2(1,0)), frac( xy.x ) ); }
|
|
float4 AudioLinkLerpMultiline(float2 xy) { return lerp(AudioLinkDataMultiline(xy), AudioLinkDataMultiline(xy+float2(1,0)), frac(xy.x)); }
|
|
bool AudioLinkIsAvailable()
|
|
{
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
int width, height;
|
|
_AudioTexture.GetDimensions(width, height);
|
|
return width > 16;
|
|
#else
|
|
return _AudioTexture_TexelSize.z > 16;
|
|
#endif
|
|
}
|
|
float AudioLinkGetVersion()
|
|
{
|
|
int2 dims;
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
_AudioTexture.GetDimensions(dims.x, dims.y);
|
|
#else
|
|
dims = _AudioTexture_TexelSize.zw;
|
|
#endif
|
|
if (dims.x >= 128)
|
|
return AudioLinkData(ALPASS_GENERALVU).x;
|
|
else if (dims.x > 16)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
#define AudioLinkGetSelfPixelData(xy) _SelfTexture2D[xy]
|
|
uint AudioLinkDecodeDataAsUInt(uint2 indexloc)
|
|
{
|
|
uint4 rpx = AudioLinkData(indexloc);
|
|
return rpx.r + rpx.g*1024 + rpx.b * 1048576 + rpx.a * 1073741824;
|
|
}
|
|
float AudioLinkDecodeDataAsSeconds(uint2 indexloc)
|
|
{
|
|
uint time = AudioLinkDecodeDataAsUInt(indexloc) & 0x7ffffff;
|
|
return float(time / 1000) + float( time % 1000 ) / 1000.;
|
|
}
|
|
#define ALDecodeDataAsSeconds( x ) AudioLinkDecodeDataAsSeconds( x )
|
|
#define ALDecodeDataAsUInt( x ) AudioLinkDecodeDataAsUInt( x )
|
|
float AudioLinkRemap(float t, float a, float b, float u, float v) { return ((t-a) / (b-a)) * (v-u) + u; }
|
|
float3 AudioLinkHSVtoRGB(float3 HSV)
|
|
{
|
|
float3 RGB = 0;
|
|
float C = HSV.z * HSV.y;
|
|
float H = HSV.x * 6;
|
|
float X = C * (1 - abs(fmod(H, 2) - 1));
|
|
if (HSV.y != 0)
|
|
{
|
|
float I = floor(H);
|
|
if (I == 0) { RGB = float3(C, X, 0); }
|
|
else if (I == 1) { RGB = float3(X, C, 0); }
|
|
else if (I == 2) { RGB = float3(0, C, X); }
|
|
else if (I == 3) { RGB = float3(0, X, C); }
|
|
else if (I == 4) { RGB = float3(X, 0, C); }
|
|
else { RGB = float3(C, 0, X); }
|
|
}
|
|
float M = HSV.z - C;
|
|
return RGB + M;
|
|
}
|
|
float3 AudioLinkCCtoRGB(float bin, float intensity, int rootNote)
|
|
{
|
|
float note = bin / AUDIOLINK_EXPBINS;
|
|
float hue = 0.0;
|
|
note *= 12.0;
|
|
note = glsl_mod(4. - note + rootNote, 12.0);
|
|
{
|
|
if(note < 4.0)
|
|
{
|
|
hue = (note) / 24.0;
|
|
}
|
|
else if(note < 8.0)
|
|
{
|
|
hue = (note-2.0) / 12.0;
|
|
}
|
|
else
|
|
{
|
|
hue = (note - 4.0) / 8.0;
|
|
}
|
|
}
|
|
float val = intensity - 0.1;
|
|
return AudioLinkHSVtoRGB(float3(fmod(hue, 1.0), 1.0, clamp(val, 0.0, 1.0)));
|
|
}
|
|
float4 AudioLinkGetAmplitudeAtFrequency(float hertz)
|
|
{
|
|
float note = AUDIOLINK_EXPBINS * log2(hertz / AUDIOLINK_BOTTOM_FREQUENCY);
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(note, 0));
|
|
}
|
|
float AudioLinkGetAmplitudeAtNote(float octave, float note)
|
|
{
|
|
float quarter = note * 2.0;
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(octave * AUDIOLINK_EXPBINS + quarter, 0));
|
|
}
|
|
float AudioLinkGetChronoTime(uint index, uint band)
|
|
{
|
|
return (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(index, band))) / 100000.0;
|
|
}
|
|
float AudioLinkGetChronoTimeNormalized(uint index, uint band, float speed)
|
|
{
|
|
return frac(AudioLinkGetChronoTime(index, band) * speed);
|
|
}
|
|
float AudioLinkGetChronoTimeInterval(uint index, uint band, float speed, float interval)
|
|
{
|
|
return AudioLinkGetChronoTimeNormalized(index, band, speed) * interval;
|
|
}
|
|
float getBandAtTime(float band, float time, float size = 1.0f)
|
|
{
|
|
return remapClamped(min(size,.9999), 1, AudioLinkData(ALPASS_AUDIOBASS + uint2(time * AUDIOLINK_WIDTH,band)).r);
|
|
}
|
|
fixed3 maximize(fixed3 c) {
|
|
if (c.x == 0 && c.y == 0 && c.z == 0)
|
|
return fixed3(1.0, 1.0, 1.0);
|
|
else
|
|
return c / max(c.r, max(c.g, c.b));
|
|
}
|
|
bool LumaIsAvailable()
|
|
{
|
|
return LumaData(0.629, 0.511).r > 0.9;
|
|
}
|
|
float3 getLumaGradient(uint index, float offset) {
|
|
return LumaData(0.57 + (index * 0.11) + lerp(0, 0.107, offset), 0.493);
|
|
}
|
|
void initPoiAudioLink(inout PoiMods poiMods)
|
|
{
|
|
if (!(1.0 /*_AudioLinkAnimToggle*/)) return;
|
|
if (AudioLinkIsAvailable())
|
|
{
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkVersion = AudioLinkGetVersion();
|
|
poiMods.audioLink.x = AudioLinkData(ALPASS_AUDIOBASS).r;
|
|
poiMods.audioLink.y = AudioLinkData(ALPASS_AUDIOLOWMIDS).r;
|
|
poiMods.audioLink.z = AudioLinkData(ALPASS_AUDIOHIGHMIDS).r;
|
|
poiMods.audioLink.w = AudioLinkData(ALPASS_AUDIOTREBLE).r;
|
|
poiMods.globalColorTheme[4] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(2, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[5] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(3, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[6] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(4, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[7] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(5, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[8] = AudioLinkData(ALPASS_THEME_COLOR0);
|
|
poiMods.globalColorTheme[9] = AudioLinkData(ALPASS_THEME_COLOR1);
|
|
poiMods.globalColorTheme[10] = AudioLinkData(ALPASS_THEME_COLOR2);
|
|
poiMods.globalColorTheme[11] = AudioLinkData(ALPASS_THEME_COLOR3);
|
|
return;
|
|
}
|
|
if (LumaIsAvailable())
|
|
{
|
|
float4 audioPixel = LumaData(0.578, 0.515);
|
|
float audioLows = audioPixel.r;
|
|
float audioHighs = audioPixel.g;
|
|
float4 zone1 = LumaData(0.856, 0.522);
|
|
float4 zone2 = LumaData(0.856, 0.507);
|
|
float4 zone3 = LumaData(0.864, 0.522);
|
|
float4 zone4 = LumaData(0.864, 0.507);
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkViaLuma = true;
|
|
poiMods.audioLink.xy = audioLows;
|
|
poiMods.audioLink.zw = audioHighs;
|
|
poiMods.globalColorTheme[8] = zone1;
|
|
poiMods.globalColorTheme[9] = zone2;
|
|
poiMods.globalColorTheme[10] = zone3;
|
|
poiMods.globalColorTheme[11] = zone4;
|
|
}
|
|
}
|
|
void DebugVisualizer(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiMods poiMods){
|
|
if (_DebugWaveform){
|
|
float waveform = AudioLinkLerpMultiline(ALPASS_WAVEFORM + float2( 500. * poiMesh.uv[0].x, 0)).r;
|
|
poiFragData.emission += clamp(1 - 50 * abs(waveform - poiMesh.uv[0].y * 2. + 1), 0, 1);
|
|
}
|
|
if (_DebugDFT){
|
|
poiFragData.emission += AudioLinkLerpMultiline(ALPASS_DFT + uint2(poiMesh.uv[0].x * AUDIOLINK_ETOTALBINS, 0)).rrr;
|
|
}
|
|
if (_DebugBass){
|
|
poiFragData.emission += poiMods.audioLink.x;
|
|
}
|
|
if (_DebugLowMids){
|
|
poiFragData.emission += poiMods.audioLink.y;
|
|
}
|
|
if (_DebugHighMids){
|
|
poiFragData.emission += poiMods.audioLink.z;
|
|
}
|
|
if (_DebugTreble){
|
|
poiFragData.emission += poiMods.audioLink.w;
|
|
}
|
|
if (_DebugCCColors){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCCOLORS + uint2(3 + 1, 0));
|
|
}
|
|
if (_DebugCCStrip){
|
|
poiFragData.emission += AudioLinkLerp(ALPASS_CCSTRIP + float2(poiMesh.uv[0].x * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if (_DebugCCLights){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCLIGHTS + uint2(uint(poiMesh.uv[0].x * 8) + uint(poiMesh.uv[0].y * 16) * 8, 0));
|
|
}
|
|
if (_DebugAutocorrelator){
|
|
poiFragData.emission += saturate(AudioLinkLerp(ALPASS_AUTOCORRELATOR + float2((abs(1. - poiMesh.uv[0].x * 2.)) * AUDIOLINK_WIDTH, 0)).rrr);
|
|
}
|
|
if (_DebugChronotensity){
|
|
poiFragData.emission += (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(1, 0)) % 1000000) / 1000000.0;
|
|
}
|
|
}
|
|
void SetupAudioLink(inout PoiFragData poiFragData, inout PoiMods poiMods, in PoiMesh poiMesh){
|
|
initPoiAudioLink(poiMods);
|
|
DebugVisualizer(poiFragData, poiMesh, poiMods);
|
|
if(_AudioLinkCCStripY)
|
|
{
|
|
poiFragData.emission += AudioLinkLerp( ALPASS_CCSTRIP + float2( poiMesh.uv[0].y * AUDIOLINK_WIDTH, 0 ) ).rgb * .5;
|
|
}
|
|
}
|
|
#endif
|
|
v2f vert(appdata v)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
PoiInitStruct(v2f, o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
o.objectPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz;
|
|
o.objNormal = v.normal;
|
|
o.normal = UnityObjectToWorldNormal(v.normal);
|
|
o.tangent = UnityObjectToWorldDir(v.tangent);
|
|
o.binormal = cross(o.normal, o.tangent) * (v.tangent.w * unity_WorldTransformParams.w);
|
|
o.vertexColor = v.color;
|
|
o.uv[0] = v.uv0;
|
|
o.uv[1] = v.uv1;
|
|
o.uv[2] = v.uv2;
|
|
o.uv[3] = v.uv3;
|
|
#if defined(LIGHTMAP_ON)
|
|
o.lightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.lightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
o.localPos = v.vertex;
|
|
o.worldPos = mul(unity_ObjectToWorld, o.localPos);
|
|
float3 localOffset = float3(0, 0, 0);
|
|
float3 worldOffset = float3(0, 0, 0);
|
|
o.localPos.rgb += localOffset;
|
|
o.worldPos.rgb += worldOffset;
|
|
o.pos = UnityObjectToClipPos(o.localPos);
|
|
#ifdef POI_PASS_OUTLINE
|
|
#if defined(UNITY_REVERSED_Z)
|
|
o.pos.z += _Offset_Z * - 0.01;
|
|
#else
|
|
o.pos.z += _Offset_Z * 0.01;
|
|
#endif
|
|
#endif
|
|
o.grabPos = ComputeGrabScreenPos(o.pos);
|
|
#ifndef FORWARD_META_PASS
|
|
#if !defined(UNITY_PASS_SHADOWCASTER)
|
|
UNITY_TRANSFER_SHADOW(o, o.uv[0].xy);
|
|
#else
|
|
TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos);
|
|
#endif
|
|
#endif
|
|
UNITY_TRANSFER_FOG(o, o.pos);
|
|
if ((0.0 /*_RenderingReduceClipDistance*/))
|
|
{
|
|
if (o.pos.w < _ProjectionParams.y * 1.01 && o.pos.w > 0)
|
|
{
|
|
o.pos.z = o.pos.z * 0.0001 + o.pos.w * 0.999;
|
|
}
|
|
}
|
|
#ifdef POI_PASS_META
|
|
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
|
#endif
|
|
#if defined(GRAIN)
|
|
float4 worldDirection;
|
|
worldDirection.xyz = o.worldPos.xyz - _WorldSpaceCameraPos;
|
|
worldDirection.w = dot(o.pos, CalculateFrustumCorrection());
|
|
o.worldDirection = worldDirection;
|
|
#endif
|
|
return o;
|
|
}
|
|
void calculateGlobalThemes(inout PoiMods poiMods)
|
|
{
|
|
poiMods.globalColorTheme[0] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[1] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[2] = float4(1,1,1,1);
|
|
poiMods.globalColorTheme[3] = float4(1,1,1,1);
|
|
}
|
|
float2 calculatePolarCoordinate(in PoiMesh poiMesh)
|
|
{
|
|
float2 delta = poiMesh.uv[(0.0 /*_PolarUV*/)] - float4(0.5,0.5,0,0);
|
|
float radius = length(delta) * 2 * (1.0 /*_PolarRadialScale*/);
|
|
float angle = atan2(delta.x, delta.y) * 1.0 / 6.28 * (1.0 /*_PolarLengthScale*/);
|
|
return float2(radius, angle + distance(poiMesh.uv[(0.0 /*_PolarUV*/)], float4(0.5,0.5,0,0)) * (0.0 /*_PolarSpiralPower*/));
|
|
}
|
|
float2 MonoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(1.0 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(1.0, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).zw;
|
|
}
|
|
float2 StereoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(0.5 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(0.5, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).zw;
|
|
}
|
|
float2 calculatePanosphereUV(in PoiMesh poiMesh)
|
|
{
|
|
float3 viewDirection = normalize(lerp(getCameraPosition().xyz, _WorldSpaceCameraPos.xyz, (1.0 /*_PanoUseBothEyes*/)) - poiMesh.worldPos.xyz) * - 1;
|
|
return lerp(MonoPanoProjection(viewDirection), StereoPanoProjection(viewDirection), (0.0 /*_StereoEnabled*/));
|
|
}
|
|
void applyAlphaOptions(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam, in PoiMods poiMods)
|
|
{
|
|
poiFragData.alpha = saturate(poiFragData.alpha + (0.0 /*_AlphaMod*/));
|
|
}
|
|
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_BRANCH_DETAIL) || defined(GEOM_TYPE_FROND) || defined(DEPTH_OF_FIELD_COC_VIEW)
|
|
float2 decalUV(float uvNumber, float4 uv_st, float2 position, half rotation, half rotationSpeed, half2 scale, float4 scaleOffset, float depth, in PoiMesh poiMesh, in PoiCam poiCam)
|
|
{
|
|
scaleOffset = float4(-scaleOffset.x, scaleOffset.y, -scaleOffset.z, scaleOffset.w);
|
|
float2 uv = poiUV(poiMesh.uv[uvNumber], uv_st) + calcParallax(depth + 1, poiCam);
|
|
float2 decalCenter = position;
|
|
float theta = radians(rotation + _Time.z * rotationSpeed);
|
|
float cs = cos(theta);
|
|
float sn = sin(theta);
|
|
uv = float2((uv.x - decalCenter.x) * cs - (uv.y - decalCenter.y) * sn + decalCenter.x, (uv.x - decalCenter.x) * sn + (uv.y - decalCenter.y) * cs + decalCenter.y);
|
|
uv = remap(uv, float2(0, 0) - scale / 2 + position + scaleOffset.xz, scale / 2 + position + scaleOffset.yw, float2(0, 0), float2(1, 1));
|
|
return uv;
|
|
}
|
|
inline float3 decalHueShift(float enabled, float3 color, float shift, float shiftSpeed)
|
|
{
|
|
if (enabled)
|
|
{
|
|
color = hueShift(color, shift + _Time.x * shiftSpeed);
|
|
}
|
|
return color;
|
|
}
|
|
inline float applyTilingClipping(float enabled, float2 uv)
|
|
{
|
|
float ret = 1;
|
|
if (!enabled)
|
|
{
|
|
if (uv.x > 1 || uv.y > 1 || uv.x < 0 || uv.y < 0)
|
|
{
|
|
ret = 0;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
void applyDecals(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam, in PoiMods poiMods, in PoiLight poiLight)
|
|
{
|
|
float decalAlpha = 1;
|
|
float alphaOverride = 0;
|
|
#if defined(PROP_DECALMASK) || !defined(OPTIMIZER_ENABLED)
|
|
float4 decalMask = POI2D_SAMPLER_PAN(_DecalMask, _MainTex, poiUV(poiMesh.uv[(0.0 /*_DecalMaskUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#else
|
|
float4 decalMask = 1;
|
|
#endif
|
|
#ifdef TPS_Penetrator
|
|
if ((0.0 /*_DecalTPSDepthMaskEnabled*/))
|
|
{
|
|
decalMask.r = lerp(0, decalMask.r * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal0TPSMaskStrength*/));
|
|
decalMask.g = lerp(0, decalMask.g * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal1TPSMaskStrength*/));
|
|
decalMask.b = lerp(0, decalMask.b * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal2TPSMaskStrength*/));
|
|
decalMask.a = lerp(0, decalMask.a * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_Decal3TPSMaskStrength*/));
|
|
}
|
|
#endif
|
|
float4 decalColor = 1;
|
|
float2 uv = 0;
|
|
float2 decalScale = float2(1, 1);
|
|
float decalRotation = 0;
|
|
float2 ddxuv = 0;
|
|
float2 ddyuv = 0;
|
|
float4 sideMod = 0;
|
|
if (alphaOverride)
|
|
{
|
|
poiFragData.alpha *= decalAlpha;
|
|
}
|
|
poiFragData.baseColor = saturate(poiFragData.baseColor);
|
|
}
|
|
#endif
|
|
#ifdef VIGNETTE_MASKED
|
|
float _LightingWrappedWrap;
|
|
float _LightingWrappedNormalization;
|
|
float RTWrapFunc(in float dt, in float w, in float norm)
|
|
{
|
|
float cw = saturate(w);
|
|
float o = (dt + cw) / ((1.0 + cw) * (1.0 + cw * norm));
|
|
float flt = 1.0 - 0.85 * norm;
|
|
if (w > 1.0)
|
|
{
|
|
o = lerp(o, flt, w - 1.0);
|
|
}
|
|
return o;
|
|
}
|
|
float3 GreenWrapSH(float fA) // Greens unoptimized and non-normalized
|
|
{
|
|
float fAs = saturate(fA);
|
|
float4 t = float4(fA + 1, fAs - 1, fA - 2, fAs + 1); // DJL edit: allow wrapping to L0-only at w=2
|
|
return float3(t.x, -t.z * t.x / 3, 0.25 * t.y * t.y * t.w);
|
|
}
|
|
float3 GreenWrapSHOpt(float fW) // optimised and normalized https://blog.selfshadow.com/2012/01/07/righting-wrap-part-2/
|
|
{
|
|
const float4 t0 = float4(0.0, 1.0 / 4.0, -1.0 / 3.0, -1.0 / 2.0);
|
|
const float4 t1 = float4(1.0, 2.0 / 3.0, 1.0 / 4.0, 0.0);
|
|
float3 fWs = float3(fW, fW, saturate(fW)); // DJL edit: allow wrapping to L0-only at w=2
|
|
float3 r;
|
|
r.xyz = t0.xxy * fWs + t0.xzw;
|
|
r.xyz = r.xyz * fWs + t1.xyz;
|
|
return r;
|
|
}
|
|
float3 ShadeSH9_wrapped(float3 normal, float wrap)
|
|
{
|
|
float3 x0, x1, x2;
|
|
float3 conv = lerp(GreenWrapSH(wrap), GreenWrapSHOpt(wrap), (0.0 /*_LightingWrappedNormalization*/)); // Should try optimizing this...
|
|
conv *= float3(1, 1.5, 4); // Undo pre-applied cosine convolution by using the inverse
|
|
x0 = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);
|
|
float3 L2_0 = float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / - 3.0;
|
|
x0 -= L2_0;
|
|
x1.r = dot(unity_SHAr.xyz, normal);
|
|
x1.g = dot(unity_SHAg.xyz, normal);
|
|
x1.b = dot(unity_SHAb.xyz, normal);
|
|
float4 vB = normal.xyzz * normal.yzzx;
|
|
x2.r = dot(unity_SHBr, vB);
|
|
x2.g = dot(unity_SHBg, vB);
|
|
x2.b = dot(unity_SHBb, vB);
|
|
float vC = normal.x * normal.x - normal.y * normal.y;
|
|
x2 += unity_SHC.rgb * vC;
|
|
x2 += L2_0;
|
|
return x0 * conv.x + x1 * conv.y + x2 * conv.z;
|
|
}
|
|
float3 GetSHDirectionL1()
|
|
{
|
|
return Unity_SafeNormalize((unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz));
|
|
}
|
|
half3 GetSHMaxL1()
|
|
{
|
|
float3 maxDirection = GetSHDirectionL1();
|
|
return ShadeSH9_wrapped(maxDirection, 0);
|
|
}
|
|
void ApplySubtractiveLighting(inout UnityIndirect indirectLight)
|
|
{
|
|
#if SUBTRACTIVE_LIGHTING
|
|
poiLight.attenuation = FadeShadows(lerp(1, poiLight.attenuation, _AttenuationMultiplier));
|
|
float ndotl = saturate(dot(i.normal, _WorldSpaceLightPos0.xyz));
|
|
float3 shadowedLightEstimate = ndotl * (1 - poiLight.attenuation) * _LightColor0.rgb;
|
|
float3 subtractedLight = indirectLight.diffuse - shadowedLightEstimate;
|
|
subtractedLight = max(subtractedLight, unity_ShadowColor.rgb);
|
|
subtractedLight = lerp(subtractedLight, indirectLight.diffuse, _LightShadowData.x);
|
|
indirectLight.diffuse = min(subtractedLight, indirectLight.diffuse);
|
|
#endif
|
|
}
|
|
UnityIndirect CreateIndirectLight(in PoiMesh poiMesh, in PoiCam poiCam, in PoiLight poiLight)
|
|
{
|
|
UnityIndirect indirectLight;
|
|
indirectLight.diffuse = 0;
|
|
indirectLight.specular = 0;
|
|
#if defined(LIGHTMAP_ON)
|
|
indirectLight.diffuse = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, poiMesh.lightmapUV.xy));
|
|
#if defined(DIRLIGHTMAP_COMBINED)
|
|
float4 lightmapDirection = UNITY_SAMPLE_TEX2D_SAMPLER(
|
|
unity_LightmapInd, unity_Lightmap, poiMesh.lightmapUV.xy
|
|
);
|
|
indirectLight.diffuse = DecodeDirectionalLightmap(
|
|
indirectLight.diffuse, lightmapDirection, poiMesh.normals[1]
|
|
);
|
|
#endif
|
|
ApplySubtractiveLighting(indirectLight);
|
|
#endif
|
|
#if defined(DYNAMICLIGHTMAP_ON)
|
|
float3 dynamicLightDiffuse = DecodeRealtimeLightmap(
|
|
UNITY_SAMPLE_TEX2D(unity_DynamicLightmap, poiMesh.lightmapUV.zw)
|
|
);
|
|
#if defined(DIRLIGHTMAP_COMBINED)
|
|
float4 dynamicLightmapDirection = UNITY_SAMPLE_TEX2D_SAMPLER(
|
|
unity_DynamicDirectionality, unity_DynamicLightmap,
|
|
poiMesh.lightmapUV.zw
|
|
);
|
|
indirectLight.diffuse += DecodeDirectionalLightmap(
|
|
dynamicLightDiffuse, dynamicLightmapDirection, poiMesh.normals[1]
|
|
);
|
|
#else
|
|
indirectLight.diffuse += dynamicLightDiffuse;
|
|
#endif
|
|
#endif
|
|
#if !defined(LIGHTMAP_ON) && !defined(DYNAMICLIGHTMAP_ON)
|
|
#if UNITY_LIGHT_PROBE_PROXY_VOLUME
|
|
if (unity_ProbeVolumeParams.x == 1)
|
|
{
|
|
indirectLight.diffuse = SHEvalLinearL0L1_SampleProbeVolume(
|
|
float4(poiMesh.normals[1], 1), poiMesh.worldPos
|
|
);
|
|
indirectLight.diffuse = max(0, indirectLight.diffuse);
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
indirectLight.diffuse = LinearToGammaSpace(indirectLight.diffuse);
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
indirectLight.diffuse += max(0, ShadeSH9(float4(poiMesh.normals[1], 1)));
|
|
}
|
|
#else
|
|
indirectLight.diffuse += max(0, ShadeSH9(float4(poiMesh.normals[1], 1)));
|
|
#endif
|
|
#endif
|
|
indirectLight.diffuse *= poiLight.occlusion;
|
|
return indirectLight;
|
|
}
|
|
void calculateShading(inout PoiLight poiLight, inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam)
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
float shadowStrength = (1.0 /*_ShadowStrength*/) * poiLight.shadowMask;
|
|
#ifdef POI_PASS_OUTLINE
|
|
shadowStrength = lerp(0, shadowStrength, _OutlineShadowStrength);
|
|
#endif
|
|
#ifdef _LIGHTINGMODE_REALISTIC
|
|
UnityLight light;
|
|
light.dir = poiLight.direction;
|
|
light.color = saturate(_LightColor0.rgb * lerp(1, poiLight.attenuation, poiLight.attenuationStrength) * poiLight.detailShadow);
|
|
light.ndotl = poiLight.nDotLSaturated;
|
|
poiLight.rampedLightMap = poiLight.nDotLSaturated;
|
|
poiLight.finalLighting = max(UNITY_BRDF_PBS(1, 0, 0, 0, poiMesh.normals[1], poiCam.viewDir, light, CreateIndirectLight(poiMesh, poiCam, poiLight)).xyz, (0.0 /*_LightingMinLightBrightness*/));
|
|
#endif
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if ((0.0 /*_LightingAdditiveType*/) == 0)
|
|
{
|
|
poiLight.rampedLightMap = max(0, poiLight.nDotL);
|
|
poiLight.finalLighting = poiLight.directColor * poiLight.attenuation * max(0, poiLight.nDotL) * poiLight.detailShadow * poiLight.additiveShadow;
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 1)
|
|
{
|
|
#if defined(POINT_COOKIE) || defined(DIRECTIONAL_COOKIE)
|
|
float passthrough = 0;
|
|
#else
|
|
float passthrough = (0.5 /*_LightingAdditivePassthrough*/);
|
|
#endif
|
|
if ((0.5 /*_LightingAdditiveGradientEnd*/) == (0.0 /*_LightingAdditiveGradientStart*/)) (0.5 /*_LightingAdditiveGradientEnd*/) += 0.001;
|
|
poiLight.rampedLightMap = smoothstep((0.5 /*_LightingAdditiveGradientEnd*/), (0.0 /*_LightingAdditiveGradientStart*/), 1 - (.5 * poiLight.nDotL + .5));
|
|
#if defined(POINT) || defined(SPOT)
|
|
poiLight.finalLighting = lerp(poiLight.directColor * max(min(poiLight.additiveShadow, poiLight.detailShadow), passthrough), poiLight.indirectColor, smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), 1 - (.5 * poiLight.nDotL + .5))) * poiLight.attenuation;
|
|
#else
|
|
poiLight.finalLighting = lerp(poiLight.directColor * max(min(poiLight.attenuation, poiLight.detailShadow), passthrough), poiLight.indirectColor, smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), 1 - (.5 * poiLight.nDotL + .5)));
|
|
#endif
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 2)
|
|
{
|
|
}
|
|
#endif
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float3 vertexLighting = float3(0, 0, 0);
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
if ((0.0 /*_LightingAdditiveType*/) == 0)
|
|
{
|
|
vertexLighting += poiLight.vColor[index] * poiLight.vAttenuationDotNL[index] * poiLight.detailShadow; // Realistic
|
|
}
|
|
if ((0.0 /*_LightingAdditiveType*/) == 1) // Toon
|
|
{
|
|
vertexLighting += lerp(poiLight.vColor[index] * poiLight.vAttenuation[index], poiLight.vColor[index] * (0.5 /*_LightingAdditivePassthrough*/) * poiLight.vAttenuation[index], smoothstep((0.0 /*_LightingAdditiveGradientStart*/), (0.5 /*_LightingAdditiveGradientEnd*/), .5 * poiLight.vDotNL[index] + .5)) * poiLight.detailShadow;
|
|
}
|
|
}
|
|
float3 mixedLight = poiLight.finalLighting;
|
|
poiLight.finalLighting = vertexLighting + poiLight.finalLighting;
|
|
#endif
|
|
}
|
|
#endif
|
|
#if defined(MOCHIE_PBR) || defined(POI_CLEARCOAT)
|
|
float GSAA_Filament(float3 worldNormal, float perceptualRoughness, float gsaaVariance, float gsaaThreshold)
|
|
{
|
|
float3 du = ddx(worldNormal);
|
|
float3 dv = ddy(worldNormal);
|
|
float variance = gsaaVariance * (dot(du, du) + dot(dv, dv));
|
|
float roughness = perceptualRoughness * perceptualRoughness;
|
|
float kernelRoughness = min(2.0 * variance, gsaaThreshold);
|
|
float squareRoughness = saturate(roughness * roughness + kernelRoughness);
|
|
return sqrt(sqrt(squareRoughness));
|
|
}
|
|
bool SceneHasReflections()
|
|
{
|
|
float width, height;
|
|
unity_SpecCube0.GetDimensions(width, height);
|
|
return !(width * height < 2);
|
|
}
|
|
float3 GetWorldReflections(float3 reflDir, float3 worldPos, float roughness)
|
|
{
|
|
float3 baseReflDir = reflDir;
|
|
reflDir = BoxProjection(reflDir, worldPos, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax);
|
|
float4 envSample0 = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflDir, roughness * UNITY_SPECCUBE_LOD_STEPS);
|
|
float3 p0 = DecodeHDR(envSample0, unity_SpecCube0_HDR);
|
|
float interpolator = unity_SpecCube0_BoxMin.w;
|
|
|
|
if (interpolator < 0.99999)
|
|
{
|
|
float3 refDirBlend = BoxProjection(baseReflDir, worldPos, unity_SpecCube1_ProbePosition, unity_SpecCube1_BoxMin, unity_SpecCube1_BoxMax);
|
|
float4 envSample1 = UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(unity_SpecCube1, unity_SpecCube0, refDirBlend, roughness * UNITY_SPECCUBE_LOD_STEPS);
|
|
float3 p1 = DecodeHDR(envSample1, unity_SpecCube1_HDR);
|
|
p0 = lerp(p1, p0, interpolator);
|
|
}
|
|
return p0;
|
|
}
|
|
float3 GetReflections(in PoiCam poiCam, in PoiLight pl, in PoiMesh poiMesh, float roughness, float ForceFallback, float LightFallback, samplerCUBE reflectionCube, float3 reflectionDir)
|
|
{
|
|
float3 reflections = 0;
|
|
float3 lighting = pl.finalLighting;
|
|
if (ForceFallback == 0)
|
|
{
|
|
|
|
if (SceneHasReflections())
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = GetWorldReflections(reflectionDir, poiMesh.worldPos.xyz, roughness);
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * lerp(1, pl.finalLighting, LightFallback);
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if (LightFallback)
|
|
{
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * pl.finalLighting;
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * lerp(1, pl.finalLighting, LightFallback);
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
if (LightFallback)
|
|
{
|
|
reflections = texCUBElod(reflectionCube, float4(reflectionDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
|
|
reflections = DecodeHDR(float4(reflections, 1), _MochieReflCube_HDR) * pl.finalLighting;
|
|
}
|
|
#endif
|
|
}
|
|
reflections *= pl.occlusion;
|
|
return reflections;
|
|
}
|
|
float GetGGXTerm(float nDotL, float nDotV, float nDotH, float roughness)
|
|
{
|
|
float visibilityTerm = 0;
|
|
if (nDotL > 0)
|
|
{
|
|
float rough = roughness;
|
|
float rough2 = roughness * roughness;
|
|
float lambdaV = nDotL * (nDotV * (1 - rough) + rough);
|
|
float lambdaL = nDotV * (nDotL * (1 - rough) + rough);
|
|
visibilityTerm = 0.5f / (lambdaV + lambdaL + 1e-5f);
|
|
float d = (nDotH * rough2 - nDotH) * nDotH + 1.0f;
|
|
float dotTerm = UNITY_INV_PI * rough2 / (d * d + 1e-7f);
|
|
visibilityTerm *= dotTerm * UNITY_PI;
|
|
}
|
|
return visibilityTerm;
|
|
}
|
|
void GetSpecFresTerm(float nDotL, float nDotV, float nDotH, float lDotH, inout float3 specularTerm, inout float3 fresnelTerm, float3 specCol, float roughness)
|
|
{
|
|
specularTerm = GetGGXTerm(nDotL, nDotV, nDotH, roughness);
|
|
fresnelTerm = FresnelTerm(specCol, lDotH);
|
|
specularTerm = max(0, specularTerm * max(0.00001, nDotL));
|
|
}
|
|
float GetRoughness(float smoothness)
|
|
{
|
|
float rough = 1 - smoothness;
|
|
rough *= 1.7 - 0.7 * rough;
|
|
return rough;
|
|
}
|
|
#endif
|
|
#ifdef MOCHIE_PBR
|
|
void MochieBRDF(inout PoiFragData poiFragData, in PoiCam poiCam, inout PoiLight poiLight, in PoiMesh poiMesh, in PoiMods poiMods)
|
|
{
|
|
float smoothness = (0.4 /*_MochieRoughnessMultiplier*/);
|
|
float smoothness2 = (0.8 /*_MochieRoughnessMultiplier2*/);
|
|
float metallic = (0.0 /*_MochieMetallicMultiplier*/);
|
|
float specularMask = 1;
|
|
float reflectionMask = 1;
|
|
#if defined(PROP_MOCHIEMETALLICMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 PRBMaps = POI2D_SAMPLER_PAN(_MochieMetallicMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_MochieMetallicMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0).xy);
|
|
|
|
if ((0.0 /*_PBRSplitMaskSample*/))
|
|
{
|
|
PRBMaps.zw = POI2D_SAMPLER_PAN(_MochieMetallicMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_MochieMetallicMasksUV*/)], float4(1,1,0,0)), float4(0,0,0,0).xy).zw;
|
|
}
|
|
metallic *= PRBMaps.r;
|
|
smoothness = (smoothness * PRBMaps.g);
|
|
smoothness2 = (smoothness2 * PRBMaps.g);
|
|
reflectionMask *= PRBMaps.b;
|
|
specularMask *= PRBMaps.a;
|
|
#endif
|
|
reflectionMask *= (0.05 /*_MochieReflectionStrength*/);
|
|
specularMask *= (1.0 /*_MochieSpecularStrength*/);
|
|
if ((0.0 /*_MochieSpecularMaskInvert*/))
|
|
{
|
|
specularMask = 1 - specularMask;
|
|
}
|
|
if ((0.0 /*_MochieReflectionMaskInvert*/))
|
|
{
|
|
reflectionMask = 1 - reflectionMask;
|
|
}
|
|
#ifdef TPS_Penetrator
|
|
if ((0.0 /*_BRDFTPSDepthEnabled*/))
|
|
{
|
|
reflectionMask = lerp(0, reflectionMask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_BRDFTPSReflectionMaskStrength*/));
|
|
specularMask = lerp(0, specularMask * TPSBufferedDepth(poiMesh.localPos, poiMesh.vertexColor), (1.0 /*_BRDFTPSSpecularMaskStrength*/));
|
|
}
|
|
#endif
|
|
if ((0.0 /*_MochieRoughnessMapInvert*/))
|
|
{
|
|
smoothness = 1 - smoothness;
|
|
smoothness2 = 1 - smoothness2;
|
|
}
|
|
float roughness = GetRoughness(smoothness);
|
|
float roughness2 = GetRoughness(smoothness2);
|
|
if ((0.0 /*_MochieMetallicMapInvert*/))
|
|
{
|
|
metallic = 1 - metallic;
|
|
}
|
|
float3 specCol = lerp(unity_ColorSpaceDielectricSpec.rgb, poiFragData.baseColor, metallic);
|
|
float omr = unity_ColorSpaceDielectricSpec.a - metallic * unity_ColorSpaceDielectricSpec.a;
|
|
float percepRough = 1 - smoothness;
|
|
float percepRough2 = 1 - smoothness2;
|
|
|
|
if ((1.0 /*_MochieGSAAEnabled*/))
|
|
{
|
|
percepRough = GSAA_Filament(poiMesh.normals[1], percepRough, (0.15 /*_PoiGSAAVariance*/), (0.1 /*_PoiGSAAThreshold*/));
|
|
if ((1.0 /*_Specular2ndLayer*/) == 1 && (1.0 /*_MochieSpecularStrength2*/) > 0)
|
|
{
|
|
percepRough2 = GSAA_Filament(poiMesh.normals[1], percepRough2, (0.15 /*_PoiGSAAVariance*/), (0.1 /*_PoiGSAAThreshold*/));
|
|
}
|
|
}
|
|
float brdfRoughness = percepRough * percepRough;
|
|
brdfRoughness = max(brdfRoughness, 0.002);
|
|
float brdfRoughness2 = percepRough2 * percepRough2;
|
|
brdfRoughness2 = max(brdfRoughness2, 0.002);
|
|
float3 diffuse = poiFragData.baseColor;
|
|
float3 specular = 0;
|
|
float3 specular2 = 0;
|
|
float3 vSpecular = 0;
|
|
float3 vSpecular2 = 0;
|
|
float3 reflections = 0;
|
|
float3 environment = 0;
|
|
float attenuation = min(poiLight.nDotLSaturated, lerp(poiLight.attenuation, 1, (0.0 /*_IgnoreCastedShadows*/)));
|
|
float3 fresnelTerm = 1;
|
|
float3 specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.nDotL, poiLight.nDotV, poiLight.nDotH, poiLight.lDotH, specularTerm, fresnelTerm, specCol, brdfRoughness);
|
|
specular = poiLight.directColor * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * attenuation;
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
fresnelTerm = 1;
|
|
specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.vDotNL[index], poiLight.nDotV, poiLight.vDotNH[index], poiLight.vDotLH[index], specularTerm, fresnelTerm, specCol, brdfRoughness);
|
|
vSpecular += poiLight.vColor[index] * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * poiLight.vAttenuation[index];
|
|
}
|
|
#endif
|
|
if ((1.0 /*_Specular2ndLayer*/) == 1)
|
|
{
|
|
float3 fresnelTerm = 1;
|
|
float3 specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.nDotL, poiLight.nDotV, poiLight.nDotH, poiLight.lDotH, specularTerm, fresnelTerm, specCol, brdfRoughness2);
|
|
specular2 = poiLight.directColor * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * attenuation * (1.0 /*_MochieSpecularStrength2*/);
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
fresnelTerm = 1;
|
|
specularTerm = 1;
|
|
GetSpecFresTerm(poiLight.vDotNL[index], poiLight.nDotV, poiLight.vDotNH[index], poiLight.vDotLH[index], specularTerm, fresnelTerm, specCol, brdfRoughness2);
|
|
vSpecular2 += poiLight.vColor[index] * specularTerm * fresnelTerm * specularMask * poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieSpecularTintThemeIndex*/)) * poiLight.occlusion * poiLight.vAttenuation[index] * (1.0 /*_MochieSpecularStrength2*/);
|
|
}
|
|
#endif
|
|
}
|
|
float surfaceReduction = (1.0 / (brdfRoughness * brdfRoughness + 1.0));
|
|
float grazingTerm = saturate(smoothness + (1 - omr));
|
|
float3 reflCol = GetReflections(poiCam, poiLight, poiMesh, roughness, (0.0 /*_MochieForceFallback*/), (0.0 /*_MochieLitFallback*/), _MochieReflCube, poiCam.reflectionDir);
|
|
reflections = surfaceReduction * reflCol * lerp(1, FresnelLerp(specCol, grazingTerm, poiLight.nDotV), (1.0 /*_RefSpecFresnel*/));
|
|
reflections *= poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_MochieReflectionTintThemeIndex*/));
|
|
reflections *= reflectionMask;
|
|
#ifdef POI_PASS_ADD
|
|
reflections *= poiLight.attenuation;
|
|
#endif
|
|
diffuse = lerp(diffuse, diffuse * omr, reflectionMask);
|
|
environment = max(specular + vSpecular, specular2 + vSpecular2);
|
|
environment += reflections;
|
|
diffuse *= poiLight.finalLighting;
|
|
poiFragData.finalColor = diffuse;
|
|
poiLight.finalLightAdd += environment;
|
|
}
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
void applyPathing(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiMods poiMods)
|
|
{
|
|
float3 albedo = poiFragData.baseColor;
|
|
float3 pathEmission;
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
float4 path = _PathingMap.Sample(SmpRepeatPoint, poiUV(poiMesh.uv[(0.0 /*_PathingMapUV*/)], float4(1,1,0,0)) + float4(0,0,0,0).xy * _Time.x);
|
|
#else
|
|
float4 path = float4(1, 1, 1, 1);
|
|
#endif
|
|
float4 PathColor[4];
|
|
half pathAudioLinkPathTimeOffsetBand[4] = {
|
|
0, 0, 0, 0
|
|
};
|
|
half2 pathAudioLinkTimeOffset[4] = {
|
|
half2(0, 0), half2(0, 0), half2(0, 0), half2(0, 0)
|
|
};
|
|
half pathAudioLinkPathWidthOffsetBand[4] = {
|
|
0, 0, 0, 0
|
|
};
|
|
half2 pathAudioLinkWidthOffset[4] = {
|
|
half2(0, 0), half2(0, 0), half2(0, 0), half2(0, 0)
|
|
};
|
|
PathColor[0] = float4(1.498039,0,0,0);
|
|
PathColor[1] = float4(0,1.498039,0,0);
|
|
PathColor[2] = float4(0,0,1.498039,0);
|
|
PathColor[3] = float4(1.498039,1.498039,1.498039,0);
|
|
if ((0.0 /*_PathGradientType*/) == 1)
|
|
{
|
|
path = (path.r + path.g + path.b + path.a) * .25;
|
|
}
|
|
#if defined(PROP_PATHINGCOLORMAP) || !defined(OPTIMIZER_ENABLED)
|
|
float4 pathColorMap = POI2D_SAMPLER_PAN(_PathingColorMap, _MainTex, poiUV(poiMesh.uv[(0.0 /*_PathingColorMapUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#else
|
|
float4 pathColorMap = float4(1, 1, 1, 1);
|
|
#endif
|
|
float4 pathAudioLinkEmission = 0;
|
|
float4 pathTime = 0;
|
|
float3 pathAlpha[4] = {
|
|
float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)
|
|
};
|
|
#ifdef POI_AUDIOLINK
|
|
float4 chronoType = float4((2.0 /*_PathChronoTypeR*/), (2.0 /*_PathChronoTypeG*/), (2.0 /*_PathChronoTypeB*/), (0.0 /*_PathChronoTypeA*/));
|
|
float4 chronoBand = float4((0.0 /*_PathChronoBandR*/), (1.0 /*_PathChronoBandG*/), (0.0 /*_PathChronoBandB*/), (0.0 /*_PathChronoBandA*/));
|
|
float4 chronoSpeed = float4((0.3 /*_PathChronoSpeedR*/), (0.4 /*_PathChronoSpeedG*/), (0.2 /*_PathChronoSpeedB*/), (0.0 /*_PathChronoSpeedA*/));
|
|
float4 autoCorrelator = float4((0.0 /*_PathALAutoCorrelatorR*/), (0.0 /*_PathALAutoCorrelatorG*/), (0.0 /*_PathALAutoCorrelatorB*/), (0.0 /*_PathALAutoCorrelatorA*/));
|
|
float2 history[4] = {
|
|
float2((1.0 /*_PathALHistoryR*/), (0.0 /*_PathALHistoryBandR*/)), float2((1.0 /*_PathALHistoryG*/), (0.0 /*_PathALHistoryBandG*/)), float2((1.0 /*_PathALHistoryB*/), (0.0 /*_PathALHistoryBandB*/)), float2((0.0 /*_PathALHistoryA*/), (0.0 /*_PathALHistoryBandA*/))
|
|
};
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALTimeOffset*/))
|
|
{
|
|
pathAudioLinkPathTimeOffsetBand[0] = (0.0 /*_AudioLinkPathTimeOffsetBandR*/);
|
|
pathAudioLinkPathTimeOffsetBand[1] = (1.0 /*_AudioLinkPathTimeOffsetBandG*/);
|
|
pathAudioLinkPathTimeOffsetBand[2] = (2.0 /*_AudioLinkPathTimeOffsetBandB*/);
|
|
pathAudioLinkPathTimeOffsetBand[3] = (0.0 /*_AudioLinkPathTimeOffsetBandA*/);
|
|
pathAudioLinkTimeOffset[0] = float4(0,0.7,0,1).xy;
|
|
pathAudioLinkTimeOffset[1] = float4(0,-0.6,0,1).xy;
|
|
pathAudioLinkTimeOffset[2] = float4(0,0.6,0,1).xy;
|
|
pathAudioLinkTimeOffset[3] = float4(0,0,0,1).xy;
|
|
}
|
|
if ((1.0 /*_PathALWidthOffset*/))
|
|
{
|
|
pathAudioLinkPathWidthOffsetBand[0] = (0.0 /*_AudioLinkPathWidthOffsetBandR*/);
|
|
pathAudioLinkPathWidthOffsetBand[1] = (1.0 /*_AudioLinkPathWidthOffsetBandG*/);
|
|
pathAudioLinkPathWidthOffsetBand[2] = (0.0 /*_AudioLinkPathWidthOffsetBandB*/);
|
|
pathAudioLinkPathWidthOffsetBand[3] = (0.0 /*_AudioLinkPathWidthOffsetBandA*/);
|
|
pathAudioLinkWidthOffset[0] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[1] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[2] = float4(0,-0.4,0,0).xy;
|
|
pathAudioLinkWidthOffset[3] = float4(0,0,0,1).xy;
|
|
}
|
|
if ((1.0 /*_PathALEmissionOffset*/))
|
|
{
|
|
pathAudioLinkEmission.r += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(2.0 /*_AudioLinkPathEmissionAddBandR*/)]);
|
|
pathAudioLinkEmission.g += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(1.0 /*_AudioLinkPathEmissionAddBandG*/)]);
|
|
pathAudioLinkEmission.b += lerp(float4(0,20,0,0).x, float4(0,20,0,0).y, poiMods.audioLink[(2.0 /*_AudioLinkPathEmissionAddBandB*/)]);
|
|
pathAudioLinkEmission.a += lerp(float4(0,0,0,1).x, float4(0,0,0,1).y, poiMods.audioLink[(0.0 /*_AudioLinkPathEmissionAddBandA*/)]);
|
|
}
|
|
if ((0.0 /*_PathALCCR*/))
|
|
{
|
|
PathColor[0] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[0] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCG*/))
|
|
{
|
|
PathColor[1] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[1] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCB*/))
|
|
{
|
|
PathColor[2] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[2] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if ((0.0 /*_PathALCCA*/))
|
|
{
|
|
PathColor[3] *= AudioLinkLerp(ALPASS_CCSTRIP + float2(path[3] * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
}
|
|
#endif
|
|
[unroll]
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
float timeOffset = 0;
|
|
#ifdef POI_AUDIOLINK
|
|
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALTimeOffset*/))
|
|
{
|
|
timeOffset += lerp(pathAudioLinkTimeOffset[index].x, pathAudioLinkTimeOffset[index].y, poiMods.audioLink[pathAudioLinkPathTimeOffsetBand[index]]);
|
|
}
|
|
if ((0.0 /*_PathALChrono*/))
|
|
{
|
|
timeOffset += AudioLinkGetChronoTime(chronoType[index], chronoBand[index]) * chronoSpeed[index];
|
|
}
|
|
}
|
|
#endif
|
|
pathTime[index] = float4(-999,-999,-999,1)[index] != -999.0f ? frac(float4(-999,-999,-999,1)[index] + float4(0,0,0,1)[index] + timeOffset) : frac(_Time.x * float4(1,-2.5,4,1)[index] + float4(0,0,0,1)[index] + timeOffset);
|
|
if (float4(0,0,0,1)[index])
|
|
{
|
|
float pathSegments = abs(float4(0,0,0,1)[index]);
|
|
pathTime = (ceil(pathTime * pathSegments) - .5) / pathSegments;
|
|
}
|
|
if (path[index])
|
|
{
|
|
half pathWidth = float4(0.8,0.75,0.9,1)[index] * .5;
|
|
#ifdef POI_AUDIOLINK
|
|
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((1.0 /*_PathALWidthOffset*/))
|
|
{
|
|
pathWidth += lerp(pathAudioLinkWidthOffset[index].x, pathAudioLinkWidthOffset[index].y, poiMods.audioLink[pathAudioLinkPathWidthOffsetBand[index]]);
|
|
}
|
|
}
|
|
#endif
|
|
pathAlpha[index].x = pathTime[index] > path[index];
|
|
pathAlpha[index].y = saturate((1 - abs(lerp(-pathWidth, 1 + pathWidth, pathTime[index]) - path[index])) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index].z = saturate((1 - distance(pathTime[index], path[index])) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index].z += saturate(distance(pathTime[index], path[index]) - (1 - pathWidth)) * (1 / pathWidth);
|
|
pathAlpha[index] = smoothstep(0, float4(0.8,0.9,0.9,1)[index] + .00001, pathAlpha[index]);
|
|
#ifdef POI_AUDIOLINK
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
if ((0.0 /*_PathALHistory*/) && history[index].x)
|
|
{
|
|
pathAlpha[index] *= AudioLinkLerp(ALPASS_AUDIOLINK + float2(path[index] * AUDIOLINK_WIDTH, history[index].y)).r;
|
|
}
|
|
if ((0.0 /*_PathALAutoCorrelator*/) && autoCorrelator[index] != 0)
|
|
{
|
|
float autoCorrelatorUV = path[index];
|
|
if (autoCorrelator[index] == 2)
|
|
{
|
|
autoCorrelatorUV = abs(1. - path[index] * 2.);
|
|
}
|
|
pathAlpha[index] *= AudioLinkLerp(ALPASS_AUTOCORRELATOR + float2(autoCorrelatorUV * AUDIOLINK_WIDTH, 0)).r;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
pathEmission = 0;
|
|
pathEmission += pathAlpha[0][(2.0 /*_PathTypeR*/)] * poiThemeColor(poiMods, PathColor[0].rgb, (0.0 /*_PathColorRThemeIndex*/)) * (float4(5,5,5,1)[0] + pathAudioLinkEmission.r);
|
|
pathEmission += pathAlpha[1][(2.0 /*_PathTypeG*/)] * poiThemeColor(poiMods, PathColor[1].rgb, (0.0 /*_PathColorGThemeIndex*/)) * (float4(5,5,5,1)[1] + pathAudioLinkEmission.g);
|
|
pathEmission += pathAlpha[2][(2.0 /*_PathTypeB*/)] * poiThemeColor(poiMods, PathColor[2].rgb, (0.0 /*_PathColorBThemeIndex*/)) * (float4(5,5,5,1)[2] + pathAudioLinkEmission.b);
|
|
pathEmission += pathAlpha[3][(0.0 /*_PathTypeA*/)] * poiThemeColor(poiMods, PathColor[3].rgb, (0.0 /*_PathColorAThemeIndex*/)) * (float4(5,5,5,1)[3] + pathAudioLinkEmission.a);
|
|
pathEmission *= pathColorMap.rgb * pathColorMap.a;
|
|
float3 colorReplace = 0;
|
|
colorReplace = pathAlpha[0][(2.0 /*_PathTypeR*/)] * poiThemeColor(poiMods, PathColor[0].rgb, (0.0 /*_PathColorRThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[0].a * pathAlpha[0][(2.0 /*_PathTypeR*/)]);
|
|
colorReplace = pathAlpha[1][(2.0 /*_PathTypeG*/)] * poiThemeColor(poiMods, PathColor[1].rgb, (0.0 /*_PathColorGThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[1].a * pathAlpha[1][(2.0 /*_PathTypeG*/)]);
|
|
colorReplace = pathAlpha[2][(2.0 /*_PathTypeB*/)] * poiThemeColor(poiMods, PathColor[2].rgb, (0.0 /*_PathColorBThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[2].a * pathAlpha[2][(2.0 /*_PathTypeB*/)]);
|
|
colorReplace = pathAlpha[3][(0.0 /*_PathTypeA*/)] * poiThemeColor(poiMods, PathColor[3].rgb, (0.0 /*_PathColorAThemeIndex*/)) * pathColorMap.rgb;
|
|
albedo.rgb = lerp(albedo.rgb, colorReplace + albedo.rgb * 0.00001, pathColorMap.a * PathColor[3].a * pathAlpha[3][(0.0 /*_PathTypeA*/)]);
|
|
float alpha = max(max(max(pathAlpha[0][(2.0 /*_PathTypeR*/)], pathAlpha[1][(2.0 /*_PathTypeG*/)]), pathAlpha[2][(2.0 /*_PathTypeB*/)]), pathAlpha[3][(0.0 /*_PathTypeA*/)]);
|
|
poiFragData.alpha *= lerp(1, alpha, (1.0 /*_PathingOverrideAlpha*/));
|
|
poiFragData.baseColor = albedo.rgb;
|
|
poiFragData.emission += pathEmission;
|
|
}
|
|
#endif
|
|
float4 frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(i);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
|
PoiMesh poiMesh;
|
|
PoiInitStruct(PoiMesh, poiMesh);
|
|
PoiLight poiLight;
|
|
PoiInitStruct(PoiLight, poiLight);
|
|
PoiVertexLights poiVertexLights;
|
|
PoiInitStruct(PoiVertexLights, poiVertexLights);
|
|
PoiCam poiCam;
|
|
PoiInitStruct(PoiCam, poiCam);
|
|
PoiMods poiMods;
|
|
PoiInitStruct(PoiMods, poiMods);
|
|
poiMods.globalEmission = 1;
|
|
PoiFragData poiFragData;
|
|
poiFragData.emission = 0;
|
|
poiFragData.baseColor = float3(0, 0, 0);
|
|
poiFragData.finalColor = float3(0, 0, 0);
|
|
poiFragData.alpha = 1;
|
|
#ifdef POI_UDIMDISCARD
|
|
applyUDIMDiscard(i);
|
|
#endif
|
|
poiMesh.objectPosition = i.objectPos;
|
|
poiMesh.objNormal = i.objNormal;
|
|
poiMesh.normals[0] = i.normal;
|
|
poiMesh.tangent = i.tangent;
|
|
poiMesh.binormal = i.binormal;
|
|
poiMesh.worldPos = i.worldPos.xyz;
|
|
poiMesh.localPos = i.localPos.xyz;
|
|
poiMesh.vertexColor = i.vertexColor;
|
|
poiMesh.isFrontFace = facing;
|
|
#ifndef POI_PASS_OUTLINE
|
|
if (!poiMesh.isFrontFace)
|
|
{
|
|
poiMesh.normals[0] *= -1;
|
|
poiMesh.tangent *= -1;
|
|
poiMesh.binormal *= -1;
|
|
}
|
|
#endif
|
|
poiCam.viewDir = !IsOrthographicCamera() ? normalize(_WorldSpaceCameraPos - i.worldPos.xyz) : normalize(UNITY_MATRIX_I_V._m02_m12_m22);
|
|
float3 tanToWorld0 = float3(i.tangent.x, i.binormal.x, i.normal.x);
|
|
float3 tanToWorld1 = float3(i.tangent.y, i.binormal.y, i.normal.y);
|
|
float3 tanToWorld2 = float3(i.tangent.z, i.binormal.z, i.normal.z);
|
|
float3 ase_tanViewDir = tanToWorld0 * poiCam.viewDir.x + tanToWorld1 * poiCam.viewDir.y + tanToWorld2 * poiCam.viewDir.z;
|
|
poiCam.tangentViewDir = normalize(ase_tanViewDir);
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
poiMesh.lightmapUV = i.lightmapUV;
|
|
#endif
|
|
poiMesh.parallaxUV = poiCam.tangentViewDir.xy / max(poiCam.tangentViewDir.z, 0.0001);
|
|
poiMesh.uv[0] = i.uv[0];
|
|
poiMesh.uv[1] = i.uv[1];
|
|
poiMesh.uv[2] = i.uv[2];
|
|
poiMesh.uv[3] = i.uv[3];
|
|
poiMesh.uv[4] = poiMesh.uv[0];
|
|
poiMesh.uv[5] = poiMesh.worldPos.xz;
|
|
poiMesh.uv[6] = poiMesh.uv[0];
|
|
poiMesh.uv[7] = poiMesh.uv[0];
|
|
poiMesh.uv[4] = calculatePanosphereUV(poiMesh);
|
|
poiMesh.uv[6] = calculatePolarCoordinate(poiMesh);
|
|
float2 mainUV = poiMesh.uv[(0.0 /*_MainTexUV*/)].xy;
|
|
if ((0.0 /*_MainPixelMode*/))
|
|
{
|
|
mainUV = sharpSample(float4(0.0002441406,0.0002441406,4096,4096), mainUV);
|
|
}
|
|
float4 mainTexture = UNITY_SAMPLE_TEX2D(_MainTex, poiUV(mainUV, float4(1,1,0,0)) + _Time.x * float4(0,0,0,0));
|
|
float3 mainNormal = UnpackScaleNormal(POI2D_SAMPLER_PAN(_BumpMap, _MainTex, poiUV(poiMesh.uv[(0.0 /*_BumpMapUV*/)], float4(1,1,0,0)), float4(0,0,0,0)), (1.0 /*_BumpScale*/));
|
|
poiMesh.tangentSpaceNormal = mainNormal;
|
|
poiMesh.normals[1] = normalize(
|
|
poiMesh.tangentSpaceNormal.x * poiMesh.tangent.xyz +
|
|
poiMesh.tangentSpaceNormal.y * poiMesh.binormal +
|
|
poiMesh.tangentSpaceNormal.z * poiMesh.normals[0]
|
|
);
|
|
float3 fancyNormal = UnpackNormal(float4(0.5, 0.5, 1, 1));
|
|
poiMesh.normals[0] = normalize(
|
|
fancyNormal.x * poiMesh.tangent.xyz +
|
|
fancyNormal.y * poiMesh.binormal +
|
|
fancyNormal.z * poiMesh.normals[0]
|
|
);
|
|
poiCam.forwardDir = getCameraForward();
|
|
poiCam.worldPos = _WorldSpaceCameraPos;
|
|
poiCam.reflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[1]);
|
|
poiCam.vertexReflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[0]);
|
|
poiCam.distanceToVert = distance(poiMesh.worldPos, poiCam.worldPos);
|
|
poiCam.grabPos = i.grabPos;
|
|
poiCam.screenUV = calcScreenUVs(i.grabPos);
|
|
poiCam.vDotN = abs(dot(poiCam.viewDir, poiMesh.normals[1]));
|
|
poiCam.clipPos = i.pos;
|
|
poiCam.worldDirection = i.worldDirection;
|
|
calculateGlobalThemes(poiMods);
|
|
#ifdef POI_AUDIOLINK
|
|
SetupAudioLink(poiFragData, poiMods, poiMesh);
|
|
#endif
|
|
poiLight.finalLightAdd = 0;
|
|
#if defined(PROP_LIGHTINGAOMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 AOMaps = POI2D_SAMPLER_PAN(_LightingAOMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingAOMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
poiLight.occlusion = lerp(1, AOMaps.r, (0.3333 /*_LightDataAOStrengthR*/)) * lerp(1, AOMaps.g, (0.3333 /*_LightDataAOStrengthG*/)) * lerp(1, AOMaps.b, (0.3333 /*_LightDataAOStrengthB*/)) * lerp(1, AOMaps.a, (0.0 /*_LightDataAOStrengthA*/));
|
|
#else
|
|
poiLight.occlusion = 1;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGDETAILSHADOWMAPS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 DetailShadows = POI2D_SAMPLER_PAN(_LightingDetailShadowMaps, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingDetailShadowMapsUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
#ifndef POI_PASS_ADD
|
|
poiLight.detailShadow = lerp(1, DetailShadows.r, (1.0 /*_LightingDetailShadowStrengthR*/)) * lerp(1, DetailShadows.g, (0.0 /*_LightingDetailShadowStrengthG*/)) * lerp(1, DetailShadows.b, (0.0 /*_LightingDetailShadowStrengthB*/)) * lerp(1, DetailShadows.a, (0.0 /*_LightingDetailShadowStrengthA*/));
|
|
#else
|
|
poiLight.detailShadow = lerp(1, DetailShadows.r, (1.0 /*_LightingAddDetailShadowStrengthR*/)) * lerp(1, DetailShadows.g, (0.0 /*_LightingAddDetailShadowStrengthG*/)) * lerp(1, DetailShadows.b, (0.0 /*_LightingAddDetailShadowStrengthB*/)) * lerp(1, DetailShadows.a, (0.0 /*_LightingAddDetailShadowStrengthA*/));
|
|
#endif
|
|
#else
|
|
poiLight.detailShadow = 1;
|
|
#endif
|
|
#if defined(PROP_LIGHTINGSHADOWMASKS) || !defined(OPTIMIZER_ENABLED)
|
|
float4 ShadowMasks = POI2D_SAMPLER_PAN(_LightingShadowMasks, _MainTex, poiUV(poiMesh.uv[(0.0 /*_LightingShadowMasksUV*/)], float4(1,1,0,0)), float4(0,0,0,0));
|
|
poiLight.shadowMask = lerp(1, ShadowMasks.r, (1.0 /*_LightingShadowMaskStrengthR*/)) * lerp(1, ShadowMasks.g, (0.0 /*_LightingShadowMaskStrengthG*/)) * lerp(1, ShadowMasks.b, (0.0 /*_LightingShadowMaskStrengthB*/)) * lerp(1, ShadowMasks.a, (0.0 /*_LightingShadowMaskStrengthA*/));
|
|
#else
|
|
poiLight.shadowMask = 1;
|
|
#endif
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
bool lightExists = false;
|
|
if (any(_LightColor0.rgb >= 0.002))
|
|
{
|
|
lightExists = true;
|
|
}
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float4 toLightX = unity_4LightPosX0 - i.worldPos.x;
|
|
float4 toLightY = unity_4LightPosY0 - i.worldPos.y;
|
|
float4 toLightZ = unity_4LightPosZ0 - i.worldPos.z;
|
|
float4 lengthSq = 0;
|
|
lengthSq += toLightX * toLightX;
|
|
lengthSq += toLightY * toLightY;
|
|
lengthSq += toLightZ * toLightZ;
|
|
float4 lightAttenSq = unity_4LightAtten0;
|
|
float4 atten = 1.0 / (1.0 + lengthSq * lightAttenSq);
|
|
float4 vLightWeight = saturate(1 - (lengthSq * lightAttenSq / 25));
|
|
poiLight.vAttenuation = min(atten, vLightWeight * vLightWeight);
|
|
poiLight.vDotNL = 0;
|
|
poiLight.vDotNL += toLightX * poiMesh.normals[1].x;
|
|
poiLight.vDotNL += toLightY * poiMesh.normals[1].y;
|
|
poiLight.vDotNL += toLightZ * poiMesh.normals[1].z;
|
|
float4 corr = rsqrt(lengthSq);
|
|
poiLight.vertexVDotNL = max(0, poiLight.vDotNL * corr);
|
|
poiLight.vertexVDotNL = 0;
|
|
poiLight.vertexVDotNL += toLightX * poiMesh.normals[0].x;
|
|
poiLight.vertexVDotNL += toLightY * poiMesh.normals[0].y;
|
|
poiLight.vertexVDotNL += toLightZ * poiMesh.normals[0].z;
|
|
poiLight.vertexVDotNL = max(0, poiLight.vDotNL * corr);
|
|
poiLight.vAttenuationDotNL = saturate(poiLight.vAttenuation * saturate(poiLight.vDotNL));
|
|
for (int index = 0; index < 4; index++)
|
|
{
|
|
poiLight.vPosition[index] = float3(unity_4LightPosX0[index], unity_4LightPosY0[index], unity_4LightPosZ0[index]);
|
|
float3 vertexToLightSource = poiLight.vPosition[index] - poiMesh.worldPos;
|
|
poiLight.vDirection[index] = normalize(vertexToLightSource);
|
|
poiLight.vColor[index] = unity_LightColor[index].rgb;
|
|
poiLight.vHalfDir[index] = Unity_SafeNormalize(poiLight.vDirection[index] + poiCam.viewDir);
|
|
poiLight.vDotNL[index] = dot(poiMesh.normals[1], -poiLight.vDirection[index]);
|
|
poiLight.vCorrectedDotNL[index] = .5 * (poiLight.vDotNL[index] + 1);
|
|
poiLight.vDotLH[index] = saturate(dot(poiLight.vDirection[index], poiLight.vHalfDir[index]));
|
|
poiLight.vDotNH[index] = dot(poiMesh.normals[1], poiLight.vHalfDir[index]);
|
|
poiLight.vertexVDotNH[index] = saturate(dot(poiMesh.normals[0], poiLight.vHalfDir[index]));
|
|
}
|
|
#endif
|
|
if ((0.0 /*_LightingColorMode*/) == 0) // Poi Custom Light Color
|
|
{
|
|
float3 magic = max(BetterSH9(normalize(unity_SHAr + unity_SHAg + unity_SHAb)), 0);
|
|
float3 normalLight = _LightColor0.rgb + BetterSH9(float4(0, 0, 0, 1));
|
|
float magiLumi = calculateluminance(magic);
|
|
float normaLumi = calculateluminance(normalLight);
|
|
float maginormalumi = magiLumi + normaLumi;
|
|
float magiratio = magiLumi / maginormalumi;
|
|
float normaRatio = normaLumi / maginormalumi;
|
|
float target = calculateluminance(magic * magiratio + normalLight * normaRatio);
|
|
float3 properLightColor = magic + normalLight;
|
|
float properLuminance = calculateluminance(magic + normalLight);
|
|
poiLight.directColor = properLightColor * max(0.0001, (target / properLuminance));
|
|
poiLight.indirectColor = BetterSH9(float4(lerp(0, poiMesh.normals[1], (0.0 /*_LightingIndirectUsesNormals*/)), 1));
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 1) // More standard approach to light color
|
|
{
|
|
float3 indirectColor = BetterSH9(float4(poiMesh.normals[1], 1));
|
|
if (lightExists)
|
|
{
|
|
poiLight.directColor = _LightColor0.rgb;
|
|
poiLight.indirectColor = indirectColor;
|
|
}
|
|
else
|
|
{
|
|
poiLight.directColor = indirectColor * 0.6;
|
|
poiLight.indirectColor = indirectColor * 0.5;
|
|
}
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 2) // UTS style
|
|
{
|
|
poiLight.indirectColor = saturate(max(half3(0.05, 0.05, 0.05) * (1.0 /*_Unlit_Intensity*/), max(ShadeSH9(half4(0.0, 0.0, 0.0, 1.0)), ShadeSH9(half4(0.0, -1.0, 0.0, 1.0)).rgb) * (1.0 /*_Unlit_Intensity*/)));
|
|
poiLight.directColor = max(poiLight.indirectColor, _LightColor0.rgb);
|
|
}
|
|
if ((0.0 /*_LightingColorMode*/) == 3) // OpenLit
|
|
{
|
|
float3 lightDirectionForSH9 = OpenLitLightingDirection();
|
|
OpenLitShadeSH9ToonDouble(lightDirectionForSH9, poiLight.directColor, poiLight.indirectColor);
|
|
poiLight.directColor += _LightColor0.rgb;
|
|
}
|
|
float lightMapMode = (0.0 /*_LightingMapMode*/);
|
|
if ((0.0 /*_LightingDirectionMode*/) == 0)
|
|
{
|
|
poiLight.direction = _WorldSpaceLightPos0.xyz + unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 1 || (0.0 /*_LightingDirectionMode*/) == 2)
|
|
{
|
|
if ((0.0 /*_LightingDirectionMode*/) == 1)
|
|
{
|
|
poiLight.direction = mul(unity_ObjectToWorld, float4(0,0,0,1)).xyz;;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 2)
|
|
{
|
|
poiLight.direction = float4(0,0,0,1);
|
|
}
|
|
if (lightMapMode == 0)
|
|
{
|
|
lightMapMode == 1;
|
|
}
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 3) // UTS
|
|
{
|
|
float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz);
|
|
float3 lightDirection = normalize(lerp(defaultLightDirection, _WorldSpaceLightPos0.xyz, any(_WorldSpaceLightPos0.xyz)));
|
|
poiLight.direction = lightDirection;
|
|
}
|
|
if ((0.0 /*_LightingDirectionMode*/) == 4) // OpenLit
|
|
{
|
|
poiLight.direction = OpenLitLightingDirection(); // float4 customDir = 0; // Do we want to give users to alter this (OpenLit always does!)?
|
|
}
|
|
if (!any(poiLight.direction))
|
|
{
|
|
poiLight.direction = float3(.4, 1, .4);
|
|
}
|
|
poiLight.direction = normalize(poiLight.direction);
|
|
poiLight.attenuationStrength = (0.0 /*_LightingCastedShadows*/);
|
|
poiLight.attenuation = 1;
|
|
if (!all(_LightColor0.rgb == 0.0))
|
|
{
|
|
UNITY_LIGHT_ATTENUATION(attenuation, i, poiMesh.worldPos)
|
|
poiLight.attenuation *= attenuation;
|
|
}
|
|
if (!any(poiLight.directColor) && !any(poiLight.indirectColor) && lightMapMode == 0)
|
|
{
|
|
lightMapMode = 1;
|
|
if ((0.0 /*_LightingDirectionMode*/) == 0)
|
|
{
|
|
poiLight.direction = normalize(float3(.4, 1, .4));
|
|
}
|
|
}
|
|
poiLight.halfDir = normalize(poiLight.direction + poiCam.viewDir);
|
|
poiLight.vertexNDotL = dot(poiMesh.normals[0], poiLight.direction);
|
|
poiLight.nDotL = dot(poiMesh.normals[1], poiLight.direction);
|
|
poiLight.nDotLSaturated = saturate(poiLight.nDotL);
|
|
poiLight.nDotLNormalized = (poiLight.nDotL + 1) * 0.5;
|
|
poiLight.nDotV = abs(dot(poiMesh.normals[1], poiCam.viewDir));
|
|
poiLight.vertexNDotV = abs(dot(poiMesh.normals[0], poiCam.viewDir));
|
|
poiLight.nDotH = dot(poiMesh.normals[1], poiLight.halfDir);
|
|
poiLight.vertexNDotH = max(0.00001, dot(poiMesh.normals[0], poiLight.halfDir));
|
|
poiLight.lDotv = dot(poiLight.direction, poiCam.viewDir);
|
|
poiLight.lDotH = max(0.00001, dot(poiLight.direction, poiLight.halfDir));
|
|
if (lightMapMode == 0)
|
|
{
|
|
float3 ShadeSH9Plus = GetSHLength();
|
|
float3 ShadeSH9Minus = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0;
|
|
float3 greyScaleVector = float3(.33333, .33333, .33333);
|
|
float bw_lightColor = dot(poiLight.directColor, greyScaleVector);
|
|
float bw_directLighting = (((poiLight.nDotL * 0.5 + 0.5) * bw_lightColor * lerp(1, poiLight.attenuation, poiLight.attenuationStrength)) + dot(ShadeSH9(float4(poiMesh.normals[1], 1)), greyScaleVector));
|
|
float bw_bottomIndirectLighting = dot(ShadeSH9Minus, greyScaleVector);
|
|
float bw_topIndirectLighting = dot(ShadeSH9Plus, greyScaleVector);
|
|
float lightDifference = ((bw_topIndirectLighting + bw_lightColor) - bw_bottomIndirectLighting);
|
|
poiLight.lightMap = smoothstep(0, lightDifference, bw_directLighting - bw_bottomIndirectLighting) * poiLight.detailShadow;
|
|
}
|
|
if (lightMapMode == 1)
|
|
{
|
|
poiLight.lightMap = poiLight.nDotLNormalized * lerp(1, poiLight.attenuation, poiLight.attenuationStrength);
|
|
}
|
|
if (lightMapMode == 2)
|
|
{
|
|
poiLight.lightMap = poiLight.nDotLSaturated * lerp(1, poiLight.attenuation, poiLight.attenuationStrength);
|
|
}
|
|
poiLight.directColor = max(poiLight.directColor, 0.0001);
|
|
poiLight.indirectColor = max(poiLight.indirectColor, 0.0001);
|
|
if ((0.0 /*_LightingColorMode*/) == 3)
|
|
{
|
|
poiLight.directColor = max(poiLight.directColor, (0.0 /*_LightingMinLightBrightness*/));
|
|
poiLight.indirectColor = max(poiLight.indirectColor, (0.0 /*_LightingMinLightBrightness*/));
|
|
}
|
|
else
|
|
{
|
|
poiLight.directColor = max(poiLight.directColor, poiLight.directColor / max(0.0001, (calculateluminance(poiLight.directColor) / (0.0 /*_LightingMinLightBrightness*/))));
|
|
poiLight.indirectColor = max(poiLight.indirectColor, poiLight.indirectColor / max(0.0001, (calculateluminance(poiLight.indirectColor) / (0.0 /*_LightingMinLightBrightness*/))));
|
|
}
|
|
poiLight.directColor = lerp(poiLight.directColor, dot(poiLight.directColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingMonochromatic*/));
|
|
poiLight.indirectColor = lerp(poiLight.indirectColor, dot(poiLight.indirectColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingMonochromatic*/));
|
|
if ((1.0 /*_LightingCapEnabled*/))
|
|
{
|
|
poiLight.directColor = min(poiLight.directColor, (1.0 /*_LightingCap*/));
|
|
poiLight.indirectColor = min(poiLight.indirectColor, (1.0 /*_LightingCap*/));
|
|
}
|
|
if ((0.0 /*_LightingForceColorEnabled*/))
|
|
{
|
|
poiLight.directColor = poiThemeColor(poiMods, float4(1,1,1,1), (0.0 /*_LightingForcedColorThemeIndex*/));
|
|
}
|
|
#ifdef UNITY_PASS_FORWARDBASE
|
|
poiLight.directColor = max(poiLight.directColor * (1.0 /*_PPLightingMultiplier*/), 0);
|
|
poiLight.directColor = max(poiLight.directColor + (0.0 /*_PPLightingAddition*/), 0);
|
|
poiLight.indirectColor = max(poiLight.indirectColor * (1.0 /*_PPLightingMultiplier*/), 0);
|
|
poiLight.indirectColor = max(poiLight.indirectColor + (0.0 /*_PPLightingAddition*/), 0);
|
|
#endif
|
|
#endif
|
|
#ifdef POI_PASS_ADD
|
|
#if defined(POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE) && defined(DIRECTIONAL)
|
|
return float4(mainTexture.rgb * .0001, 1);
|
|
#endif
|
|
#if defined(POINT) || defined(SPOT)
|
|
poiLight.direction = normalize(_WorldSpaceLightPos0.xyz - i.worldPos.xyz);
|
|
#ifdef POINT
|
|
poiLight.additiveShadow = UNITY_SHADOW_ATTENUATION(i, poiMesh.worldPos);
|
|
unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(poiMesh.worldPos, 1)).xyz;
|
|
poiLight.attenuation = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).r;
|
|
#endif
|
|
#ifdef SPOT
|
|
poiLight.additiveShadow = UNITY_SHADOW_ATTENUATION(i, poiMesh.worldPos);
|
|
unityShadowCoord4 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(poiMesh.worldPos, 1));
|
|
poiLight.attenuation = (lightCoord.z > 0) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate(lightCoord.xyz);
|
|
#endif
|
|
#else
|
|
poiLight.direction = _WorldSpaceLightPos0.xyz;
|
|
UNITY_LIGHT_ATTENUATION(attenuation, i, poiMesh.worldPos)
|
|
poiLight.additiveShadow == 0;
|
|
poiLight.attenuation = attenuation;
|
|
#endif
|
|
poiLight.directColor = (0.0 /*_LightingAdditiveLimited*/) ? min((1.0 /*_LightingAdditiveLimit*/), _LightColor0.rgb) : _LightColor0.rgb;
|
|
#if defined(POINT_COOKIE) || defined(DIRECTIONAL_COOKIE)
|
|
poiLight.indirectColor = 0;
|
|
#else
|
|
poiLight.indirectColor = lerp(0, poiLight.directColor, (0.5 /*_LightingAdditivePassthrough*/));
|
|
#endif
|
|
poiLight.directColor = lerp(poiLight.directColor, dot(poiLight.directColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingAdditiveMonochromatic*/));
|
|
poiLight.indirectColor = lerp(poiLight.indirectColor, dot(poiLight.indirectColor, float3(0.299, 0.587, 0.114)), (0.0 /*_LightingAdditiveMonochromatic*/));
|
|
poiLight.halfDir = normalize(poiLight.direction + poiCam.viewDir);
|
|
poiLight.nDotL = dot(poiMesh.normals[1], poiLight.direction);
|
|
poiLight.nDotLSaturated = saturate(poiLight.nDotL);
|
|
poiLight.nDotLNormalized = (poiLight.nDotL + 1) * 0.5;
|
|
poiLight.nDotV = abs(dot(poiMesh.normals[1], poiCam.viewDir));
|
|
poiLight.nDotH = dot(poiMesh.normals[1], poiLight.halfDir);
|
|
poiLight.lDotv = dot(poiLight.direction, poiCam.viewDir);
|
|
poiLight.lDotH = dot(poiLight.direction, poiLight.halfDir);
|
|
poiLight.vertexNDotL = dot(poiMesh.normals[0], poiLight.direction);
|
|
poiLight.vertexNDotV = abs(dot(poiMesh.normals[0], poiCam.viewDir));
|
|
poiLight.vertexNDotH = max(0.00001, dot(poiMesh.normals[0], poiLight.halfDir));
|
|
poiLight.lightMap = 1;
|
|
#endif
|
|
poiFragData.baseColor = mainTexture.rgb * poiThemeColor(poiMods, float4(1,1,1,1).rgb, (0.0 /*_ColorThemeIndex*/));
|
|
poiFragData.alpha = mainTexture.a * float4(1,1,1,1).a;
|
|
#if defined(PROP_CLIPPINGMASK) || !defined(OPTIMIZER_ENABLED)
|
|
float alphaMask = POI2D_SAMPLER_PAN(_ClippingMask, _MainTex, poiUV(poiMesh.uv[(0.0 /*_ClippingMaskUV*/)], float4(1,1,0,0)), float4(0,0,0,0)).r;
|
|
if ((0.0 /*_Inverse_Clipping*/))
|
|
{
|
|
alphaMask = 1 - alphaMask;
|
|
}
|
|
#else
|
|
float alphaMask = 1;
|
|
#endif
|
|
poiFragData.alpha *= alphaMask;
|
|
applyAlphaOptions(poiFragData, poiMesh, poiCam, poiMods);
|
|
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_BRANCH_DETAIL) || defined(GEOM_TYPE_FROND) || defined(DEPTH_OF_FIELD_COC_VIEW)
|
|
applyDecals(poiFragData, poiMesh, poiCam, poiMods, poiLight);
|
|
#endif
|
|
#if defined(_LIGHTINGMODE_SHADEMAP) && defined(VIGNETTE_MASKED)
|
|
#ifndef POI_PASS_OUTLINE
|
|
#endif
|
|
#endif
|
|
#ifdef VIGNETTE_MASKED
|
|
#ifdef POI_PASS_OUTLINE
|
|
if (_OutlineLit)
|
|
{
|
|
calculateShading(poiLight, poiFragData, poiMesh, poiCam);
|
|
}
|
|
else
|
|
{
|
|
poiLight.finalLighting = 1;
|
|
}
|
|
#else
|
|
calculateShading(poiLight, poiFragData, poiMesh, poiCam);
|
|
#endif
|
|
#else
|
|
poiLight.finalLighting = 1;
|
|
poiLight.rampedLightMap = poiEdgeNonLinear(poiLight.nDotL, 0.1, .1);
|
|
#endif
|
|
#ifdef POI_PATHING
|
|
#if defined(PROP_PATHINGMAP) || !defined(OPTIMIZER_ENABLED)
|
|
applyPathing(poiFragData, poiMesh, poiMods);
|
|
#endif
|
|
#endif
|
|
if ((0.0 /*_AlphaPremultiply*/))
|
|
{
|
|
poiFragData.baseColor *= saturate(poiFragData.alpha);
|
|
}
|
|
poiFragData.finalColor = poiFragData.baseColor;
|
|
poiFragData.finalColor = poiFragData.baseColor * poiLight.finalLighting;
|
|
#ifdef MOCHIE_PBR
|
|
MochieBRDF(poiFragData, poiCam, poiLight, poiMesh, poiMods);
|
|
#endif
|
|
if ((0.0 /*_IgnoreFog*/) == 0)
|
|
{
|
|
UNITY_APPLY_FOG(i.fogCoord, poiFragData.finalColor);
|
|
}
|
|
poiFragData.alpha = (0.0 /*_AlphaForceOpaque*/) ? 1 : poiFragData.alpha;
|
|
poiFragData.finalColor += poiLight.finalLightAdd;
|
|
if ((0.0 /*_Mode*/) == POI_MODE_OPAQUE)
|
|
{
|
|
poiFragData.alpha = 1;
|
|
}
|
|
clip(poiFragData.alpha - (0.5 /*_Cutoff*/));
|
|
if ((0.0 /*_AddBlendOp*/) == 4)
|
|
{
|
|
poiFragData.alpha = saturate(poiFragData.alpha * (10.0 /*_AlphaBoostFA*/));
|
|
}
|
|
if ((0.0 /*_Mode*/) != POI_MODE_TRANSPARENT)
|
|
{
|
|
poiFragData.finalColor *= poiFragData.alpha;
|
|
}
|
|
return float4(poiFragData.finalColor, poiFragData.alpha) + POI_SAFE_RGB0;
|
|
}
|
|
ENDCG
|
|
}
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "ShadowCaster" }
|
|
Stencil
|
|
{
|
|
Ref [_StencilRef]
|
|
ReadMask [_StencilReadMask]
|
|
WriteMask [_StencilWriteMask]
|
|
Comp [_StencilCompareFunction]
|
|
Pass [_StencilPassOp]
|
|
Fail [_StencilFailOp]
|
|
ZFail [_StencilZFailOp]
|
|
}
|
|
ZWrite [_ZWrite]
|
|
Cull [_Cull]
|
|
AlphaToMask Off
|
|
ZTest [_ZTest]
|
|
ColorMask [_ColorMask]
|
|
Offset [_OffsetFactor], [_OffsetUnits]
|
|
BlendOp [_BlendOp], [_BlendOpAlpha]
|
|
Blend [_SrcBlend] [_DstBlend]
|
|
CGPROGRAM
|
|
#define MOCHIE_PBR
|
|
#define POI_AUDIOLINK
|
|
#define POI_LIGHT_DATA_ADDITIVE_DIRECTIONAL_ENABLE
|
|
#define POI_LIGHT_DATA_ADDITIVE_ENABLE
|
|
#define POI_PATHING
|
|
#define POI_VERTEXLIGHT_ON
|
|
#define VIGNETTE_MASKED
|
|
#define _LIGHTINGMODE_REALISTIC
|
|
#define PROP_PATHINGMAP
|
|
#define PROP_PATHINGCOLORMAP
|
|
#define OPTIMIZER_ENABLED
|
|
#pragma target 5.0
|
|
#pragma skip_variants LIGHTMAP_ON DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK DIRLIGHTMAP_COMBINED _MIXED_LIGHTING_SUBTRACTIVE
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile_shadowcaster
|
|
#pragma multi_compile_fog
|
|
#define POI_PASS_SHADOW
|
|
#include "UnityCG.cginc"
|
|
#include "UnityStandardUtils.cginc"
|
|
#include "AutoLight.cginc"
|
|
#include "UnityLightingCommon.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#ifdef POI_PASS_META
|
|
#include "UnityMetaPass.cginc"
|
|
#endif
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#define DielectricSpec float4(0.04, 0.04, 0.04, 1.0 - 0.04)
|
|
#define PI float(3.14159265359)
|
|
#define POI2D_SAMPLER_PAN(tex, texSampler, uv, pan) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan))
|
|
#define POI2D_SAMPLER_PANGRAD(tex, texSampler, uv, pan, ddx, ddy) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv + _Time.x * pan, ddx, ddy))
|
|
#define POI2D_SAMPLER(tex, texSampler, uv) (UNITY_SAMPLE_TEX2D_SAMPLER(tex, texSampler, uv))
|
|
#define POI2D_PAN(tex, uv, pan) (tex2D(tex, uv + _Time.x * pan))
|
|
#define POI2D(tex, uv) (tex2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D(tex, uv) (UNITY_SAMPLE_TEX2D(tex, uv))
|
|
#define POI_SAMPLE_TEX2D_PAN(tex, uv, pan) (UNITY_SAMPLE_TEX2D(tex, uv + _Time.x * pan))
|
|
#define POI2D_MAINTEX_SAMPLER_PAN_INLINED(tex, poiMesh) (POI2D_SAMPLER_PAN(tex, _MainTex, poiUV(poiMesh.uv[tex##UV], tex##_ST), tex##Pan))
|
|
#define POI_SAFE_RGB0 float4(mainTexture.rgb * .0001, 0)
|
|
#define POI_SAFE_RGB1 float4(mainTexture.rgb * .0001, 1)
|
|
#define POI_SAFE_RGBA mainTexture
|
|
#if defined(UNITY_COMPILER_HLSL)
|
|
#define PoiInitStruct(type, name) name = (type)0;
|
|
#else
|
|
#define PoiInitStruct(type, name)
|
|
#endif
|
|
#define POI_ERROR(poiMesh, gridSize) lerp(float3(1, 0, 1), float3(0, 0, 0), fmod(floor((poiMesh.worldPos.x) * gridSize) + floor((poiMesh.worldPos.y) * gridSize) + floor((poiMesh.worldPos.z) * gridSize), 2) == 0)
|
|
#define POI_MODE_OPAQUE 0
|
|
#define POI_MODE_CUTOUT 1
|
|
#define POI_MODE_FADE 2
|
|
#define POI_MODE_TRANSPARENT 3
|
|
#define POI_MODE_ADDITIVE 4
|
|
#define POI_MODE_SOFTADDITIVE 5
|
|
#define POI_MODE_MULTIPLICATIVE 6
|
|
#define POI_MODE_2XMULTIPLICATIVE 7
|
|
#define POI_MODE_TRANSCLIPPING 9
|
|
#define ALPASS_DFT uint2(0,4) //Size: 128, 2
|
|
#define ALPASS_WAVEFORM uint2(0,6) //Size: 128, 16
|
|
#define ALPASS_AUDIOLINK uint2(0,0) //Size: 128, 4
|
|
#define ALPASS_AUDIOBASS uint2(0,0) //Size: 128, 1
|
|
#define ALPASS_AUDIOLOWMIDS uint2(0,1) //Size: 128, 1
|
|
#define ALPASS_AUDIOHIGHMIDS uint2(0,2) //Size: 128, 1
|
|
#define ALPASS_AUDIOTREBLE uint2(0,3) //Size: 128, 1
|
|
#define ALPASS_AUDIOLINKHISTORY uint2(1,0) //Size: 127, 4
|
|
#define ALPASS_GENERALVU uint2(0,22) //Size: 12, 1
|
|
#define ALPASS_CCINTERNAL uint2(12,22) //Size: 12, 2
|
|
#define ALPASS_CCCOLORS uint2(25,22) //Size: 11, 1
|
|
#define ALPASS_CCSTRIP uint2(0,24) //Size: 128, 1
|
|
#define ALPASS_CCLIGHTS uint2(0,25) //Size: 128, 2
|
|
#define ALPASS_AUTOCORRELATOR uint2(0,27) //Size: 128, 1
|
|
#define ALPASS_GENERALVU_INSTANCE_TIME uint2(2,22)
|
|
#define ALPASS_GENERALVU_LOCAL_TIME uint2(3,22)
|
|
#define ALPASS_GENERALVU_NETWORK_TIME uint2(4,22)
|
|
#define ALPASS_GENERALVU_PLAYERINFO uint2(6,22)
|
|
#define ALPASS_FILTEREDAUDIOLINK uint2(0,28) //Size: 16, 4
|
|
#define ALPASS_CHRONOTENSITY uint2(16,28) //Size: 8, 4
|
|
#define ALPASS_THEME_COLOR0 uint2(0,23)
|
|
#define ALPASS_THEME_COLOR1 uint2(1,23)
|
|
#define ALPASS_THEME_COLOR2 uint2(2,23)
|
|
#define ALPASS_THEME_COLOR3 uint2(3,23)
|
|
#define ALPASS_FILTEREDVU uint2(24,28) //Size: 4, 4
|
|
#define ALPASS_FILTEREDVU_INTENSITY uint2(24,28) //Size: 4, 1
|
|
#define ALPASS_FILTEREDVU_MARKER uint2(24,29) //Size: 4, 1
|
|
#define AUDIOLINK_SAMPHIST 3069 // Internal use for algos, do not change.
|
|
#define AUDIOLINK_SAMPLEDATA24 2046
|
|
#define AUDIOLINK_EXPBINS 24
|
|
#define AUDIOLINK_EXPOCT 10
|
|
#define AUDIOLINK_ETOTALBINS (AUDIOLINK_EXPBINS * AUDIOLINK_EXPOCT)
|
|
#define AUDIOLINK_WIDTH 128
|
|
#define AUDIOLINK_SPS 48000 // Samples per second
|
|
#define AUDIOLINK_ROOTNOTE 0
|
|
#define AUDIOLINK_4BAND_FREQFLOOR 0.123
|
|
#define AUDIOLINK_4BAND_FREQCEILING 1
|
|
#define AUDIOLINK_BOTTOM_FREQUENCY 13.75
|
|
#define AUDIOLINK_BASE_AMPLITUDE 2.5
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MIN 0.3
|
|
#define AUDIOLINK_DELAY_COEFFICIENT_MAX 0.9
|
|
#define AUDIOLINK_DFT_Q 4.0
|
|
#define AUDIOLINK_TREBLE_CORRECTION 5.0
|
|
#define COLORCHORD_EMAXBIN 192
|
|
#define COLORCHORD_IIR_DECAY_1 0.90
|
|
#define COLORCHORD_IIR_DECAY_2 0.85
|
|
#define COLORCHORD_CONSTANT_DECAY_1 0.01
|
|
#define COLORCHORD_CONSTANT_DECAY_2 0.0
|
|
#define COLORCHORD_NOTE_CLOSEST 3.0
|
|
#define COLORCHORD_NEW_NOTE_GAIN 8.0
|
|
#define COLORCHORD_MAX_NOTES 10
|
|
#ifndef glsl_mod
|
|
#define glsl_mod(x, y) (((x) - (y) * floor((x) / (y))))
|
|
#endif
|
|
uniform float4 _AudioTexture_TexelSize;
|
|
#ifdef SHADER_TARGET_SURFACE_ANALYSIS
|
|
#define AUDIOLINK_STANDARD_INDEXING
|
|
#endif
|
|
#ifdef AUDIOLINK_STANDARD_INDEXING
|
|
sampler2D _AudioTexture;
|
|
#define AudioLinkData(xycoord) tex2Dlod(_AudioTexture, float4(uint2(xycoord) * _AudioTexture_TexelSize.xy, 0, 0))
|
|
#else
|
|
uniform Texture2D<float4> _AudioTexture;
|
|
SamplerState sampler_AudioTexture;
|
|
#define AudioLinkData(xycoord) _AudioTexture[uint2(xycoord)]
|
|
#endif
|
|
uniform sampler2D _Stored;
|
|
uniform float4 _Stored_TexelSize;
|
|
#define LumaData(x,y) tex2Dlod(_Stored, float4(x, y, 0, 0))
|
|
float _Mode;
|
|
float _StereoEnabled;
|
|
float _PolarUV;
|
|
float2 _PolarCenter;
|
|
float _PolarRadialScale;
|
|
float _PolarLengthScale;
|
|
float _PolarSpiralPower;
|
|
float _PanoUseBothEyes;
|
|
#ifdef POI_AUDIOLINK
|
|
float _AudioLinkDelay;
|
|
float _AudioLinkAnimToggle;
|
|
float _DebugWaveform;
|
|
float _DebugDFT;
|
|
float _DebugBass;
|
|
float _DebugLowMids;
|
|
float _DebugHighMids;
|
|
float _DebugTreble;
|
|
float _DebugCCColors;
|
|
float _DebugCCStrip;
|
|
float _DebugCCLights;
|
|
float _DebugAutocorrelator;
|
|
float _DebugChronotensity;
|
|
float _AudioLinkCCStripY;
|
|
#endif
|
|
float _IgnoreFog;
|
|
float _RenderingReduceClipDistance;
|
|
float _AddBlendOp;
|
|
float4 _Color;
|
|
float _ColorThemeIndex;
|
|
UNITY_DECLARE_TEX2D(_MainTex);
|
|
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
|
float _MainPixelMode;
|
|
float4 _MainTex_ST;
|
|
float2 _MainTexPan;
|
|
float _MainTexUV;
|
|
float4 _MainTex_TexelSize;
|
|
Texture2D _BumpMap;
|
|
float4 _BumpMap_ST;
|
|
float2 _BumpMapPan;
|
|
float _BumpMapUV;
|
|
float _BumpScale;
|
|
Texture2D _ClippingMask;
|
|
float4 _ClippingMask_ST;
|
|
float2 _ClippingMaskPan;
|
|
float _ClippingMaskUV;
|
|
float _Inverse_Clipping;
|
|
float _Cutoff;
|
|
SamplerState sampler_linear_clamp;
|
|
SamplerState sampler_linear_repeat;
|
|
float _AlphaForceOpaque;
|
|
float _AlphaMod;
|
|
float _AlphaPremultiply;
|
|
float _AlphaBoostFA;
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
float4 tangent : TANGENT;
|
|
float4 color : COLOR;
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv1 : TEXCOORD1;
|
|
float2 uv2 : TEXCOORD2;
|
|
float2 uv3 : TEXCOORD3;
|
|
uint vertexId : SV_VertexID;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
struct v2f
|
|
{
|
|
float4 pos : SV_POSITION;
|
|
float2 uv[4] : TEXCOORD0;
|
|
float3 objNormal : TEXCOORD4;
|
|
float3 normal : TEXCOORD5;
|
|
float3 tangent : TEXCOORD6;
|
|
float3 binormal : TEXCOORD7;
|
|
float4 worldPos : TEXCOORD8;
|
|
float4 localPos : TEXCOORD9;
|
|
float3 objectPos : TEXCOORD10;
|
|
float4 vertexColor : TEXCOORD11;
|
|
float4 lightmapUV : TEXCOORD12;
|
|
float4 grabPos: TEXCOORD13;
|
|
float4 worldDirection: TEXCOORD14;
|
|
UNITY_SHADOW_COORDS(15)
|
|
UNITY_FOG_COORDS(16)
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
struct PoiMesh
|
|
{
|
|
float3 normals[2];
|
|
float3 objNormal;
|
|
float3 tangentSpaceNormal;
|
|
float3 binormal;
|
|
float3 tangent;
|
|
float3 worldPos;
|
|
float3 localPos;
|
|
float3 objectPosition;
|
|
float isFrontFace;
|
|
float4 vertexColor;
|
|
float4 lightmapUV;
|
|
float2 uv[8];
|
|
float2 parallaxUV;
|
|
};
|
|
struct PoiCam
|
|
{
|
|
float3 viewDir;
|
|
float3 forwardDir;
|
|
float3 worldPos;
|
|
float distanceToVert;
|
|
float4 clipPos;
|
|
float3 reflectionDir;
|
|
float3 vertexReflectionDir;
|
|
float3 tangentViewDir;
|
|
float4 grabPos;
|
|
float2 screenUV;
|
|
float vDotN;
|
|
float4 worldDirection;
|
|
};
|
|
struct PoiMods
|
|
{
|
|
float4 Mask;
|
|
float4 audioLink;
|
|
float audioLinkAvailable;
|
|
float audioLinkVersion;
|
|
float4 audioLinkTexture;
|
|
float audioLinkViaLuma;
|
|
float2 detailMask;
|
|
float2 backFaceDetailIntensity;
|
|
float globalEmission;
|
|
float4 globalColorTheme[12];
|
|
float ALTime[8];
|
|
};
|
|
struct PoiLight
|
|
{
|
|
float3 direction;
|
|
float attenuation;
|
|
float attenuationStrength;
|
|
float3 directColor;
|
|
float3 indirectColor;
|
|
float occlusion;
|
|
float shadowMask;
|
|
float detailShadow;
|
|
float3 halfDir;
|
|
float lightMap;
|
|
float3 rampedLightMap;
|
|
float vertexNDotL;
|
|
float nDotL;
|
|
float nDotV;
|
|
float vertexNDotV;
|
|
float nDotH;
|
|
float vertexNDotH;
|
|
float lDotv;
|
|
float lDotH;
|
|
float nDotLSaturated;
|
|
float nDotLNormalized;
|
|
#ifdef POI_PASS_ADD
|
|
float additiveShadow;
|
|
#endif
|
|
float3 finalLighting;
|
|
float3 finalLightAdd;
|
|
#if defined(VERTEXLIGHT_ON) && defined(POI_VERTEXLIGHT_ON)
|
|
float4 vDotNL;
|
|
float4 vertexVDotNL;
|
|
float3 vColor[4];
|
|
float4 vCorrectedDotNL;
|
|
float4 vAttenuation;
|
|
float4 vAttenuationDotNL;
|
|
float3 vPosition[4];
|
|
float3 vDirection[4];
|
|
float3 vFinalLighting;
|
|
float3 vHalfDir[4];
|
|
half4 vDotNH;
|
|
half4 vertexVDotNH;
|
|
half4 vDotLH;
|
|
#endif
|
|
};
|
|
struct PoiVertexLights
|
|
{
|
|
float3 direction;
|
|
float3 color;
|
|
float attenuation;
|
|
};
|
|
struct PoiFragData
|
|
{
|
|
float3 baseColor;
|
|
float3 finalColor;
|
|
float alpha;
|
|
float3 emission;
|
|
};
|
|
float2 poiUV(float2 uv, float4 tex_st)
|
|
{
|
|
return uv * tex_st.xy + tex_st.zw;
|
|
}
|
|
float calculateluminance(float3 color)
|
|
{
|
|
return color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
|
|
}
|
|
bool IsInMirror()
|
|
{
|
|
return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f;
|
|
}
|
|
bool IsOrthographicCamera()
|
|
{
|
|
return unity_OrthoParams.w == 1 || UNITY_MATRIX_P[3][3] == 1;
|
|
}
|
|
float shEvaluateDiffuseL1Geomerics_local(float L0, float3 L1, float3 n)
|
|
{
|
|
float R0 = max(0, L0);
|
|
float3 R1 = 0.5f * L1;
|
|
float lenR1 = length(R1);
|
|
float q = dot(normalize(R1), n) * 0.5 + 0.5;
|
|
q = saturate(q); // Thanks to ScruffyRuffles for the bug identity.
|
|
float p = 1.0f + 2.0f * lenR1 / R0;
|
|
float a = (1.0f - lenR1 / R0) / (1.0f + lenR1 / R0);
|
|
return R0 * (a + (1.0f - a) * (p + 1.0f) * pow(q, p));
|
|
}
|
|
half3 BetterSH9(half4 normal)
|
|
{
|
|
float3 indirect;
|
|
float3 L0 = float3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + float3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0;
|
|
indirect.r = shEvaluateDiffuseL1Geomerics_local(L0.r, unity_SHAr.xyz, normal.xyz);
|
|
indirect.g = shEvaluateDiffuseL1Geomerics_local(L0.g, unity_SHAg.xyz, normal.xyz);
|
|
indirect.b = shEvaluateDiffuseL1Geomerics_local(L0.b, unity_SHAb.xyz, normal.xyz);
|
|
indirect = max(0, indirect);
|
|
indirect += SHEvalLinearL2(normal);
|
|
return indirect;
|
|
}
|
|
float3 getCameraForward()
|
|
{
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
float3 p1 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 1, 1));
|
|
float3 p2 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 0, 1));
|
|
#else
|
|
float3 p1 = mul(unity_CameraToWorld, float4(0, 0, 1, 1)).xyz;
|
|
float3 p2 = mul(unity_CameraToWorld, float4(0, 0, 0, 1)).xyz;
|
|
#endif
|
|
return normalize(p2 - p1);
|
|
}
|
|
half3 GetSHLength()
|
|
{
|
|
half3 x, x1;
|
|
x.r = length(unity_SHAr);
|
|
x.g = length(unity_SHAg);
|
|
x.b = length(unity_SHAb);
|
|
x1.r = length(unity_SHBr);
|
|
x1.g = length(unity_SHBg);
|
|
x1.b = length(unity_SHBb);
|
|
return x + x1;
|
|
}
|
|
float3 BoxProjection(float3 direction, float3 position, float4 cubemapPosition, float3 boxMin, float3 boxMax)
|
|
{
|
|
#if UNITY_SPECCUBE_BOX_PROJECTION
|
|
if (cubemapPosition.w > 0)
|
|
{
|
|
float3 factors = ((direction > 0 ? boxMax : boxMin) - position) / direction;
|
|
float scalar = min(min(factors.x, factors.y), factors.z);
|
|
direction = direction * scalar + (position - cubemapPosition.xyz);
|
|
}
|
|
#endif
|
|
return direction;
|
|
}
|
|
float poiMax(float2 i)
|
|
{
|
|
return max(i.x, i.y);
|
|
}
|
|
float poiMax(float3 i)
|
|
{
|
|
return max(max(i.x, i.y), i.z);
|
|
}
|
|
float poiMax(float4 i)
|
|
{
|
|
return max(max(max(i.x, i.y), i.z), i.w);
|
|
}
|
|
float3 calculateNormal(in float3 baseNormal, in PoiMesh poiMesh, in Texture2D normalTexture, in float4 normal_ST, in float2 normalPan, in float normalUV, in float normalIntensity)
|
|
{
|
|
float3 normal = UnpackScaleNormal(POI2D_SAMPLER_PAN(normalTexture, _MainTex, poiUV(poiMesh.uv[normalUV], normal_ST), normalPan), normalIntensity);
|
|
return normalize(
|
|
normal.x * poiMesh.tangent +
|
|
normal.y * poiMesh.binormal +
|
|
normal.z * baseNormal
|
|
);
|
|
}
|
|
float remap(float x, float minOld, float maxOld, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float2 remap(float2 x, float2 minOld, float2 maxOld, float2 minNew = 0, float2 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float3 remap(float3 x, float3 minOld, float3 maxOld, float3 minNew = 0, float3 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float4 remap(float4 x, float4 minOld, float4 maxOld, float4 minNew = 0, float4 maxNew = 1)
|
|
{
|
|
return minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld);
|
|
}
|
|
float remapClamped(float minOld, float maxOld, float x, float minNew = 0, float maxNew = 1)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 remapClamped(float2 minOld, float2 maxOld, float2 x, float2 minNew, float2 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float3 remapClamped(float3 minOld, float3 maxOld, float3 x, float3 minNew, float3 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float4 remapClamped(float4 minOld, float4 maxOld, float4 x, float4 minNew, float4 maxNew)
|
|
{
|
|
return clamp(minNew + (x - minOld) * (maxNew - minNew) / (maxOld - minOld), minNew, maxNew);
|
|
}
|
|
float2 calcParallax(in float height, in PoiCam poiCam)
|
|
{
|
|
return ((height * - 1) + 1) * (poiCam.tangentViewDir.xy / poiCam.tangentViewDir.z);
|
|
}
|
|
float4 poiBlend(const float sourceFactor, const float4 sourceColor, const float destinationFactor, const float4 destinationColor, const float4 blendFactor)
|
|
{
|
|
float4 sA = 1 - blendFactor;
|
|
const float4 blendData[11] = {
|
|
float4(0.0, 0.0, 0.0, 0.0),
|
|
float4(1.0, 1.0, 1.0, 1.0),
|
|
destinationColor,
|
|
sourceColor,
|
|
float4(1.0, 1.0, 1.0, 1.0) - destinationColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sourceColor,
|
|
sA,
|
|
float4(1.0, 1.0, 1.0, 1.0) - sA,
|
|
saturate(sourceColor.aaaa),
|
|
1 - sA,
|
|
};
|
|
return lerp(blendData[sourceFactor] * sourceColor + blendData[destinationFactor] * destinationColor, sourceColor, sA);
|
|
}
|
|
float3 blendAverage(float3 base, float3 blend)
|
|
{
|
|
return (base + blend) / 2.0;
|
|
}
|
|
float blendColorBurn(float base, float blend)
|
|
{
|
|
return (blend == 0.0)?blend : max((1.0 - ((1.0 - base) / blend)), 0.0);
|
|
}
|
|
float3 blendColorBurn(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorBurn(base.r, blend.r), blendColorBurn(base.g, blend.g), blendColorBurn(base.b, blend.b));
|
|
}
|
|
float blendColorDodge(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendColorDodge(float3 base, float3 blend)
|
|
{
|
|
return float3(blendColorDodge(base.r, blend.r), blendColorDodge(base.g, blend.g), blendColorDodge(base.b, blend.b));
|
|
}
|
|
float blendDarken(float base, float blend)
|
|
{
|
|
return min(blend, base);
|
|
}
|
|
float3 blendDarken(float3 base, float3 blend)
|
|
{
|
|
return float3(blendDarken(base.r, blend.r), blendDarken(base.g, blend.g), blendDarken(base.b, blend.b));
|
|
}
|
|
float3 blendExclusion(float3 base, float3 blend)
|
|
{
|
|
return base + blend - 2.0 * base * blend;
|
|
}
|
|
float blendReflect(float base, float blend)
|
|
{
|
|
return (blend == 1.0)?blend : min(base * base / (1.0 - blend), 1.0);
|
|
}
|
|
float3 blendReflect(float3 base, float3 blend)
|
|
{
|
|
return float3(blendReflect(base.r, blend.r), blendReflect(base.g, blend.g), blendReflect(base.b, blend.b));
|
|
}
|
|
float3 blendGlow(float3 base, float3 blend)
|
|
{
|
|
return blendReflect(blend, base);
|
|
}
|
|
float blendOverlay(float base, float blend)
|
|
{
|
|
return base < 0.5?(2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendOverlay(float3 base, float3 blend)
|
|
{
|
|
return float3(blendOverlay(base.r, blend.r), blendOverlay(base.g, blend.g), blendOverlay(base.b, blend.b));
|
|
}
|
|
float3 blendHardLight(float3 base, float3 blend)
|
|
{
|
|
return blendOverlay(blend, base);
|
|
}
|
|
float blendVividLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendColorBurn(base, (2.0 * blend)) : blendColorDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendVividLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendVividLight(base.r, blend.r), blendVividLight(base.g, blend.g), blendVividLight(base.b, blend.b));
|
|
}
|
|
float blendHardMix(float base, float blend)
|
|
{
|
|
return (blendVividLight(base, blend) < 0.5)?0.0 : 1.0;
|
|
}
|
|
float3 blendHardMix(float3 base, float3 blend)
|
|
{
|
|
return float3(blendHardMix(base.r, blend.r), blendHardMix(base.g, blend.g), blendHardMix(base.b, blend.b));
|
|
}
|
|
float blendLighten(float base, float blend)
|
|
{
|
|
return max(blend, base);
|
|
}
|
|
float3 blendLighten(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLighten(base.r, blend.r), blendLighten(base.g, blend.g), blendLighten(base.b, blend.b));
|
|
}
|
|
float blendLinearBurn(float base, float blend)
|
|
{
|
|
return max(base + blend - 1.0, 0.0);
|
|
}
|
|
float3 blendLinearBurn(float3 base, float3 blend)
|
|
{
|
|
return max(base + blend - float3(1.0, 1.0, 1.0), float3(0.0, 0.0, 0.0));
|
|
}
|
|
float blendLinearDodge(float base, float blend)
|
|
{
|
|
return min(base + blend, 1.0);
|
|
}
|
|
float3 blendLinearDodge(float3 base, float3 blend)
|
|
{
|
|
return min(base + blend, float3(1.0, 1.0, 1.0));
|
|
}
|
|
float blendLinearLight(float base, float blend)
|
|
{
|
|
return blend < 0.5?blendLinearBurn(base, (2.0 * blend)) : blendLinearDodge(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendLinearLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendLinearLight(base.r, blend.r), blendLinearLight(base.g, blend.g), blendLinearLight(base.b, blend.b));
|
|
}
|
|
float3 blendMultiply(float3 base, float3 blend)
|
|
{
|
|
return base * blend;
|
|
}
|
|
float3 blendNegation(float3 base, float3 blend)
|
|
{
|
|
return float3(1.0, 1.0, 1.0) - abs(float3(1.0, 1.0, 1.0) - base - blend);
|
|
}
|
|
float3 blendNormal(float3 base, float3 blend)
|
|
{
|
|
return blend;
|
|
}
|
|
float3 blendPhoenix(float3 base, float3 blend)
|
|
{
|
|
return min(base, blend) - max(base, blend) + float3(1.0, 1.0, 1.0);
|
|
}
|
|
float blendPinLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?blendDarken(base, (2.0 * blend)) : blendLighten(base, (2.0 * (blend - 0.5)));
|
|
}
|
|
float3 blendPinLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendPinLight(base.r, blend.r), blendPinLight(base.g, blend.g), blendPinLight(base.b, blend.b));
|
|
}
|
|
float blendScreen(float base, float blend)
|
|
{
|
|
return 1.0 - ((1.0 - base) * (1.0 - blend));
|
|
}
|
|
float3 blendScreen(float3 base, float3 blend)
|
|
{
|
|
return float3(blendScreen(base.r, blend.r), blendScreen(base.g, blend.g), blendScreen(base.b, blend.b));
|
|
}
|
|
float blendSoftLight(float base, float blend)
|
|
{
|
|
return (blend < 0.5)?(2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend));
|
|
}
|
|
float3 blendSoftLight(float3 base, float3 blend)
|
|
{
|
|
return float3(blendSoftLight(base.r, blend.r), blendSoftLight(base.g, blend.g), blendSoftLight(base.b, blend.b));
|
|
}
|
|
float blendSubtract(float base, float blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float3 blendSubtract(float3 base, float3 blend)
|
|
{
|
|
return max(base - blend, 0.0);
|
|
}
|
|
float blendDifference(float base, float blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float3 blendDifference(float3 base, float3 blend)
|
|
{
|
|
return abs(base - blend);
|
|
}
|
|
float blendDivide(float base, float blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 blendDivide(float3 base, float3 blend)
|
|
{
|
|
return base / max(blend, 0.0001);
|
|
}
|
|
float3 customBlend(float3 base, float3 blend, float blendType)
|
|
{
|
|
float3 ret = 0;
|
|
switch(blendType)
|
|
{
|
|
case 0:
|
|
{
|
|
ret = blendNormal(base, blend);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ret = blendDarken(base, blend);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ret = blendMultiply(base, blend);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
ret = blendColorBurn(base, blend);
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
ret = blendLinearBurn(base, blend);
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
ret = blendLighten(base, blend);
|
|
break;
|
|
}
|
|
case 6:
|
|
{
|
|
ret = blendScreen(base, blend);
|
|
break;
|
|
}
|
|
case 7:
|
|
{
|
|
ret = blendColorDodge(base, blend);
|
|
break;
|
|
}
|
|
case 8:
|
|
{
|
|
ret = blendLinearDodge(base, blend);
|
|
break;
|
|
}
|
|
case 9:
|
|
{
|
|
ret = blendOverlay(base, blend);
|
|
break;
|
|
}
|
|
case 10:
|
|
{
|
|
ret = blendSoftLight(base, blend);
|
|
break;
|
|
}
|
|
case 11:
|
|
{
|
|
ret = blendHardLight(base, blend);
|
|
break;
|
|
}
|
|
case 12:
|
|
{
|
|
ret = blendVividLight(base, blend);
|
|
break;
|
|
}
|
|
case 13:
|
|
{
|
|
ret = blendLinearLight(base, blend);
|
|
break;
|
|
}
|
|
case 14:
|
|
{
|
|
ret = blendPinLight(base, blend);
|
|
break;
|
|
}
|
|
case 15:
|
|
{
|
|
ret = blendHardMix(base, blend);
|
|
break;
|
|
}
|
|
case 16:
|
|
{
|
|
ret = blendDifference(base, blend);
|
|
break;
|
|
}
|
|
case 17:
|
|
{
|
|
ret = blendExclusion(base, blend);
|
|
break;
|
|
}
|
|
case 18:
|
|
{
|
|
ret = blendSubtract(base, blend);
|
|
break;
|
|
}
|
|
case 19:
|
|
{
|
|
ret = blendDivide(base, blend);
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
float random(float2 p)
|
|
{
|
|
return frac(sin(dot(p, float2(12.9898, 78.2383))) * 43758.5453123);
|
|
}
|
|
float2 random2(float2 p)
|
|
{
|
|
return frac(sin(float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)))) * 43758.5453);
|
|
}
|
|
float3 random3(float3 p)
|
|
{
|
|
return frac(sin(float3(dot(p, float3(127.1, 311.7, 248.6)), dot(p, float3(269.5, 183.3, 423.3)), dot(p, float3(248.3, 315.9, 184.2)))) * 43758.5453);
|
|
}
|
|
float3 randomFloat3(float2 Seed, float maximum)
|
|
{
|
|
return (.5 + float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * .5) * (maximum);
|
|
}
|
|
float3 randomFloat3Range(float2 Seed, float Range)
|
|
{
|
|
return (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1) * Range;
|
|
}
|
|
float3 randomFloat3WiggleRange(float2 Seed, float Range, float wiggleSpeed)
|
|
{
|
|
float3 rando = (float3(
|
|
frac(sin(dot(Seed.xy, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(Seed.yx, float2(12.9898, 78.233))) * 43758.5453),
|
|
frac(sin(dot(float2(Seed.x * Seed.y, Seed.y + Seed.x), float2(12.9898, 78.233))) * 43758.5453)
|
|
) * 2 - 1);
|
|
float speed = 1 + wiggleSpeed;
|
|
return float3(sin((_Time.x + rando.x * PI) * speed), sin((_Time.x + rando.y * PI) * speed), sin((_Time.x + rando.z * PI) * speed)) * Range;
|
|
}
|
|
void poiDither(float4 In, float4 ScreenPosition, out float4 Out)
|
|
{
|
|
float2 uv = ScreenPosition.xy * _ScreenParams.xy;
|
|
float DITHER_THRESHOLDS[16] = {
|
|
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
|
|
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
|
|
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
|
|
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
|
|
};
|
|
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
|
|
Out = In - DITHER_THRESHOLDS[index];
|
|
}
|
|
static const float Epsilon = 1e-10;
|
|
static const float3 HCYwts = float3(0.299, 0.587, 0.114);
|
|
static const float HCLgamma = 3;
|
|
static const float HCLy0 = 100;
|
|
static const float HCLmaxL = 0.530454533953517; // == exp(HCLgamma / HCLy0) - 0.5
|
|
static const float3 wref = float3(1.0, 1.0, 1.0);
|
|
#define TAU 6.28318531
|
|
float3 HUEtoRGB(in float H)
|
|
{
|
|
float R = abs(H * 6 - 3) - 1;
|
|
float G = 2 - abs(H * 6 - 2);
|
|
float B = 2 - abs(H * 6 - 4);
|
|
return saturate(float3(R, G, B));
|
|
}
|
|
float3 RGBtoHCV(in float3 RGB)
|
|
{
|
|
float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0 / 3.0) : float4(RGB.gb, 0.0, -1.0 / 3.0);
|
|
float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
|
|
float C = Q.x - min(Q.w, Q.y);
|
|
float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
|
|
return float3(H, C, Q.x);
|
|
}
|
|
float3 HSVtoRGB(in float3 HSV)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSV.x);
|
|
return ((RGB - 1) * HSV.y + 1) * HSV.z;
|
|
}
|
|
float3 RGBtoHSV(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float S = HCV.y / (HCV.z + Epsilon);
|
|
return float3(HCV.x, S, HCV.z);
|
|
}
|
|
float3 HSLtoRGB(in float3 HSL)
|
|
{
|
|
float3 RGB = HUEtoRGB(HSL.x);
|
|
float C = (1 - abs(2 * HSL.z - 1)) * HSL.y;
|
|
return (RGB - 0.5) * C + HSL.z;
|
|
}
|
|
float3 RGBtoHSL(in float3 RGB)
|
|
{
|
|
float3 HCV = RGBtoHCV(RGB);
|
|
float L = HCV.z - HCV.y * 0.5;
|
|
float S = HCV.y / (1 - abs(L * 2 - 1) + Epsilon);
|
|
return float3(HCV.x, S, L);
|
|
}
|
|
float3 hueShift(float3 color, float hueOffset)
|
|
{
|
|
color = RGBtoHSV(color);
|
|
color.x = frac(hueOffset +color.x);
|
|
return HSVtoRGB(color);
|
|
}
|
|
float xyzF(float t)
|
|
{
|
|
return lerp(pow(t, 1. / 3.), 7.787037 * t + 0.139731, step(t, 0.00885645));
|
|
}
|
|
float xyzR(float t)
|
|
{
|
|
return lerp(t * t * t, 0.1284185 * (t - 0.139731), step(t, 0.20689655));
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float x, float y, float z)
|
|
{
|
|
float angleX = radians(x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float4x4 poiRotationMatrixFromAngles(float3 angles)
|
|
{
|
|
float angleX = radians(angles.x);
|
|
float c = cos(angleX);
|
|
float s = sin(angleX);
|
|
float4x4 rotateXMatrix = float4x4(1, 0, 0, 0,
|
|
0, c, -s, 0,
|
|
0, s, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleY = radians(angles.y);
|
|
c = cos(angleY);
|
|
s = sin(angleY);
|
|
float4x4 rotateYMatrix = float4x4(c, 0, s, 0,
|
|
0, 1, 0, 0,
|
|
- s, 0, c, 0,
|
|
0, 0, 0, 1);
|
|
float angleZ = radians(angles.z);
|
|
c = cos(angleZ);
|
|
s = sin(angleZ);
|
|
float4x4 rotateZMatrix = float4x4(c, -s, 0, 0,
|
|
s, c, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1);
|
|
return mul(mul(rotateXMatrix, rotateYMatrix), rotateZMatrix);
|
|
}
|
|
float3 getCameraPosition()
|
|
{
|
|
#ifdef USING_STEREO_MATRICES
|
|
return lerp(unity_StereoWorldSpaceCameraPos[0], unity_StereoWorldSpaceCameraPos[1], 0.5);
|
|
#endif
|
|
return _WorldSpaceCameraPos;
|
|
}
|
|
half2 calcScreenUVs(half4 grabPos)
|
|
{
|
|
half2 uv = grabPos.xy / (grabPos.w + 0.0000000001);
|
|
#if UNITY_SINGLE_PASS_STEREO
|
|
uv.xy *= half2(_ScreenParams.x * 2, _ScreenParams.y);
|
|
#else
|
|
uv.xy *= _ScreenParams.xy;
|
|
#endif
|
|
return uv;
|
|
}
|
|
float CalcMipLevel(float2 texture_coord)
|
|
{
|
|
float2 dx = ddx(texture_coord);
|
|
float2 dy = ddy(texture_coord);
|
|
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
|
|
return 0.5 * log2(delta_max_sqr);
|
|
}
|
|
float inverseLerp(float A, float B, float T)
|
|
{
|
|
return (T - A) / (B - A);
|
|
}
|
|
float inverseLerp2(float2 a, float2 b, float2 value)
|
|
{
|
|
float2 AB = b - a;
|
|
float2 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp3(float3 a, float3 b, float3 value)
|
|
{
|
|
float3 AB = b - a;
|
|
float3 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float inverseLerp4(float4 a, float4 b, float4 value)
|
|
{
|
|
float4 AB = b - a;
|
|
float4 AV = value - a;
|
|
return dot(AV, AB) / dot(AB, AB);
|
|
}
|
|
float4 quaternion_conjugate(float4 v)
|
|
{
|
|
return float4(
|
|
v.x, -v.yzw
|
|
);
|
|
}
|
|
float4 quaternion_mul(float4 v1, float4 v2)
|
|
{
|
|
float4 result1 = (v1.x * v2 + v1 * v2.x);
|
|
float4 result2 = float4(
|
|
- dot(v1.yzw, v2.yzw),
|
|
cross(v1.yzw, v2.yzw)
|
|
);
|
|
return float4(result1 + result2);
|
|
}
|
|
float4 get_quaternion_from_angle(float3 axis, float angle)
|
|
{
|
|
float sn = sin(angle * 0.5);
|
|
float cs = cos(angle * 0.5);
|
|
return float4(axis * sn, cs);
|
|
}
|
|
float4 quaternion_from_vector(float3 inVec)
|
|
{
|
|
return float4(0.0, inVec);
|
|
}
|
|
float degree_to_radius(float degree)
|
|
{
|
|
return (
|
|
degree / 180.0 * PI
|
|
);
|
|
}
|
|
float3 rotate_with_quaternion(float3 inVec, float3 rotation)
|
|
{
|
|
float4 qx = get_quaternion_from_angle(float3(1, 0, 0), radians(rotation.x));
|
|
float4 qy = get_quaternion_from_angle(float3(0, 1, 0), radians(rotation.y));
|
|
float4 qz = get_quaternion_from_angle(float3(0, 0, 1), radians(rotation.z));
|
|
#define MUL3(A, B, C) quaternion_mul(quaternion_mul((A), (B)), (C))
|
|
float4 quaternion = normalize(MUL3(qx, qy, qz));
|
|
float4 conjugate = quaternion_conjugate(quaternion);
|
|
float4 inVecQ = quaternion_from_vector(inVec);
|
|
float3 rotated = (
|
|
MUL3(quaternion, inVecQ, conjugate)
|
|
).yzw;
|
|
return rotated;
|
|
}
|
|
float4 transform(float4 input, float4 pos, float4 rotation, float4 scale)
|
|
{
|
|
input.rgb *= (scale.xyz * scale.w);
|
|
input = float4(rotate_with_quaternion(input.xyz, rotation.xyz * rotation.w) + (pos.xyz * pos.w), input.w);
|
|
return input;
|
|
}
|
|
float3 poiThemeColor(in PoiMods poiMods, in float3 srcColor, in float themeIndex)
|
|
{
|
|
if (themeIndex == 0) return srcColor;
|
|
themeIndex -= 1;
|
|
if (themeIndex <= 3)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
if (poiMods.audioLinkAvailable)
|
|
{
|
|
return poiMods.globalColorTheme[themeIndex];
|
|
}
|
|
#endif
|
|
return srcColor;
|
|
}
|
|
float lilIsIn0to1(float f)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, 1.0));
|
|
}
|
|
float lilIsIn0to1(float f, float nv)
|
|
{
|
|
float value = 0.5 - abs(f - 0.5);
|
|
return saturate(value / clamp(fwidth(value), 0.0001, nv));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border)
|
|
{
|
|
return (value - border) / clamp(fwidth(value), 0.0001, 1.0);
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return (value - borderMin) / saturate(borderMax - borderMin + fwidth(value));
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
return smoothstep(border - fwidthValue, border + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinearNoSaturate(float value, float border, float blur, float borderRange)
|
|
{
|
|
float fwidthValue = fwidth(value);
|
|
float borderMin = saturate(border - blur * 0.5 - borderRange);
|
|
float borderMax = saturate(border + blur * 0.5);
|
|
return smoothstep(borderMin - fwidthValue, borderMax + fwidthValue, value);
|
|
}
|
|
float poiEdgeNonLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeNonLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeNonLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float poiEdgeLinear(float value, float border)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur));
|
|
}
|
|
float poiEdgeLinear(float value, float border, float blur, float borderRange)
|
|
{
|
|
return saturate(poiEdgeLinearNoSaturate(value, border, blur, borderRange));
|
|
}
|
|
float3 OpenLitLinearToSRGB(float3 col)
|
|
{
|
|
return LinearToGammaSpace(col);
|
|
}
|
|
float3 OpenLitSRGBToLinear(float3 col)
|
|
{
|
|
return GammaToLinearSpace(col);
|
|
}
|
|
float OpenLitLuminance(float3 rgb)
|
|
{
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
return dot(rgb, float3(0.22, 0.707, 0.071));
|
|
#else
|
|
return dot(rgb, float3(0.0396819152, 0.458021790, 0.00609653955));
|
|
#endif
|
|
}
|
|
float OpenLitGray(float3 rgb)
|
|
{
|
|
return dot(rgb, float3(1.0/3.0, 1.0/3.0, 1.0/3.0));
|
|
}
|
|
void OpenLitShadeSH9ToonDouble(float3 lightDirection, out float3 shMax, out float3 shMin)
|
|
{
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 N = lightDirection * 0.666666;
|
|
float4 vB = N.xyzz * N.yzzx;
|
|
float3 res = float3(unity_SHAr.w,unity_SHAg.w,unity_SHAb.w);
|
|
res.r += dot(unity_SHBr, vB);
|
|
res.g += dot(unity_SHBg, vB);
|
|
res.b += dot(unity_SHBb, vB);
|
|
res += unity_SHC.rgb * (N.x * N.x - N.y * N.y);
|
|
float3 l1;
|
|
l1.r = dot(unity_SHAr.rgb, N);
|
|
l1.g = dot(unity_SHAg.rgb, N);
|
|
l1.b = dot(unity_SHAb.rgb, N);
|
|
shMax = res + l1;
|
|
shMin = res - l1;
|
|
#if defined(UNITY_COLORSPACE_GAMMA)
|
|
shMax = OpenLitLinearToSRGB(shMax);
|
|
shMin = OpenLitLinearToSRGB(shMin);
|
|
#endif
|
|
#else
|
|
shMax = 0.0;
|
|
shMin = 0.0;
|
|
#endif
|
|
}
|
|
float3 OpenLitComputeCustomLightDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 customDir = length(lightDirectionOverride.xyz) * normalize(mul((float3x3)unity_ObjectToWorld, lightDirectionOverride.xyz));
|
|
return lightDirectionOverride.w ? customDir : lightDirectionOverride.xyz; // .w isn't doc'd anywhere and is always 0 unless end user changes it
|
|
}
|
|
float3 OpenLitLightingDirection(float4 lightDirectionOverride)
|
|
{
|
|
float3 mainDir = _WorldSpaceLightPos0.xyz * OpenLitLuminance(_LightColor0.rgb);
|
|
#if !defined(LIGHTMAP_ON) && UNITY_SHOULD_SAMPLE_SH
|
|
float3 sh9Dir = unity_SHAr.xyz * 0.333333 + unity_SHAg.xyz * 0.333333 + unity_SHAb.xyz * 0.333333;
|
|
float3 sh9DirAbs = float3(sh9Dir.x, abs(sh9Dir.y), sh9Dir.z);
|
|
#else
|
|
float3 sh9Dir = 0;
|
|
float3 sh9DirAbs = 0;
|
|
#endif
|
|
float3 customDir = OpenLitComputeCustomLightDirection(lightDirectionOverride);
|
|
return normalize(sh9DirAbs + mainDir + customDir);
|
|
}
|
|
float3 OpenLitLightingDirection()
|
|
{
|
|
float4 customDir = float4(0.001,0.002,0.001,0.0);
|
|
return OpenLitLightingDirection(customDir);
|
|
}
|
|
inline float4 CalculateFrustumCorrection()
|
|
{
|
|
float x1 = -UNITY_MATRIX_P._31 / (UNITY_MATRIX_P._11 * UNITY_MATRIX_P._34);
|
|
float x2 = -UNITY_MATRIX_P._32 / (UNITY_MATRIX_P._22 * UNITY_MATRIX_P._34);
|
|
return float4(x1, x2, 0, UNITY_MATRIX_P._33 / UNITY_MATRIX_P._34 + x1 * UNITY_MATRIX_P._13 + x2 * UNITY_MATRIX_P._23);
|
|
}
|
|
inline float CorrectedLinearEyeDepth(float z, float B)
|
|
{
|
|
return 1.0 / (z / UNITY_MATRIX_P._34 + B);
|
|
}
|
|
float2 sharpSample( float4 texelSize , float2 p )
|
|
{
|
|
p = p*texelSize.zw;
|
|
float2 c = max(0.0, fwidth(p));
|
|
p = floor(p) + saturate(frac(p) / c);
|
|
p = (p - 0.5)*texelSize.xy;
|
|
return p;
|
|
}
|
|
#ifdef POI_AUDIOLINK
|
|
float4 AudioLinkDataMultiline(uint2 xycoord) { return AudioLinkData(uint2(xycoord.x % AUDIOLINK_WIDTH, xycoord.y + xycoord.x/AUDIOLINK_WIDTH)); }
|
|
float4 AudioLinkLerp(float2 xy) { return lerp( AudioLinkData(xy), AudioLinkData(xy+int2(1,0)), frac( xy.x ) ); }
|
|
float4 AudioLinkLerpMultiline(float2 xy) { return lerp(AudioLinkDataMultiline(xy), AudioLinkDataMultiline(xy+float2(1,0)), frac(xy.x)); }
|
|
bool AudioLinkIsAvailable()
|
|
{
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
int width, height;
|
|
_AudioTexture.GetDimensions(width, height);
|
|
return width > 16;
|
|
#else
|
|
return _AudioTexture_TexelSize.z > 16;
|
|
#endif
|
|
}
|
|
float AudioLinkGetVersion()
|
|
{
|
|
int2 dims;
|
|
#if !defined(AUDIOLINK_STANDARD_INDEXING)
|
|
_AudioTexture.GetDimensions(dims.x, dims.y);
|
|
#else
|
|
dims = _AudioTexture_TexelSize.zw;
|
|
#endif
|
|
if (dims.x >= 128)
|
|
return AudioLinkData(ALPASS_GENERALVU).x;
|
|
else if (dims.x > 16)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
#define AudioLinkGetSelfPixelData(xy) _SelfTexture2D[xy]
|
|
uint AudioLinkDecodeDataAsUInt(uint2 indexloc)
|
|
{
|
|
uint4 rpx = AudioLinkData(indexloc);
|
|
return rpx.r + rpx.g*1024 + rpx.b * 1048576 + rpx.a * 1073741824;
|
|
}
|
|
float AudioLinkDecodeDataAsSeconds(uint2 indexloc)
|
|
{
|
|
uint time = AudioLinkDecodeDataAsUInt(indexloc) & 0x7ffffff;
|
|
return float(time / 1000) + float( time % 1000 ) / 1000.;
|
|
}
|
|
#define ALDecodeDataAsSeconds( x ) AudioLinkDecodeDataAsSeconds( x )
|
|
#define ALDecodeDataAsUInt( x ) AudioLinkDecodeDataAsUInt( x )
|
|
float AudioLinkRemap(float t, float a, float b, float u, float v) { return ((t-a) / (b-a)) * (v-u) + u; }
|
|
float3 AudioLinkHSVtoRGB(float3 HSV)
|
|
{
|
|
float3 RGB = 0;
|
|
float C = HSV.z * HSV.y;
|
|
float H = HSV.x * 6;
|
|
float X = C * (1 - abs(fmod(H, 2) - 1));
|
|
if (HSV.y != 0)
|
|
{
|
|
float I = floor(H);
|
|
if (I == 0) { RGB = float3(C, X, 0); }
|
|
else if (I == 1) { RGB = float3(X, C, 0); }
|
|
else if (I == 2) { RGB = float3(0, C, X); }
|
|
else if (I == 3) { RGB = float3(0, X, C); }
|
|
else if (I == 4) { RGB = float3(X, 0, C); }
|
|
else { RGB = float3(C, 0, X); }
|
|
}
|
|
float M = HSV.z - C;
|
|
return RGB + M;
|
|
}
|
|
float3 AudioLinkCCtoRGB(float bin, float intensity, int rootNote)
|
|
{
|
|
float note = bin / AUDIOLINK_EXPBINS;
|
|
float hue = 0.0;
|
|
note *= 12.0;
|
|
note = glsl_mod(4. - note + rootNote, 12.0);
|
|
{
|
|
if(note < 4.0)
|
|
{
|
|
hue = (note) / 24.0;
|
|
}
|
|
else if(note < 8.0)
|
|
{
|
|
hue = (note-2.0) / 12.0;
|
|
}
|
|
else
|
|
{
|
|
hue = (note - 4.0) / 8.0;
|
|
}
|
|
}
|
|
float val = intensity - 0.1;
|
|
return AudioLinkHSVtoRGB(float3(fmod(hue, 1.0), 1.0, clamp(val, 0.0, 1.0)));
|
|
}
|
|
float4 AudioLinkGetAmplitudeAtFrequency(float hertz)
|
|
{
|
|
float note = AUDIOLINK_EXPBINS * log2(hertz / AUDIOLINK_BOTTOM_FREQUENCY);
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(note, 0));
|
|
}
|
|
float AudioLinkGetAmplitudeAtNote(float octave, float note)
|
|
{
|
|
float quarter = note * 2.0;
|
|
return AudioLinkLerpMultiline(ALPASS_DFT + float2(octave * AUDIOLINK_EXPBINS + quarter, 0));
|
|
}
|
|
float AudioLinkGetChronoTime(uint index, uint band)
|
|
{
|
|
return (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(index, band))) / 100000.0;
|
|
}
|
|
float AudioLinkGetChronoTimeNormalized(uint index, uint band, float speed)
|
|
{
|
|
return frac(AudioLinkGetChronoTime(index, band) * speed);
|
|
}
|
|
float AudioLinkGetChronoTimeInterval(uint index, uint band, float speed, float interval)
|
|
{
|
|
return AudioLinkGetChronoTimeNormalized(index, band, speed) * interval;
|
|
}
|
|
float getBandAtTime(float band, float time, float size = 1.0f)
|
|
{
|
|
return remapClamped(min(size,.9999), 1, AudioLinkData(ALPASS_AUDIOBASS + uint2(time * AUDIOLINK_WIDTH,band)).r);
|
|
}
|
|
fixed3 maximize(fixed3 c) {
|
|
if (c.x == 0 && c.y == 0 && c.z == 0)
|
|
return fixed3(1.0, 1.0, 1.0);
|
|
else
|
|
return c / max(c.r, max(c.g, c.b));
|
|
}
|
|
bool LumaIsAvailable()
|
|
{
|
|
return LumaData(0.629, 0.511).r > 0.9;
|
|
}
|
|
float3 getLumaGradient(uint index, float offset) {
|
|
return LumaData(0.57 + (index * 0.11) + lerp(0, 0.107, offset), 0.493);
|
|
}
|
|
void initPoiAudioLink(inout PoiMods poiMods)
|
|
{
|
|
if (!(1.0 /*_AudioLinkAnimToggle*/)) return;
|
|
if (AudioLinkIsAvailable())
|
|
{
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkVersion = AudioLinkGetVersion();
|
|
poiMods.audioLink.x = AudioLinkData(ALPASS_AUDIOBASS).r;
|
|
poiMods.audioLink.y = AudioLinkData(ALPASS_AUDIOLOWMIDS).r;
|
|
poiMods.audioLink.z = AudioLinkData(ALPASS_AUDIOHIGHMIDS).r;
|
|
poiMods.audioLink.w = AudioLinkData(ALPASS_AUDIOTREBLE).r;
|
|
poiMods.globalColorTheme[4] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(2, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[5] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(3, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[6] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(4, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[7] = float4(AudioLinkCCtoRGB(glsl_mod(AudioLinkData(ALPASS_CCINTERNAL + uint2(5, 0)).x, AUDIOLINK_EXPBINS), 1, AUDIOLINK_ROOTNOTE), 1.0);
|
|
poiMods.globalColorTheme[8] = AudioLinkData(ALPASS_THEME_COLOR0);
|
|
poiMods.globalColorTheme[9] = AudioLinkData(ALPASS_THEME_COLOR1);
|
|
poiMods.globalColorTheme[10] = AudioLinkData(ALPASS_THEME_COLOR2);
|
|
poiMods.globalColorTheme[11] = AudioLinkData(ALPASS_THEME_COLOR3);
|
|
return;
|
|
}
|
|
if (LumaIsAvailable())
|
|
{
|
|
float4 audioPixel = LumaData(0.578, 0.515);
|
|
float audioLows = audioPixel.r;
|
|
float audioHighs = audioPixel.g;
|
|
float4 zone1 = LumaData(0.856, 0.522);
|
|
float4 zone2 = LumaData(0.856, 0.507);
|
|
float4 zone3 = LumaData(0.864, 0.522);
|
|
float4 zone4 = LumaData(0.864, 0.507);
|
|
poiMods.audioLinkAvailable = true;
|
|
poiMods.audioLinkViaLuma = true;
|
|
poiMods.audioLink.xy = audioLows;
|
|
poiMods.audioLink.zw = audioHighs;
|
|
poiMods.globalColorTheme[8] = zone1;
|
|
poiMods.globalColorTheme[9] = zone2;
|
|
poiMods.globalColorTheme[10] = zone3;
|
|
poiMods.globalColorTheme[11] = zone4;
|
|
}
|
|
}
|
|
void DebugVisualizer(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiMods poiMods){
|
|
if (_DebugWaveform){
|
|
float waveform = AudioLinkLerpMultiline(ALPASS_WAVEFORM + float2( 500. * poiMesh.uv[0].x, 0)).r;
|
|
poiFragData.emission += clamp(1 - 50 * abs(waveform - poiMesh.uv[0].y * 2. + 1), 0, 1);
|
|
}
|
|
if (_DebugDFT){
|
|
poiFragData.emission += AudioLinkLerpMultiline(ALPASS_DFT + uint2(poiMesh.uv[0].x * AUDIOLINK_ETOTALBINS, 0)).rrr;
|
|
}
|
|
if (_DebugBass){
|
|
poiFragData.emission += poiMods.audioLink.x;
|
|
}
|
|
if (_DebugLowMids){
|
|
poiFragData.emission += poiMods.audioLink.y;
|
|
}
|
|
if (_DebugHighMids){
|
|
poiFragData.emission += poiMods.audioLink.z;
|
|
}
|
|
if (_DebugTreble){
|
|
poiFragData.emission += poiMods.audioLink.w;
|
|
}
|
|
if (_DebugCCColors){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCCOLORS + uint2(3 + 1, 0));
|
|
}
|
|
if (_DebugCCStrip){
|
|
poiFragData.emission += AudioLinkLerp(ALPASS_CCSTRIP + float2(poiMesh.uv[0].x * AUDIOLINK_WIDTH, 0));
|
|
}
|
|
if (_DebugCCLights){
|
|
poiFragData.emission += AudioLinkData(ALPASS_CCLIGHTS + uint2(uint(poiMesh.uv[0].x * 8) + uint(poiMesh.uv[0].y * 16) * 8, 0));
|
|
}
|
|
if (_DebugAutocorrelator){
|
|
poiFragData.emission += saturate(AudioLinkLerp(ALPASS_AUTOCORRELATOR + float2((abs(1. - poiMesh.uv[0].x * 2.)) * AUDIOLINK_WIDTH, 0)).rrr);
|
|
}
|
|
if (_DebugChronotensity){
|
|
poiFragData.emission += (AudioLinkDecodeDataAsUInt(ALPASS_CHRONOTENSITY + uint2(1, 0)) % 1000000) / 1000000.0;
|
|
}
|
|
}
|
|
void SetupAudioLink(inout PoiFragData poiFragData, inout PoiMods poiMods, in PoiMesh poiMesh){
|
|
initPoiAudioLink(poiMods);
|
|
DebugVisualizer(poiFragData, poiMesh, poiMods);
|
|
if(_AudioLinkCCStripY)
|
|
{
|
|
poiFragData.emission += AudioLinkLerp( ALPASS_CCSTRIP + float2( poiMesh.uv[0].y * AUDIOLINK_WIDTH, 0 ) ).rgb * .5;
|
|
}
|
|
}
|
|
#endif
|
|
v2f vert(appdata v)
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
v2f o;
|
|
PoiInitStruct(v2f, o);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
o.objectPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz;
|
|
o.objNormal = v.normal;
|
|
o.normal = UnityObjectToWorldNormal(v.normal);
|
|
o.tangent = UnityObjectToWorldDir(v.tangent);
|
|
o.binormal = cross(o.normal, o.tangent) * (v.tangent.w * unity_WorldTransformParams.w);
|
|
o.vertexColor = v.color;
|
|
o.uv[0] = v.uv0;
|
|
o.uv[1] = v.uv1;
|
|
o.uv[2] = v.uv2;
|
|
o.uv[3] = v.uv3;
|
|
#if defined(LIGHTMAP_ON)
|
|
o.lightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
|
#endif
|
|
#ifdef DYNAMICLIGHTMAP_ON
|
|
o.lightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
|
#endif
|
|
o.localPos = v.vertex;
|
|
o.worldPos = mul(unity_ObjectToWorld, o.localPos);
|
|
float3 localOffset = float3(0, 0, 0);
|
|
float3 worldOffset = float3(0, 0, 0);
|
|
o.localPos.rgb += localOffset;
|
|
o.worldPos.rgb += worldOffset;
|
|
o.pos = UnityObjectToClipPos(o.localPos);
|
|
#ifdef POI_PASS_OUTLINE
|
|
#if defined(UNITY_REVERSED_Z)
|
|
o.pos.z += _Offset_Z * - 0.01;
|
|
#else
|
|
o.pos.z += _Offset_Z * 0.01;
|
|
#endif
|
|
#endif
|
|
o.grabPos = ComputeGrabScreenPos(o.pos);
|
|
#ifndef FORWARD_META_PASS
|
|
#if !defined(UNITY_PASS_SHADOWCASTER)
|
|
UNITY_TRANSFER_SHADOW(o, o.uv[0].xy);
|
|
#else
|
|
TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos);
|
|
#endif
|
|
#endif
|
|
UNITY_TRANSFER_FOG(o, o.pos);
|
|
if ((0.0 /*_RenderingReduceClipDistance*/))
|
|
{
|
|
if (o.pos.w < _ProjectionParams.y * 1.01 && o.pos.w > 0)
|
|
{
|
|
o.pos.z = o.pos.z * 0.0001 + o.pos.w * 0.999;
|
|
}
|
|
}
|
|
#ifdef POI_PASS_META
|
|
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
|
#endif
|
|
#if defined(GRAIN)
|
|
float4 worldDirection;
|
|
worldDirection.xyz = o.worldPos.xyz - _WorldSpaceCameraPos;
|
|
worldDirection.w = dot(o.pos, CalculateFrustumCorrection());
|
|
o.worldDirection = worldDirection;
|
|
#endif
|
|
return o;
|
|
}
|
|
float2 calculatePolarCoordinate(in PoiMesh poiMesh)
|
|
{
|
|
float2 delta = poiMesh.uv[(0.0 /*_PolarUV*/)] - float4(0.5,0.5,0,0);
|
|
float radius = length(delta) * 2 * (1.0 /*_PolarRadialScale*/);
|
|
float angle = atan2(delta.x, delta.y) * 1.0 / 6.28 * (1.0 /*_PolarLengthScale*/);
|
|
return float2(radius, angle + distance(poiMesh.uv[(0.0 /*_PolarUV*/)], float4(0.5,0.5,0,0)) * (0.0 /*_PolarSpiralPower*/));
|
|
}
|
|
float2 MonoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(1.0 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(1.0, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 1.0).zw;
|
|
}
|
|
float2 StereoPanoProjection(float3 coords)
|
|
{
|
|
float3 normalizedCoords = normalize(coords);
|
|
float latitude = acos(normalizedCoords.y);
|
|
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
|
|
float2 sphereCoords = float2(longitude, latitude) * float2(0.5 / UNITY_PI, 1.0 / UNITY_PI);
|
|
sphereCoords = float2(0.5, 1.0) - sphereCoords;
|
|
return(sphereCoords + float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).xy) * float4(0, 1 - unity_StereoEyeIndex, 1, 0.5).zw;
|
|
}
|
|
float2 calculatePanosphereUV(in PoiMesh poiMesh)
|
|
{
|
|
float3 viewDirection = normalize(lerp(getCameraPosition().xyz, _WorldSpaceCameraPos.xyz, (1.0 /*_PanoUseBothEyes*/)) - poiMesh.worldPos.xyz) * - 1;
|
|
return lerp(MonoPanoProjection(viewDirection), StereoPanoProjection(viewDirection), (0.0 /*_StereoEnabled*/));
|
|
}
|
|
void applyAlphaOptions(inout PoiFragData poiFragData, in PoiMesh poiMesh, in PoiCam poiCam, in PoiMods poiMods)
|
|
{
|
|
poiFragData.alpha = saturate(poiFragData.alpha + (0.0 /*_AlphaMod*/));
|
|
}
|
|
float4 frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(i);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
|
PoiMesh poiMesh;
|
|
PoiInitStruct(PoiMesh, poiMesh);
|
|
PoiLight poiLight;
|
|
PoiInitStruct(PoiLight, poiLight);
|
|
PoiVertexLights poiVertexLights;
|
|
PoiInitStruct(PoiVertexLights, poiVertexLights);
|
|
PoiCam poiCam;
|
|
PoiInitStruct(PoiCam, poiCam);
|
|
PoiMods poiMods;
|
|
PoiInitStruct(PoiMods, poiMods);
|
|
poiMods.globalEmission = 1;
|
|
PoiFragData poiFragData;
|
|
poiFragData.emission = 0;
|
|
poiFragData.baseColor = float3(0, 0, 0);
|
|
poiFragData.finalColor = float3(0, 0, 0);
|
|
poiFragData.alpha = 1;
|
|
#ifdef POI_UDIMDISCARD
|
|
applyUDIMDiscard(i);
|
|
#endif
|
|
poiMesh.objectPosition = i.objectPos;
|
|
poiMesh.objNormal = i.objNormal;
|
|
poiMesh.normals[0] = i.normal;
|
|
poiMesh.tangent = i.tangent;
|
|
poiMesh.binormal = i.binormal;
|
|
poiMesh.worldPos = i.worldPos.xyz;
|
|
poiMesh.localPos = i.localPos.xyz;
|
|
poiMesh.vertexColor = i.vertexColor;
|
|
poiMesh.isFrontFace = facing;
|
|
#ifndef POI_PASS_OUTLINE
|
|
if (!poiMesh.isFrontFace)
|
|
{
|
|
poiMesh.normals[0] *= -1;
|
|
poiMesh.tangent *= -1;
|
|
poiMesh.binormal *= -1;
|
|
}
|
|
#endif
|
|
poiCam.viewDir = !IsOrthographicCamera() ? normalize(_WorldSpaceCameraPos - i.worldPos.xyz) : normalize(UNITY_MATRIX_I_V._m02_m12_m22);
|
|
float3 tanToWorld0 = float3(i.tangent.x, i.binormal.x, i.normal.x);
|
|
float3 tanToWorld1 = float3(i.tangent.y, i.binormal.y, i.normal.y);
|
|
float3 tanToWorld2 = float3(i.tangent.z, i.binormal.z, i.normal.z);
|
|
float3 ase_tanViewDir = tanToWorld0 * poiCam.viewDir.x + tanToWorld1 * poiCam.viewDir.y + tanToWorld2 * poiCam.viewDir.z;
|
|
poiCam.tangentViewDir = normalize(ase_tanViewDir);
|
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
|
poiMesh.lightmapUV = i.lightmapUV;
|
|
#endif
|
|
poiMesh.parallaxUV = poiCam.tangentViewDir.xy / max(poiCam.tangentViewDir.z, 0.0001);
|
|
poiMesh.uv[0] = i.uv[0];
|
|
poiMesh.uv[1] = i.uv[1];
|
|
poiMesh.uv[2] = i.uv[2];
|
|
poiMesh.uv[3] = i.uv[3];
|
|
poiMesh.uv[4] = poiMesh.uv[0];
|
|
poiMesh.uv[5] = poiMesh.worldPos.xz;
|
|
poiMesh.uv[6] = poiMesh.uv[0];
|
|
poiMesh.uv[7] = poiMesh.uv[0];
|
|
poiMesh.uv[4] = calculatePanosphereUV(poiMesh);
|
|
poiMesh.uv[6] = calculatePolarCoordinate(poiMesh);
|
|
float2 mainUV = poiMesh.uv[(0.0 /*_MainTexUV*/)].xy;
|
|
if ((0.0 /*_MainPixelMode*/))
|
|
{
|
|
mainUV = sharpSample(float4(0.0002441406,0.0002441406,4096,4096), mainUV);
|
|
}
|
|
float4 mainTexture = UNITY_SAMPLE_TEX2D(_MainTex, poiUV(mainUV, float4(1,1,0,0)) + _Time.x * float4(0,0,0,0));
|
|
float3 mainNormal = UnpackScaleNormal(POI2D_SAMPLER_PAN(_BumpMap, _MainTex, poiUV(poiMesh.uv[(0.0 /*_BumpMapUV*/)], float4(1,1,0,0)), float4(0,0,0,0)), (1.0 /*_BumpScale*/));
|
|
poiMesh.tangentSpaceNormal = mainNormal;
|
|
poiMesh.normals[1] = normalize(
|
|
poiMesh.tangentSpaceNormal.x * poiMesh.tangent.xyz +
|
|
poiMesh.tangentSpaceNormal.y * poiMesh.binormal +
|
|
poiMesh.tangentSpaceNormal.z * poiMesh.normals[0]
|
|
);
|
|
float3 fancyNormal = UnpackNormal(float4(0.5, 0.5, 1, 1));
|
|
poiMesh.normals[0] = normalize(
|
|
fancyNormal.x * poiMesh.tangent.xyz +
|
|
fancyNormal.y * poiMesh.binormal +
|
|
fancyNormal.z * poiMesh.normals[0]
|
|
);
|
|
poiCam.forwardDir = getCameraForward();
|
|
poiCam.worldPos = _WorldSpaceCameraPos;
|
|
poiCam.reflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[1]);
|
|
poiCam.vertexReflectionDir = reflect(-poiCam.viewDir, poiMesh.normals[0]);
|
|
poiCam.distanceToVert = distance(poiMesh.worldPos, poiCam.worldPos);
|
|
poiCam.grabPos = i.grabPos;
|
|
poiCam.screenUV = calcScreenUVs(i.grabPos);
|
|
poiCam.vDotN = abs(dot(poiCam.viewDir, poiMesh.normals[1]));
|
|
poiCam.clipPos = i.pos;
|
|
poiCam.worldDirection = i.worldDirection;
|
|
#ifdef POI_AUDIOLINK
|
|
SetupAudioLink(poiFragData, poiMods, poiMesh);
|
|
#endif
|
|
poiFragData.baseColor = mainTexture.rgb * poiThemeColor(poiMods, float4(1,1,1,1).rgb, (0.0 /*_ColorThemeIndex*/));
|
|
poiFragData.alpha = mainTexture.a * float4(1,1,1,1).a;
|
|
#if defined(PROP_CLIPPINGMASK) || !defined(OPTIMIZER_ENABLED)
|
|
float alphaMask = POI2D_SAMPLER_PAN(_ClippingMask, _MainTex, poiUV(poiMesh.uv[(0.0 /*_ClippingMaskUV*/)], float4(1,1,0,0)), float4(0,0,0,0)).r;
|
|
if ((0.0 /*_Inverse_Clipping*/))
|
|
{
|
|
alphaMask = 1 - alphaMask;
|
|
}
|
|
#else
|
|
float alphaMask = 1;
|
|
#endif
|
|
poiFragData.alpha *= alphaMask;
|
|
applyAlphaOptions(poiFragData, poiMesh, poiCam, poiMods);
|
|
poiFragData.finalColor = poiFragData.baseColor;
|
|
if ((0.0 /*_IgnoreFog*/) == 0)
|
|
{
|
|
UNITY_APPLY_FOG(i.fogCoord, poiFragData.finalColor);
|
|
}
|
|
poiFragData.alpha = (0.0 /*_AlphaForceOpaque*/) ? 1 : poiFragData.alpha;
|
|
if ((0.0 /*_Mode*/) == POI_MODE_OPAQUE)
|
|
{
|
|
poiFragData.alpha = 1;
|
|
}
|
|
clip(poiFragData.alpha - (0.5 /*_Cutoff*/));
|
|
return float4(poiFragData.finalColor, poiFragData.alpha) + POI_SAFE_RGB0;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
CustomEditor "Thry.ShaderEditor"
|
|
}
|