在軟體使用插件時報錯,最后一句就是AttributeError:“ NoneType”物件沒有屬性“ inputs”原提示
追溯(最近一次通話):
執行中的檔案“ C:\ Users \ Administrator \ AppData \ Roaming \ Blender Foundation \ Blender \ 2.81 \ scripts \ addons \ DECALmachine \ operators \ bake.py”,行133
target_mask = bake_target_mask(bakescene,bakebasepath,target.name,'mask',bakeimg,bakemat,margin = 0,ray_distance = ray_distance)
檔案“ C:\ Users \ Administrator \ AppData \ Roaming \ Blender Foundation \ Blender \ 2.81 \ scripts \ addons \ DECALmachine \ utils \ bake.py”,行161,位于bake_target_mask中
tree.links.new(emit.outputs ['Emission'],output.inputs ['Surface'])
AttributeError:“ NoneType”物件沒有屬性“ inputs”
位置:<未知位置>:-1
這是原py檔案
# TODO: always bake combine masks?
class Bake(bpy.types.Operator):
bl_idname = "machin3.bake_decals"
bl_label = "MACHIN3: Bake Decals"
bl_description = "description"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if get_prefs().pil and context.mode == 'OBJECT':
dm = context.scene.DM
if any([dm.export_bake_color, dm.export_bake_normal, dm.export_bake_aocurvheight, dm.export_bake_masks]):
return [obj for obj in context.selected_objects if obj.type == 'MESH' and not obj.DM.isdecal and obj.data.uv_layers and not obj.DM.prebakepreviewmats and not obj.name == 'Combined']
def execute(self, context):
# only non decal mesh objects with decal children can be baked down to
targets = [obj for obj in context.selected_objects if obj.type == 'MESH' and not obj.DM.isdecal and obj.data.uv_layers and [child for child in obj.children if child.DM.isdecal] and not obj.DM.prebakepreviewmats and not obj.name == 'Combined']
if targets:
start = datetime.now()
templatepath = os.path.join(get_path(), "resources", "Templates.blend")
exportpath = os.path.join(get_path(), "assets", "Export")
bakespath = os.path.join(exportpath, "bakes")
blendname = os.path.basename(bpy.data.filepath)[:-6] if bpy.data.filepath else ''
bakebasepath = create_bakebasepath(bakespath, blendname)
# get the current cyclcles device
device = context.scene.cycles.device
dm = context.scene.DM
width = dm.export_bake_x
height = dm.export_bake_y
supersample = int(dm.export_bake_supersample)
samples = dm.export_bake_samples
# turn off prefs.edit.use_enter_edit_mode
init_prefs(context)
print("\nInfo: Starting to bake decals to %s, at %s with %s samples and %dx Anti Aliasing using the %s --------------------" % (", ".join([target.name for target in targets]), "x".join([str(width), str(height)]), samples, supersample, device))
if supersample:
width *= supersample
height *= supersample
margin = dm.export_bake_margin
ray_distance = dm.export_bake_distance
triangulate = dm.export_bake_triangulate
combine_bakes = dm.export_bake_combine_bakes and len(targets) > 1
preview_bakes = dm.export_bake_preview
open_bake_folder = dm.export_bake_open_folder
substance_naming = dm.export_bake_substance_naming
bake_color = dm.export_bake_color
bake_normal = dm.export_bake_normal
bake_aocurvheight = dm.export_bake_aocurvheight
bake_masks = dm.export_bake_masks
# first, remove any orphan decals, otherwise you may get problems linking decals to the bakescene, especially in local view with orphan decals(not backups)
remove_decal_orphans(debug=True)
# get the current(pre bakescene) view_layer
view_layer = context.view_layer
# get and set create scene
bakescene = append_scene(templatepath, "Bake")
# switch to the bakescene
context.window.scene = bakescene
# set the bakescene cycles device
bakescene.cycles.device = device
# set the samples
bakescene.cycles.samples = samples
# set tilesize according to render size, see https://devtalk.blender.org/t/why-is-texture-baking-so-mind-meltingly-slow/5653
# based on my tests, I can not see any speed improvement, in fact it's a few seconds slower, tested 256-2048
# if device == 'CPU':
# bpy.context.scene.render.tile_x = width
# bpy.context.scene.render.tile_y = height
# get baketypes
baketypes = []
if bake_color:
baketypes.append('COLOR')
if bake_normal:
baketypes.append('NORMAL')
if bake_aocurvheight:
baketypes.append('AO_CURV_HEIGHT')
if bake_masks:
baketypes.append('SUBSET')
# initialize bakes dict, which collects the main bakes per target
bakes = {}
for target in targets:
bakes[target] = {}
if baketypes:
# collect support bakes, so they can be removed at the end
support_bakes = []
for target in targets:
bpy.ops.object.select_all(action='DESELECT')
# create and prepare the active, its bake material and the bake image
active, bakeimg, bakemat = prepare_active(context, bakescene, target, width, height, triangulate)
# """
# bake the active's uv mask, with a margin of 0, which is used to create decal bakes with margin onlys outside the UVs
target_mask = bake_target_mask(bakescene, bakebasepath, target.name, 'mask', bakeimg, bakemat, margin=0, ray_distance=ray_distance)
if bake_masks:
bakes[target]['MASKS'] = [target_mask]
else:
support_bakes.append(target_mask)
# bake a combine mask, which is like the target mask, but with margins, and used to combine bakes of multiple targets into one map
if combine_bakes:
combine_mask = bake_target_mask(bakescene, bakebasepath, target.name, 'combine', bakeimg, bakemat, margin=margin, ray_distance=ray_distance)
bakes[target]['COMBINE'] = combine_mask
support_bakes.append(combine_mask)
normal_decals_mask = None
color_decals_mask = None
# """
for baketype in baketypes:
# print("\nInfo: Baking %s to %s from decals:" % (baketype, target.name))
# link and prepare the decals for this baketype
decals = prepare_decals(context, view_layer, bakescene, target, baketype, debug=False)
# """
if decals:
# bake decals uv masks (margin 0 and margin 3)
if baketype in ['NORMAL', 'AO_CURV_HEIGHT', 'SUBSET']:
if not normal_decals_mask:
normal_margin_0_mask = bake_decals_margin_mask(bakescene, bakebasepath, target.name, 'normal', bakeimg, decals, margin=0, ray_distance=ray_distance)
normal_margin_3_mask = bake_decals_margin_mask(bakescene, bakebasepath, target.name, 'normal', bakeimg, decals, margin=margin, ray_distance=ray_distance)
support_bakes.extend([normal_margin_0_mask, normal_margin_3_mask])
normal_decals_mask = create_decals_mask(bakebasepath, target.name, 'normal', target_mask, normal_margin_0_mask, normal_margin_3_mask)
if bake_masks:
bakes[target]['MASKS'].append(normal_decals_mask)
else:
support_bakes.append(normal_decals_mask)
if baketype in ['COLOR']:
if not color_decals_mask:
color_margin_0_mask = bake_decals_margin_mask(bakescene, bakebasepath, target.name, 'color', bakeimg, decals, margin=0, ray_distance=ray_distance)
color_margin_3_mask = bake_decals_margin_mask(bakescene, bakebasepath, target.name, 'color', bakeimg, decals, margin=margin, ray_distance=ray_distance)
support_bakes.extend([color_margin_0_mask, color_margin_3_mask])
color_decals_mask = create_decals_mask(bakebasepath, target.name, 'color', target_mask, color_margin_0_mask, color_margin_3_mask)
if bake_masks:
bakes[target]['MASKS'].append(color_decals_mask)
else:
support_bakes.append(color_decals_mask)
# with the decals mask(s) out of the way, bake the main map types
bake_map = bake(bakescene, bakebasepath, decals, target.name, baketype, bakeimg, marg
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/46711.html
