Good evening, I am new to shader programming. I would like to simulate a circle shaded from black to white based on the distance of pixels from the center of the shader. How can I render the gradient effect? it results in pixelated image
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Light/Lanterna"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_Center("Center", Vector) = (0,0,0)
}
Subshader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform half4 _Color;
float3 _Center;
struct vertexInput
{
float4 vertex : POSITION;
};
struct vertexOutput
{
float4 pos : SV_POSITION;
float4 col0 : COLOR;
};
vertexOutput vert(vertexInput i)
{
vertexOutput o;
float s = length(i.vertex - _Center)*3;
if (s > 5)
{
o.col0 = float4(1, 1, 1, 1);
}
else
{
o.col0 = float4(0, 0, 0, 0);
}
o.pos = UnityObjectToClipPos(i.vertex);
return o;
}
half4 frag(vertexOutput u) : COLOR
{
u.col0 += smoothstep(0.5,1,u.pos.z);
return u.col0;
}
ENDCG
}
}
}