I need to create an asset post processor that takes 2 textures and modifies their mip maps. Problem is, both depend on each other. Smoothness texture is used to modify normal map and then normal map mips are used to modify the smoothness mips.
Creating new assets, using ScriptedImporter, is certainly an option, but not a very good one: doubles amount of normal/mask textures in the project, need to reassign textures for each material, possibly leaking useless assets to build etc
But asset post processors can operate on 1 texture at a time only, and doing so would involve circular dependencies anyway
So question is, is there any way to avoid ScriptedImporter in this case?
You could use OnPostprocessAllAssets and filter for your specific textures. But carefully design this code to early out as quickly as possible since the method is called for every import.
If I modify asset in PostProcessAllAssets that’s just gonna trigger reimport and and then an infinite loop
Not if you safeguard your modification. I mean you get the texture in a way that isn’t what you want, then you change it, so you should be able to check if you made that change. For instance perhaps the number of mip levels change, or the size of the textures, or something else. I bet you can even add a flag to the asset in some way, I believe we can add custom info to the .meta file.
Worst case, you could remember the time of last modification and if that was within a few seconds from current time, you ignore the second call.
My point was more that I get notice after re-import so any modifications I did to the texture are gone by then…
Well, maybe explain what you aim to do?
Perhaps you’re trying to do something that has a far simpler solution, such as a Photoshop action, or a runtime shader that works off of the original textures.