Runtime Mesh Component

So, 4.20 is adding 3 addition UV channels for the Procedural Mesh Component. 4.19 on the left and 4.20 on the right.

Hey everyone! I’ll have more of an update soon but for now I just wanted to open up a new discord server dedicated to the RMC. It’s far faster to get my attention that way and easier for me to respond as well as for people to be able to help each other.

ill be posting more information there first and more frequently.

PS there is a 4.19 and 4.20 update coming soon.

How can I get the runtime mesh section out of the runtime mesh component? Just like you do with static or procedural? I need to read vertices and triangles data in order to copy it into another mesh section. Thanks

Does this plugin allow me to work with a mesh that’s had morph targets applied to it? Collision doesn’t update when morph targets applied and I really need to be able to do something like that. Nothing I’ve done so far get the vertex data out of a mesh that accounts for morph targets.

Are you refering to this? Static Mesh Morph Targets in Unreal Engine | Unreal Engine 5.3 Documentation
I know there is morph target stuff with animation setups as well. But did not work with it.
At least with the material version: Vertex position changes with material does not affect collision as it is only rendering data. Don’t know whats the case with animation stuff.

If you realy need that with the RuntimeMesh, export your Mesh in its original and morphed states. Then write some logic that interpolates (not big of a deal, node/functions are already there) the mesh data (Vertex, normals. tangents (and colors if needed)) between the original and the morphed. **Destroy **the mesh section and **Create **it again (dunno if collision update is possible with UpdateMeshSection). This however can get quite expensive depending on the complexity of the mesh and number of meshes you need to update per frame. Maybe Destroy and Create only if the morph value (interpolation alpha) delta is to high, update in the meantime, depending on your collision accuracy need.

Yeah, that’s what I’m using. AFAIK, it’s not a material deformer, it’s working on the mesh directly.

I’ll explain what I’m doing, that might help. I have a project that we use for sciencey work that allows you to change the the shape of a person with 20+ morph targets. I can get loads of useful data, but ideally I’d like to be able to take measurements of the body shape after various morphs have been applied. Everything I’ve got to work so far just gets me the base mesh shape. I suspect that the new version of the skeletal mesh might help, but I’m not a very experienced programmer and got stuck when ComputeSkinnedPositions wanted me to stop rendering before reading data.

Your idea will work if I rebuild the morphs using RMC, so thanks for that. I was hoping this plugin had a portion for reading data from existing meshes, but it doesn’t seem that way.

I yet did not work with skeletal meshes. I gues that the visual transform of the skeletal mesh you see when playing is rendering only + updates of the collision volumes for physics, otherwise you would need to transform all meshdata for every skeletal mesh every frame on the CPU.

There is a function to retrieve the mesh data of a static mesh. I gues its called GetSectionFromStaticMesh or something like that.

Hey Everyone!

As of now, RMCv3.2 on GitHub fully supports UE4.17-4.20. After some more testing and documentation I’ll push that to the Marketplace to bring that version back up to date.

I’ve posted some additional information in the README in GitHub and also the first post in this thread, and will be updating the wiki documentation soon. I can use as many people testing it as possible and would love feedback on any issues you find as well as what platforms you’ve tested it on so I can see what platforms it’s known to work on!

There is a new Discord server for the RMC you can find here: Runtime Mesh Component I tend to post most things there first and try to respond pretty quickly to questions/suggestions/comments so feel free to drop in!

The RMC takes a substantial amount of time and effort to build and maintain. There’s many more things I’d like to do it with, and other related tools I’d like to build. As much as I like just working on it, the reality is there’s other things I can do with my time. To be able to justify the time commitment, I’m asking for support. Additionally I will be releasing an extended version of the RMC in the, hopefully, near future that just brings additional abilities, and useful tools to the RMC. The current ā€œcommunityā€ version will remain free, but the extended version will not be.

To find out more information on how to support the project, and on the upcoming extended RMC, see here!

Hey , thanks for the update.

There is an small code issue with the 2UV channel function in RuntimeMeshData.cpp


void FRuntimeMeshData::CreateMeshSectionFromComponents(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
    const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, TFunction<FColor(int32 Index)> ColorAccessor, int32 NumColors,
    const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision, EUpdateFrequency UpdateFrequency, ESectionUpdateFlags UpdateFlags,
    bool bUseHighPrecisionTangents, bool bUseHighPrecisionUVs, bool bWantsSecondUV)
{
    SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSectionFromComponents);

    FRuntimeMeshScopeLock Lock(SyncRoot);

    // Create the section
    auto NewSection = CreateOrResetSectionForBlueprint(SectionIndex, false, bUseHighPrecisionTangents, bUseHighPrecisionUVs, UpdateFrequency);
...


void FRuntimeMeshData::CreateMeshSectionFromComponents(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
    const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, TFunction<FColor(int32 Index)> ColorAccessor, int32 NumColors,
    const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision, EUpdateFrequency UpdateFrequency, ESectionUpdateFlags UpdateFlags,
    bool bUseHighPrecisionTangents, bool bUseHighPrecisionUVs, bool bWantsSecondUV)
{
    SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSectionFromComponents);

    FRuntimeMeshScopeLock Lock(SyncRoot);

    // Create the section
    auto NewSection = CreateOrResetSectionForBlueprint(SectionIndex, bWantsSecondUV, bUseHighPrecisionTangents, bUseHighPrecisionUVs, UpdateFrequency);
...

Can someone please explain the dual/tripple buffer thing? I gues it is for peformance improvements in some cases, but I can’t find any documation about it.

Has anyone been able to get the RMC working with materials and UVs? I posted my question to the Discord channel as well, but wanted to see if anyone here has any suggestions.

When using the RMC in place of PMC, the mesh is created and everything seems to work except it really seems to screw up the UV coords. Here’s an example:

This screenshot is my mesh using PMC. The material being used is an texture atlas and I’m setting the UVs dynamically.

Here is the same mesh but this time I’m using the RMC. All the data is exactly the same including the UVs and all other geometry data.

RMCmin.png

From the looks of this last image, it appears the UVs are all messed up. Does anyone have any ideas?

should work. Do you feed the correct UV channel? Code snipped would be good as well.

Try a basic material. Just a texture, nothing fancy.

I’m only using one UV channel. Setting it like so:



mesh->SetSectionMaterial(0, material);
mesh->CreateMeshSection(0, vertices, triangles, normals, UVs, vertexColors, tangents, true, EUpdateFrequency::Infrequent);    


Here’s the code I use for creating the PMC mesh with no issues:



mesh->SetMeshSectionCollisionEnabled(0, true);
 mesh->CreateMeshSection_LinearColor(0, vertices, triangles, normals, UVs, vertexColors, tangents, true);
 mesh->SetMaterial(0, material);


When building the RMC mesh, I have to change the vertexColor and tangent arrays since they use a different structure than the PMC



TArray<FColor> vertexColors vertexColors;
// instead of
TArray<FLinearColor> vertexColors;

TArray<FRuntimeMeshTangent> tangents;
// instead of
TArray<FProcMeshTangent> tangents;


I should note that when using the PMC I pass in an empty tangent array. I have tried that with RMC as well, but it makes no difference.

I’ll attempt a basic texture and see how that goes.

There’s clearly a shading issue with RMC on 4.20 right now. Comparison with ProceduralMeshComponent :

Try setting the material after CreateMeshSection().

I’m having the same issue. It looks like all vertex normal values are coming out positive (comparison shown with a default static cube):

Is it possible to use this with the 4.19 flex version of unreal? I’ve added the plugin to my project but having problems building.

Managed to build, but now when I try to copy a static mesh to runtime mesh I get ā€˜assertion failed’. It’s only happening with one mesh though, other meshes work fine. The mesh works fine with the procedural mesh component though…

Make sure all meshes you want to retrieve the mesh data from are CPU accessible. Open the static mesh in question and use the search bar to search for ā€œCPUā€.