Description

When a Material Instance is loaded that has a nullptr layer in StaticParametrs.Materiallayers.  The Material Instance will create it's own CachedExpressionData but the ConnectedParameterMask will be 0 and Nanite material logic that calls functions like HasVertexPositionOffsetConnected will return false.

You can look for material instances with nullptr Material Layers by looking at materials in the [Link Removed] which can be opened from Asset Editor > Tools > Audit > Material Analyzer.  If a nullptr Material Layer is found you will see the "None 000000000000000000" in the Material Layer Parameters column.

One workaround is to remove the nullptr material layers by adding code in UMaterialInstance::Serialize() and then load and re-save the affected materials.

	Super::Serialize(Ar);

#if WITH_EDITOR

// Remove layers if only a nullptr layer is serialized
if (Ar.IsLoading() && !StaticParametersRuntime.MaterialLayers.Layers.IsEmpty() && StaticParametersRuntime.MaterialLayers.Layers[0] == nullptr)
{
    StaticParametersRuntime.MaterialLayers.Empty();
    StaticParametersRuntime.bHasMaterialLayers = false;
}
Steps to Reproduce

These repro steps are unconfirmed - the Material Instance test asset with the nullptr material layer was created in an older version of the engine so this is a guess of how it was created.

  1. Create a Material a Masked blend type
  2. Connect a texture sampler to the opacity mask and assign a constant value to WPO
  3. Add a material function layer to the material 
  4. Create a Material Instance and a Material Layer and assign it in the Material Instance layer parameters
  5. Delete the material function layer from the base Material

Expected

The unused material layer in the material instance doesn't cause the WPO and opacity mask to break.  The material layer can be removed from the Material Instance.

Actual

The opacity mask and WPO will not work, and the opacity mask texture won't even be bound and the Material Layer cannot be removed in the Material Editor UI.

 

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-229356 in the post.

0
Login to Vote

Backlogged
ComponentUE - Rendering Architecture - Materials
Affects Versions5.55.4.4
Target Fix5.7
CreatedOct 31, 2024
UpdatedNov 20, 2024
View Jira Issue