Skip to content

Billboards and shadows

The people in the generation-4 and generation-5 DS games are flat pictures. The towns around them are 3D. The two sit together so well that most players never notice. This page explains how: what a character is in the 3D scene, how its picture is chosen, how it stands behind a fence or a counter, and what its shadow is. How a creator adds people is on People and characters.

A character is a card: one rectangle, two triangles, with one frame of a sprite sheet as its texture. It stands at the middle of its cell. The 3D engine draws it like any other polygon: it is lit, it fogs with distance, and the depth buffer decides what is in front of it. The DS has no sprite layer inside its 3D picture, so a textured rectangle is the natural way to put a picture into a scene. It also costs very little: a person is one card and one shadow, four triangles in a budget of 2,048 polygons (see The 3D engine).

There are two ways to stand a card in the world.

A billboard is a card that always lies in the plane of the screen. However the camera is tilted, its rows are the screen’s rows. The generation-4 games draw their people this way. Because their camera is tilted steeply down, a card that faces it leans back over the cell behind the character, rather than standing straight up.

The benefit is exactness: a 32-pixel frame always covers 32 rows of the screen, wherever the character stands, so the sprite’s pixels are shown one to one, never squashed or stretched. The cost is that the leaning top of the card can reach into a wall or roof behind the character, where the depth buffer cuts it off.

An upright card stands straight up from the ground like a cut-out. Seen from a tilted camera it is foreshortened, so it is made taller by the right amount to show its frame at the same size on screen. It never leans into what is behind it. Under a perspective camera, though, a card far from the middle of the screen is seen a little from the side and can look slightly squeezed.

Both kinds are one setting. By default PokeLoom’s cards stand upright, because an original game’s buildings and counters are not drawn around a leaning card. A game whose originals draw billboards sets:

[world]
character_facing = true # cards face the camera, as generation 4's billboards

Three more keys fit the card to a game’s look: character_size (how much of a cell a 32-pixel frame spans), character_dip (how much lower a card is drawn as the camera tilts down) and character_south (how far in front of its cell’s middle it stands). The engine’s defaults are its own look; an import writes the original’s values. Every key is in the game.toml reference.

The engine computes the card’s height from the camera each time the framing changes, so a camera zone or a script move keeps the sprite at its drawn size.

A sheet holds a few frames for each facing: standing, and a step with each foot. The frame drawn is chosen by two things:

  • Facing. The row of the sheet for the direction the character faces. With a camera that always looks north, “facing down” is always “facing the player”.
  • Step. While walking, the frames alternate stand, step, stand, other step, a new frame every few frames of movement. Standing shows the stand frame.

Games differ in how many frames a facing has and in whether one side is drawn as a mirror of the other. That is a layout of the sheet, not a different system: the importer lays each sheet out in the engine’s own layout.

Planned (plan 25): with a camera turned away from north (yaw), the frame takes the turn into account, so a character walking along a turned street shows the right side.

Because cards are drawn by the 3D engine, ordinary depth does most of the work. A character walking behind a house is hidden by the house’s polygons; one in front of it covers them. The cases that need care are the ones where a flat card meets a thin 3D object:

  • Counters, fences, tall grass. The legs should be hidden, the head should not. The world’s pieces are built to stand in front of or behind the card’s plane in the right place, and effect cards (a card of grass blades drawn over the legs) cover what depth alone would not.
  • Doorways. Walking through a door, the top of a tall card would show through the roof above it. The engine stops drawing a character once it is past the wall of the door’s cell.
  • One height for everyone. The rails that hide legs and the shadows are tuned to one figure. PokeLoom holds every person’s sheet to one height and checks it in the build, for this reason.

A character’s shadow in these games is not cast by a light. It is a blob: a small soft texture on a flat, translucent polygon lying on the ground under the feet. It is cheap, it never flickers, and it reads clearly at the games’ size.

The DS draws translucent polygons after opaque ones and blends each with what is already drawn. Overlapping shadows could darken twice where they meet; the hardware can refuse to draw a translucent polygon over a pixel already drawn by one with the same polygon ID, which is one way a game keeps two shadows from stacking.

Details that make a shadow look right:

  • Where it lies. Under the feet, slightly offset, at a small height above the ground so it never fights the ground for depth.
  • By the hour. Generation 4 changes the shadow with the time of day: wider by day, fainter at night.
  • Size classes. Some games give large figures a larger shadow.

Every character casts graphics/shadow.png. A map can turn shadows off with shadows = false in its map.toml, and a sheet can be listed as having none. The shadow’s opacity, width and depth by the hour, and where it lies from the cell’s middle, are [world.shadow]:

[world.shadow]
hours = [6, 12, 19] # each row starts at its hour; the first also before it
alpha = [16, 20, 12] # opacity, 0 to 31
width = [17, 20, 16] # size across, in sixteenths of its own
depth = [16, 17, 16] # size along

(Made-up values for illustration.) Without the table the shadow is the same all day.

Planned (plan 42): on desktop, shadows from the sun’s direction (shadow maps, soft shadows, ray-traced shadows) as a presentation setting. They change only pixels. The DS keeps blob shadows. See Presentation settings.

Over still water and polished floors, the games draw a character’s reflection. It is another card or sprite: the same frame, flipped upside down, drawn below the character in a lighter or bluer palette, and only where the cell below is marked reflective. Nothing is rendered twice; the reflection is one more picture.

In PokeLoom’s tile-map style this is built: a cell marked reflective shows a flipped copy of the character’s sprite, sharing its tiles. In the 3D field it is not yet.

Planned (plan 25): reflections in the 3D field, a mirrored card over cells marked reflective, for characters and the follower. On desktop, a mirrored scene or ray-traced reflections are planned as presentation settings (plan 42).

Generation 5 also draws some actors as small 3D models rather than cards (boulders, vehicles, some set pieces that move), and plays scripted turns and scalings on them.

Planned (plan 25): actors drawn as 3D models, moving as actors do, with scripted transforms.

A game’s characters are a choice of card (upright or facing), a size, a dip and an offset, a shadow and its table by the hour, and later a reflection rule. Platinum’s people and Black’s people differ only in those values, which their imports write. An original game picks its own.