Calling UStaticMeshComponent::GetMaterial() during a Blueprint compile on load can cause the Material shader to fail to compile because GetMaterial will trigger a PostLoad call on that Material and cause it to be loaded in an order the Editor doesn't expect. Material Instances for that material that failed to compile will show the default world material in the viewport and in content browser thumbnails until the Material Instance is opened up or RECOMPILESHADERS CHANGED is run. If the the game is cooked before the materials are fixed they will show as the world grid material in game also.
if (Blueprint->SimpleConstructionScript) { for (USCS_Node* Node : Blueprint->SimpleConstructionScript->GetAllNodes()) { if (auto StaticMeshComponent = Cast<UStaticMeshComponent>(Node->ComponentTemplate)) { for(int i=0; i < StaticMeshComponent->GetNumMaterials(); ++i) { auto Material = StaticMeshComponent->GetMaterial(i); } } } }
Expected
Materials shaders compile correctly and Material Instances don't use the default world material
Actual
Some Material shaders will not compile correctly because UStaticMeshComponent::GetMaterial() will trigger a UMaterial::PostLoad() call and cause the Material to be loaded in an order the Editor does not expect. Material Instances for that material that failed to compile will show the default world material in the viewport and in the content browser thumbnail render until the Material Instance is opened up or RECOMPILESHADERS CHANGED is run.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-226715 in the post.
0 |
Component | UE - Rendering Architecture - Materials |
---|---|
Affects Versions | 5.4, 5.4.4 |
Created | Oct 4, 2024 |
---|---|
Resolved | Oct 7, 2024 |
Updated | Oct 21, 2024 |