AtomTressFX: `.tfxhair` assets never load in a GameLauncher because `HairAssetHandler` is registered only by the Builders module (26.05 SDK)
Describe the bug
In the 26.05 prebuilt Windows SDK, the runtime AtomTressFX module does not register an asset handler for HairAsset (.tfxhair). The handler AZ::Render::Hair::HairAssetHandler (declared in Gems/AtomTressFX/Code/Assets/HairAsset.h, a GenericAssetHandler<HairAsset>) is created and registered only by HairBuilderComponent::Activate in AtomTressFX.Builders. HairSystemComponent::Activate in the runtime module registers the feature processor and pass creators, but no asset handler. A GameLauncher loads AtomTressFX.dll but not AtomTressFX.Builders.dll, so a HairComponent (AZ::Render::Hair::HairComponent, {9556883B-6F3C-4010-BB3F-EBB480515D68}) can never load its .tfxhair and waits forever.
Inspecting the shipped binaries: AtomTressFX.dll contains the HairAsset type reflection but no handler registration. AtomTressFX.Builders.dll contains HairAssetHandler. This matches the source: Hair_files.cmake puts HairAsset.cpp in AtomTressFX.Static, but the only code that instantiates and registers the handler is HairBuilderComponent (Hair_builders_files.cmake).
The Asset Processor side is fine. AtomTressFX.Builders.dll registers HairAssetBuilder, and .tfx/.tfxbone (with or without .tfxmesh) cook to a .tfxhair product. The gem's own sample, Gems/AtomTressFX/Assets/TestData/HeadBoneChainHairStyle/test_hair_bone_chain_head_style.tfx, cooks to a .tfxhair.
Assets required
The gem's own sample is enough: Gems/AtomTressFX/Assets/TestData/HeadBoneChainHairStyle/test_hair_bone_chain_head_style.tfx (and its .tfxbone), which the Asset Processor cooks to test_hair_bone_chain_head_style.tfxhair.
Steps to reproduce
- Install O3DE 26.05 from the prebuilt Windows SDK installer (no engine source).
- Create a C++ game project. Enable the
AtomTressFXgem inproject.json. - Let the Asset Processor cook the sample
test_hair_bone_chain_head_style.tfx. Confirm a.tfxhairproduct exists. - Give a runtime entity a
HairComponentwith theHairAssetfield set to that.tfxhair. (We add the component in code at spawn; see Additional context for why a prefab does not work either.) - Run the project's GameLauncher and spawn the entity.
Expected behavior
The launcher loads the .tfxhair, the HairComponent becomes ready, and the hair renders (or, for the sample on a different skeleton, reports missing bones).
Actual behavior
The asset is never loaded. The JSON deserializer reports for the HairAsset field that the asset is in the catalog but no handler exists for its type, and the gem logs the "not ready" warning on every attempt, forever.
Screenshots/Video Log lines (GameLauncher):
Asset Info was found in the Asset Catalog, but the Asset Type does not have an Asset Handler registered that could load the Asset.Hair Asset was not ready - second attempt will be made when readyFound in Branch
26.05 release, prebuilt Windows SDK installer (release tag 2605.0).
Commit ID from o3de/o3de Repository
Tag 2605.0 = 3db6943249d8bd7960b9ed7e9aee310b7668586e. At this commit:
Gems/AtomTressFX/Code/Components/HairSystemComponent.cpp:Activate()callsRegisterFeatureProcessor<HairFeatureProcessor>()andAddPassCreator(...)only. No asset handler.Gems/AtomTressFX/Code/Builders/HairBuilderComponent.cpp:Activate()callsm_hairAssetBuilder.RegisterBuilder(); m_hairAssetHandler.Register();.Gems/AtomTressFX/CMakeLists.txt:Gem::AtomTressFX.Clients/.Servers/.Unifiedalias onlyGem::AtomTressFX;Gem::AtomTressFX.ToolsaliasesGem::AtomTressFXplusGem::AtomTressFX.Builders. So only the Editor and Asset Processor ever load the module that registers the handler. The same code is ondevelopment.
Desktop/Device (please complete the following information):
- Device: PC
- OS: Windows
- Version: 11
- CPU: AMD
- GPU: AMD Radeon RX 9070 (DX12)
- Memory: n/a to this bug
Additional context
Workaround that works. Add Gem::AtomTressFX.Builders as a RUNTIME_DEPENDENCIES entry of the game's client module target (ly_add_target(... RUNTIME_DEPENDENCIES Gem::AtomTressFX.Builders)). The launcher then also loads AtomTressFX.Builders.dll, HairBuilderComponent registers the handler, and the sample hair loads in the launcher (it then only reports that its joint1..8 bones are not on our skeleton, as expected). This ships a builder module with a game, which is not what a shipped launcher should need.
Settings-registry-only approach did not work. Adding the Builders module under /O3DE/Gems/AtomTressFX/Targets in a project .setreg has no effect, because the launcher's generated cmake_dependencies.*.setreg is what lists the modules to load.
Proposed fix. Register HairAssetHandler from the runtime side, i.e. from HairSystemComponent (or a small runtime system component in the AtomTressFX target), so a launcher can load .tfxhair without the Builders module. Guard the registration so the Editor and Asset Processor, which load both modules, do not double-register (compare PR #5606, which fixed an earlier double registration in the builder component). The .tfxhair type and HairAsset.cpp are already in AtomTressFX.Static, so this is a registration move, not a new dependency.
Related, not the main bug. A prefab carrying a HairComponent in a GenericComponentWrapper is dropped when the Asset Processor cooks the prefab:
Prefab Serialization: Serialization information for target type {9556883B-6F3C-4010-BB3F-EBB480515D68} not foundThis happens because the Asset Processor does not load the runtime AtomTressFX module (only .Builders). We worked around it by adding the component in code at spawn (pre-insertion callback). This looks like the same root cause as #6204.
Minor, may be our malformed file. A hand-written .tfx that omits the per-strand UV array (offsetStrandUV = 0) and has only positions crashed the launcher (0xC0000005) inside the loader used by AtomTressFX.Builders (TressFXAsset::LoadHairData), whereas the sample loads. LoadCombinedHairData/LoadHairData seek and read from header offsets and counts without checking them against the stream size. Suggest the loader validate offsets and counts and return false instead of faulting. Happy to split this into a separate issue if preferred.
Source: o3de/o3de