Hey, I’m new to working with shaders in Unity. I’ve been using the built-in transparent shader, but since I needed to render both sides of the object, I created my own custom shader. I’m facing an issue where the shader images start dissolving or fading out when the camera moves a bit farther away from the object. Does anyone know how I can fix this? I’ve included the code and images below for reference.
Shader "Net"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" { }
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 50
Cull Off // Disable backface culling
Pass
{
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" }
ZWrite On // Enable depth writing
Blend SrcAlpha OneMinusSrcAlpha // Set blending mode to Transparent
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;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
return col;
}
ENDCG
}
}
}