So I implemented a custom shadowpass into my surface shader, in order to get LOD Dithering working also on the shadows, when objects fade out. I noticed, that i have to add instancing modifications to the shadowpass too, or else it will break the gpu instancing. I added the #pragma multi_compile_instancing to the shadowpass, which solves this problem, but now, shadows on objects pop in kind of randomly-
Pass
{
Tags {"LightMode"="ShadowCaster"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing
#pragma multi_compile _ LOD_FADE_CROSSFADE
#include "UnityCG.cginc"
struct v2f {
V2F_SHADOW_CASTER;
};
v2f vert(appdata_full v)
{
v2f o;
o.pos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
return o;
}
float4 frag(v2f i) : SV_Target
{
#ifdef LOD_FADE_CROSSFADE
float2 vpos = i.pos.xy / i.pos.w * _ScreenParams.xy;
UnityApplyDitherCrossFade(vpos);
#endif
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
Did I miss out something?