Static mesh merging requires rhi

Hi,

In our production pipeline, we are considering to merge actors in order to reduce the actor count as recommended in world building guide.

While the merge actor tool works fine in editor, reproducing the behavior in a commandlet operation started with nullrhi fails.

I narrowed it down to the MeshMergeHelpers.cpp code which checks resource “validity” :

// Make sure the resource actual exists, otherwise use default material

StoredMaterial = (StoredMaterial != nullptr) && StoredMaterial->GetMaterialResource (GMaxRHIFeatureLevel) ? StoredMaterial : DefaultMaterial;

What is the reason behind this extra check ?

Commenting out the extra check as below leads to correct behavior :

// Make sure the resource actual exists, otherwise use default material

StoredMaterial = (StoredMaterial != nullptr) /* && StoredMaterial->GetMaterialResource (GMaxRHIFeatureLevel)*/ ? StoredMaterial : DefaultMaterial;

Is there any way to force the resource creation upfront in a nullrhi environment ?

Thanks,

Basile

[Attachment Removed]

Steps to Reproduce
In order to reproduce the issue, you need a level with one or more static mesh actors that you want to merge.

[Attachment Removed]

Hello!

This seems to be related to the fact the material might be baked which requires a full rendering context. I recommend running the commandlet with `-AllowCommandletRendering` to avoid further issues. It should still work without a dedicated GPU. In this case, add -AllowSoftwareRendering which will consider the WARP adapter instead of using the more basic “Microsoft Basic Render Driver”

Regards,

Martin

[Attachment Removed]

Hi Martin,

It seems this may not be enough or that -nullrhi is stronger than the parameter you are suggesting.

Here is how our command line is built:

UnrealEditor-Cmd xxx -DDC-ForceMemoryCache -nullrhi -UNATTENDED -trace=default,task -AllowCommandletRendering -tracefile=K:/Temp/traceexport/xxx.trace

We are using nullrhi to minimize resources usage and prevent editor display which is not required.

Am I missing something or misusing the scripting capabilities ?

Thanks,

Basile

[Attachment Removed]

Hi,

It appears you are not using a commandlet as the command line is missing the -run=XXX argument. In that case, you are starting the whole editor and AllowCommandletRendering won’t be useful. You can use -RenderOffscreen so the editor runs in headless mode (without -nullrhi).

I’m guessing a proper rendering context is required for GetMaterialResource return a valid material.

Martin

[Attachment Removed]

Hi Martin,

This seems to be indeed enough to get the merging done without the editor being fully displayed.

Still, would you happen to know why the rendering is even needed for this ? As I mentioned, bypassing that part of the test was leading to accurate results on my attempts. Is there any corner cases that could failed or is it (unnecessary) extra validation that could be removed as optimization.

Thanks,

Basile

[Attachment Removed]

Hi,

This code is part of a system that can bake textures for the merge mesh and the material is required in this case.

Martin

[Attachment Removed]