# Exploring WebGPU on Android: Turning a 2D Image into a 3D Relief with Jetpack Compose

DevFeed: [Exploring WebGPU on Android: Turning a 2D Image into a 3D Relief with Jetpack Compose](<https://devfeed.tech/articles/exploring-webgpu-on-android-turning-a-2d-image-into-a-3d-relief-with-jetpack-compose-91131.md>)

Original publisher: [Read original article](<https://proandroiddev.com/exploring-webgpu-on-android-turning-a-2d-image-into-a-3d-relief-with-jetpack-compose-8cd60b655860?source=rss----c72404660798---4>)

Author: Samuel

Published: 2026-10-20T16:26:21Z

Content type: tutorial

Language: en

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

Topics: [3D rendering](<https://devfeed.tech/topics/3d-rendering.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [shaders](<https://devfeed.tech/topics/shaders.md>), [Image processing](<https://devfeed.tech/topics/image-processing.md>), [Android](<https://devfeed.tech/topics/android.md>), [Image](<https://devfeed.tech/topics/image.md>), [3D](<https://devfeed.tech/topics/3d.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [3d-image-rendering](<https://devfeed.tech/tags/3d-image-rendering.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [compose](<https://devfeed.tech/tags/compose.md>), [gpu](<https://devfeed.tech/tags/gpu.md>), [image](<https://devfeed.tech/tags/image.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [shaders](<https://devfeed.tech/tags/shaders.md>), [webgpu](<https://devfeed.tech/tags/webgpu.md>)

## AI overview

The tutorial describes an Android app that renders a photo as a GPU-drawn 3D relief: brighter pixels become higher terrain and darker pixels lower terrain. Kotlin scales the image to a 64 x 64 grid, converts pixels to normalized BT.601 luminance values, and embeds those heights in WGSL shader code. The vertex shader derives a triangle mesh from vertex indices and applies an isometric projection; the fragment shader colors low, middle, and high areas navy, teal, and near-white. Jetpack Compose hosts the WebGPU surface and UI, while coroutine cancellation triggers GPU cleanup. The example uses AndroidX WebGPU 1.0.0-alpha06 and Coil, requires a physical Android device with API 26 or higher and a modern GPU, and cautions that the WebGPU library is still in alpha, so its current version should be checked.

## Source excerpt

This image is AI generatedOverview In this tutorial, you will build an Android app that turns an ordinary photo into a 3D landscape. Bright areas of the image rise into hills, dark areas sink into valleys, and the result is drawn directly on the GPU using the AndroidX WebGPU library and Jetpack Compose. How it works The whole technique rests on one rule: the brighter a pixel is, the higher it sits. The app processes an image in five stages: The user picks an image from the device. The image is resized to a 64 x 64 grid. The brightness of each pixel is calculated. Those values are stored in a height map. A shader reads the height map and draws a 3D-looking surface. Two small GPU programs, called shaders and written in WGSL (WebGPU Shading Language), do the drawing: The vertex shader decides where each point of the surface appears on screen. The fragment shader decides what color each pixel should be. Project files The app is split into three files, each with a single responsibility: WebGpuRenderer.ktImage processing, shaders, and GPU drawingWebGpuSurface.ktConnects Compose to the renderer and manages the drawing surfaceMainActivity.ktThe UI: pick an image, preview it, and tap Generate 3DPrerequisites Android Studio with Jetpack Compose support Basic knowledge of Kotlin and Compose A physical Android device (API 26 or higher) with a modern GPU No previous graphics programming experience is required. Step 1: Create the Project and Add Dependencies In Android Studio, select File -> New -> New Project and choose the Empty Activity template. Set the Minimum SDK to API 26. Open your module's build.gradle.kts and add the WebGPU library and Coil (used for the image preview): dependencies { implementation("androidx.webgpu:webgpu:1.0.0-alpha06") implementation("io.coil-kt:coil-compose:<latest-version>") } Sync the project. Create two new Kotlin files next to MainActivity.kt: WebGpuRenderer.kt and WebGpuSurface.kt. Tip: the WebGPU library is still in alpha. Check the AndroidX Web