Transform your 3D texturing workflow with the power of generative AI, directly within Blender!
fade every view at its frame edge and weigh distance between views
sakalondbc7c93df35f3
diff --git a/stablegen/core/properties.py b/stablegen/core/properties.pyindex 00ac515..72b9661 100644--- a/stablegen/core/properties.py+++ b/stablegen/core/properties.py@@ -894,6 +894,13 @@ def register_properties(update_model_list, ControlNetUnit, LoRAUnit,description="Prefer views that observe the surface more directly and with more projected detail. Estimates geometric observation quality, not the artistic quality of generated images.",default=TEXTURING_DEFAULTS["sg_rework_acquisition_quality"], update=update_parameters,)+ bpy.types.Scene.sg_view_density_exponent = bpy.props.FloatProperty(+ name="Distance weight",+ description="With Weight by view quality: how much nearer views win where views overlap. Each view's weight "+ "is multiplied by its projected pixel density raised to this power; 0 ignores distance, 1 weighs "+ "a view at half the distance twice as much",+ default=1.0, min=0.0, max=4.0, update=update_parameters,+ )bpy.types.Scene.sg_rework_projection_guard = bpy.props.BoolProperty(name="Depth/Part Projection Guard",description="Reduce projection near depth and object/material boundaries to prevent foreground colors spilling onto surfaces behind them. DPPG controls source acceptance separately from ordinary view weighting.",@@ -2155,6 +2162,7 @@ def unregister_properties(load_handler, _sg_queue_load_handler):'sg_rework_aligned_resolution','sg_rework_full_resolution_scale','sg_rework_acquisition_quality',+ 'sg_view_density_exponent','sg_rework_projection_guard','qwen_global_style_vlm_only','qwen_context_vlm_only',diff --git a/stablegen/texturing/projection.py b/stablegen/texturing/projection.pyindex 3436f54..6f9cfb9 100644--- a/stablegen/texturing/projection.py+++ b/stablegen/texturing/projection.py@@ -900,11 +900,12 @@ def _bake_visibility_weights(_scene_projection_scale(context) * focal_pixels/ np.maximum(dists, 1e-8))- density_confidence = np.clip(+ # Unclamped and only with view-quality weighting, like the live+ # material's density term (see there).+ density_confidence = np.power(projected_span / max(0.5 * min(cam_res_x_n, cam_res_y_n), 1.0),- 0.0,- 1.0,- )+ getattr(scene, 'sg_view_density_exponent', 1.0),+ ) if getattr(scene, 'sg_rework_acquisition_quality', False) else 1.0# Store unsharpened acquisition quality. The material owns the# single authoritative SharpW exponent stage.w = np.maximum(dot_dn, 0.0) * density_confidence@@ -2873,7 +2874,14 @@ def project_image(return guard_weightdef _acquisition_quality(weight, length_node, camera, cam_index):- """Multiply a projection weight by the view's projected pixel density."""+ """Multiply a projection weight by the view's projected pixel density.++ The density used to be clamped at 1, which every camera within+ about four scene scales reached, so distance never decided between+ views and a far view at a slightly better angle beat a near one.+ Only ratios between views matter after normalization, so the+ unclamped density is raised to the scene's distance weight.+ """cam_res_x, cam_res_y = _get_camera_resolution(camera, context.scene)fov_for_density = camera.data.angle_xif cam_res_y > cam_res_x:@@ -2891,8 +2899,9 @@ def project_image(density.label = f"ProjectedDensity-{cam_index}-{mat_id}"links.new(length_node.outputs["Value"], density.inputs[1])clamp_density = nodes.new("ShaderNodeMath")- clamp_density.operation = 'MINIMUM'- clamp_density.inputs[1].default_value = 1.0+ clamp_density.operation = 'POWER'+ clamp_density.label = f"DistanceWeight-{cam_index}-{mat_id}"+ clamp_density.inputs[1].default_value = getattr(context.scene, 'sg_view_density_exponent', 1.0)links.new(density.outputs[0], clamp_density.inputs[0])acquisition = nodes.new("ShaderNodeMath")acquisition.operation = 'MULTIPLY'@@ -3008,13 +3017,15 @@ def project_image(# ── Native Raycast path (Blender 5.1+) ──is_local_edit_mode = (context.scene.generation_method == 'local_edit' or (context.scene.model_architecture in QWEN_ARCHITECTURES and context.scene.qwen_generation_method == 'local_edit'))native_pre_factors = None- if (not is_local_edit_mode- and getattr(context.scene, 'sg_rework_acquisition_quality', False)):+ acquisition = getattr(context.scene, 'sg_rework_acquisition_quality', False)+ if not is_local_edit_mode and (acquisition or context.scene.visibility_vignette):# Frame-edge and density terms do not depend on the- # raycast; they are combined before it (see there).+ # raycast; they are combined before it (see there). The+ # frame fade applies on its own: without it a view's+ # frame edge is a hard seam wherever another view+ # continues the surface.def native_pre_factors(weight, parts, camera=camera, i=i):- if (context.scene.generation_method == 'sequential'- and context.scene.visibility_vignette):+ if context.scene.visibility_vignette:frame_weight = create_native_feather(nodes, links, parts['normalize'], parts['fov'],parts['aspect'], parts['direction'], parts['up'],@@ -3026,6 +3037,8 @@ def project_image(links.new(weight, frame_quality.inputs[0])links.new(frame_weight.outputs[0], frame_quality.inputs[1])weight = frame_quality.outputs[0]+ if not acquisition:+ return weightreturn _acquisition_quality(weight, parts['length'], camera, i).outputs[0]result = create_native_raycast_visibility(nodes, links, camera, geometry, context, i, mat_id, stop_index,@@ -3134,10 +3147,7 @@ def project_image(or (context.scene.model_architecture in QWEN_ARCHITECTURESand context.scene.qwen_generation_method == 'local_edit'))- needs_frame_quality = (- context.scene.generation_method == 'sequential'- and context.scene.visibility_vignette- )+ needs_frame_quality = context.scene.visibility_vignetteif is_local_edit_mode or needs_frame_quality:# Add Feather scriptscript_feather = nodes.new("ShaderNodeScript")@@ -3180,7 +3190,7 @@ def project_image(final_weight_node = (script_angle, script_feather)elif is_local_edit_mode:final_weight_node = (script_angle, script_feather)- elif getattr(context.scene, 'sg_rework_acquisition_quality', False):+ elif needs_frame_quality:frame_quality = nodes.new("ShaderNodeMath")frame_quality.operation = 'MULTIPLY'frame_quality.label = f"FrameEdgeQuality-{i}-{mat_id}"diff --git a/stablegen/texturing/surface_blend.py b/stablegen/texturing/surface_blend.pyindex a00709f..d6675c8 100644--- a/stablegen/texturing/surface_blend.py+++ b/stablegen/texturing/surface_blend.py@@ -284,7 +284,8 @@ def build(context, objects, cameras, images, material, mat_id, stop_index):widths.append(world_pixel * scene.sg_silhouette_feather)quality = cosine * visibleif scene.sg_rework_acquisition_quality:- quality *= np.clip(scale/np.maximum(world_pixel,epsilon)/(max(.5*min(x,y),1)),0,1)+ quality *= (scale/np.maximum(world_pixel,epsilon)/(max(.5*min(x,y),1))) ** getattr(+ scene, 'sg_view_density_exponent', 1.)if scene.visibility_vignette:w = max(min(scene.visibility_vignette_width,.49),1e-9)edge = np.max(np.abs(uv*2-1),axis=1)diff --git a/stablegen/ui/panel.py b/stablegen/ui/panel.pyindex 4930061..451f914 100644--- a/stablegen/ui/panel.py+++ b/stablegen/ui/panel.py@@ -1468,6 +1468,8 @@ class StableGenPanel(bpy.types.Panel):if width_mode == 'narrow':row = content_box.row(align=True)row.prop(scene, "sg_rework_acquisition_quality", text="Weight by view quality", toggle=True)+ if scene.sg_rework_acquisition_quality:+ content_box.prop(scene, "sg_view_density_exponent")content_box.prop(scene, "sg_rework_projection_guard", text="Depth/Part Projection Guard", toggle=True)if scene.sg_rework_projection_guard:guard_box = content_box.box()diff --git a/stablegen/ui/presets.py b/stablegen/ui/presets.pyindex 4eb5573..54da9a6 100644--- a/stablegen/ui/presets.py+++ b/stablegen/ui/presets.py@@ -432,6 +432,7 @@ GEN_PARAMETERS = ['sg_rework_aligned_resolution','sg_rework_full_resolution_scale','sg_rework_acquisition_quality',+ 'sg_view_density_exponent','sg_rework_projection_guard','qwen_global_style_vlm_only','qwen_context_vlm_only',