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.
Inside, the left part shows the depth map (white near, black far); each spot shifts by its gray, so near parts move most. Faint lines show where everything stood facing straight on.
One flat sheet slides the whole picture the same amount, so it stays flat; With depth shifts each part by its gray, so it looks deep. Point at With depth 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.
Your settings
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 GitHubWhat it is
The full explanation is in README.md.