Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ Download this repo as a zip file and install through the Blender addons.

### Inputs

| Field | Description |
| ----------- | ------------------------------------------------------ |
| Name | Name used for baked images and material |
| Mode | What to do with images after bake |
| Size | Bake image size in pixels |
| Save Images | Save images to external directory |
| Layers | Enable baking of different layers, one image per layer |
| Field | Description |
| ------------- | ------------------------------------------------------ |
| Name | Name used for baked images and material |
| Mode | What to do with images after bake |
| Size | Bake image size in pixels |
| Bake UV | UV layer name used for baking |
| Unwrap Object | Unwrap the object using smart project before baking |
| Save Images | Save images to external directory |
| Layers | Enable baking of different layers, one image per layer |

Mode has the following options

Expand Down
Binary file modified docs/panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions quickbake/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,17 @@ def execute(self, context: bpy.types.Context):
return {"FINISHED"}

def unwrap_object(self, mesh: bpy.types.Mesh) -> bpy.types.MeshUVLoopLayer:
uv_name = "bake_uv"
_log.debug("Unwrapping mesh %s with uv layer %s", mesh.name, uv_name)
_log.debug("Unwrapping mesh %s with uv layer %s", mesh.name, self.props.uv_name)

# Use existing or create new uv layer for baking
bake_uv = mesh.uv_layers.get(uv_name)
bake_uv = mesh.uv_layers.get(self.props.uv_name)
if bake_uv is None:
_log.info("Creating new uv layer %s", uv_name)
bake_uv = mesh.uv_layers.new(name=uv_name)
_log.info("Creating new uv layer %s", self.props.uv_name)
bake_uv = mesh.uv_layers.new(name=self.props.uv_name)
else:
_log.debug("Reusing existing uv layer %s", uv_name)
_log.debug("Reusing existing uv layer %s", self.props.uv_name)
if not self.props.unwrap_object:
return bake_uv

# Store currently active layer
active_layer = None
Expand Down
4 changes: 3 additions & 1 deletion quickbake/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def draw(self, context):
props = scene.QuickBakeToolPropertyGroup # type: ignore

layout.prop(props, "bake_name")
layout.prop(props, "mat_mode")
layout.prop(props, "bake_size")
layout.prop(props, "uv_name")
layout.prop(props, "unwrap_object")
layout.prop(props, "mat_mode")
layout.prop(props, "save_img")

row = layout.row()
Expand Down
15 changes: 15 additions & 0 deletions quickbake/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ class QuickBakeToolPropertyGroup(bpy.types.PropertyGroup):
step=1024, # not yet implemented
)

uv_name: bpy.props.StringProperty(
name="Bake UV",
description="UV layer name used for bake texture",
default="bake_uv",
)

unwrap_object: bpy.props.BoolProperty(
name="Unwrap Object",
description=(
"Unwrap object using smart project before baking. "
"If the uv layer does not exist, the object will be unwrapped regardless of this option."
),
default=True,
)

mat_mode: bpy.props.EnumProperty(
name="Mode",
description="What to do with images after baking",
Expand Down