Goal
Bloom's post-fx surface includes effects that need per-pixel Metal shaders to implement properly:
bloom_set_chromatic_aberration(strength) — sample R/G/B at slightly different positions
bloom_set_film_grain(strength) — time-animated noise overlay
bloom_set_sun_shafts(...) — radial blur from light source
Today these are stored in watchOS but visually no-op. SwiftUI on watchOS 10+ supports .colorEffect(Shader(function:args:)) which runs Metal shader code against a view's rasterized content.
Scope
Perry-side
Add a new native-library manifest field metal_sources (array of paths) alongside the existing swift_sources. Perry:
- Compiles each .metal file with
xcrun metal -c -target <triple> against the watchOS SDK.
- Links into a
.metallib via xcrun metallib.
- Copies the
.metallib into .app/default.metallib so ShaderLibrary.default picks it up.
Bloom-side
- native/watchos/src/shaders/: three
.metal files — chromatic_aberration.metal, film_grain.metal, sun_shafts.metal. Each exports a [[ stitchable ]] half4 <name>(float2 position, half4 color) function.
- BloomWatchApp.swift reads the effect strengths from
bloom_watchos_postfx_state, wraps the root view with .colorEffect(Shader(function: .init(library: .default, name: "..."), arguments: [...])) per enabled effect.
- Film grain needs time as a shader arg; sun shafts need the sun position in NDC.
Acceptance
bloom_set_chromatic_aberration(0.5) visibly offsets R/G/B channels near screen edges.
bloom_set_film_grain(0.3) overlays animated noise.
bloom_set_sun_shafts(...) produces radial light streaks from the sun direction.
Related
Goal
Bloom's post-fx surface includes effects that need per-pixel Metal shaders to implement properly:
bloom_set_chromatic_aberration(strength)— sample R/G/B at slightly different positionsbloom_set_film_grain(strength)— time-animated noise overlaybloom_set_sun_shafts(...)— radial blur from light sourceToday these are stored in watchOS but visually no-op. SwiftUI on watchOS 10+ supports
.colorEffect(Shader(function:args:))which runs Metal shader code against a view's rasterized content.Scope
Perry-side
Add a new native-library manifest field
metal_sources(array of paths) alongside the existingswift_sources. Perry:xcrun metal -c -target <triple>against the watchOS SDK..metallibviaxcrun metallib..metallibinto.app/default.metallibsoShaderLibrary.defaultpicks it up.Bloom-side
.metalfiles —chromatic_aberration.metal,film_grain.metal,sun_shafts.metal. Each exports a[[ stitchable ]] half4 <name>(float2 position, half4 color)function.bloom_watchos_postfx_state, wraps the root view with.colorEffect(Shader(function: .init(library: .default, name: "..."), arguments: [...]))per enabled effect.Acceptance
bloom_set_chromatic_aberration(0.5)visibly offsets R/G/B channels near screen edges.bloom_set_film_grain(0.3)overlays animated noise.bloom_set_sun_shafts(...)produces radial light streaks from the sun direction.Related
metal_sourcesfield, then implement bloom-side once it's merged.