U.ZU Lab Notes

Implementation techniques / Part 31

Turning a single illustration into a walkable 2.5D scene: the back-projection math

Reconstruct depth from one illustration using disparity and back-projection, then validate it at the original viewpoint and the limits of camera travel.

Languages
On this page

I wanted a single title-screen illustration to become a scene you could walk through. For IKEBEROTH’s title screen, I converted the illustration into a space with depth and let a character walk within it. The first problem was easy to spot. The scene had depth, but moving the viewpoint even slightly made silhouettes stretch and buildings warp like rubber.

Separate the depth problem from the geometry problem

I traced the distortion to 2 areas: how depth was assigned and how the geometry was built. A single continuous surface stretches the texture across depth discontinuities. I therefore used back-projection from the original illustration’s camera as the common basis for reconstructing the scene.

Move the viewpoint in a single illustration
  1. Source artworkPreserve the locations of points in the image
  2. DepthConvert disparity to depth and back-project
  3. ValidationMove left and right and check silhouettes and gaps

Here is the procedure. First, divide the source artwork into a grid and assign each point a disparity d. Compute depth as z = 1/(1/far + d×(1/near − 1/far)). This interpolates in inverse depth between near and far, giving finer depth resolution near the camera and coarser resolution farther away. Vertex positions are ((2u−1)·aspect·t·z, (1−2v)·t·z, −z), where t = tan(FOV/2). The working example uses a vertical FOV of 38 degrees, a 360×204 grid, near = 4.5 and far = 160. First check that the silhouettes match the source artwork from the center viewpoint. Any later tuning is wasted if this check fails.

Color artwork, depth, region mask and title screen

Color illustration of the waterfront town
The waterfront color artwork. This composition and these silhouettes are the reference at the center viewpoint.
Grayscale near and far depth image for the waterfront scene
The matching depth asset. It lets us assign different depths to foreground and background features.
Waterfront region map marked in red, blue and green
The region mask for the same scene. It lets us handle boundaries and the water surface separately.
The IKEBEROTH title screen with the waterfront town in the background
The IKEBEROTH title screen. The composition combines depth in the background with the title overlay.

Back-projection and boundary handling

There are 3 ways to prevent stretched silhouettes. Split geometry at sharp depth boundaries so the surfaces do not connect across them. Cut out conspicuous occluders with dedicated masks and make them separate surfaces. Paint in the hidden background and place it on its own surface farther back. Use projected UVs for broad planes. Limit drag input to small camera translations: ±0.38 horizontally and ±0.17 vertically in this example. Adjust the travel range and crop before missing areas become visible.

For walking, define a walkable polygon on the original artwork. Place the character’s feet at the intersection of the ray from the current camera with the walkable surface. Depth alone did not produce a character size that looked right next to the buildings. In practice, I set size references for each city block and interpolated between them.

The waterfront title sequence

The IKEBEROTH title sequence. A short clip of the waterfront background in motion, without audio. 8 seconds.Open the video directly

Check walking against the source artwork

With disparity normalized from 0 to 1, first check both ends: 0 is the far end and 1 is the near end. After changing the formula, confirm that the projected features line up with the artwork at the center viewpoint. Then move left and right to inspect the boundaries. A fixed test order makes it easier to distinguish projection bugs from gaps where the original artwork had no hidden surface information.

Choosing near and far takes some tuning. Set near too low and small disparity changes make foreground depth swing too far. Set far too high and distant buildings flatten onto a single plane. A finer grid makes silhouettes smoother, but gives you more places to assign disparity incorrectly. I prioritized matching the center viewpoint before increasing resolution. Deployment has a fixed order too. Publish the assets and code first, then the entry HTML. Putting the entry point live first can expose a broken scene while the upload is still in progress.

To verify the result, take the same view at the center and at both travel limits. Use a bright background color to expose holes and gaps. The guiding principle is to reconstruct the original camera numerically. Once you have the camera, you can use the math to bring the rest of the scene into alignment.