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.
Answer
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!
No comments:
Post a Comment