6
\$\begingroup\$

What's the most efficient way to do billboarding sprites in Unity 5?

I want to make a forest of sprite trees in 3d space. Those sprites need to face the camera at all times. I am working on VERY performance restricted hardware - I need the game to run on mobile at 60+ FPS - the scripts have their overhead and moving/turnign trees cannot be static, so I cant use static batching for them.

The naive method of adding a script to each tree that makes it LookAt the camera each update is not good enough in terms of FPS.

I know the grass/details for terrain uses billboards, but it uses the sprite only as a silhouette for the grass and paints it with a flat colour.

\$\endgroup\$
6
\$\begingroup\$

Instead of using LookAt, you can have the shader force the object to be rendered facing the camera. Thus, no script needs to be added to the tree, and the extra work the shader does is very little. Here's an example: Billboard Shader

Also, since they don't actually move or rotate (as far as the CPU is concerned) and share the same material, you can turn on static batching.

I hope this helps!

\$\endgroup\$
  • \$\begingroup\$ Awesome! :D Will try it out ASAP. \$\endgroup\$ – K.L. Apr 16 '15 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.