Transform your 3D texturing workflow with the power of generative AI, directly within Blender!
add operator to regenerate selected viewpoints, change default fallback color to black
sakalonda7bc402dd008
diff --git a/stablegen/__init__.py b/stablegen/__init__.pyindex 5de95f6..ed0a40d 100755--- a/stablegen/__init__.py+++ b/stablegen/__init__.py@@ -3,7 +3,7 @@ import bpy # pylint: disable=import-errorfrom .stablegen import StableGenPanel, ApplyPreset, SavePreset, DeletePreset, get_preset_items, update_parametersfrom .render_tools import BakeTextures, AddCameras, SwitchMaterial, ExportOrbitGIF, CollectCameraPrompts, CameraPromptItemfrom .utils import AddHDRI, ApplyModifiers, CurvesToMesh-from .generator import ComfyUIGenerate, Reproject+from .generator import ComfyUIGenerate, Reproject, Regenerateimport osfrom bpy.app.handlers import persistent@@ -31,6 +31,7 @@ classes = [CurvesToMesh,ComfyUIGenerate,Reproject,+ Regenerate]def update_combined(self, context): # Combined with load_handler to load controlnet unit on first setup@@ -980,7 +981,7 @@ def register():name="Fallback Color",description="Color to use as fallback in texture generation",subtype='COLOR',- default=(0.5, 0.5, 0.5), # Changed from 4 values to 3 values+ default=(0.0, 0.0, 0.0),min=0.0, max=1.0,update=update_parameters)@@ -1201,10 +1202,15 @@ def register():update=update_parameters)- bpy.types.Scene.project_only = bpy.props.BoolProperty(- name ="Project Only",- description="""Internal flag to only project existing textures onto the model""",- default=False,+ bpy.types.Scene.generation_mode = bpy.props.EnumProperty(+ name="Generation Mode",+ description="Controls the generation behavior",+ items=[+ ('standard', 'Standard', 'Standard generation process'),+ ('regenerate_selected', 'Regenerate Selected', 'Regenerate only specific viewpoints, keeping the rest from the previous run'),+ ('project_only', 'Project Only', 'Only project existing textures onto the model without generating new ones')+ ],+ default='standard',update=update_parameters)@@ -1333,7 +1339,7 @@ def unregister():del bpy.types.Scene.show_image_guidance_settingsdel bpy.types.Scene.show_masking_inpainting_settingsdel bpy.types.Scene.show_mode_specific_settings- del bpy.types.Scene.project_only+ del bpy.types.Scene.generation_modedel bpy.types.Scene.early_priority_strengthdel bpy.types.Scene.early_prioritydel bpy.types.Scene.texture_objectsdiff --git a/stablegen/generator.py b/stablegen/generator.pyindex 5c34a4c..691e809 100644--- a/stablegen/generator.py+++ b/stablegen/generator.py@@ -15,7 +15,7 @@ from PIL import Imagefrom .util.helpers import prompt_text, prompt_text_img2img # pylint: disable=relative-beyond-top-levelfrom .render_tools import export_emit_image, export_visibility, export_canny, bake_texture, prepare_baking, unwrap # pylint: disable=relative-beyond-top-levelfrom .utils import get_last_material_index, get_generation_dirs, get_file_path, get_dir_path, remove_empty_dirs # pylint: disable=relative-beyond-top-level-from .project import project_image # pylint: disable=relative-beyond-top-level+from .project import project_image, reinstate_compare_nodes # pylint: disable=relative-beyond-top-level# Import wheelsimport websocket@@ -25,6 +25,90 @@ def redraw_ui(context):for area in context.screen.areas:area.tag_redraw()+class Regenerate(bpy.types.Operator):+ """Regenerate textures for selected cameras / viewpoints+ - Works for sequential and separate generation modes+ - Generates new images for the selected cameras only, keeping existing images for unselected cameras+ - This can be used with different prompts or settings to refine specific viewpoints without affecting others"""+ bl_idname = "object.stablegen_regenerate"+ bl_label = "Regenerate Selected Viewpoints"+ bl_options = {'REGISTER', 'UNDO'}++ _original_method = None+ _original_overwrite_material = None+ _timer = None+ @classmethod+ def poll(cls, context):+ """+ Polls whether the operator can be executed.+ :param context: Blender context.+ :return: True if the operator can be executed, False otherwise.+ """+ # Check for other modal operators+ operator = None+ if not (context.scene.generation_method == 'sequential' or context.scene.generation_method == 'separate'):+ return False+ if context.scene.output_timestamp == "":+ return False+ for window in context.window_manager.windows:+ for op in window.modal_operators:+ if op.bl_idname == 'OBJECT_OT_add_cameras' or op.bl_idname == 'OBJECT_OT_bake_textures' or\+ op.bl_idname == 'OBJECT_OT_collect_camera_prompts' or op.bl_idname == 'OBJECT_OT_test_stable' or\+ op.bl_idname == 'OBJECT_OT_stablegen_reproject' or op.bl_idname == 'OBJECT_OT_stablegen_regenerate' \+ or context.scene.generation_status == 'waiting':+ operator = op+ break+ if operator:+ break+ if operator:+ return False+ return True++ def execute(self, context):+ """+ Executes the operator.+ :param context: Blender context.+ :return: {'FINISHED'}+ """++ self._original_overwrite_material = context.scene.overwrite_material+ # Set the flag to reproject+ context.scene.generation_mode = 'regenerate_selected'+ # Set the generation method to 'separate' to avoid generating new images+ context.scene.overwrite_material = True+ # Set timer to 1 seconds to give some time for the generate to start+ context.window_manager.modal_handler_add(self)+ self._timer = context.window_manager.event_timer_add(1.0, window=context.window)+ # Run the generation operator+ bpy.ops.object.test_stable('INVOKE_DEFAULT')++ # Switch to modal and wait for completion+ print("Going modal")+ return {'RUNNING_MODAL'}++ def modal(self, context, event):+ """+ Handles modal events.+ :param context: Blender context.+ :param event: Blender event.+ :return: {'PASS_THROUGH'}+ """+ if event.type == 'TIMER':+ running = False+ if ComfyUIGenerate._is_running:+ running = True+ if not running:+ # Reset the generation method and overwrite material flag+ context.scene.overwrite_material = self._original_overwrite_material+ # Reset the project only flag+ context.scene.generation_mode = 'standard'+ # Remove the modal handler+ context.window_manager.event_timer_remove(self._timer)+ # Report completion+ self.report({'INFO'}, "Regeneration complete.")+ return {'FINISHED'}+ return {'PASS_THROUGH'}+class Reproject(bpy.types.Operator):"""Rerun projection of existing images- Uses the Generate operator to reproject images, new textures will respect new Viewpoint Blending Settings@@ -51,7 +135,8 @@ class Reproject(bpy.types.Operator):for op in window.modal_operators:if op.bl_idname == 'OBJECT_OT_add_cameras' or op.bl_idname == 'OBJECT_OT_bake_textures' or\op.bl_idname == 'OBJECT_OT_collect_camera_prompts' or op.bl_idname == 'OBJECT_OT_test_stable' or\- op.bl_idname == 'OBJECT_OT_stablegen_reproject' or context.scene.generation_status == 'waiting':+ op.bl_idname == 'OBJECT_OT_stablegen_reproject' or op.bl_idname == 'OBJECT_OT_stablegen_regenerate' \+ or context.scene.generation_status == 'waiting':operator = opbreakif operator:@@ -90,7 +175,7 @@ class Reproject(bpy.types.Operator):self._original_method = context.scene.generation_methodself._original_overwrite_material = context.scene.overwrite_material# Set the flag to reproject- context.scene.project_only = True+ context.scene.generation_mode = 'project_only'# Set the generation method to 'separate' to avoid generating new imagescontext.scene.generation_method = 'separate'context.scene.overwrite_material = True@@ -120,7 +205,7 @@ class Reproject(bpy.types.Operator):context.scene.generation_method = self._original_methodcontext.scene.overwrite_material = self._original_overwrite_material# Reset the project only flag- context.scene.project_only = False+ context.scene.generation_mode = 'standard'# Remove the modal handlercontext.window_manager.event_timer_remove(self._timer)# Report completion@@ -145,6 +230,7 @@ class ComfyUIGenerate(bpy.types.Operator):_is_running = False_threads_left = 0_cameras = None+ _selected_camera_ids = None_grid_width = 0_grid_height = 0_material_id = -1@@ -221,7 +307,7 @@ class ComfyUIGenerate(bpy.types.Operator):return {'FINISHED'}# Timestamp for output directory- if not context.scene.project_only:+ if context.scene.generation_mode == 'standard':context.scene.output_timestamp = datetime.now().strftime("%Y-%m-%dT%H-%M-%S")# If UV inpainting and we're in prompt collection mode, collect prompts first.@@ -271,6 +357,9 @@ class ComfyUIGenerate(bpy.types.Operator):return {'CANCELLED'}# Sort cameras by nameself._cameras.sort(key=lambda x: x.name)+ self._selected_camera_ids = [i for i, cam in enumerate(self._cameras) if cam in bpy.context.selected_objects] #TEST+ if len(self._selected_camera_ids) == 0:+ self._selected_camera_ids = list(range(len(self._cameras))) # All cameras selected if none are selected# Check if there is at least one ControlNet unitcontrolnet_units = getattr(context.scene, "controlnet_units", [])@@ -284,10 +373,12 @@ class ComfyUIGenerate(bpy.types.Operator):if any(obj.type == 'CURVE' for obj in bpy.context.scene.objects):self.report({'WARNING'}, "Curves detected in the scene. This may cause issues with the generation process. Consider removing them before proceeding.")- if context.scene.project_only:+ if context.scene.generation_mode == 'project_only':print(f"Reprojecting images for {len(self._cameras)} cameras")- else:+ elif context.scene.generation_mode == 'standard':print(f"Generating images for {len(self._cameras)} cameras")+ else:+ print(f"Regenerating images for {len(self._selected_camera_ids)} selected cameras")uv_slots_needed = len(self._cameras)@@ -365,7 +456,7 @@ class ComfyUIGenerate(bpy.types.Operator):self._cameras.append(camera)bpy.context.scene.collection.objects.link(camera)- if not context.scene.project_only:+ if context.scene.generation_mode == 'standard':# If there is depth controlnet unitif any(unit["unit_type"] == "depth" for unit in controlnet_units) or (context.scene.use_flux_lora and context.scene.model_architecture == 'flux1'):if context.scene.generation_method != 'uv_inpaint':@@ -470,7 +561,7 @@ class ComfyUIGenerate(bpy.types.Operator):self.prompt_text = context.scene.comfyui_promptself._progress = 0.0- if context.scene.project_only:+ if context.scene.generation_mode == 'project_only':self._stage = "Reprojecting"else:self._stage = "Starting"@@ -484,6 +575,15 @@ class ComfyUIGenerate(bpy.types.Operator):elif context.scene.generation_method == 'uv_inpaint':self._total_images = len(self._to_texture)+ # Regenerate mode preparation+ if context.scene.generation_mode == 'regenerate_selected':+ # Reset weights for selected viewpoints+ # Prepare list of camera_ids and material_ids to reset weights for+ ids = []+ for camera_id in self._selected_camera_ids:+ ids.append((camera_id, self._material_id))+ reinstate_compare_nodes(context, self._to_texture, ids)+# Add modal timercontext.window_manager.modal_handler_add(self)self._timer = context.window_manager.event_timer_add(0.5, window=context.window)@@ -527,8 +627,12 @@ class ComfyUIGenerate(bpy.types.Operator):remove_empty_dirs(context)context.scene.generation_status = 'idle'return {'CANCELLED'}- if not context.scene.project_only:+ if not context.scene.generation_mode == 'project_only':self.report({'INFO'}, "Generation complete.")+ # If viewport rendering mode is 'Rendered' and mode is 'regenerate_selected', switch to 'Solid' and then back to 'Rendered' to refresh the viewport+ if context.scene.generation_mode == 'regenerate_selected' and context.area.spaces.active.shading.type == 'RENDERED':+ context.area.spaces.active.shading.type = 'SOLID'+ context.area.spaces.active.shading.type = 'RENDERED'context.scene.display_settings.display_device = 'sRGB'context.scene.view_settings.view_transform = 'Standard'context.scene.generation_status = 'idle'@@ -597,10 +701,10 @@ class ComfyUIGenerate(bpy.types.Operator):normal_path = Nonemask_path = Nonerender_path = None- while self._threads_left > 0 and not context.scene.project_only:- if context.scene.steps != 0:+ while self._threads_left > 0 and not context.scene.generation_mode == 'project_only':+ if context.scene.steps != 0 and not (context.scene.generation_mode == 'regenerate_selected' and camera_id not in self._selected_camera_ids):# Generate image without ControlNet if needed- if camera_id == 0 and (context.scene.generation_method == 'sequential' or context.scene.generation_method == 'separate' or context.scene.generation_method == 'refine')\+ if context.scene.generation_mode == 'standard' and camera_id == 0 and (context.scene.generation_method == 'sequential' or context.scene.generation_method == 'separate' or context.scene.generation_method == 'refine')\and context.scene.sequential_ipadapter and context.scene.sequential_ipadapter_regenerate and not context.scene.use_ipadapter and context.scene.sequential_ipadapter_mode == 'first':self._stage = "Generating Reference Image"# Don't use ControlNet for the first image if sequential_ipadapter_regenerate_wo_controlnet is enabled@@ -642,6 +746,15 @@ class ComfyUIGenerate(bpy.types.Operator):else:image = self.generate(context, depth_path=depth_path, canny_path=canny_path, normal_path=normal_path)else:+ def context_callback():+ # Export visibility mask and render for the current camera, we need to use a callback to be in the main thread+ export_visibility(context, self._to_texture, camera_visibility=self._cameras[self._current_image - 1]) # Export mask for current view+ export_emit_image(context, self._to_texture, camera_id=self._current_image, bg_color=context.scene.fallback_color) # Export render for next view+ self._wait_event.set()+ return None+ bpy.app.timers.register(context_callback)+ self._wait_event.wait()+ self._wait_event.clear()# Get paths for the previous render and maskrender_path = get_file_path(context, "inpaint", subtype="render", camera_id=self._current_image)mask_path = get_file_path(context, "inpaint", subtype="visibility", camera_id=self._current_image)@@ -700,10 +813,6 @@ class ComfyUIGenerate(bpy.types.Operator):def image_project_callback():redraw_ui(context)project_image(context, self._to_texture, self._material_id, stop_index=self._current_image)- if self._current_image < len(self._cameras) - 1:- next_camera_id = self._current_image + 1- export_visibility(context, self._to_texture, camera_visibility=self._cameras[self._current_image]) # Export mask for current view- export_emit_image(context, self._to_texture, camera_id=next_camera_id, bg_color=context.scene.fallback_color) # Export render for next view# Set the event to signal the end of the processself._wait_event.set()return Nonediff --git a/stablegen/project.py b/stablegen/project.pyindex 6c6af89..ea39545 100644--- a/stablegen/project.py+++ b/stablegen/project.py@@ -241,7 +241,8 @@ def project_image(context, to_project, mat_id, stop_index=1000000):mat = obj.active_material.copy()obj.data.materials.append(mat)to_switch = True- elif obj.active_material and (context.scene.overwrite_material or (context.scene.generation_method == "refine" and context.scene.refine_preserve) or (context.scene.generation_method == 'sequential' and stop_index > 0)):+ elif obj.active_material and (context.scene.overwrite_material or (context.scene.generation_method == "refine" and context.scene.refine_preserve) \+ or (context.scene.generation_method == 'sequential' and stop_index > 0) or context.scene.generation_mode == 'regenerate_selected'):# Use active materialmat = obj.active_materialelse:@@ -273,7 +274,7 @@ def project_image(context, to_project, mat_id, stop_index=1000000):original_uv_map = obj.data.uv_layers[0]- if context.scene.generation_method == 'sequential' and stop_index > 0:+ if (context.scene.generation_method == 'sequential' and stop_index > 0) or context.scene.generation_mode == 'regenerate_selected':# We just need to remove the compare nodes which are connected to script node at stop_indexscript_node = None# First find all script nodes with label {stop_index}-{mat_id}@@ -571,3 +572,50 @@ def simple_project_bake(context, camera_id, obj, mat_id):# Remove the temporary materialbpy.ops.object.material_slot_remove()++def reinstate_compare_nodes(context, to_project, stop_id_mat_id_pairs):+ """+ Reinstates the 'LESS_THAN' compare nodes that were removed for sequential generation.+ This will esentially revert given views to not-generated state for viewpoint regeneration.+ """++ for obj in to_project:+ if not obj.active_material:+ continue++ mat = obj.active_material+ if not mat.use_nodes:+ continue++ nodes = mat.node_tree.nodes+ links = mat.node_tree.links++ for stop_id, mat_id in stop_id_mat_id_pairs:+ script_node = None+ # Find the script node with the specific label+ for node in nodes:+ if node.type == 'SCRIPT' and node.label == f"{stop_id}-{mat_id}":+ script_node = node+ break++ if not script_node:+ continue++ # Store links to disconnect and reconnect later+ links_to_recreate = []+ for link in list(script_node.outputs[0].links):+ links_to_recreate.append((link.from_socket, link.to_socket))+ links.remove(link)++ # For each original connection, insert a 'LESS_THAN' node+ for from_socket, to_socket in links_to_recreate:+ # Create a new 'LESS_THAN' math node+ less_than_node = nodes.new(type='ShaderNodeMath')+ less_than_node.operation = 'LESS_THAN'+ less_than_node.inputs[1].default_value = -1+ # Position it between the script node and its original destination+ less_than_node.location = (script_node.location.x + 200, script_node.location.y)++ # Connect script_node -> less_than_node -> original destination+ links.new(from_socket, less_than_node.inputs[0])+ links.new(less_than_node.outputs[0], to_socket)diff --git a/stablegen/stablegen.py b/stablegen/stablegen.pyindex 4c827eb..3e33236 100755--- a/stablegen/stablegen.py+++ b/stablegen/stablegen.py@@ -7,13 +7,13 @@ import math # pylint: disable=import-error# Stock presetsPRESETS = {- "DEFAULT": {"description": "Default settings for general purpose generation", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 90.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.15, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},- "MODEL IS IMPORTANT": {"description": "Same as default, but is more guided by the model", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 90.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.15, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.75, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},- "CHARACTERS": {"description": "Optimized settings for character generation", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 80.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.1, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},- "CHARACTERS (ALTERNATIVE MASKING)": {"description": "Optimized for character generation. Uses alternative masking parameters to be more consistent between images, but may produce more artifacts. Try if \"Characters\" fails.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 80.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.5, "sequential_factor_smooth": 0.3499999940395355, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 10, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},- "QUICK DRAFT": {"description": "Optimized for speed", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 4, "cfg": 1.0, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 70.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "grid", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.1, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 2, "blur_mask_sigma": 1.0, "grow_mask_by": 2, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'Hyper-SDXL-4steps-lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},- "UV INPAINTING": {"description": "Recommended UV Inpainting setup. It is recommended to bake texutures manually before running the generation to fine-tune unwrapping and avoid lag when generating.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 10, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 80.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "uv_inpaint", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "3,0,1,2", "sequential_factor": 0.6000000238418579, "sequential_factor_smooth": 0.11000001430511475, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 3, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]}, # No ControlNet for UV Inpainting by default- "ARCHITECTURE": {"description": "Prioritizes only the most straight-on camera for each point. This means details generated on flat surfaces will not get blurred by getting generated differently from two or more viewpoints. Does not use visibility masking. Each picture will get generated as new, consistency depends on IPAdapter + geometry.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.5, 0.5, 0.5)), "discard_factor": 80.0, "weight_exponent": 10.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "separate", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": False, "sequential_custom_camera_order": "", "sequential_factor": 0.75, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "ipadapter_weight_type": "style", "ipadapter_strength": 0.800000011920929, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": False, "blur_mask": True, "blur_mask_radius": 3, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.6000000238418579, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "DEFAULT": {"description": "Default settings for general purpose generation", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 90.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.15, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "MODEL IS IMPORTANT": {"description": "Same as default, but is more guided by the model", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 90.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.15, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.75, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "CHARACTERS": {"description": "Optimized settings for character generation", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 80.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.1, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "CHARACTERS (ALTERNATIVE MASKING)": {"description": "Optimized for character generation. Uses alternative masking parameters to be more consistent between images, but may produce more artifacts. Try if \"Characters\" fails.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 80.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.5, "sequential_factor_smooth": 0.3499999940395355, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 10, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "QUICK DRAFT": {"description": "Optimized for speed", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 4, "cfg": 1.0, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "weight_exponent": 3.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "grid", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.7, "sequential_factor_smooth": 0.1, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 2, "blur_mask_sigma": 1.0, "grow_mask_by": 2, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'Hyper-SDXL-4steps-lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},+ "UV INPAINTING": {"description": "Recommended UV Inpainting setup. It is recommended to bake texutures manually before running the generation to fine-tune unwrapping and avoid lag when generating.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 10, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 80.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "uv_inpaint", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "3,0,1,2", "sequential_factor": 0.6000000238418579, "sequential_factor_smooth": 0.11000001430511475, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 3, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]}, # No ControlNet for UV Inpainting by default+ "ARCHITECTURE": {"description": "Prioritizes only the most straight-on camera for each point. This means details generated on flat surfaces will not get blurred by getting generated differently from two or more viewpoints. Does not use visibility masking. Each picture will get generated as new, consistency depends on IPAdapter + geometry.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 80.0, "weight_exponent": 10.0, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "bake_texture": False, "bake_texture_size": 2048, "bake_unwrap_method": "none", "bake_unwrap_overlap_only": True, "generation_method": "separate", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": False, "sequential_custom_camera_order": "", "sequential_factor": 0.75, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "ipadapter_weight_type": "style", "ipadapter_strength": 0.800000011920929, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": False, "blur_mask": True, "blur_mask_radius": 3, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.6000000238418579, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},}# Global list of all generation parameter names to check for a preset.@@ -226,7 +226,13 @@ class StableGenPanel(bpy.types.Panel):action_row.operator("object.test_stable", text="Cannot generate: Model Directory Empty", icon="ERROR")action_row.enabled = Falseelif scene.generation_status == 'idle':- action_row.operator("object.test_stable", text="Generate", icon="PLAY")+ # Check if any cameras are selected and if there is existing output+ selected_cameras = [obj for obj in context.selected_objects if obj.type == 'CAMERA']+ if not selected_cameras or scene.get("output_timestamp") == "":+ action_row.operator("object.test_stable", text="Generate", icon="PLAY")+ else:+ # Use the regenerate operator+ action_row.operator("object.stablegen_regenerate", text="Regenerate Selected Views", icon="PLAY")elif scene.generation_status == 'running':action_row.operator("object.test_stable", text="Cancel Generation", icon="CANCEL")