Hy everyone! Im trying to write shader, which is making shadows on it look pixelated. First I made shader like this (code below), but it's pixelating shadows in screen space. Than I realized that I need to pass rounded uv world position to the _ShadowCoord, but I don't know how. Can anybody help me?
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o._ShadowCoord = ComputeScreenPos(o.vertex);
o.wPos = mul(unity_ObjectToWorld, v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
float2 shadow_screen = i._ShadowCoord.xy / i._ShadowCoord.w;
float map_dist = tex2D(_ShadowMapTexture, shadow_screen).r;
float shadow_dist = mul(unity_WorldToShadow[0], i.wPos);
if (shadow_dist>map_dist) return 0;
return col;
}