Transform your 3D texturing workflow with the power of generative AI, directly within Blender!
make the diagnostics displays near-instant and turn them on by default
sakalondb48056e502eb
diff --git a/stablegen/core/preferences.py b/stablegen/core/preferences.pyindex 6636d5f..b2a1ddb 100644--- a/stablegen/core/preferences.py+++ b/stablegen/core/preferences.py@@ -151,7 +151,7 @@ class StableGenAddonPreferences(bpy.types.AddonPreferences):enable_debug: bpy.props.BoolProperty(name="Enable Debug Settings",description="Show diagnostic tools in the main panel for visualising projection weights, blending and coverage",- default=False+ default=True) # type: ignoreshow_advanced: bpy.props.BoolProperty(diff --git a/stablegen/debug_tools.py b/stablegen/debug_tools.pyindex 7cead83..7aa66b5 100644--- a/stablegen/debug_tools.py+++ b/stablegen/debug_tools.py@@ -16,6 +16,7 @@ import colorsysimport globimport jsonimport numpy as np+import reimport sysimport tempfileimport shutil@@ -31,10 +32,6 @@ from .texturing.projection import (project_image,create_native_raycast_visibility,create_native_feather,- _SG_BUFFER_UV_NAME,- _copy_uv_to_attribute,- _projection_uvw_name,- _write_projection_uvw,)from .texturing.rendering import export_emit_image, export_visibilityfrom .cameras.geometry import _get_camera_resolution, _SGCameraResolution@@ -467,51 +464,6 @@ def _save_grid_image(path, width, height, color_rgb, grid_size=64):bpy.data.images.remove(img)-def _apply_uv_projections(context, cameras, meshes, mat_id):- """Create UV projections for each camera on each mesh, storing them- as named attributes. Returns True on success."""- for i, camera in enumerate(cameras):- for obj in meshes:- bpy.ops.object.select_all(action='DESELECT')- context.view_layer.objects.active = obj- obj.select_set(True)- bpy.ops.object.make_single_user(object=True, obdata=True)- if obj.data.users > 1:- obj.data = obj.data.copy()- obj.data.name = f"{obj.name}_data"- obj.data.update()-- buffer_uv = obj.data.uv_layers.get(_SG_BUFFER_UV_NAME)- if not buffer_uv:- buffer_uv = obj.data.uv_layers.new(name=_SG_BUFFER_UV_NAME)-- mod = obj.modifiers.new(name="UVProject", type='UV_PROJECT')- mod.projectors[0].object = camera- mod.uv_layer = buffer_uv.name- cam_res_x, cam_res_y = _get_camera_resolution(camera, context.scene)- aspect = cam_res_x / cam_res_y- mod.aspect_x = aspect if aspect > 1 else 1- mod.aspect_y = 1 / aspect if aspect < 1 else 1- obj.data.uv_layers.active = buffer_uv- bpy.ops.object.modifier_apply(modifier=mod.name)-- attr_name = f"ProjectionUV_{i}_{mat_id}"- _copy_uv_to_attribute(obj, _SG_BUFFER_UV_NAME, attr_name)- _write_projection_uvw(obj, camera, attr_name, _projection_uvw_name(i, mat_id))-- original_uv = obj.data.uv_layers[0]- if original_uv.name == _SG_BUFFER_UV_NAME and len(obj.data.uv_layers) > 1:- original_uv = obj.data.uv_layers[1]- obj.data.uv_layers.active = original_uv-- # Clean up buffer UV- for obj in meshes:- buf = obj.data.uv_layers.get(_SG_BUFFER_UV_NAME)- if buf:- obj.data.uv_layers.remove(buf)- return True--def _get_active_camera(context):"""Return the camera the user intends to preview and its index in thesorted camera list. Detection: selected camera → scene camera → first."""@@ -627,6 +579,76 @@ def _debug_projection_build_state(scene):# 1. Draw Solid Colors (calls the real project_image)# ═════════════════════════════════════════════════════════════════════════+def _linear(color):+ """The debug colours are what their PNGs held, sRGB; shader colours are linear."""+ return tuple(c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 for c in color) + (1.0,)+++def _replace_view_colors(context, meshes, colour):+ """Give each projected view in *meshes*' materials (Studio passes private copies) another colour than its image:+ ``colour(tree, image_node, camera, debug_colour)`` returns the socket, its weights, gates and alpha unchanged,+ so nothing is projected anew. Returns False when the materials hold no projected views."""+ cameras = _interactive_generation_cameras(context)+ colors = _saturated_colors(len(cameras))+ replaced, seen = False, set()+ for obj in meshes:+ for slot in obj.material_slots:+ material = slot.material+ if material is None or not material.use_nodes or material.as_pointer() in seen:+ continue+ seen.add(material.as_pointer())+ tree = material.node_tree+ for node in list(tree.nodes):+ view = re.fullmatch(r'(\d+)-\d+', node.label) if node.type == 'TEX_IMAGE' else None+ if view is None or int(view[1]) >= len(colors) or not node.outputs['Color'].links:+ continue+ index = int(view[1])+ socket = colour(tree, node, cameras[index], colors[index])+ if socket is None:+ continue+ for link in list(node.outputs['Color'].links):+ tree.links.new(socket, link.to_socket)+ replaced = True+ if replaced:+ for camera, color in zip(cameras, colors):+ camera['_sg_debug_projection_color'] = color+ return replaced+++def solid_view_colors(context, meshes):+ """View colours on the textures as they are: each view in its camera's solid colour."""+ def solid(tree, node, _camera, color):+ rgb = tree.nodes.new('ShaderNodeRGB')+ rgb.label = 'SGViewColor-' + node.label+ rgb.location = (node.location.x - 220, node.location.y)+ rgb.outputs[0].default_value = _linear(color)+ return rgb.outputs[0]+ return _replace_view_colors(context, meshes, solid)+++def grid_view_colors(context, meshes, grid_size):+ """The projection grid on the textures as they are: each view a checkerboard in its camera's colour, cells of+ *grid_size* of that camera's image pixels, read through the view's own projection UV."""+ def checker(tree, node, camera, color):+ if not node.inputs['Vector'].links:+ return None+ width, height = _get_camera_resolution(camera, context.scene)+ cells = tree.nodes.new('ShaderNodeVectorMath')+ cells.operation = 'MULTIPLY'+ cells.inputs[1].default_value = (width / grid_size, height / grid_size, 0.0)+ tree.links.new(node.inputs['Vector'].links[0].from_socket, cells.inputs[0])+ grid = tree.nodes.new('ShaderNodeTexChecker')+ grid.label = 'SGViewGrid-' + node.label+ grid.location = (node.location.x - 220, node.location.y)+ grid.inputs['Scale'].default_value = 1.0+ # Unit cells; Color1 where the column and row parities differ, the dark cells of the grid PNGs+ grid.inputs['Color1'].default_value = _linear(tuple(c * 0.4 for c in color))+ grid.inputs['Color2'].default_value = _linear(color)+ tree.links.new(cells.outputs[0], grid.inputs['Vector'])+ return grid.outputs['Color']+ return _replace_view_colors(context, meshes, checker)++class SG_OT_DebugSolidColors(bpy.types.Operator):"""Project solid saturated colours (one per camera) through the realproject_image() pipeline. Useful for understanding how views are@@ -800,6 +822,11 @@ class SG_OT_DebugVisibilityMaterial(bpy.types.Operator):return _common_poll(cls, context)def execute(self, context):+ # The solid images replace generated views: never write them over the real ones+ with _debug_projection_output(context):+ return self._execute_projection(context)++ def _execute_projection(self, context):selected_cams = _get_selected_cameras(context)meshes = _get_target_meshes(context)@@ -883,11 +910,14 @@ class SG_OT_DebugCoverageHeatmap(bpy.types.Operator):else:context.scene.cycles.use_osl = True- _apply_uv_projections(context, cameras, meshes, mat_id)-+ # One material for every mesh: the raycast graph reads no projection UVs and nothing per object+ mat = Nonefor obj in meshes:- mat = bpy.data.materials.new(name="SG_Debug_Heatmap")obj.data.materials.clear()+ if mat is not None:+ obj.data.materials.append(mat)+ continue+ mat = bpy.data.materials.new(name="SG_Debug_Heatmap")obj.data.materials.append(mat)mat.use_nodes = Truenodes = mat.node_tree.nodes@@ -1057,9 +1087,13 @@ class SG_OT_DebugPerCameraWeight(bpy.types.Operator):use_native = bpy.app.version >= (5, 1, 0)+ mat = None # one material for every mesh: the graph holds nothing per objectfor obj in meshes:- mat = bpy.data.materials.new(name=f"SG_Debug_Weight_{cam.name}")obj.data.materials.clear()+ if mat is not None:+ obj.data.materials.append(mat)+ continue+ mat = bpy.data.materials.new(name=f"SG_Debug_Weight_{cam.name}")obj.data.materials.append(mat)mat.use_nodes = Truenodes = mat.node_tree.nodes@@ -1122,9 +1156,13 @@ class SG_OT_DebugFeatherPreview(bpy.types.Operator):use_native = bpy.app.version >= (5, 1, 0)+ mat = None # one material for every mesh: the graph holds nothing per objectfor obj in meshes:- mat = bpy.data.materials.new(name=f"SG_Debug_Feather_{cam.name}")obj.data.materials.clear()+ if mat is not None:+ obj.data.materials.append(mat)+ continue+ mat = bpy.data.materials.new(name=f"SG_Debug_Feather_{cam.name}")obj.data.materials.append(mat)mat.use_nodes = Truenodes = mat.node_tree.nodes@@ -1189,14 +1227,17 @@ class SG_OT_DebugUVSeamViz(bpy.types.Operator):else:context.scene.cycles.use_osl = True- _apply_uv_projections(context, cameras, meshes, mat_id)-use_native = bpy.app.version >= (5, 1, 0)colors = _saturated_colors(len(cameras))+ # One material for every mesh: the raycast graph reads no projection UVs and nothing per object+ mat = Nonefor obj in meshes:- mat = bpy.data.materials.new(name="SG_Debug_UVSeams")obj.data.materials.clear()+ if mat is not None:+ obj.data.materials.append(mat)+ continue+ mat = bpy.data.materials.new(name="SG_Debug_UVSeams")obj.data.materials.append(mat)mat.use_nodes = Truenodes = mat.node_tree.nodesdiff --git a/stablegen/ui/studio.py b/stablegen/ui/studio.pyindex 426fa75..b78003e 100644--- a/stablegen/ui/studio.py+++ b/stablegen/ui/studio.py@@ -38,9 +38,12 @@ from ..core.architectures import ARCHITECTURE_ITEMS, QWEN_ARCHITECTURES, architeTAB = 'StableGen'PAGES = [('GENERATE', 'Texture'), ('CAMERAS', 'Cameras'), ('BLEND', 'Blending')]MORE = [('TOOLS', 'Tools'), ('QUEUE', 'Scene queue'), ('DEBUG', 'Diagnostics'),- ('MESH', 'Mesh & rig'), ('PRINT', '3D printing'), ('EXPERIMENTS', 'Experiments')]+ ('MESH', 'Mesh & rig'), ('PRINT', '3D printing'), ('EXPERIMENTS', 'Experiments'),+ ('SETUP', 'ComfyUI setup')]# Architectures that generate the asset itself rather than texturing an existing mesh.ASSET_ARCHITECTURES = {'trellis2'}+DIAGNOSTIC_ICONS = {'SOLID': 'material', 'GRID': 'grid', 'COVERAGE': 'layers', 'VISIBILITY': 'eye', 'WEIGHT': 'graph',+ 'FEATHER': 'widen', 'CONFIDENCE': 'check', 'SEAMS': 'curve', 'DPPG': 'shield'}ARCHITECTURE_PROPERTIES = {'architecture_mode', 'model_architecture', 'trellis2_texture_mode', 'trellis2_initial_image_arch'}@@ -450,15 +453,12 @@ class StudioSession:self.refresh()def write_binding(self, binding, value, undo=True):- if binding.path == 'sg_studio_diagnostics':- scope, mode = _viewport_mode(self, 'EXEC_DEFAULT')- with scope:- bpy.ops.stablegen.studio_diagnostic(mode, setting=binding.property, value=json.dumps(value))- _undo('Change diagnostic display')- else:- binding.set(bpy.context, value)- if undo:- _undo('Change ' + binding.rna(bpy.context).name)+ # Read the label first: after a rename the binding's old name no longer resolves. A diagnostic option+ # only changes the setting; Update view applies it.+ label = binding.rna(bpy.context).name+ binding.set(bpy.context, value)+ if undo:+ _undo('Change ' + label)def begin_edit(self, target, select=False):self.commit()@@ -1657,7 +1657,8 @@ class StudioSession:decision = [item for n in self.document.actions for item in model.controls(n)if item.control.method == 'operator' and item.control.args[0] == 'stablegen.resolve_masked_edit']utilities = self.page in {'TOOLS', 'DEBUG'} and not decision- preview = diagnostics.active(bpy.context.scene)+ # Diagnostics has its own Restore textures beside the display it shows+ preview = diagnostics.active(bpy.context.scene) and self.page != 'DEBUG'# Keep the last action row twelve pixels clear of the panel's bottom edge.bottom_padding = 12if progress:@@ -1830,11 +1831,29 @@ class StudioSession:state = bpy.context.scene.sg_studio_diagnosticsitems = [(obj.name, obj.name, 'Inspect this camera') for obj in bpy.context.scene.objects if obj.type == 'CAMERA']items.sort()- self.menu = {'anchor': rect, 'items': items, 'query': '', 'binding': None,- 'callback': lambda name: self.call('stablegen.studio_diagnostic',- {'setting': 'camera', 'value': json.dumps(name)}, mode='EXEC_DEFAULT'),+ def choose(name):+ state.camera = bpy.data.objects.get(name)+ _undo('Change diagnostic camera')+ self.menu = {'anchor': rect, 'items': items, 'query': '', 'binding': None, 'callback': choose,'index': next((i for i, item in enumerate(items) if state.camera and item[0] == state.camera.name), 0), 'scroll': 0}+ def diagnostic_settings(self, mode):+ """What a shown display depends on: when it differs from what is shown, Update view applies it."""+ state = bpy.context.scene.sg_studio_diagnostics+ return (mode, state.grid_size, state.coverage, state.confidence, state.scope, state.stage,+ state.camera.name if state.camera else '')++ def show_diagnostic(self, mode):+ self.call('stablegen.studio_diagnostic', {'value': json.dumps(mode)}, mode='EXEC_DEFAULT')+ scene = bpy.context.scene+ if mode == 'TEXTURES' or not diagnostics.active(scene):+ self.diagnostic_shown = None+ failure = diagnostics.SG_OT_StudioDiagnostic.failure+ if mode != 'TEXTURES' and failure:+ self.tell(failure)+ else:+ self.diagnostic_shown = self.diagnostic_settings(mode)+def draw_diagnostics(self, p, x, y, width):scene, state = bpy.context.scene, bpy.context.scene.sg_studio_diagnosticsif not any(s.key == 'debug' for s in self.document.sections):@@ -1846,33 +1865,85 @@ class StudioSession:p.rect(x + 12, y - 3, width - 24, 1, 'divider')with _viewport(self):available = model.operator('stablegen.studio_diagnostic').poll()- y += self.draw_binding(p, model.Binding.from_data(state, 'mode'), 'Display', x + 8, y + 8, width - 16, enabled=available) + 8- description = diagnostics.DISPLAY_SUMMARIES[state.mode]- for _, _, line in wrap(description, width - 16, p.measure):- p.text(line, x + 8, y, 10, 'secondary')- y += 15- y += 6- if diagnostics.active(scene):+ active = diagnostics.active(scene)+ x, width, y = x + 8, width - 16, y + 8+ if active:+ # A display replaces the textures right now: say so above everything it could be confused with+ name = next(label for key, label, _ in diagnostics.MODES if key == state.mode)count = sum(record.object is not None for record in state.meshes)- p.text(f'Previewing {count} mesh' + ('es' if count != 1 else '') + ' · Originals preserved',- x + 8, y, 10, 'accent', width - 16)- y += 22+ p.rect(x, y, width, 26, 'tab_selected', 4)+ p.rect(x, y, 3, 26, 'blue', 1)+ p.rect(x + 12, y + 10, 6, 6, 'accent', 3)+ p.text('Showing ' + name, x + 26, y + 7, FONT_SIZE, 'text', width - 40)+ p.text(f'{count} mesh' + ('es' if count != 1 else '') + ' · originals kept',+ x + 36 + p.measure('Showing ' + name), y + 8, 10, 'muted')+ y += 38+ # Tiles only choose; Show in viewport applies the chosen display with its options.+ pick = self.diagnostic_pick or (state.mode if active else 'SOLID')+ modes = [mode for mode in diagnostics.MODES if mode[0] != 'TEXTURES']+ columns = 3 if width >= 420 else 2+ tile_width, tile_height, gap = (width - 6 * (columns - 1)) / columns, 30, 6+ for index, (key, label, description) in enumerate(modes):+ rect = (x + index % columns * (tile_width + gap), y + index // columns * (tile_height + gap),+ tile_width, tile_height)+ missing = diagnostics.unavailable(bpy.context, key)+ hover = self.hovered('diagnostic:' + key)+ chosen = key == pick+ p.outline(*rect, 'selected' if chosen else 'raised',+ 'accent' if chosen else 'hover_border' if hover else 'tool_border')+ tint = 'disabled' if missing else 'text'+ p.icon(DIAGNOSTIC_ICONS[key], rect[0] + 10, rect[1] + 8, 13, tint)+ p.text(label, rect[0] + 30, rect[1] + 8, FONT_SIZE, tint, tile_width - 50)+ if active and key == state.mode:+ p.rect(rect[0] + tile_width - 13, rect[1] + 12, 6, 6, 'accent', 3)+ p.target('diagnostic:' + key, rect, lambda key=key: setattr(self, 'diagnostic_pick', key),+ available and not self.busy, missing or description)+ y += (len(modes) + columns - 1) // columns * (tile_height + gap) - gap + 12+ option = state.confidence if pick == 'CONFIDENCE' else None+ missing = diagnostics.unavailable(bpy.context, pick, option)+ if missing:+ p.icon('shield', x, y, 12, 'warning')+ for _, _, line in wrap(missing + '.', width - 18, lambda text: p.measure(text, 10)):+ p.text(line, x + 18, y + 1, 10, 'warning')+ y += 15+ else:+ for _, _, line in wrap(diagnostics.DISPLAY_SUMMARIES[pick], width, lambda text: p.measure(text, 10)):+ p.text(line, x, y, 10, 'secondary')+ y += 15+ y += 8options = {'GRID': ['grid_size'], 'COVERAGE': ['coverage'], 'CONFIDENCE': ['confidence'],- 'DPPG': ['scope', 'stage']}.get(state.mode, [])+ 'DPPG': ['scope', 'stage']}.get(pick, [])for key in options:binding = model.Binding.from_data(state, key)- y += self.draw_binding(p, binding, binding.rna(bpy.context).name, x + 8, y, width - 16, enabled=available)- if state.mode in {'WEIGHT', 'FEATHER', 'VISIBILITY', 'CONFIDENCE'} or state.mode == 'DPPG' and state.scope == 'ACTIVE':- p.text('Camera', x + 8, y, FONT_SIZE, 'text')+ y += self.draw_binding(p, binding, binding.rna(bpy.context).name, x, y, width, enabled=available)+ if pick in {'WEIGHT', 'FEATHER', 'VISIBILITY', 'CONFIDENCE'} or pick == 'DPPG' and state.scope == 'ACTIVE':+ p.text('Camera', x, y, FONT_SIZE, 'text')y += 17- rect = (x + 8, y, width - 16, CONTROL_HEIGHT)+ rect = (x, y, width, CONTROL_HEIGHT)p.outline(*rect, 'menu', 'hover_border' if self.hovered('diagnostic-camera') else 'menu_border')- p.text(state.camera.name if state.camera else 'Choose camera', rect[0] + 8, y + 5, FONT_SIZE, 'menu_text', width - 49)- p.icon('down', x + width - 24, y + 6, 10, 'menu_text')+ p.text(state.camera.name if state.camera else 'Choose camera', rect[0] + 8, y + 5, FONT_SIZE, 'menu_text', width - 33)+ p.icon('down', x + width - 16, y + 6, 10, 'menu_text')p.target('diagnostic-camera', rect, lambda rect=rect: self.diagnostic_camera_menu(rect), available and not self.busy,'Choose the camera whose signal is displayed')y += CONTROL_HEIGHT + 8y += 2+ can_show = available and not self.busy and not missing+ if active:+ changed = self.diagnostic_settings(pick) != self.diagnostic_shown+ half = (width - 6) / 2+ p.button('diagnostic-update', (x, y, half, CONTROL_HEIGHT + 2), 'Update view',+ lambda pick=pick: self.show_diagnostic(pick), icon='play', style='primary',+ enabled=can_show and changed,+ hint='Show the chosen display with these settings' if changed else 'The viewport shows these settings')+ p.button('diagnostic-restore', (x + half + 6, y, half, CONTROL_HEIGHT + 2), 'Restore textures',+ lambda: self.show_diagnostic('TEXTURES'), icon='reset', style='outlined',+ enabled=available and not self.busy, hint='Restore the original mesh, materials and render settings')+ else:+ p.button('diagnostic-show', (x, y, width, CONTROL_HEIGHT + 2), 'Show in viewport',+ lambda pick=pick: self.show_diagnostic(pick), icon='play', style='primary', enabled=can_show,+ hint=missing or 'Replace the textures with this display; your originals are kept')+ y += CONTROL_HEIGHT + 2 + 10+ x, width = x - 8, width + 16p.end_group((x, start, width, y - start), 'subbox', 'section_border', 3)y += 12y = self.draw_actions(p, 'Projection analysis', [diff --git a/stablegen/ui/studio_diagnostics.py b/stablegen/ui/studio_diagnostics.pyindex f20f5b9..afab4d8 100644--- a/stablegen/ui/studio_diagnostics.py+++ b/stablegen/ui/studio_diagnostics.py@@ -8,11 +8,12 @@ import uuidimport bpy+from ..texturing.projection import _remove_stale_uv_projectorsfrom ..utils import sg_modal_activeMODES = [('TEXTURES', 'Projected textures', 'Return to the original mesh and materials'),- ('SOLID', 'View colors', 'One solid color per camera, through the real projection pipeline'),+ ('SOLID', 'View colors', 'One solid color per camera, blended by the textures’ own view weights'),('GRID', 'Projection grid', 'Check projected image alignment and distortion'),('COVERAGE', 'Coverage', 'Average or strongest camera visibility, shown on a logarithmic heatmap to reveal weak coverage; not normalized RGB contributions'),('VISIBILITY', 'Visibility', 'Inspect which surfaces the cameras can see'),@@ -39,6 +40,20 @@ OPERATORS = {'DPPG': 'debug_dppg_material',}OPTIONS = {'mode', 'camera', 'grid_size', 'coverage', 'confidence', 'scope', 'stage'}+# Displays that read a signal from the projection material: the node label it needs, and how to get it.+SIGNALS = {+ 'CONFIDENCE': {'QUALITY': 'SGBestSourceQuality', 'TRUSTED': 'SGBestSourceQuality',+ 'REPAIR': 'SGBestSourceQuality', 'ACQUISITION': 'AcquisitionQuality-',+ 'WRITE': 'SequentialWriteWeight-', 'GUARD': 'ProjectionGuardWeight-'},+ 'DPPG': {None: 'ProjectionGuardWeight-'},+}+MISSING = {+ 'SGBestSourceQuality': 'Not in these textures: generate with Confidence context on',+ 'AcquisitionQuality-': 'Not in these textures: reproject with acquisition quality on',+ 'SequentialWriteWeight-': 'Not in these textures: generate with projection write masks on',+ 'ProjectionGuardWeight-': 'Not in these textures: reproject with the depth/part guard on',+}+_found = {}_OWNED = '_sg_studio_preview'@@ -109,6 +124,30 @@ def _targets(context):if obj.library is None and obj.data.library is None]+def unavailable(context, mode, option=None):+ """Why the inspected textures cannot show *mode*, or ''. *option* is the Confidence signal to check;+ without it any of the mode's signals will do."""+ needs = SIGNALS.get(mode)+ if not needs:+ return ''+ state = context.scene.sg_studio_diagnostics+ labels = [needs[option]] if option in needs else list(dict.fromkeys(needs.values()))+ if state.token:+ materials = {saved.material for record in state.meshes for saved in record.slots}+ else:+ materials = {slot.material for obj in _targets(context) for slot in obj.material_slots}+ materials = sorted((m for m in materials if m is not None and m.use_nodes), key=lambda m: m.as_pointer())+ for label in labels:+ key = (label, tuple((m.as_pointer(), len(m.node_tree.nodes)) for m in materials))+ if key not in _found:+ if len(_found) > 64:+ _found.clear()+ _found[key] = any(node.label.startswith(label) for m in materials for node in m.node_tree.nodes)+ if _found[key]:+ return ''+ return MISSING[labels[0]]++def _snapshot(context, state):targets = _targets(context)if not targets:@@ -267,19 +306,25 @@ def apply(context):if camera is None:raise ValueError('Add cameras before inspecting projection.')state.camera = camera- selected = meshes + [camera]- kwargs = {'grid_size': state.grid_size} if mode == 'GRID' else (- {'mode': state.coverage} if mode == 'COVERAGE' else- {'mode': state.confidence} if mode == 'CONFIDENCE' else- {'scope': state.scope, 'stage': state.stage} if mode == 'DPPG' else {})- with context.temp_override(selected_objects=selected, selected_editable_objects=selected,- active_object=camera, object=camera):- op = getattr(bpy.ops.stablegen, OPERATORS[mode])- if not op.poll():- raise ValueError('This diagnostic requires meshes, cameras and Debug enabled in preferences.')- result = op('EXEC_DEFAULT', **kwargs)- if 'FINISHED' not in result:- raise ValueError('This signal is unavailable. Reproject textures with the relevant feature enabled.')+ from ..debug_tools import grid_view_colors, solid_view_colors+ # View colors and the grid recolour the shown views in place; only textures without projected views are+ # projected anew+ recolored = (solid_view_colors(context, meshes) if mode == 'SOLID' else+ grid_view_colors(context, meshes, state.grid_size) if mode == 'GRID' else False)+ if not recolored:+ selected = meshes + [camera]+ kwargs = {'grid_size': state.grid_size} if mode == 'GRID' else (+ {'mode': state.coverage} if mode == 'COVERAGE' else+ {'mode': state.confidence} if mode == 'CONFIDENCE' else+ {'scope': state.scope, 'stage': state.stage} if mode == 'DPPG' else {})+ with context.temp_override(selected_objects=selected, selected_editable_objects=selected,+ active_object=camera, object=camera):+ op = getattr(bpy.ops.stablegen, OPERATORS[mode])+ if not op.poll():+ raise ValueError('This diagnostic requires meshes, cameras and Debug enabled in preferences.')+ result = op('EXEC_DEFAULT', **kwargs)+ if 'FINISHED' not in result:+ raise ValueError('This signal is unavailable. Reproject textures with the relevant feature enabled.')except Exception:# Include new IDs even when an existing diagnostic fails halfway through.for collection, previous in zip(collections, before):@@ -305,6 +350,7 @@ class SG_OT_StudioDiagnostic(bpy.types.Operator):setting: bpy.props.StringProperty(default='mode', options={'HIDDEN'})value: bpy.props.StringProperty(default='"TEXTURES"', options={'HIDDEN'})+ failure = '' # why the last change fell back to the textures, for the panel to say@classmethoddef poll(cls, context):@@ -314,6 +360,7 @@ class SG_OT_StudioDiagnostic(bpy.types.Operator):if self.setting not in OPTIONS:return {'CANCELLED'}state = context.scene.sg_studio_diagnostics+ SG_OT_StudioDiagnostic.failure = ''try:value = json.loads(self.value)if self.setting == 'camera':@@ -322,7 +369,8 @@ class SG_OT_StudioDiagnostic(bpy.types.Operator):apply(context)except Exception as exc:restore(context.scene)- self.report({'WARNING'}, str(exc).split('\n')[0])+ SG_OT_StudioDiagnostic.failure = str(exc).split('\n')[0]+ self.report({'WARNING'}, SG_OT_StudioDiagnostic.failure)return {'FINISHED'} # rollback itself must be undoablefor screen in bpy.data.screens:for area in screen.areas: