Open RiederAlex opened 1 month ago
Thanks for the detailed bug report. The material editor always had problems with updating the preview when you use the visual shader feature and add modify the inputs (add or remove textures or other inputs). Probably also in some other cases. In such situations the only way to fix it, is to close the material document and reopen it again. I never had time to look into this further.
Anyway, this may be unrelated to the problem that you are seeing, but it may have happened to you when you assumed "it is completely broken".
Currently working with the MaterialEditor (both with Visual Shader Editor and file based) behaves inconsistent in terms of Saving/Transforming.
The behavior observed is the following when unsaved changes exist on a material:
Expected behavior: Saving does also update the preview or Saving does not update the thumbnail (= does not trigger a transform). In ezEngine.Release.23.12.0 saving did not trigger a transform, so this behavior was consistent.
I've took some time and investigated this issue (as initially though the Material Editor is completely broken).
Back in 0199cb8f4a a change was introduced:
This means that the
ezAssetTableWriter
(what is called after Save) now no longer reloads all assets, only the one that was actually changed. However, this now causes issues - as theezMaterialResource
is reloaded (viaezReloadResourceMsgToEngine
), but the shader & the shader permutations are not, resulting in this inconsistent state.Manually triggering a transform pre-save works, as this triggers a thumbnail creation on the engine process, which triggers a "ReloadAllResources" inside
ezEngineProcessDocumentContext::HandleMessage
.I did investigate solutions, but I failed to find a fix which seems good (= does not reload all resources, as by the original intend of that change). The main issue from my current understanding is that reloading a
ezMaterialResource
does not trigger any sort of reload for theezShaderResource
/ezShaderPermutationResource
.Generally speaking I've failed to find a way to reload all shader permutations for a specific shader via code - the only work-around I've spotted would be to do
ezShaderManager::PreloadSinglePermutation
or implementingPreloadPermutations
.