+2

Billboard Flip

Kit 8 years ago updated by Tom Spratt 7 years ago 2

When used on a Unity quad, Billboard makes the quad face away from the camera. With a double-sided shader applied, the texture appears upside-down. I don't understand vector math, but it was easy to remove the Negatives from the matrix math in Vert, which makes it face camera and appear the correct way up. I imagine it would be easy to add UI toggle in shaderforge allowing us to flip the billboard, and have it set up this way by default.



Example - Arrow faces upwards in photoshop.




Image 693


From Left

1. texture on unity's particle alpha shader

2. texture on shaderforge double-sided alpha shader with no billboarding

3. same as #2 but with billboard enabled

4. shaderforge double sided alpha billboard, but changing the code as such:

bbmv._m00 = -1.0/length(unity_WorldToObject[0].xyz);

to

bbmv._m00 = 1.0/length(unity_WorldToObject[0].xyz);

and so on, making removing the - symbols

I haven't worked with billboards but I would try a "External Data -> Projection Params" node, and use its "Sign" output to flip the .y value of the UV. So, you'll need that projection params node, and you'll need a "Geometry Data -> UV Coordinates" node. Feed that UV node into the "UV" input of your Texture2D node. But before you feed it in, flip it's "y" value according to that projection params "sign". And after you've modified the y value of the UV node, then merge its x and y value back together using an Append node, so you can feed it into the UV input of your Texture2D. No idea if this will work, by the way. :P

Thanks for the solution in editing the code Kit, I wonder what the reason for this is if it hasn't been fixed yet. Can't think of why I'd want my Billboards to be upside down by default. Also this happens to Single Sided (Front or Back Face culling) shader variants too, not just Double Sided.