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
15 changes: 4 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
run: uv sync --frozen

- name: Lint
run: uv run --frozen ruff check .
run: |
uv run --frozen ruff format --check .
uv run --frozen ruff check .

# - name: Test
# TODO everything after pytest might not be needed
Expand All @@ -54,20 +56,11 @@ jobs:
uses: automas-dev/reusable-workflows/increment_version@main
id: version

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version

- name: Install UV
uses: astral-sh/setup-uv@v7

- name: Set Version
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
uv version $VERSION
sed -i "s/DEV_BUILD/${VERSION}/g" src/quickbake/blender_manifest.toml
sed -i "s/^version = \"[^\"]\+\"$/version=\"${VERSION}\"/g" src/quickbake/blender_manifest.toml

- name: Create Archive
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ dmypy.json

# Cython debug symbols
cython_debug/

release/
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@

INSTALL_DIR=$(HOME)/.config/blender/5.0/extensions/user_default/quickbake
ZIP_ARCHIVE_NAME=quickbake_0.0.0.zip

setup:
uv sync

build_dev:
@mkdir -p release/
@cd src/quickbake && zip $(PWD)/release/$(ZIP_ARCHIVE_NAME) *

install:
rm -rf $(INSTALL_DIR)/*
cp -r src/quickbake/* $(INSTALL_DIR)/

run: install
blender

checks: lint test

lint:
uv run ruff format --check
uv run ruff check .

format:
uv run ruff format
uv run ruff check --fix .

test:
uv run pytest

.PHONY: setup install checks lint format test
.PHONY: setup build_dev install checks lint format test
10 changes: 6 additions & 4 deletions src/quickbake/bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def setup_bake_nodes(obj):
'''Create material nodes required for baking.'''
"""Create material nodes required for baking."""
_l.info('Creating bake nodes for object %s', obj.name)

bake_nodes = []
Expand All @@ -27,7 +27,7 @@ def setup_bake_nodes(obj):


def cleanup_bake_nodes(obj):
'''Remove material nodes created for baking by setup_bake_nodes.'''
"""Remove material nodes created for baking by setup_bake_nodes."""
_l.info('Cleaning up bake nodes for object %s', obj.name)

for mat in obj.data.materials:
Expand All @@ -40,7 +40,7 @@ def cleanup_bake_nodes(obj):


def setup_bake_uv(obj, name):
'''Create a uv layer to unwrap obj for baking.'''
"""Create a uv layer to unwrap obj for baking."""
_l.info('Creating uv layer %s for baking', name)

def unwrap_uv(obj, uv):
Expand Down Expand Up @@ -75,7 +75,9 @@ def unwrap_uv(obj, uv):
return bake_uv


def setup_bake_image(obj, bake_nodes, bake_name, bake_size, pass_name, reuse_tex, is_data=False):
def setup_bake_image(
obj, bake_nodes, bake_name, bake_size, pass_name, reuse_tex, is_data=False
):
_l.info('Creating image for baking object %s', obj.name)

image_name = obj.name + '_' + bake_name + '_' + pass_name
Expand Down
3 changes: 1 addition & 2 deletions src/quickbake/blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "quickbake"
# the value DEV_BUILD is replaced with the version string by ci
version = "DEV_BUILD"
version = "0.0.0"
name = "Quick Bake"
tagline = "Fast baking for blender"
maintainer = "Thomas Harrison <theharrisoncrafter@gmail.com>"
Expand Down
13 changes: 6 additions & 7 deletions src/quickbake/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
_l = logging.getLogger(__name__)


def setup_bake_material(obj, name, bake_uv_name, diffuse=None, roughness=None, normal=None):
def setup_bake_material(
obj, name, bake_uv_name, diffuse=None, roughness=None, normal=None
):
_l.info('Creating material %s for object %s', name, obj.name)

mat = bpy.data.materials.get(name)
Expand Down Expand Up @@ -53,21 +55,18 @@ def make_tex_node(img, y):

if diffuse is not None:
diff_node = make_tex_node(diffuse, 400)
links.new(diff_node.outputs['Color'],
principled_node.inputs['Base Color'])
links.new(diff_node.outputs['Color'], principled_node.inputs['Base Color'])

if roughness is not None:
rough_node = make_tex_node(roughness, 100)
links.new(rough_node.outputs['Color'],
principled_node.inputs['Roughness'])
links.new(rough_node.outputs['Color'], principled_node.inputs['Roughness'])

if normal is not None:
norm_node = make_tex_node(normal, -200)
norm_map_node = nodes.new(type='ShaderNodeNormalMap')
norm_map_node.location.x -= 200
norm_map_node.location.y -= 200
links.new(norm_node.outputs['Color'], norm_map_node.inputs['Color'])
links.new(norm_map_node.outputs['Normal'],
principled_node.inputs['Normal'])
links.new(norm_map_node.outputs['Normal'], principled_node.inputs['Normal'])

return mat
27 changes: 15 additions & 12 deletions src/quickbake/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
class QuickBake_PT_main(bpy.types.Panel):
"""Creates a Sub-Panel in the Property Area of the 3D View."""

bl_label = "Quick Bake"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Tool"
bl_context = "objectmode"
bl_label = 'Quick Bake'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Tool'
bl_context = 'objectmode'

def draw(self, context):
"""Override Panel draw method."""
layout = self.layout
assert layout is not None, 'Missing layout'

assert context.scene is not None, 'Missing scene from context'

row = layout.row()
row.operator(QuickBake_OT_bake.bl_idname)
Expand All @@ -26,31 +29,31 @@ def draw(self, context):

layout.label(text='Texture')
row = layout.row()
row.prop(props, "bake_name")
row.prop(props, 'bake_name')

row = layout.row()
row.prop(props, "bake_uv")
row.prop(props, 'bake_uv')

row = layout.row()
row.prop(props, "bake_size")
row.prop(props, 'bake_size')

layout.separator()
layout.label(text='Material')
row = layout.row()
row.prop(props, "create_mat")
row.prop(props, 'create_mat')

row = layout.row()
row.prop(props, "mat_name")
row.prop(props, 'mat_name')

layout.separator()
layout.label(text='Options')
row = layout.row()
row.enabled = not props.create_mat
row.prop(props, "reuse_tex")
row.prop(props, 'reuse_tex')

row = layout.row()
row.enabled = not props.create_mat
row.prop(props, "clean_up")
row.prop(props, 'clean_up')

# layout.separator()
# layout.label(text='Output')
Expand Down
Loading