Hi,
I’m trying to reduce drawcalls in my game, a lot of our models use multiple materials with exactly the same tile scale and offsets and shaders, it’s just the texture that changes. This has ended up using a lot of draw calls that I think we could avoid so I’ve written a shader that uses vertex color (applied per face) to offset and repeat UVs within a small part of a larger tile atlas.
e.g. a vertex with RGBA (0.5, 0.5, 0.5, 0.5) would always wrap the UVs into the bottom right quarter of the texture.
The issue I have is 1 pixel lines at the edge of each tile
I’m fairly confident its not a mipmapping issue as when setting the RGBA values I add a 5% border around each tile, also the lines are never more than 1 pixel even when zoomed right in so I think its more likely to be a shader issue.
Here’s my shader
Shader "Custom/VertColorTileSS" {
Properties {
_Color ("_Color", Color) = (1, 1, 1, 1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
float2 uv = frac(IN.uv_MainTex) * IN.color.ba + IN.color.rg;
half4 c = tex2D (_MainTex, uv);
o.Albedo = c.rgb * _Color.rgb;
}
ENDCG
}
FallBack "Diffuse"
}