# How a holographic foil effect works in Jetpack Compose

DevFeed: [How a holographic foil effect works in Jetpack Compose](<https://devfeed.tech/articles/how-a-holographic-foil-effect-works-in-jetpack-compose-100954.md>)

Original publisher: [Read original article](<https://proandroiddev.com/how-a-holographic-foil-effect-works-in-jetpack-compose-9535d621c055?source=rss----c72404660798---4>)

Author: Manuel Mato

Published: 2026-10-26T13:45:32Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Spec Driven Development](<https://devfeed.tech/topics/spec-driven-development.md>), [Image](<https://devfeed.tech/topics/image.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [compose](<https://devfeed.tech/tags/compose.md>), [drawing](<https://devfeed.tech/tags/drawing.md>), [gradient](<https://devfeed.tech/tags/gradient.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [recomposition](<https://devfeed.tech/tags/recomposition.md>), [sensor](<https://devfeed.tech/tags/sensor.md>), [shaders](<https://devfeed.tech/tags/shaders.md>), [spec-driven-development](<https://devfeed.tech/tags/spec-driven-development.md>)

## AI overview

The holographic foil is rendered as an AGSL shader that recalculates each pixel from screen position and phone tilt. To reveal a changing background through scratch strokes, Compose paints it beneath a black offscreen layer and clears stroke paths with `BlendMode.Clear`. The shader builds the foil from warped fractal noise for relief, thin-film interference for shifting RGB colors, a tilt-positioned light band, and cell-based glitter. A filtered `TYPE_GAME_ROTATION_VECTOR` reading (with accelerometer fallback) updates a brush uniform read inside `drawBehind`, triggering redraws without recomposition or relayout. AGSL requires Android 13; the app uses a static gradient on Android 7-12 because its moving-gradient imitation looked pastel and weakly responsive. Holographic sharing uses looping MP4 rather than GIF because GIF's 256-color limit caused banding.

## Source excerpt

Thin-film interference, glitter flakes and the tilt sensor, in an AGSL shader for a scratch-art appThe same Playink drawing with three backgrounds: holographic, gold and silverWhat you'll find in this article Some time ago I published Playink on Google Play, a scratch-art app for kids. I built the first version on my own, without AI, and the idea was simple: a black layer you scratch with your finger and, underneath, a colour gradient. Like the scratch-art paper we all had as kids, without the mess. It worked, but the colours underneath were static, just like on paper. I wanted more: a holographic foil underneath, like those shiny stickers, with the light moving across the drawing as you tilt the phone. For that part I did use AI. I worked with spec-driven development: I started from a spec describing what I wanted, several AI agents worked on it in parallel, and I decided how it had to look, tested it on the phone and approved every change. In this article I'll walk you through how the effect works: why the scratch surface had to change, the AGSL shader layer by layer, and how the tilt of the phone reaches the shader without a single recomposition. The full code is in the gists along the way. The problem: a background that changes every frame In the first version, every stroke was painted with the colour of the background at that point. That's fine for a gradient that never changes, but a holographic foil changes every frame, so a stroke can't have "a colour". The solution was to turn it around. The background is painted in full, and on top of it there's a black layer where every stroke cuts a hole. In Compose, that's an offscreen layer and a Clear blend mode (simplified): drawIntoCanvas { it.saveLayer(surfaceSize.toRect(), Paint()) } drawRect(surfaceColor, size = surfaceSize) strokes.forEach { drawPath(it, Color.Black, blendMode = BlendMode.Clear) } drawIntoCanvas { it.restore() } The strokes only clear the black layer, not the background below it. From the outsid