06.20 · 3D & Advanced

Depth-Map Photo

A flat photo turns 3D as you point: near parts shift more. Best for hero images.

Hover it

Move your pointer over the picture, drag a finger across it (or Tab to it and use the arrow keys), or press Show me.

Try it

Change a setting, then try it again or press Show me.

Depth strength

How far the near parts slide against the far ones.

The gray picture behind the effect: white is near, black is far.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add a depth effect to [the photo you want to bring to life]. Make a grayscale depth map the same size as the photo, white for near parts and black for far ones, and blur it slightly. Draw the photo with a WebGL shader that reads each pixel from a spot shifted by the pointer's position times that pixel's depth, so near parts move more than far ones and the flat photo looks three-dimensional. Zoom in a little so the edges never show, and let the view glide toward the pointer and back to the middle when it leaves. On touch screens, dragging a finger should do the same. If the visitor has reduced motion turned on, keep the photo still. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Hero images
  • Portfolio photos
  • Travel stories
  • Album art

Avoid on

  • Photos with text
  • Small thumbnails