- Home /
Modify texture coordenates with a shader.
I have a TextureAtlas with 4x4 tiles managed by a shader. I need a margin to avoid the texture bleeding produced by mipmaps.
Does anyone know how to subtract an uv offset from the final tile region?
Shader "TileableAtlas 4x4" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" "IgnoreProjector" = "True"}
LOD 200
CGPROGRAM
#pragma exclude_renderers gles
#pragma debug
#pragma surface surf Lambert
#pragma vertex vert
#include "UnityCG.cginc"
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 color: Color; // Vertex color
};
struct appdata {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
void vert (inout appdata_full v) { }
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, (frac(IN.uv_MainTex) * 0.25f) + float2(IN.color.r,IN.color.g));
o.Albedo = c.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
offset.jpg
(21.9 kB)
Comment