Transparent shader disappears with multiple objects

I’m trying to write a transparent billboard shader that mimics a plane always aiming at the camera. The shader works on one object, but when two objects with the same shader are both in view they disappear at most angles.

VertexOutput vert(VertexInput i)
	VertexOutput o;

	float3 center = mul(_Object2World, float4(0,0,0,1));

	float3 eye = _WorldSpaceCameraPos - center;
	float3 right = normalize(cross(eye, float3(0, 1, 0)));
	float3 up = normalize(cross(right, eye));

	o.pos = float4(center, 1);
	o.pos += i.pos.x + float4(right, 0);
	o.pos += i.pos.y + float4(up, 0);
	o.pos = mul(UNITY_MATRIX_VP, o.pos);

	o.col = i.col;
	o.tex = i.tex;

	return o;

After trying to debug for a while I think the part that’s causing this issue is the part that updates the world position with the right and up vectors:

o.pos += i.pos.x + float4(right, 0);
o.pos += i.pos.y + float4(up, 0);

I would appreciate any help with this.

Hey did you find an answer? If so, I would appreciate if you can explain. I have exactly the same problem with billboard shader on transparent textures. Although I am not sure if it is related to their being transparent or not. My shader doesn’t work if I use the same material for multiple objects with the same texture.

Any help greatly appreciated.

You might be running into issues due to “Dynamic Batching” being enabled (which is the default). Try disabling it. Unity - Manual: ShaderLab: assigning tags to a SubShader

Shader "ExampleShader" {
    SubShader {
        Tags { "DisableBatching" = "false" }
        Pass {