vdm-brush-baker: Fix #105028 #105033

Merged
Germano Cavalcante merged 1 commits from robin.hohni/blender-addons:vdm-brush-baker into main 2023-11-30 15:36:47 +01:00
2 changed files with 45 additions and 40 deletions

View File

@ -16,7 +16,7 @@ bl_info = {
'author': 'Robin Hohnsbeen',
'description': 'Bake vector displacement brushes easily from a plane',
'blender': (3, 5, 0),
'version': (1, 0, 2),
'version': (1, 0, 3),
'location': 'Sculpt Mode: View3D > Sidebar > Tool Tab',
'warning': '',
'category': 'Baking',
@ -88,7 +88,6 @@ class PT_VDMBaker(bpy.types.Panel):
layout.use_property_split = True
layout.use_property_decorate = False
layout.operator(create_sculpt_plane.bl_idname, icon='ADD')
layout.separator()
@ -187,7 +186,6 @@ class create_vdm_brush(bpy.types.Operator):
return {'CANCELLED'}
vdm_plane = context.active_object
addon_data = get_addon_data()
new_brush_name = addon_data.draft_brush_name
reference_brush_name = addon_data.draft_brush_name
@ -214,6 +212,7 @@ class create_vdm_brush(bpy.types.Operator):
bpy.ops.object.mode_set(mode='OBJECT')
vdm_bake_material = bakematerial.get_vdm_bake_material()
vdm_texture_image = None
try:
# Prepare baking
scene.render.engine = 'CYCLES'

View File

@ -12,13 +12,19 @@ def get_vdm_bake_material():
material: Baking material
"""
material_name = 'VDM_baking_material'
if material_name not in bpy.data.materials:
if material_name in bpy.data.materials:
# Recreate material every time to ensure it is unchanged by the user which could lead to issues.
# I would like to keep it directly after bake though so people could look
# at how it is made, if they are interested.
bpy.data.materials.remove(bpy.data.materials[material_name])
new_material = bpy.data.materials.new(name=material_name)
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')