Can't render and create VDM texture blender error #105028

Closed
opened 2023-11-26 02:49:25 +01:00 by Liany · 5 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: Intel(R) HD Graphics 520 Intel 4.6.0 - Build 31.0.101.2111

Blender Version
Broken: version: 4.0.1, branch: blender-v4.0-release, commit date: 2023-11-16 16:40, hash: d0dd92834a08
Worked: (newest version of Blender that worked as expected)

Addon Information
Name: VDM Brush Baker (1, 0, 2)
Author: Robin Hohnsbeen

Short description of error
I made my VDM texture, but an error screen appears when I click the "Render and Create VDM Brush" button, making it impossible for me to finish and be able to use my texture.

Python: Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\scripts\addons\vdm_brush_baker_init_.py", line 300, in execute
vdm_texture.image = vdm_texture_image
UnboundLocalError: local variable 'vdm_texture_image' referenced before assignment

imagem_2023-11-25_224847395.png
imagem_2023-11-25_224916926.png

Exact steps for others to reproduce the error

  • Open a default blend file
  • delete all objects
  • In the Sidebar (N) > Tool > VDM Brush Baker, Create Sculpting Plane
  • Press Render and Create VDM Brush a temporary new material is created
  • Go to the Shading Workspace and remove all nodes from that temporary material
  • Back to Layout or Sculpt Mode and try to Create a VDM Brush again

Python error

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: Intel(R) HD Graphics 520 Intel 4.6.0 - Build 31.0.101.2111 **Blender Version** Broken: version: 4.0.1, branch: blender-v4.0-release, commit date: 2023-11-16 16:40, hash: `d0dd92834a08` Worked: (newest version of Blender that worked as expected) **Addon Information** Name: VDM Brush Baker (1, 0, 2) Author: Robin Hohnsbeen **Short description of error** I made my VDM texture, but an error screen appears when I click the "Render and Create VDM Brush" button, making it impossible for me to finish and be able to use my texture. ``` Python: Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\scripts\addons\vdm_brush_baker_init_.py", line 300, in execute vdm_texture.image = vdm_texture_image UnboundLocalError: local variable 'vdm_texture_image' referenced before assignment ``` ![imagem_2023-11-25_224847395.png](attachments/139cfba2-deb1-4098-a061-5aff983c7388) ![imagem_2023-11-25_224916926.png](attachments/faa44f12-4803-44e1-a45d-ec5cadb1c1bb) **Exact steps for others to reproduce the error** - Open a default blend file - delete all objects - In the Sidebar (N) > Tool > VDM Brush Baker, Create Sculpting Plane - Press `Render and Create VDM Brush` a temporary new material is created - Go to the Shading Workspace and remove all nodes from that temporary material - Back to Layout or Sculpt Mode and try to Create a VDM Brush again Python error
Liany added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-11-26 02:49:26 +01:00
Liany changed title from Can't render and create VDM blender error to Can't render and create VDM texture blender error 2023-11-26 02:51:22 +01:00

Related to the following issues as well:
#104847
#104853

I am not able to reproduce the problem locally.

Related to the following issues as well: https://projects.blender.org/blender/blender-addons/issues/104847 https://projects.blender.org/blender/blender-addons/issues/104853 I am not able to reproduce the problem locally.

Thank you for reporting this issue, @Liany.

I have found the steps to reproduce the bug and have edited the description in the report to include these steps.
The steps might need to be simplified, but for now, I can confirm the issue.

@robin.hohni ^

Thank you for reporting this issue, @Liany. I have found the steps to reproduce the bug and have edited the description in the report to include these steps. The steps might need to be simplified, but for now, I can confirm the issue. @robin.hohni ^
Germano Cavalcante added
Status
Confirmed
Module
Add-ons (Community)
and removed
Status
Needs Triage
labels 2023-11-30 01:50:20 +01:00
Member

Note that an error also occurs if the translation of data is enabled and the material couldn’t be created properly. From the screenshots, it looks like a Portuguese translation is being used.

For this specific case, this would fix the temp material creation:

diff --git a/vdm_brush_baker/bakematerial.py b/vdm_brush_baker/bakematerial.py
index 4e7b7e5b6..7ccd7e417 100644
--- a/vdm_brush_baker/bakematerial.py
+++ b/vdm_brush_baker/bakematerial.py
@@ -17,8 +17,11 @@ def get_vdm_bake_material():
 
         new_material.use_nodes = True
         nodes = new_material.node_tree.nodes
-        nodes.remove(nodes['Principled BSDF'])
-        material_output = nodes['Material Output']
+        principled_node = next(n for n in new_material.node_tree.nodes
+                               if n.type == "BSDF_PRINCIPLED")
+        nodes.remove(principled_node)
+        material_output = next(n for n in new_material.node_tree.nodes
+                               if n.type == "OUTPUT_MATERIAL")
 
         # Create relevant nodes
         combine_node = nodes.new('ShaderNodeCombineXYZ')
Note that an error also occurs if the translation of data is enabled and the material couldn’t be created properly. From the screenshots, it looks like a Portuguese translation is being used. For this specific case, this would fix the temp material creation: ```diff diff --git a/vdm_brush_baker/bakematerial.py b/vdm_brush_baker/bakematerial.py index 4e7b7e5b6..7ccd7e417 100644 --- a/vdm_brush_baker/bakematerial.py +++ b/vdm_brush_baker/bakematerial.py @@ -17,8 +17,11 @@ def get_vdm_bake_material(): new_material.use_nodes = True nodes = new_material.node_tree.nodes - nodes.remove(nodes['Principled BSDF']) - material_output = nodes['Material Output'] + principled_node = next(n for n in new_material.node_tree.nodes + if n.type == "BSDF_PRINCIPLED") + nodes.remove(principled_node) + material_output = next(n for n in new_material.node_tree.nodes + if n.type == "OUTPUT_MATERIAL") # Create relevant nodes combine_node = nodes.new('ShaderNodeCombineXYZ') ```
Contributor

Thanks for the report! I will look into it.

@pioverfour Very good points thanks! I didn't think other languages could create any problems.

The addon needs the nodes inside the material so they shouldn't be touched. :D I left it in the file since I didn't want to recreate it every time a user creates a new brush. And the material can't be locked. So one solution would be to just recreate it once used.

Thanks for the report! I will look into it. @pioverfour Very good points thanks! I didn't think other languages could create any problems. The addon needs the nodes inside the material so they shouldn't be touched. :D I left it in the file since I didn't want to recreate it every time a user creates a new brush. And the material can't be locked. So one solution would be to just recreate it once used.
Contributor

Made a PR. Hopefully, I configured everything correctly. Somehow it lists all commits of my branch but the changelog seems to be correct. Anyway, I addressed the issues mentioned here. :)

Made a PR. Hopefully, I configured everything correctly. Somehow it lists all commits of my branch but the changelog seems to be correct. Anyway, I addressed the issues mentioned here. :)
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-11-30 15:36:49 +01:00
Brecht Van Lommel added
Type
Bug
and removed
Type
Report
labels 2023-12-11 16:02:15 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105028
No description provided.