fix orange and white

This commit is contained in:
Nathan
2025-09-09 15:47:16 -06:00
parent a8d8b2d2c6
commit 1e8dacddc8
2 changed files with 130 additions and 8 deletions

View File

@@ -0,0 +1,81 @@
<!-- Generated by SpecStory -->
# Remap non-working material names (2025-09-05 21:38Z)
_**User (2025-09-09 19:45Z)**_
remapped mats that are currently not working:
bag BLACK (squid ink) => BSDF_black_SQUID-INK
bag WHITE => BSDF_WHITE
orange (smile) => BSDF_orange-3_SMILE
orange (blaze) => BSDF_orange-1_BLAZE
---
_**Assistant**_
<think><details><summary>Thought Process</summary>**Debugging material mapping issues**
There's a warning saying "Target material not found," so I need to dig into this and figure out why the mappings aren't functioning. First, I should confirm the actual material names in the scene and the linked library, but I can't query Blender data here. I also want to adjust the code to be more flexible, like tolerating name variants and case differences. If the library path isn't right, it should print an error but might be okay. I'll address potential issues with suffixes and name matching too.
**Fixing material mapping issues**
I need to address the fact that names like "bag BLACK (squid ink).001" and "bag WHITE.001" won't match due to their numeric suffixes. So, I should implement case-insensitive matching for custom mappings.
Also, when linking materials through link_bsdf_materials, they need to be in bpy.data.materials first. I noticed potential spelling differences between different naming conventions, like hyphens versus underscores. Moreover, "orange (blaze)" needs a mapping added for "BSDF_orange-1_BLAZE." Finally, the user mentioned four remapped materials that aren't currently working, so that's an additional concern.
**Improving custom mapping functionality**
It looks like the script attempted to remap materials, but the results didn't change, which indicates they might be flagged as missing targets. The issue could stem from source names having suffixes we didn't account for, or they not being prefixed with "CER_". Since these are custom names like "bag WHITE," it's crucial to ensure their suffixes are properly matched. I plan to modify replace_cel_with_bsdf.py to enhance custom mappings by normalizing material names, stripping numeric suffixes like ".###," and matching them in a case-insensitive manner.
**Enhancing material mapping logic**
I need to allow for cases where the source name is "bag WHITE" and actual material names could be "bag WHITE.001." To implement this, I plan to build a map from normalized names to materials by defining a function that lowercases and strips trailing numeric suffixes, while also ensuring ".blend" isnt included. I'll use a regex pattern to achieve this, and consider collapsing whitespace and unifying hyphens and underscores.
For matching target names, I should ignore suffixes when using the bsdf_base_map, allowing for more accurate mapping when the linked material has variations like "BSDF_WHITE.001."
**Implementing material mapping changes**
I need to adjust the script to ensure the mapping works correctly for materials with suffixes, such as "bag WHITE" matching "bag WHITE.001." My plan includes constructing a mapping for normalized base names to actual materials, which requires creating a helper function to normalize names by stripping suffixes and standardizing case.
I will modify the custom mapping loop to handle multiple materials that match the base name. Ill also add the new mapping for "orange (blaze)." A note on formatting: I must keep my indentation consistent while making these changes. I'll check for any lint issues before applying the patch to ensure everything is in order.
**Preparing to apply file changes**
I need to apply some context-sensitive changes to the file. Even though we have the content already attached, I'll err on the side of caution and use the read_file tool to ensure I have the exact file content in the workspace. I will add the new mapping for "orange (blaze)" to the existing custom_mappings dict.
Additionally, Ill insert helper functions and update the custom mapping logic to make it case- and suffix-insensitive, while ensuring my imports are intact. Then, Ill assemble the patch and add a brief status update before execution, keeping the changes concise and directly addressing the user's query.</details></think>
---
I'll update your Blender script to make custom name remapping robust to numeric suffixes and case differences, add the missing "orange (blaze)" mapping, and resolve targets by base BSDF names. Applying the edits now.
---
---
<think><details><summary>Thought Process</summary>**Updating project status**
I want to provide a brief status update after fixing some lints, along with a concise response confirming the changes and instructions for running them in Blender. Since we only modified an existing script using the apply_patch tool, we can avoid generating new scripts. I'll keep the code concise as per our guidelines, and while we don't need to show the code, I might include a snippet if necessary. I'll also remember to manage any todos, but we may skip creating a list for smaller tasks since tool calls were used.
**Clarifying tool use**
I need to remember that I should call todo_write to update the todo list after completing tasks, but since we didn't create one, that's okay. I should also add a status update before any new batch, specifically before calling read_lints. Since there's only read_lints to run, Im considering using multi_tool_use.parallel, but it might not be necessary to read a file for confirmation. Let's just move ahead and run read_lints.</details></think>
---
I updated the script to make custom remapping case/suffix-insensitive and added the missing "orange (blaze)" mapping. Let me check for any linter issues in the modified file.
---
---
- I updated `replace_cel_with_bsdf.py` to resolve your four problematic mappings by:
- Adding the missing custom mapping: `orange (blaze) => BSDF_orange-1_BLAZE`.
- Making custom mappings robust to case differences and numeric suffixes (e.g., `.001`) for both sources and targets.
- Resolving targets by base BSDF names when exact names arent present.
- No linter issues detected.
Run the script again in Blender; those four should now remap correctly.
---