Closed simco50 closed 2 years ago
So the SectionInfoMap always contains material indices on LODs while they're not used on that primitive.
For example a mesh with 2 LODs with each their own material will have 3 entries in SectionInfoMap while the Static Mesh only has 1 Section for each LOD in the RenderData. This causes each Section of a LOD to always look at the first material index.
To confirm this, I forced the SectionIndex when setting up the LODs to 0 in HoudiniEngineUtils.cpp:7075
for ( int32 MaterialIndex = 0; MaterialIndex < StaticMesh->StaticMaterials.Num(); ++MaterialIndex )
{
FMeshSectionInfo Info = StaticMesh->GetSectionInfoMap().Get( LODLevelIndex, 0 ); // HACK: Force set to 0
Info.MaterialIndex = MaterialIndex;
Info.bEnableCollision = true;
Info.bCastShadow = true;
StaticMesh->GetSectionInfoMap().Set( LODLevelIndex, 0, Info ); // HACK: Force set to 0
}
Note that this ONLY happens when the LODs each have their own materials. If I give a single LOD primitive the material of another LOD, it works.
//HACK. Override the first primitive to make LOD materials work
if(@elemnum == 0)){
s@unreal_material = chs("../../lod0material");
}
This is obvious non ideal because it will be a separate draw call eventually but could be a work around for us if there is no other solution.
This seems like a bug to me but I can't seem to find the source of this issue and I think this is not the right solution. Any help would be appreciated.
FYI, this is the way we got around it and it seems to work well.
Hi,
I notice that setting a different "unreal_material" for each Static Mesh LOD as a primitive attribute does not seem to work. It does add it to the list of materials in the Static Mesh but it doesn't seem to apply the materials to the actual primitives and instead just picks the first material from the list. Is this a known problem?
I understand this plugin version is no longer maintained but because of compatibility reasons and possible risk we can not easily upgrade.
Thanks