FABIEN SANGLARD'S WEBSITE

ABOUT  CONTACT  RSS  GIVE


Aug 18, 2024
Watching sunsets

My wife and I often walk Charleston Slough in the evenings. At sunset all the hikers stop. Like everybody else, we love to watch the sun cross the horizon.

I have a preference for sunrise. Mostly because it means I got up early and I will be able to get a lot done that day. It is a time when fewer people are around, there are no lines anywhere. It is like the world belongs to you.

All that to say that, since Pixel 1, my wallpaper was Horizon from the Live Earth series.

Look to the horizon. The sun rises as your phone charges, and lowers as the battery is used.

- Horizon Live Earth description

Unfortunately, when I migrated from Pixel 5 to Pixel 7 in 2022, I found out that it was no longer available[1].

PBR Shader attempt

My first thought was to write my own wallpaper and a shader to power it. There is much literature about the topic of light scattering. I even studied the effect back in my GPU days. But to speed up the process I started from wwwtyro's implementation[2]. If you are rusty about your Rayleigh and Mie, Nvidia's GPU Gems has a great article about it[3].

I took one hundred screencap of my Pixel 5 to have a reference and got started.

Horizon (screen capture) Horizon (cleaned[4]) PBR shader version

I tweaked the shader by adding a pink pastel gradient toward the end of the day but it was still too clean looking. Another issue was the lack of visual feedback in the afternoon. I could not really get an idea of the charge from a glimpse at the screen.

A simpler solution

I thought about writing another shader, using artistically picked and hard-coded color values for five or six key skies. I would use bilinear interpolation between keyframes and generate a color gradient in screen space. I would get to learn about color interpolation, LAB, and GLSL in/out syntax instead of my good ol' uniform/varying.

But it would take me months of spare time. And there was an alternative that would take half a day.

I wrote a Photoshop script to "clean" my one hundred reference screencaps and remove the widgets. I was quite impressed by the power of "content-aware" filling. Then I wrote a WallpaperService[5] following Kirill Grouchnikov's tutorial[6]. It draws a new frame when it receives a Intent.ACTION_BATTERY_CHANGED event. The battery level is converted into a filename and it loads the background from the res folder. The whole thing took 1h to write and is 150 lines long.

My "Hackizon" on Pixel 7
Epilogue

Some people "paint the back of the fence". Some people solve their problems with screencap. Most hacks kick the can down the road and this approach was set to fail as soon as the phone screen aspect ratio changed.

A year later, Horizon was back[7][8]. Sometimes the solution is to just sit tight.

References

^ [1]Pixel 7 and 7 Pro missing ‘Horizon’ live wallpaper
^ [2]wwwtyro's glsl-atmosphere
^ [3]GPU Gems 2: Accurate Atmospheric Scattering
^ [4]Photoshops's Content-Aware fill + Batch Process blew my mind.
^ [5]Neo-horizon
^ [6]Live wallpapers with Android SDK 2.1
^ [7]Google's latest Pixel live wallpaper is a blast from the past
^ [8]Google brings back the Horizon live wallpaper on Pixel 7


*