Skip to content

AssetGenerator: restore static switch handling for UE 5.6 - #19

Open
UresiiZo wants to merge 1 commit into
satisfactorymodding:devfrom
UresiiZo:fix/restore-static-switch-5.6
Open

AssetGenerator: restore static switch handling for UE 5.6#19
UresiiZo wants to merge 1 commit into
satisfactorymodding:devfrom
UresiiZo:fix/restore-static-switch-5.6

Conversation

@UresiiZo

Copy link
Copy Markdown

Summary

Restores the static switch parameter handling in UMaterialInstanceGenerator that was disabled in "Fix deprecated usages for UE5.2" (7fb42af), updated for the UE 5.6 API.

Why it can come back in 5.6

UE 5.2 moved static switch parameters into FStaticParameterSetEditorOnlyData and deprecated the old field, which is why the code was commented out. In UE 5.6 they moved back into the runtime base struct — FStaticParameterSetRuntimeData::StaticSwitchParameters (see Engine/Source/Runtime/Engine/Public/StaticParameterSet.h; the editor-only copy is now StaticSwitchParameters_DEPRECATED). Static component masks are still editor-only data.

What was broken while it was commented out

  1. IsSimpleAssetUpToDate returned true without comparing static switches, so a MaterialInstance whose stored switch set diverged from the dump was never refreshed. Measured on a full Satisfactory 1.1 dump (18,544 packages): a MaterialInstanceConstant-whitelisted re-run with the comparison restored flagged and corrected 337 material instances with stale/missing switch data (e.g. MI_FactoryBaked_BF missing its bIsBuildEffect=true override).
  2. Missing switch parameters were never spawned into stub parent materials, so instance-level switch overrides referenced parameters that did not exist in the generated parent graph.

Changes

  • EnsureStaticSwitchNodesPresent: restored both loops using the 5.6 field locations (runtime StaticSwitchParameters, editor-only StaticComponentMaskParameters). Two additions over the pre-5.2 code:
    • Existing parameters are collected from GetAllParameterInfoOfType (cached expression data) as well as top-level expressions. Real materials keep switches inside material function calls, where a top-level scan cannot see them — without this the generator spawns duplicate parameters into non-stub parents.
    • The function now reports whether it modified the parent graph, and PopulateSimpleAssetWithData records the parent package in ModifiedParentPackages, saved via a GetAdditionalPackagesToSave override. The parent asset was already saved during its own generation pass, so without this the spawned nodes are silently lost (same failure class as AssetGenerator: save simple assets (MaterialInstance, MPC, PhysMat, DataAsset...) after data population - 5.6.1 regression #18).
  • IsSimpleAssetUpToDate: restored the comparison with two deliberate differences from the pre-5.2 operator== version:
    • ExpressionGUID is ignored. The dump GUID belongs to the original game material, while stub parents re-create parameter expressions with fresh GUIDs and UMaterialInstance::PostLoad (UpdateParameterSet) rewrites the instance-side GUIDs to match; comparing GUIDs would flag such assets "not up to date" on every run.
    • Non-overridden entries are skipped, because UpdateStaticPermutation trims them on apply.

Testing

  • Built against UE 5.6.1 (CSS engine build), FactoryEditor Win64 Development.
  • Targeted regeneration of MI_WallSetConcrete_8x4 / MI_Pillar_01 (dump switch overrides present): both judged up to date once their stored values match the dump — no churn on repeat runs.
  • Full MaterialInstanceConstant re-run: 337 instances refreshed once, converging to up-to-date afterwards; read-back via editor Python confirms the corrected instances resolve the dumped switch values (e.g. 19 switches on MI_Railings including CanBePainted=True).
  • Spawn path verified on stub parents (e.g. MM_Grass_Master gained its child's Emissive switch parameter and was re-saved through GetAdditionalPackagesToSave); parents whose cached data already exposes the switches (function-based parameters) are left untouched.

🤖 Generated with Claude Code

UE 5.2 moved static switch parameters into editor-only data and the
handling in UMaterialInstanceGenerator was commented out. UE 5.6 moved
them back to the runtime set (FStaticParameterSetRuntimeData), so the
node spawning and the up-to-date comparison can be restored:

- EnsureStaticSwitchNodesPresent: restored with 5.6 field locations;
  existing parameters are also collected from cached expression data so
  function-based parameters in real parents are not duplicated; modified
  parent packages are now saved via GetAdditionalPackagesToSave.
- IsSimpleAssetUpToDate: restored the static parameter comparison,
  ignoring ExpressionGUID (rewritten by PostLoad against stub parents)
  and non-overridden entries (trimmed by UpdateStaticPermutation).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant