Skip to content

Commit c6a25f6

Browse files
illixionclaude
andcommitted
Decouple spatial 3D source resolution from 2D display cap
The 3D resolution limit was being silently clamped by the 2D maxImageResolution setting, so picking "Off" for the 3D cap still inherited whatever 2D was set to. The two caps govern different pipelines (MTLTexture vs Spatial3DImage source) and should be fully independent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a3a8447 commit c6a25f6

3 files changed

Lines changed: 10 additions & 19 deletions

File tree

SpatialStash/SpatialStash/Model/AppModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ class AppModel {
546546
("Off", 0),
547547
]
548548

549-
/// Maximum resolution passed to RealityKit's `Spatial3DImage`. Independent
550-
/// of `maxImageResolution` so the 2D path can stay full-res while the 3D
551-
/// depth/parallax mesh uses a smaller source. Capped at min(this, maxImageResolution)
552-
/// when the latter is non-zero. 0 = no extra cap (defer to maxImageResolution).
549+
/// Maximum resolution passed to RealityKit's `Spatial3DImage`. Fully
550+
/// independent of `maxImageResolution` the 2D cap governs the on-screen
551+
/// MTLTexture, this one governs the source fed into the depth/parallax
552+
/// mesh. 0 = no cap (use native resolution).
553553
var spatial3DMaxResolution: Int {
554554
didSet {
555555
if spatial3DMaxResolution != oldValue {

SpatialStash/SpatialStash/Model/PhotoWindowModel+Spatial3D.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,11 @@ extension PhotoWindowModel {
158158
sourceURL = imageURL
159159
}
160160

161-
// Respect the max image resolution setting by downsampling the source
162-
// image before passing it to RealityKit's Spatial3DImage. The dedicated
163-
// spatial3DMaxResolution can clamp lower than the global cap so the 2D
164-
// path keeps its full resolution while the depth/parallax mesh works
165-
// off a smaller source.
166-
let globalRes = effectiveMaxResolution
167-
let s3dRes = effectiveSpatial3DMaxResolution
168-
let effectiveRes: Int
169-
switch (globalRes, s3dRes) {
170-
case (0, 0): effectiveRes = 0
171-
case (0, let s): effectiveRes = s
172-
case (let g, 0): effectiveRes = g
173-
case (let g, let s): effectiveRes = min(g, s)
174-
}
161+
// The spatial 3D source resolution is independent of the 2D display
162+
// resolution: the 2D cap governs the on-screen MTLTexture, while
163+
// this cap governs the source fed into RealityKit's Spatial3DImage.
164+
// 0 = no cap (use native resolution).
165+
let effectiveRes = effectiveSpatial3DMaxResolution
175166
if effectiveRes > 0,
176167
let downsampledData = Self.createDownsampledImageData(from: sourceURL, maxDimension: CGFloat(effectiveRes)),
177168
let downsampledSource = CGImageSourceCreateWithData(downsampledData as CFData, nil) {

SpatialStash/SpatialStash/Model/PhotoWindowModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class PhotoWindowModel {
468468
}
469469

470470
/// The effective spatial 3D source resolution, considering per-window override.
471-
/// 0 means "no extra cap beyond `effectiveMaxResolution`".
471+
/// 0 means "no cap" (use native resolution).
472472
var effectiveSpatial3DMaxResolution: Int {
473473
spatial3DResolutionOverride ?? appModel.spatial3DMaxResolution
474474
}

0 commit comments

Comments
 (0)