diff --git a/Shader/Includes/Moonlight.hlsl b/Shader/Includes/Moonlight.hlsl new file mode 100644 index 0000000..8f477d2 --- /dev/null +++ b/Shader/Includes/Moonlight.hlsl @@ -0,0 +1,10 @@ +#ifndef MOONLIGHT_CORE_INCLUDED +#define MOONLIGHT_CORE_INCLUDED + +#include "Variables.hlsl" +#include "DefaultSetup.hlsl" +#include "LightStrength.hlsl" +#include "Lambert.hlsl" +#include "Shadowcaster.cginc" + +#endif \ No newline at end of file diff --git a/Shader/Includes/Variables.hlsl b/Shader/Includes/Variables.hlsl index 95e74a8..31dfa89 100644 --- a/Shader/Includes/Variables.hlsl +++ b/Shader/Includes/Variables.hlsl @@ -1,14 +1,40 @@ -#ifndef MoonlightGlobalVariables -#define MoonlightGlobalVariables \ - \ - float _InverseSqareMultiplier; \ - float _LightCutoffDistance; \ - \ - float4 _Udon_LightPositions[MAX_LIGHTS]; /* xyz = position */ \ - float4 _Udon_LightColors[MAX_LIGHTS]; /* xyz = position */ \ - float4 _Udon_LightDirections[MAX_LIGHTS]; /* xyz = direction, w = cos(halfAngle) */ \ - float _Udon_LightType[MAX_LIGHTS]; /* 0 = sphere, 1 = cone */ \ - float _Udon_ShadowMapIndex[MAX_LIGHTS];\ - float _Udon_PlayerCount; /* set via SetFloat */ \ +#ifndef MOONLIGHT_GLOBAL_VARIABLES_INCLUDED +#define MOONLIGHT_GLOBAL_VARIABLES_INCLUDED + +float _InverseSqareMultiplier; +float _LightCutoffDistance; + +float4 _Udon_LightPositions[MAX_LIGHTS]; /* xyz = position */ +float4 _Udon_LightColors[MAX_LIGHTS]; /* xyz = position */ +float4 _Udon_LightDirections[MAX_LIGHTS]; /* xyz = direction, w = cos(halfAngle) */ +float _Udon_LightType[MAX_LIGHTS]; /* 0 = sphere, 1 = cone */ +float _Udon_ShadowMapIndex[MAX_LIGHTS]; +float _Udon_PlayerCount; /* set via SetFloat */ + +float4 _Udon_Plane_Origin_1; // xyz = origin (world), w unused +float4 _Udon_Plane_Uinv_1; // xyz = Udir / (2*halfWidth) +float4 _Udon_Plane_Vinv_1; // xyz = Vdir / (2*halfHeight) +float4 _Udon_Plane_Normal_1; // xyz = unit normal + +sampler2D _Udon_shadowCasterTex_1; +float4 _Udon_shadowCasterColor_1; +float4 _Udon_OutSideColor_1; +float _Udon_MinBrightnessShadow_1; + +float4 _Udon_Plane_Origin_2; +float4 _Udon_Plane_Uinv_2; +float4 _Udon_Plane_Vinv_2; +float4 _Udon_Plane_Normal_2; + +sampler2D _Udon_shadowCasterTex_2; +float4 _Udon_shadowCasterColor_2; +float4 _Udon_OutSideColor_2; +float _Udon_MinBrightnessShadow_2; + +float _BlurPixels; +float4 _Udon_shadowCasterTex_1_TexelSize; // xy = 1/width, 1/height +float4 _Udon_shadowCasterTex_2_TexelSize; + +bool _EnableShadowCasting; #endif \ No newline at end of file diff --git a/Shader/LitParticles_2SP.shader b/Shader/LitParticles_2SP.shader index 03b0658..d0c9a46 100644 --- a/Shader/LitParticles_2SP.shader +++ b/Shader/LitParticles_2SP.shader @@ -35,11 +35,7 @@ Shader "DeMuenu/World/Hoppou/Particles/LitParticles_2SP" #define MAX_LIGHTS 80 // >= maxPlayers in script #include "UnityCG.cginc" - #include "Includes/LightStrength.hlsl" - #include "Includes/Lambert.hlsl" - #include "Includes/DefaultSetup.hlsl" - #include "Includes/Variables.hlsl" - #include "Includes/Shadowcaster.cginc" + #include "Includes/Moonlight.hlsl" @@ -79,35 +75,6 @@ Shader "DeMuenu/World/Hoppou/Particles/LitParticles_2SP" float4 _EmmissiveColor; float _EmmissiveStrength; - - MoonlightGlobalVariables - - float4 _Udon_Plane_Origin_1; // xyz = origin (world), w unused - float4 _Udon_Plane_Uinv_1; // xyz = Udir / (2*halfWidth) - float4 _Udon_Plane_Vinv_1; // xyz = Vdir / (2*halfHeight) - float4 _Udon_Plane_Normal_1; // xyz = unit normal - - sampler2D _Udon_shadowCasterTex_1; - float4 _Udon_shadowCasterColor_1; - float4 _Udon_OutSideColor_1; - float _Udon_MinBrightnessShadow_1; - - float4 _Udon_Plane_Origin_2; - float4 _Udon_Plane_Uinv_2; - float4 _Udon_Plane_Vinv_2; - float4 _Udon_Plane_Normal_2; - - sampler2D _Udon_shadowCasterTex_2; - float4 _Udon_shadowCasterColor_2; - float4 _Udon_OutSideColor_2; - float _Udon_MinBrightnessShadow_2; - - float _BlurPixels; - float4 _Udon_shadowCasterTex_1_TexelSize; // xy = 1/width, 1/height - float4 _Udon_shadowCasterTex_2_TexelSize; - - bool _EnableShadowCasting; - v2f vert (appdata v) { v2f o; diff --git a/Shader/Standard_2SP.shader b/Shader/Standard_2SP.shader index cbb91b1..25825b7 100644 --- a/Shader/Standard_2SP.shader +++ b/Shader/Standard_2SP.shader @@ -37,16 +37,12 @@ Shader "DeMuenu/World/Hoppou/Standard_2SP" #pragma vertex vert #pragma fragment frag - #include "UnityCG.cginc" - #include "Includes/LightStrength.hlsl" - #include "Includes/Lambert.hlsl" - #include "Includes/DefaultSetup.hlsl" - #include "Includes/Variables.hlsl" - #include "Includes/Shadowcaster.cginc" - //Moonlight Defines #define MAX_LIGHTS 80 // >= maxPlayers in script //Moonlight Defines END + + #include "UnityCG.cginc" + #include "Includes/Moonlight.hlsl" struct appdata { @@ -89,35 +85,6 @@ Shader "DeMuenu/World/Hoppou/Standard_2SP" float _EmmissiveStrength; - MoonlightGlobalVariables - - - float4 _Udon_Plane_Origin_1; // xyz = origin (world), w unused - float4 _Udon_Plane_Uinv_1; // xyz = Udir / (2*halfWidth) - float4 _Udon_Plane_Vinv_1; // xyz = Vdir / (2*halfHeight) - float4 _Udon_Plane_Normal_1; // xyz = unit normal - - sampler2D _Udon_shadowCasterTex_1; - float4 _Udon_shadowCasterColor_1; - float4 _Udon_OutSideColor_1; - float _Udon_MinBrightnessShadow_1; - - float4 _Udon_Plane_Origin_2; - float4 _Udon_Plane_Uinv_2; - float4 _Udon_Plane_Vinv_2; - float4 _Udon_Plane_Normal_2; - - sampler2D _Udon_shadowCasterTex_2; - float4 _Udon_shadowCasterColor_2; - float4 _Udon_OutSideColor_2; - float _Udon_MinBrightnessShadow_2; - - float _BlurPixels; - float4 _Udon_shadowCasterTex_1_TexelSize; // xy = 1/width, 1/height - float4 _Udon_shadowCasterTex_2_TexelSize; - - bool _EnableShadowCasting; - v2f vert (appdata v) { v2f o; diff --git a/Shader/Standard_Lightmap_2SP.shader b/Shader/Standard_Lightmap_2SP.shader index f53dc26..137255c 100644 --- a/Shader/Standard_Lightmap_2SP.shader +++ b/Shader/Standard_Lightmap_2SP.shader @@ -39,16 +39,12 @@ Shader "DeMuenu/World/Hoppou/Standard_Lightmap_2SP" #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _ DIRLIGHTMAP_COMBINED - #include "UnityCG.cginc" - #include "Includes/LightStrength.hlsl" - #include "Includes/Lambert.hlsl" - #include "Includes/DefaultSetup.hlsl" - #include "Includes/Variables.hlsl" - #include "Includes/Shadowcaster.cginc" - //Moonlight Defines #define MAX_LIGHTS 80 // >= maxPlayers in script //Moonlight Defines END + + #include "UnityCG.cginc" + #include "Includes/Moonlight.hlsl" struct appdata { @@ -97,37 +93,6 @@ Shader "DeMuenu/World/Hoppou/Standard_Lightmap_2SP" float _EmmissiveStrength; - MoonlightGlobalVariables - - - float4 _Udon_Plane_Origin_1; // xyz = origin (world), w unused - float4 _Udon_Plane_Uinv_1; // xyz = Udir / (2*halfWidth) - float4 _Udon_Plane_Vinv_1; // xyz = Vdir / (2*halfHeight) - float4 _Udon_Plane_Normal_1; // xyz = unit normal - - sampler2D _Udon_shadowCasterTex_1; - float4 _Udon_shadowCasterColor_1; - float4 _Udon_OutSideColor_1; - float _Udon_MinBrightnessShadow_1; - - float4 _Udon_Plane_Origin_2; - float4 _Udon_Plane_Uinv_2; - float4 _Udon_Plane_Vinv_2; - float4 _Udon_Plane_Normal_2; - - sampler2D _Udon_shadowCasterTex_2; - float4 _Udon_shadowCasterColor_2; - float4 _Udon_OutSideColor_2; - float _Udon_MinBrightnessShadow_2; - - float _BlurPixels; - float4 _Udon_shadowCasterTex_1_TexelSize; // xy = 1/width, 1/height - float4 _Udon_shadowCasterTex_2_TexelSize; - - bool _EnableShadowCasting; - - - v2f vert (appdata v) { v2f o; diff --git a/Shader/Water_2SP.shader b/Shader/Water_2SP.shader index ec2fda7..53bf98c 100644 --- a/Shader/Water_2SP.shader +++ b/Shader/Water_2SP.shader @@ -49,16 +49,12 @@ Shader "DeMuenu/World/Hoppou/WaterFlat_2SP" #pragma vertex vert #pragma fragment frag - #include "UnityCG.cginc" - #include "Includes/LightStrength.hlsl" - #include "Includes/Lambert.hlsl" - #include "Includes/DefaultSetup.hlsl" - #include "Includes/Variables.hlsl" - #include "Includes/Shadowcaster.cginc" - //Moonlight Defines #define MAX_LIGHTS 80 // >= maxPlayers in script //Moonlight Defines END + + #include "UnityCG.cginc" + #include "Includes/Moonlight.hlsl" struct appdata { @@ -95,35 +91,6 @@ Shader "DeMuenu/World/Hoppou/WaterFlat_2SP" float _NormalMapScrollSpeed2; float _MinTransparency; - - MoonlightGlobalVariables - - float4 _Udon_Plane_Origin_1; // xyz = origin (world), w unused - float4 _Udon_Plane_Uinv_1; // xyz = Udir / (2*halfWidth) - float4 _Udon_Plane_Vinv_1; // xyz = Vdir / (2*halfHeight) - float4 _Udon_Plane_Normal_1; // xyz = unit normal - - sampler2D _Udon_shadowCasterTex_1; - float4 _Udon_shadowCasterColor_1; - float4 _Udon_OutSideColor_1; - float _Udon_MinBrightnessShadow_1; - - float4 _Udon_Plane_Origin_2; - float4 _Udon_Plane_Uinv_2; - float4 _Udon_Plane_Vinv_2; - float4 _Udon_Plane_Normal_2; - - sampler2D _Udon_shadowCasterTex_2; - float4 _Udon_shadowCasterColor_2; - float4 _Udon_OutSideColor_2; - float _Udon_MinBrightnessShadow_2; - - float _BlurPixels; - float4 _Udon_shadowCasterTex_1_TexelSize; // xy = 1/width, 1/height - float4 _Udon_shadowCasterTex_2_TexelSize; - - bool _EnableShadowCasting; - //Watershader specific float _SpecPower, _SpecIntensity;