Repository navigation
Add the u_tilt uniform for OpenGL live wallpapers (3.6.0) - #87
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Android OpenGL live wallpapers get an optional renderer uniform,
u_tilt(vec2, -1 to 1 per axis). Apps also getWallpaperCapabilities.supportsTilt, so a shader declaresu_tiltonly when the plugin and the device support it. Version 3.6.0.TYPE_GAME_ROTATION_VECTOR, or the accelerometer when the device has no game rotation vector. Without either sensor,u_tiltstays (0, 0).xgrows as the right edge dips.ygrows 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.TiltLifecycleregisters the sensor only while the engine is visible and the linked program readsu_tilt. It unregisters on invisible, surface loss, render failure, a new configuration withoutu_tilt, and destroy. The sensor, its events and the lifecycle all stay on the render thread.u_tiltonly as a non-arrayvec2.supportsTiltis 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.:async_wallpaper:testDebugUnitTest: 179 tests, 0 failures. This includesTiltTrackerTest(rest pose, clamping, zero and NaN, reset, decay, signed upright pitch),TiltLifecycleTest(visibility, renderer, failure and destroy transitions, no per-frame re-registration), andShaderContractTest(u_tiltvec2 accepted; float and array rejected).tool/check_pigeon.sh: bindings current.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: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.
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
async_wallpaper: ^3.6.0. That turns tilt on for Prism's 3D live wallpaper with no other change (Prism PR: Hash-Studios/Prism, brancht3/day7-3d-live-wallpaper).Do not publish from this PR; the owner publishes.
🤖 Generated with Claude Code