Is there a way to update InstancedStaticMesh positions with GPU?

Hi!

I have a compute shader that moves something like 10000-100000 (maybe more, depends on actual performance of the final implementation) “particles” (which are just a data in a structured buffer by now). I can render them into a texture and put on camera post process, so I know that everything works as intended up to that point.

Now I want to visualize them using InstancedStaticMesh. Rewriting them with c++ code on each frame will take too much time because of huge amount of them so I want to update an InstancedStaticMesh instance buffer with a shader instead.

I found the FStaticMeshInstanceBuffer structure in source code, however all the GPU resources in it are marked as private, so I only can access them by rebuilding the engine from source and changing acess modifiers on that structure.


Is there any easier way to acess these gpu buffers? Or maybe did someone already tried to update Instanced Mesh with GPU and have some plugin or workaround?

I will also appreciate an advice on any other way to visualize multiple similar meshes and controll their positions with a compute shader. Particle system maybe?

Hi there, I’m dealing with a similar problem.
Did you ever figure it out and care to share some insights?

Nope.
It’s probably possible by editing Instanced Static Mesh source code and making this buffers acessible and revritable from outside, but I haven’t finished my investigation about that

Found something interesting that might be of use to us.

I just started reading the code suggested there, but maybe this will give us a strong hint as to how to approach this.

A viable option is to write a custom component that functions similarly to HISM, but uses the compute shader to update transforms or properties.

Also interested in this. Fortunately in my case, I was instancing hundreds of thousands of quads for runtime procedural foliage growth. I was able to fake transform scale changes using per instance custom data and modifying UV scale.

This obviously wouldn’t work the same for meshes that aren’t planes, or transform position, however I’m playing with the idea of using world position offset to see if that could be a viable work around to again “fake” it.

Another idea I’m playing with is to apply translations with cpu, but only mark the renderer dirty once all instances have been modified. Doesn’t solve the broad issue of CPU->GPU->CPU, but could work for some cases.

Really cool approach for the foliage growth!

Marking only last for dirty doesn’t help (At least from what I have experienced).
If you have done what I tried (batch update transforms every tick) it won’t help you,
especially for this amount of instances.
I think the best answer would be to write a customized component based on hism and load transforms from a buffer filled by the compute shader.
Also, culling and LOD calculations are being done in the CPU side (On the render thread).
You could take this overhead off the cpu by writing a compute shader that will do these stuff on the GPU.