- Home /
Can a Shader Animated Mesh Use GPU Instancing?
I am currently using a vertex shader for making grass on planes, but I am quickly running into an issue. It lags. A lot. My batches go up to 300+ with not much, and any kind of batching isn't helping, and neither is GPU instancing.
I usually get 15 FPS.
So, that brings me to my actual question. Can a mesh that is animated by a vertex shader use the GPU instancing?
I should probably also mention that my CPU is barely being utilized, but my R9 290X is maxed out.
Thanks.
Edit: Now it's 1300+ batches with no changes. Yay. Any help?
Can you check unity's frame debugger? IT provides information about why isn't batching working. Also, instancing works only if you are using the same mesh and the same material, the shader supports it and the material has it enabled
Answer by Pangamini · Oct 12, 2021 at 10:21 AM
Yes. Instancing happens before the vertex shader. You can then apply vertex animations (you do have to apply vertex transforms to move each instance's verts to its own location anyway). You can tessellate or do anything else you would. The problem with skinned mesh renderers is that skinning / mesh deformation is done in a separate pass, creating a deformed copy of the original mesh inside GPU.
Btw you could have a completely GPU made grass from the base / terrain mesh using tessellation, geometry shaders or compute shaders.
Your answer
Follow this Question
Related Questions
WebGL lags and throws shader errors in chrome only 1 Answer
GPU Instancing (Dynamic Batching) Not Working on Oculus Quest 2 (Android). Works fine in-editor. 0 Answers
Performance concerns about using too many materials in one scene 2 Answers
Dissable Batching in Shader 0 Answers
Unity 5.4 Gpu Instancing reduces amount of saved batches to zero 0 Answers