I need a configuration that allows me to have the different faces of a mesh (all mapped UV 0-1) act as billboards of their own, turning around their own centers rather than around the object’s pivot.
This is my current configuration which makes a single billboard out of the entire mesh.
I’ve tried modifying it in a million ways in an attempt to make it work as I want but I can’t figure out how to do it.
I can think of a possible way of doing this, but it involves the rather hacky technique of hi-jacking vertex attributes to pass custom per-vertex data to your shader, and you’d also have to deal with some relatively complicated maths.
Here’s the basic idea: every fragment needs to know where the center of its face is, because that’s the point that we want to rotate around. For this to be possible, each vertex needs to contain the world-space center-point of the face it belongs to. So you need to put this information into your mesh’s vertex attributes somehow. You have the choice between using the tangent or two uv attributes here. If you’re not planning on actually using the tangent for stuff like normal maps, that’s probably the way to go. Otherwise, go with two uv attributes.
Then, in your shader, you’d have to rotate each fragment around this point. To do this, you first have to calculate a rotation matrix that rotates your fragment around its face’s center point, using the difference between the view direction and the world-space vertex normal as the rotation amount. These vectors can be obtained using the view direction and normal vector nodes, respectively.
You could also choose to calculate the matrices outside of the shader, chop it up into vectors, put those into your vertex attributes, and then reassemble the matrix in your shader. This is probably more performant and possibly easier, since you can just use a quaternion to get the rotation matrix in this case and you won’t have to bother with the maths yourself. However, you’ll need to use up like five uv attributes to pass the matrix to your shader now.
Honestly though, you’re probably better off just splitting each face off into its own mesh, rotating the game objects towards your camera every Update/FixedUpdate loop and rendering them separately, unless there is a particular reason why you can’t do that.
// Edit: I dropped this yesterday in hurry, but I see now this not exactly what you need, Sinterklaas is right, you need to know rotation point for each quad first. I can add that you can use vertex color to store this information too.