Skip to content

Add the u_tilt uniform for OpenGL live wallpapers (3.6.0) - #87

Merged
codenameakshay merged 3 commits into
mainfrom
feat/tilt-uniform
Oct 28, 2026
Merged

codenameakshay merged 3 commits into
mainfrom
feat/tilt-uniform

Conversation

@codenameakshay

Copy link
Copy Markdown
Owner

What

Android OpenGL live wallpapers get an optional renderer uniform, u_tilt (vec2, -1 to 1 per axis). Apps also get WallpaperCapabilities.supportsTilt, so a shader declares u_tilt only when the plugin and the device support it. Version 3.6.0.

  • Source. TYPE_GAME_ROTATION_VECTOR, or the accelerometer when the device has no game rotation vector. Without either sensor, u_tilt stays (0, 0).
  • Meaning. x grows as the right edge dips. y grows as the top edge leans away. Both are measured from a rest pose that follows how the user holds the phone, with a time constant of about 7 s. Pitch uses the Y/Z cross component, so it stays signed when the rest pose is upright.
  • Battery. The sensor samples at about 15 Hz (66,667 µs), and the renderer eases the value each frame. TiltLifecycle registers the sensor only while the engine is visible and the linked program reads u_tilt. It unregisters on invisible, surface loss, render failure, a new configuration without u_tilt, and destroy. The sensor, its events and the lifecycle all stay on the render thread.
  • Validator. It accepts u_tilt only as a non-array vec2.
  • Capabilities. supportsTilt is true on Android when OpenGL live wallpapers are supported and a tilt sensor exists, and false on iOS. The Pigeon field is added at the end.

Note: 3.5.0 already accepted an unknown uniform vec2 u_tilt; and left it at (0, 0). The validator rejects only bad types and samplers. Shaders that declare it still work on 3.5.0.

Tests

  • fvm flutter test: 63 passed. fvm flutter analyze: no issues.
  • Kotlin :async_wallpaper:testDebugUnitTest: 179 tests, 0 failures. This includes TiltTrackerTest (rest pose, clamping, zero and NaN, reset, decay, signed upright pitch), TiltLifecycleTest (visibility, renderer, failure and destroy transitions, no per-frame re-registration), and ShaderContractTest (u_tilt vec2 accepted; float and array rejected).
  • tool/check_pigeon.sh: bindings current.
  • Codex (gpt-6.1-sol) reviewed and fixed lifecycle, pitch sign and array findings in b110e08. I reverted one part of it, a hand-written legacy capabilities transport, because the Dart bindings and the hosts ship in one version.

Device proof (Android emulator, Prism scratch build on this branch)

Sensor registration from dumpsys sensorservice. Opening Settings unregisters (-), and going home registers again (+) at 66,667 µs:

14:35:55 - 0x5f676172 pid=25426 uid=10214 samplingPeriod=   N/A  us batchingPeri
14:35:58 + 0x5f676172 pid=25426 uid=10214 samplingPeriod=   66667us batchingPeri
14:36:07 - 0x5f676172 pid=25426 uid=10214 samplingPeriod=   N/A  us batchingPeri
14:36:10 + 0x5f676172 pid=25426 uid=10214 samplingPeriod=   66667us batchingPeri

Tilt through the emulator's virtual accelerometer (fused Game Rotation Vector). Far and near regions shift in opposite directions: on a left roll, far +7 px and near -5 px; on a right roll, the opposite signs.

10 s mp4

The emulator's fused sensor gives small, uneven magnitudes. The owner must check how tilt feels on a real phone. FULL_TILT (0.34) and the per-frame ease (0.15) are the values to tune.

Release order

  1. Merge and publish async_wallpaper 3.6.0 (owner).
  2. Bump Prism to async_wallpaper: ^3.6.0. That turns tilt on for Prism's 3D live wallpaper with no other change (Prism PR: Hash-Studios/Prism, branch t3/day7-3d-live-wallpaper).

Do not publish from this PR; the owner publishes.

🤖 Generated with Claude Code

codenameakshay and others added 3 commits October 28, 2026 13:36
OpenGL live wallpaper shaders can now declare `uniform vec2 u_tilt;`.
It is the phone tilt from the game rotation vector, or the
accelerometer when that is missing, from -1 to 1 per axis and (0, 0)
at rest or without a sensor. The sensor runs at about 15 Hz only while
the wallpaper is visible and its shader reads u_tilt, and the renderer
eases the value per frame.

WallpaperCapabilities.supportsTilt tells apps when to declare it.
Bump to 3.6.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stop sensor work when renderer state changes and clear stale tilt.

Keep pitch signed near upright rest and reject u_tilt arrays.

Preserve existing capabilities when older hosts omit tilt.
The Dart bindings and the Android and iOS hosts ship in one package
version, so a host that sends 13 capability fields cannot meet these
bindings. The hand-written transport only duplicated generated Pigeon
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codenameakshay
codenameakshay merged commit 966f3be into main Oct 28, 2026
6 checks passed
@codenameakshay
codenameakshay deleted the feat/tilt-uniform branch October 28, 2026 16:50
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.

1 participant