michael-gh1 / Addons-And-Tools-For-Blender-miHoYo-Shaders

Blender Addons and Tools for streamlining the character model setup when using HoYoverse Shaders.
GNU General Public License v3.0
197 stars 11 forks source link

Unused Materials Cleaned Up When Reopening File #30

Closed michael-gh1 closed 1 year ago

michael-gh1 commented 1 year ago

Unused Materials Cleaned Up When Reopening File

This may have been reported before, but the steps to reproduce the issue were unknown to me (usually user is asked to run through the Setup Wizard process again), but this time I stumbled upon the steps to reproduce the issue myself! (thanks to kitty♡ on Discord for confirmation on the steps to reproduce)

Description

Blender cleans up unused materials (and probably other things) and this can result in missing materials that may have been imported by the Setup Wizard.

If you run the Setup Wizard partially, save the file and then reopen it, materials that were not being used are no longer there. This can result in errors when trying to run additional Setup Wizard steps.

Solution

Assign fake user to materials so that Blender does not clean up unused materials when reopening a file

Steps to Reproduce

  1. Run Set Up Character
  2. Run Set Up Materials
  3. Run Finish Setup
  4. Save Blender file
  5. Reopen Blender file
  6. Certain materials necessary for Set Up Outlines are now missing. They were cleaned up and removed by Blender.

The exact error happened when the Setup Wizard was trying to clone the outlines when setting up geometry nodes (outlines). This is because the shader's outlines material was missing due to it being cleaned up and removed.

michael-gh1 commented 1 year ago

There are additional materials that are created beyond just the ones that are imported (ex. Dress, Body Outlines, etc.).

This should be reviewed again so I'm reopening it.