Skip to content

feat(watchos): wire SCNTechnique post-fx via keyed-subscript uniforms (#16, #18)#49

Open
proggeramlug wants to merge 1 commit intomainfrom
feat/watchos-postfx-technique-16-18
Open

feat(watchos): wire SCNTechnique post-fx via keyed-subscript uniforms (#16, #18)#49
proggeramlug wants to merge 1 commit intomainfrom
feat/watchos-postfx-technique-16-18

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

The previous `BloomPostFXTechnique` was a no-op based on the conclusion that watchOS had no path to push per-frame uniforms into an `SCNTechnique`. `handleBindingOfSymbol:usingBlock:` is genuinely unreachable (SCNRenderer isn't in the watchOS SDK), but the keyed-subscript path on the technique itself doesn't need SCNRenderer. SceneKit translates `technique[symbol] = NSData(bytes:length:)` into the matching `[[buffer(N)]]` slot whenever the symbol is declared with a `type` in the technique dictionary — this is the documented Metal uniform-binding API and works wherever SCNTechnique ships, watchOS included.

This PR:

  • Builds the technique once with three `vec4` symbols mapping to `bloom_postfx.metal`'s `params0/1/2` (`[[buffer(0)]]` / `[[buffer(1)]]` / `[[buffer(2)]]` in declaration order).
  • Pushes chromatic-aberration / film-grain / sun-shafts strengths each frame from the existing `PostFxState` poll.
  • Defaults the sun position to top-center (`bloom_set_sun_shafts` has no positional arg, matching the issue's "above the viewport" behavior).
  • Updates the surrounding architecture comments + `postfx.rs` docstring, both of which still framed Metal post-fx as deferred.

Closes #16, closes #18.

Test plan

  • `cargo check --lib` in `native/watchos/` clean (no new warnings)
  • `bloom_set_film_grain(0.15)` visibly overlays animated noise on the 3D helmet / fox / buggy in `examples/test-gltf-watch`
  • `bloom_set_chromatic_aberration(8.0)` visibly splits R/G/B at the corners
  • `bloom_set_sun_shafts(0.4, 0.85, 1.0, 0.9, 0.5)` produces amber rays from a point above the viewport
  • 2D-only games unaffected (Metal pass skipped when `anyEffectActive` is false)
  • Vignette + manual exposure (SwiftUI modifiers) continue to work in parallel

…#16, #18)

The previous BloomPostFXTechnique was a no-op based on the (wrong)
conclusion that watchOS had no path to push per-frame uniforms into a
SCNTechnique. The handleBindingOfSymbol:usingBlock: route is genuinely
unreachable — SCNRenderer isn't in the watchOS SDK — but the
keyed-subscript path on the technique itself doesn't need SCNRenderer.
SceneKit translates `technique[symbol] = NSData(bytes:length:)` into
the matching `[[buffer(N)]]` slot when the symbol is declared with a
`type` in the technique dictionary; this is the documented Metal
uniform-binding API and works on every Apple platform that ships
SCNTechnique, watchOS included.

Build the technique once with three vec4 symbols (params0/1/2 →
buffer(0/1/2) in declaration order, matching bloom_postfx.metal) and
push the chromatic-aberration / film-grain / sun-shafts strengths each
frame from the existing PostFx state poll. Sun position defaults to
top-center; bloom_set_sun_shafts has no positional argument so this
matches the implicit "above the viewport" behavior the issue calls out.

Updates the surrounding architecture comments and the postfx.rs
docstring, both of which still claimed Metal post-fx was deferred.

Needs simulator/device verification — the Rust check passes but the
Swift compile happens through Perry's toolchain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

watchOS: SCNTechnique-based post-fx for 3D-layer effects watchOS: Metal-shader post-FX (chromatic aberration, film grain, sun shafts)

1 participant