I’m getting these weird edges on my sprites after trying to make a color swap shader. I’m not great with writing shaders, so that could be part of the issue. But, as you can see in the image, the edges are less than a pixel, if that makes any sense. I don’t see how they’re popping up.
Here is the shader I’m using.
Shader "Hidden/GuyColorShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_RampTex("RampTex", 2D) = "white"{}
}
SubShader
{
Tags {"Queue" = "Transparent+1" "RenderType" = "Opaque"}
// No culling or depth
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _RampTex;
sampler2D _MainTex;
fixed4 frag (v2f i) : SV_Target
{
fixed4 hold = tex2D(_MainTex, i.uv);
fixed4 col = tex2D(_RampTex,float2(hold.r,.5));
col.a = hold.a;
return col;
}
ENDCG
}
}
}
I’ve tried changing the queue and render type, but no matter what, I’m getting those strange edges. The edges are definitely getting their colors from the gradient image I’m passing in, it’s almost like the pictures are being blurred a little, but I have the import settings set to no compression.
Thank you for your time.
edit:
Also, the edge’s ratio of edge size to pixel size gets worse the further the camera is zoomed out. But, if the camera’s zoom/orthographic size is set to .54, and the player’s position is at a whole number, then the edges are gone.