- Home /
Clarification on static batching a shader-animated mesh
I've read that objects set to static will be static batched, but you should not do this to any objects that will move, rotate, or scale as it is very inefficient.
However, if a meshes vertices are being animated by a shader does that count as moving? Or can it be safely marked as static in the scene?
Hi, I don't have an full answer but this information may help:
I think I read that the static flag is used to (pre)compute occlusion more efficiently so if the animation you do is moving vertices too much it may modify the occlusion the object provides and then cause visual glitches.
Also, with dynamic batching, I had problems with shaders that modify vertices positions and I guess it is the same with static batching. Batching merges objects together, this changes the local origin and then the local coordinates of all vertices (before being transformed to world position). It may become a problem if you are using this information in your shaders.
Hmm… that makes sense, thanks for the info.
I think if nobody knows the answer I will try testing it for myself to be sure.
Answer by Matt-Murch · Jun 10, 2020 at 11:41 AM
Yes, you can use vertex animated shaders on static objects! I ran some tests in editor and in builds, and it works.
Here is a demo form Double M Digital showing vertex animated and UV animated shaders on static geometry: DMD Shader animation on static objects demo