Hello there.
So im trying to write custom depth for the object with my shader (i want to turn a quad, into a circle), but it doesnt seem to do absolutely anything.
Heres my current shader:
Shader "Custom/My Metaball" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff("CUTOFF", Range(0,1)) = 0.1
}
SubShader {
Pass{
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _Cutoff;
struct v2f
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
};
struct fragOut
{
half4 color : COLOR;
float depth : DEPTH;
};
v2f vert(appdata_base v)
{
v2f o;
o.position = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
fragOut frag(v2f i) : COLOR {
fragOut o;
fixed4 col = tex2D(_MainTex, i.uv);
o.color = col;
o.depth = 0;
return o;
}
ENDCG
}
}
//Fallback "Diffuse"
}
Im setting the depth to 0 just for test purposes.
If i uncomment the fallback, then it does standard depth writing, but with commented fallback - no depth output. Am i doing something wrong? Is it not possible at all? Ive seen some folk do this on forums.