Blur Bake

This commit is contained in:
2026-02-16 13:51:25 +09:00
parent fc2dc0a478
commit 67178e0f52
10 changed files with 826 additions and 285 deletions
+60 -17
View File
@@ -8,6 +8,7 @@ for controlling mask generation and blur application.
import bpy
from bpy.types import Panel
from ..core.async_bake_generator import get_bake_generator
from ..core.async_generator import get_generator
from ..core.utils import get_server_status, get_cache_info, format_size
@@ -29,20 +30,18 @@ class SEQUENCER_PT_face_mask(Panel):
# Note: Blender 5.0 uses 'strips' instead of 'sequences'
generator = get_generator()
bake_generator = get_bake_generator()
# Always show parameters and status
self._draw_parameters(layout, scene)
self._draw_server_status(layout)
self._draw_cache_info(layout, seq_editor)
layout.separator()
# Show progress if generating
# Show progress if generating masks
if generator.is_running:
self._draw_progress(layout, wm, generator)
return
# Show progress if baking blur
if bake_generator.is_running:
self._draw_bake_progress(layout, wm, bake_generator)
return
# Show controls if strip selected
# Show primary controls first (top priority in UI)
if seq_editor and seq_editor.active_strip:
strip = seq_editor.active_strip
@@ -53,6 +52,13 @@ class SEQUENCER_PT_face_mask(Panel):
layout.label(text="Select a video or image strip")
else:
layout.label(text="No strip selected")
layout.separator()
# Secondary sections
self._draw_parameters(layout, scene)
self._draw_server_status(layout)
self._draw_cache_info(layout, context, seq_editor)
def _draw_parameters(self, layout, scene):
"""Draw detection parameters."""
@@ -94,7 +100,7 @@ class SEQUENCER_PT_face_mask(Panel):
row.label(text="GPU:", icon='ERROR')
row.label(text="Not Available")
def _draw_cache_info(self, layout, seq_editor):
def _draw_cache_info(self, layout, context, seq_editor):
"""Draw cache information and clear button."""
box = layout.box()
box.label(text="Cache", icon='FILE_CACHE')
@@ -115,6 +121,9 @@ class SEQUENCER_PT_face_mask(Panel):
row.label(text="Files:")
row.label(text=str(file_count))
# Cache directory setting
box.prop(context.scene, "facemask_cache_dir")
# Clear cache buttons
row = box.row(align=True)
if seq_editor and seq_editor.active_strip:
@@ -150,6 +159,23 @@ class SEQUENCER_PT_face_mask(Panel):
text="Cancel",
icon='CANCEL',
)
def _draw_bake_progress(self, layout, wm, generator):
"""Draw progress bar during blur bake."""
box = layout.box()
box.label(text="Baking Blur...", icon='RENDER_ANIMATION')
progress = wm.bake_progress / max(wm.bake_total, 1)
box.progress(
factor=progress,
text=f"Frame {wm.bake_progress} / {wm.bake_total}",
)
box.operator(
"sequencer.cancel_bake_blur",
text="Cancel",
icon='CANCEL',
)
def _draw_generation_controls(self, layout, context, strip):
"""Draw mask generation controls."""
@@ -179,7 +205,7 @@ class SEQUENCER_PT_face_mask(Panel):
def _draw_blur_controls(self, layout, context, strip):
"""Draw blur application controls."""
box = layout.box()
box.label(text="Blur Application", icon='MATFLUID')
box.label(text="Blur Bake", icon='MATFLUID')
# Check for mask strip
seq_editor = context.scene.sequence_editor
@@ -189,12 +215,29 @@ class SEQUENCER_PT_face_mask(Panel):
if not has_mask:
box.label(text="Generate a mask first", icon='INFO')
return
# Apply blur button
op = box.operator(
"sequencer.apply_mask_blur",
text="Apply Mask Blur",
icon='PROP_CON',
# Bake parameters
col = box.column(align=True)
col.prop(context.scene, "facemask_bake_blur_size")
col.prop(context.scene, "facemask_bake_format")
# Source status
source_mode = strip.get("facemask_source_mode", "original")
if source_mode == "baked":
box.label(text="Source: Baked", icon='CHECKMARK')
else:
box.label(text="Source: Original", icon='FILE_MOVIE')
# Bake and restore buttons
box.operator(
"sequencer.bake_and_swap_blur_source",
text="Bake & Swap Source",
icon='RENDER_STILL',
)
box.operator(
"sequencer.restore_original_source",
text="Restore Original Source",
icon='LOOP_BACK',
)