Combining billboards is not fun

So, I have a vertex fragment shader that will billboard, but when I run my script to combine these meshes together, the entire combined mesh gets billboarded as one. Which makes sense, but how can I tell the shader to billboard each plane individually? I tried also a geometry shader, which will do so, but there are other problems with that way too.

Any ideas on how to individually billboard in vertex fragment shader?

How does unity grass shader billboard individually yet still batch/combine?

I am also attempting to copy TerrainEngine.cginc and the wavinggrassbillboard shader to new shadder file and cginc and cutting its ties to the actual terrain engine. No luck so far.

I think the Unity grass shader doesn’t do any billboarding, it’s done on the CPU each frame and a new mesh is uploaded. The particle system works like this too.

If you want to billboard in the shader you need to make sure the shader knows where the center of the billboard is. You could do that by storing the center position in additional UV channels, or I like to encode the relative offset to center. Basically I have all my billboards facing z and set the second UV channel to its position away from the center x and y (usually just -0.5 or 0.5 to keep it 1 unit across), then the center is as easy as float4(v.vertex.xy - v.uv2.xy, v.vertex.z, 1);

How do you store the center in UV channel?