Four interactive demos of the progressive blur API in Jetpack Compose 1.13, combined with
custom AGSL RuntimeShaders.
Compose 1.13 adds BlurRadiusSpec, a way to describe a blur whose radius varies across the
surface: sharp in one place, blurred in another, with a smooth ramp between. You can shape it
with linear or radial gradients, multi-stop gradients, or any Shader used as an intensity mask.
The demo also covers two related additions from the same release (Compose BOM 2026.11.01):
- Window blur on
Dialog:DialogProperties(blurBehindRadius, backgroundBlurRadius, scrimAlpha, windowShape), with a fallback driven byWindowInfo.isCrossWindowBlurEnabled. - Runtime shaders on
Modifier.border: aShaderBrushbacked by an AGSLRuntimeShadernow works as a border brush on every shape.
| Feed | Dialog | Focus | Fog | Lens |
|---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
// Static: sharp at the top, 24dp blur at the bottom
Modifier.blur(BlurRadiusSpec.verticalGradient(startRadius = 0.dp, endRadius = 24.dp))
// Block form: values read here are read during the layer phase, so animated or
// scroll-driven values only re-run the layer, with no recomposition.
Modifier.blur {
blurRadiusSpec = BlurRadiusSpec.radialGradient(startRadius = 0.dp, endRadius = animatedRadius)
edgeTreatment = BlurredEdgeTreatment.Rectangle
}| Factory | Shape |
|---|---|
BlurRadiusSpec.uniform(radius) |
Same radius everywhere (API 31+) |
verticalGradient / horizontalGradient |
Top→bottom / left→right ramp |
linearGradient(start, end, …) |
Ramp along any line (angled blurs) |
radialGradient(…, center, fallOffRadius) |
Ramp outward from a point |
…(stops = listOf(BlurStop(fraction, radius), …)) |
Multi-stop variants of all of the above (2–16 stops) |
BlurRadiusSpec.shader(maxRadius) { sizePx -> shader } |
Any Shader as a mask: its alpha (0..1) scales maxRadius per pixel |
spec.createRenderEffect(size, density) |
A plain RenderEffect, so you can chain it with other effects |
Platform support: uniform blur needs Android 12 (API 31). Spatially varying blur needs Android 13 (API 33). On older versions the content draws unblurred. Spatially varying radii are capped at 150 px once resolved; uniform radii are not.
ui/demos/EdgeFadeFeedScreen.kt
An iOS-style list whose content melts into the header and the floating controls instead of being cut off.
-
A 4-stop
verticalGradientkeeps the middle sharp and blurs both edges:[0 → edge] [fade → 0dp] [1-fade → 0dp] [1 → edge]. -
Scroll-reactive: the top blur only appears once you scroll away from the top, and the bottom blur relaxes when you reach the end of the list.
-
The scroll state is read inside the
blur { }block, so scrolling only re-runs the graphics layer and never recomposes the list. -
A Featured row at the top uses a 4-stop
horizontalGradient. Its left and right edges blur only while there is more to scroll in that direction. -
Tap any card to open a
Dialogthat blurs the window behind it with the newDialogPropertiesoptions. If cross-window blur is off (battery saver or GPU support), it uses a darker scrim and a more opaque card instead. -
The dialog border is an animated AGSL shader (
AgslShaders.GLOW_BORDER) passed toModifier.borderthrough aShaderBrush.
Try: scroll the list and the Featured row, drag Edge blur and Fade depth, then tap a card.
LazyColumn(Modifier.blur {
val topEdge = if (listState.firstVisibleItemIndex > 0) 1f
else (listState.firstVisibleItemScrollOffset / 240f).coerceIn(0f, 1f)
blurRadiusSpec = BlurRadiusSpec.verticalGradient(listOf(
BlurStop(0f, (edgeBlur * topEdge).dp),
BlurStop(fadeDepth, 0.dp),
BlurStop(1f - fadeDepth, 0.dp),
BlurStop(1f, (edgeBlur * bottomEdge).dp),
))
})
// Dialog with window blur, and a fallback when the system has it turned off
val blurEnabled = LocalWindowInfo.current.isCrossWindowBlurEnabled
Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(
blurBehindRadius = 16.dp,
backgroundBlurRadius = 32.dp,
scrimAlpha = if (blurEnabled) 0.25f else 0.6f,
windowShape = RoundedCornerShape(28.dp),
),
) {
Column(
Modifier
.drawWithContent {
glow.setFloatUniform("resolution", size.width, size.height)
glow.setFloatUniform("time", time.value)
drawContent()
}
.border(2.dp, ShaderBrush(glow), RoundedCornerShape(28.dp))
) { /* ... */ }
}ui/demos/FocusStudioScreen.kt
A camera-style focus tool over a procedurally drawn night city. Thousands of lit windows make every change in blur radius easy to see.
Tilt-shift mode: an angled, 4-stop linearGradient with a sharp band through the
middle (the "miniature" look).
- Drag anywhere: your finger is projected onto the gradient line to place the band.
- The Angle slider rotates the line. The geometry is computed so the line exactly spans the layer at any angle.
Spotlight mode: a radialGradient whose center follows your finger on a spring
animation (Animatable<Offset>). It stays sharp up to 35% of the falloff radius, then ramps to
the max blur.
Dashed guides show the focus region and are drawn on top without blur.
Try: switch modes, drag across the scene, and change Angle, Focus band and Falloff.
ui/demos/FoggedGlassScreen.kt · shader: AgslShaders.FOG_MASK
A fogged-up window you wipe clear with your finger. It slowly fogs over again.
This uses BlurRadiusSpec.shader, where an AGSL shader decides the blur radius of every
pixel. The mask shader combines three sources:
- Your finger: a low-res (1/6 scale)
Bitmapmask. Dragging erases it with a softDST_OUTstroke. It is passed to AGSL as a childuniform shader fog(aBitmapShaderwith linear filtering). - Condensation texture: animated value noise, so the fog looks uneven and slowly shifts.
- Drips: procedural water streaks that run down random lanes and cut clear trails.
Every frame, a faint black fill is drawn over the bitmap so its alpha creeps back toward fully
fogged. The same AGSL source runs a second time with a pale tint to paint the frosty
highlight on top. Two RuntimeShader instances are used because uniforms are captured each
time a RenderEffect is created or a draw is recorded.
Try: wipe the glass, change Re-fog speed and Finger size, and tap Breathe to fog it up again.
val blurSpec = remember(fog, maxBlur) {
BlurRadiusSpec.shader(maxRadius = maxBlur.dp) { sizePx ->
maskShader.apply {
setInputShader("fog", fog.shader)
setFloatUniform("resolution", sizePx.width, sizePx.height)
setFloatUniform("time", time.value)
// ...
}
}
}ui/demos/LiquidLensScreen.kt · shader: AgslShaders.LIQUID_LENS
A draggable liquid-glass lens with depth of field: sharp through the glass, out of focus everywhere else.
- Custom AGSL
RenderEffect(uniform shader content):- dome-shaped refraction that magnifies the middle and bends the rim
- chromatic dispersion: the R, G and B channels are sampled at slightly different scales
- a specular highlight, rim light and an anti-aliased edge
- Chained with a progressive blur built with the low-level
BlurRadiusSpec.radialGradient(...).createRenderEffect(size, density)and centered on the lens. RenderEffect.createChainEffect(lens, blur)runs the blur first, then refracts the result. Because the lens samples from its own sharp center, the view through the glass stays crisp.- The lens "squishes" with a bouncy spring while pressed.
Try: drag the lens over the text and grid, change Magnify and Dispersion, and toggle Depth of field.
Modifier.graphicsLayer {
val lens = RenderEffect.createRuntimeShaderEffect(lensShader, "content")
val dof = BlurRadiusSpec.radialGradient(
stops = listOf(BlurStop(0f, 0.dp), BlurStop(1f / 3f, 0.dp), BlurStop(1f, dofBlur.dp)),
center = DpOffset(c.x.toDp(), c.y.toDp()),
fallOffRadius = (lensRadiusPx * 3f).toDp(),
).createRenderEffect(size, density = this, edgeTreatment = TileMode.Clamp)
renderEffect = RenderEffect.createChainEffect(lens, dof.asAndroidRenderEffect())
.asComposeRenderEffect()
}app/src/main/java/com/simform/composeblurredeffectdemo/
├── MainActivity.kt
├── shader/
│ ├── AgslShaders.kt # AURORA, GLOW_BORDER, FOG_MASK, LIQUID_LENS shader sources
│ └── ShaderTime.kt # frame clock for shader `time` uniforms
└── ui/
├── DemoApp.kt # shell: header, tab bar, API-level gate
├── components/
│ ├── Backdrops.kt # AGSL aurora background, procedural CityScene
│ └── Controls.kt # ControlPanel, LabeledSlider
└── demos/
├── EdgeFadeFeedScreen.kt
├── FocusStudioScreen.kt
├── FoggedGlassScreen.kt
└── LiquidLensScreen.kt
The AGSL aurora background (AuroraBackground) is a third use of RuntimeShader: a plain
paint shader drawn with a ShaderBrush.
- Read animated or scroll state inside
blur { }orgraphicsLayer { }, not in composition. It only invalidates the layer.rememberShaderTime()returns aState<Float>for this reason. - Create
RuntimeShaders once (remember) and only update their uniforms per frame. BlurRadiusSpec.shaderconfigurations never compare equal, so hoist the spec withrememberand trigger re-resolution by reading state in theblur { }block.Modifier.blurblurs the composable's own content, not what's behind it. Blur the content layer and draw headers and controls on top of it, unblurred. To blur what's behind a dialog, use theDialogPropertiesblur options instead.- Always plan for window blur being off. Check
WindowInfo.isCrossWindowBlurEnabledand use a stronger scrim when it returns false. - To animate a shader border, update its uniforms in a draw modifier placed before
border. Reading the frame clock there redraws the border each frame without recomposing.
- Android Studio with AGP 9.5+, JDK 25 (the bundled JBR works)
- Compose BOM
2026.11.01(Compose UI 1.13.0) compileSdk37.2. Compose 1.13 requires compiling against API 37.1+:compileSdk { version = release(37) { minorApiLevel = 2 } }- Runs on Android 13+ (API 33). minSdk is 24; older devices see an explanation screen.
Performance note: these effects are GPU work. On an emulator using the SwiftShader software renderer, a shader-based blur frame can take seconds. Use a physical device, or start the emulator with
-gpu host, to see the animations at full frame rate.




