添加线稿渲染功能,用于生成 ControlNet Canny 所需的黑白线稿图。实现通过 Freestyle 渲染引擎,在白色背景上生成黑色线条,并临时替换材质与世界设置以确保输出符合要求。同时更新了清理函数以移除新增的临时白色材质。
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
bl_info = {
|
|
"name" : "ComfyProjector",
|
|
"author" : "小煜のChannel",
|
|
"description" : "Projector for ComfyUI",
|
|
"blender" : (5, 0, 0),
|
|
"version" : (1, 0, 0),
|
|
"location" : "",
|
|
"warning" : "",
|
|
"doc_url": "",
|
|
"tracker_url": "",
|
|
"category" : "3D View"
|
|
}
|
|
|
|
import bpy # noqa: E402
|
|
from .utils import classes, cleanup_preview_collections # noqa: E402
|
|
from .utils import Comfy_RenderedImageItem # noqa: E402
|
|
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
bpy.types.Scene.sna_activeobject = bpy.props.PointerProperty(type=bpy.types.Object)
|
|
bpy.types.Scene.sna_bakecam = bpy.props.PointerProperty(type=bpy.types.Object)
|
|
bpy.types.Scene.sna_activeobject_name = bpy.props.StringProperty()
|
|
bpy.types.Scene.sna_render_resolution = bpy.props.EnumProperty(
|
|
name="Render Resolution",
|
|
description="Resolution for depth and normal map renders",
|
|
items=[
|
|
('1024', '1024 x 1024', ''),
|
|
('2048', '2048 x 2048', ''),
|
|
],
|
|
default='1024',
|
|
)
|
|
bpy.types.Scene.sna_rendered_images = bpy.props.CollectionProperty(
|
|
type=Comfy_RenderedImageItem,
|
|
)
|
|
bpy.types.Scene.sna_rendered_images_index = bpy.props.IntProperty(
|
|
name="Active Rendered Image Index",
|
|
default=0,
|
|
)
|
|
|
|
|
|
def unregister():
|
|
cleanup_preview_collections()
|
|
if hasattr(bpy.types.Scene, "sna_rendered_images_index"):
|
|
del bpy.types.Scene.sna_rendered_images_index
|
|
if hasattr(bpy.types.Scene, "sna_rendered_images"):
|
|
del bpy.types.Scene.sna_rendered_images
|
|
if hasattr(bpy.types.Scene, "sna_render_resolution"):
|
|
del bpy.types.Scene.sna_render_resolution
|
|
if hasattr(bpy.types.Scene, "sna_activeobject_name"):
|
|
del bpy.types.Scene.sna_activeobject_name
|
|
if hasattr(bpy.types.Scene, "sna_bakecam"):
|
|
del bpy.types.Scene.sna_bakecam
|
|
if hasattr(bpy.types.Scene, "sna_activeobject"):
|
|
del bpy.types.Scene.sna_activeobject
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls)
|
|
|