Correct way to setup vertex buffers in Scene Mesh Proxy?


I had some code for voxel rendering based of ProceduralMeshComponent when I moved to 4.19 it broke but I found someone else with the same issue (here). It worked when I disabled manual fetch but in the end I moved over to using the same setup as ProceduralMeshComponent.

However in FProceduralMeshSceneProxy’s constructor it uses the function FStaticMeshVertexBuffers::InitFromDynamicVertex which has the following comment above it:

This is a temporary function to refactor and convert old code, do not copy this as is and try to build your data as SoA from the beginning.

So I’m a bit concerned that what I have (and ProceduralMeshComponent also has) is just a temporary workaround. Is there a better way to layout and initialize my vertex buffers?

In the 4.19 release notes I saw:

We changed the Vertexbuffer layout from AoS to SoA because after this change we can bind the Input Attributes via SRV and load them in the shader directly (also from compute). Before this change it was very difficult and involved manual interpretation of the Raw Data in the Shader. We recommend everyone to follow this route and change their Vertexbuffers as we probably will deprecate mixed AoS Vertexbuffers in the Future.

Does this mean instead of using an array of FDynamicMeshVertex I should be storing each element instead in separate arrays, so arrays of positions, tangent, and color?

If that is correct doesn’t seem like a difficult change for me but I can’t see any example of this.