CSS shapes lit as solid objects

The pieces below are buttons and boxes whose outlines come from corner-shape, border-shape and clip-path: shape(). A fragment shader treats each picture's alpha channel as the height of a solid and lights it: the edges are bevelled, and each piece casts a shadow with its own outline. Move the pointer or drag a finger across the panel to move the light. Press the pieces.

0
Admit onecorner-shape: scoop

This paragraph wraps round the button on the left. The button is clipped with clip-path: shape() and its holder has shape-outside with the same value, from one custom property. The shader gets the clipped picture, so the bevel and the shadow follow the curve.

The light follows the pointer. With no input for a moment it moves in a circle.

Show the code alpha → height → light
  1. The markup. Each piece that is lit has fx="solid". The keypad is one piece: its seven keys share a canvas.
  2. The outlines, in CSS.
  3. The shader. Sixteen samples of alpha around each pixel give a height and a slope. The slope is the surface normal.
  4. The light, as two custom properties.
  5. Pressing, as a CSS transition.
  6. The page script. It connects the pointer and the tilt sensor to the two properties.
  7. The tilt sensor.
  8. Inside the fx library: the upload and the draw.

How it works

Live checks

Each check builds its own fixture in a corner of the window. The panel above isn't touched.

ResultExperimentDetail

Findings

From Chromium 157 with software rendering. The rows above say what your browser does.