Hello, im trying to make a billboard shader with alpha blending but i don’t know a single line of this : p
The blending was really easy using shader lab syntax to get working and i found a billboard shader on the internet but the problem is it only works when i have one on the screen at a time. As soon as i add another one both turn invisible. Also i wonder how its possible to change the scale of the billboard and if its possible to optimize it further.
Here is the code:
Shader "Alpha Billboard"
{
Properties
{
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest Greater .01
Cull Off
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _TintColor;
struct appdata_t
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
+ float4(v.vertex.x, v.vertex.y, 0.0, 0.0));
o.color = v.color;
o.texcoord = float4(v.vertex.x + 0.5, v.vertex.y + 0.5, 0.0, 0.0);
return o;
}
fixed4 frag (v2f i) : COLOR
{
return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
}
ENDCG
}
}
}
}