Devlog

Removing the painted shadows: the characters

Every hero and monster in Diablo carries its shadow painted into the picture. Here's how we told shadow from character in 92,424 frames, and why a black boot on a black shadow kept us busy.

Get down to Hell and the Blood Knights are waiting, black armour in the dark. Look closely at one and you see a knight and a dark patch on the floor. To the game it's one picture: Blizzard North rendered every character from a 3D model and painted its shadow onto the floor of each frame, in the same pure black as the armour:

A Blood Knight swinging his sword, his painted floor shadow marked in magentaThe same Blood Knight as the game draws him, his shadow painted in black
Magenta is what we cut. Tap or click the picture to hide it.

In 1996 that was the cheapest good-looking shadow you could have. For us it's in the way. This post is about the characters: heroes, monsters and townsfolk, with a game for you near the end. Barrels, statues and floors get a post of their own.

Why it has to come off first

A painted shadow never moves. It falls the same way under a torch and in the Tristram sun. In our lighting every fire (torches, braziers, candles) throws a real shadow, so the painted one would be a second shadow, usually pointing the wrong way:

In the game, a Blood Knight beside a fire, with the black shadow painted into his picture pointing back towards the flameThe same Blood Knight by the same fire with the painted shadow cut out
In the game: a Blood Knight by a fire, with his painted shadow still in the picture. Tap or click to take it off, as the game now draws him.

With it gone, the shadow follows the light. Here we swing a fire round the knight:

In the game: a fire swings round the knight, and his shadow turns away from it.

It also gets in the way of everything else we do to a sprite: an upscaler draws boot and shadow as one black shape, and our lighting would shade the shadow as part of the body. So this comes first.

92,424 frames

Four characters on one floor, a Skeleton swinging his sword, the Warrior in heavy armour, lunging, Griswold the blacksmith, a Succubus casting, each with its painted shadow in magentaThe same four characters in the original, their shadows painted black
922files
92,424frames
28 millionblack pixels
A Skeleton, the Warrior, Griswold and a Succubus: monsters, heroes and townsfolk alike carry their shadow painted in (magenta).

That's 26 sets of monster art, the three heroes in 27 looks of armour and weapon each, and the townsfolk: 922 files, 92,424 frames. Every frame needs a mask, a map of which of its black pixels are shadow. We're a small team doing this next to our jobs and families. Going through 28 million black pixels by hand was never an option, so it had to be a method.

How the shadow got there

The shadows all follow one recipe. Take the character's outline, squash it to a third of its height, slant it a quarter of a pixel to the left for every row up (about 14 degrees), and pin it to the ground under the feet:

The knight's outline, squashed to a third of its height and slanted to the left, lying on the floor almost exactly over his painted shadow
The knight's outline, squashed and slanted, lands on the shadow Blizzard North painted. "Show our prediction" lays ours over it in orange, to show how close the recipe gets.

We checked it against all of Diablo's own frames, and nearly every animation fits it to within a pixel or two. Through Diablo's camera, which looks down at 30 degrees, that's a sun about 58 degrees up and 20 degrees to our right.

One surprise: the ground is one fixed row per direction, not wherever the feet are. That's why a bat's shadow stays put while the bat flaps above it:

A bat flapping its wings and bobbing up and down, its painted shadow staying on the same row of the floorOriginal
A bat flying, every frame of it. The bat bobs, the shadow stays on its row.

Now the catch. The shadow is palette colour 0, pure black. So are the knight's armour, the dark outlines around most characters, and every gap between two legs.

The obvious way, and why it fails

If we know how the shadow was made, why not test every black pixel? Squash it the same way. If it lands on black, that pixel casts a shadow there, so it belongs to the character. If not, it's shadow. It's the first thing anyone would try, and it fails three ways:

Here it is on our knight:

The obvious test on the knight: magenta over most of his shadow, black specks of it missed, and bits of his legs takenThe same knight as drawn
The obvious test on our knight, counted on the 1996 pixels: it takes 54 pixels of the knight and leaves 35 of shadow.

So we turned it round: predict the shadow from the outline, and call any black near it shadow. That finds the shadow. It also eats the legs:

  • The prediction alone: magenta covers the shadow and much of the knight's black legsThe same knight in the originalThe prediction aloneOriginal
  • Our cut: magenta covers the shadow onlyThe same knight in the originalOursOriginal
The same knight two ways. The prediction alone finds all of the shadow, and takes 74 pixels of the knight's legs with it (counted on the 1996 art).

On 311 frames we hold the answers for, the prediction alone took about 3,600 pixels of character. The steps below bring that down to about 600.

Step by step

The method we kept, after sixteen versions, is a stack of steps. Not every step helps every frame: on this knight the rules make it worse and the 3D model cleans up after them. The numbers count the pixels still wrong:

The knight after step 0, The shape of the black, the cut in magenta
The original knight
Step 0 of 6: The shape of the black

Where we started: a cut from the shape of the black alone. It takes the legs.

70character cut
0shadow left

Pixels still wrong on this frame, counted on the 1996 art against the answer that ships (step 6).

The Blood Knight from the top of the post after each step.

Follow the motion. Shadow stays on the floor, so black that travels with the body from frame to frame is body. A knight standing still on his shadow gives this step nothing.

Eight views, one pose. Every pose exists in eight directions. A leg lost in the shadow in one view is often in the clear in another.

The Blood Knight's attack pose drawn from eight directions, each with its painted shadow. In some views his legs stand in the shadow, in others they are in the clear.
One pose of the knight's attack, all eight directions as the game has them. Framed: the knight from the steps above.

The rules. Things we learned by looking, written down. A crease in the armour is armour. A lone speck at the edge of the cut goes. A hero's thin black rim against the shadow is shadow, but a knight's we kept as armour, and on this knight that was wrong. The 3D model puts it right.

Spells apart. When a hero casts, we split the fire and lightning off first, so black behind a spell isn't taken for shadow. The knight casts nothing, so here's the Warrior instead:

The Warrior in heavy armour casting a ring of fire, his painted shadow marked in magenta and the black between the flames left aloneThe same Warrior as the game draws him, his shadow painted in black
The Warrior casting fire. The black between the flames stays his.

A 3D model where black stands on black. The Blood Knights, the Succubi and some of the heroes wear black boots on black shadows, and nothing above can tell the two apart. For them we built a 3D model and nudged it until its outline matched all eight views of the character in motion, then let it decide which black is boot:

The 3D model moves with the knight, frame for frame, as the camera swings off the game's view and back. Back on the game's view its outline sits on his pixels: the black boots inside it stay, the shadow outside goes.

Side by side with the method alone, it won on all but two of the 141 frames we compared. It isn't magic: on the heavy Rogue's near-black legs it mostly cut the legs away, so most of her frames keep the method's answer, as does the heavy Warrior when he casts lightning.

The same model now casts the knight's shadow in the game: lit from the side, he throws his profile, not his picture stretched sideways.

A second look. Before any of it reaches a person, AI agents go through the animations one direction at a time, flipping frame to frame as you would through a flipbook. They hunt for the error we kept running into while painting fixes by hand: a leg found on one frame and half missing on the next, which in the game shows up as a flicker at the knee. So an agent starts each direction on the frame where the character stands clearest, before the spell is cast, and builds every next frame on the one it has just fixed. A leg keeps its place from the frame before and takes its width from what is drawn on its own frame. Without that second half, legs grew a little wider with every frame until the Warrior walked on planks. Of the first casts we checked, eight went back to the agents with notes, three of them for a leg broken at the knee. In all they corrected 2,401 frames across the cast of characters. On the 137 spell casts that flickered worst, they gave back 22,325 pixels of boots and shins and took 7,319 more of shadow, and the black that changes from one frame to the next fell from 9,428 pixels to 2,095.

A human eye. Whatever is left, we fix by hand: more than a hundred frames, over seven rounds, in a little pixel editor, and every fix stays when the method runs again. Our random spot checks found most frames needing nothing, so for one round the method picked the 60 frames it was least sure of, and 59 of them needed a fix. Its doubts point at the right frames.

Your turn

Think you can do better? Pick a difficulty and paint the shadow. Your brush paints the character too, so mind his boots. Check counts the shadow you found and the character you cut.

A Flesh Clan goat man attacking, as Diablo (1996) draws it with its shadow painted in black, and the same frame with the shadow in magenta

The game needs JavaScript. Here is one frame as the game draws it, and the same frame with its shadow in magenta.

Raw frames of Diablo (1996), enlarged, five to a round, every answer checked by a person.

Watch the 26-second version of this post:

If you spot a shadow we missed, or a boot we cut, tell us on our Discord. Brutal Diablo is free and coming early 2027.

Thanks

To Blizzard North, who painted every one of those shadows, and the knights' boots in the same black. To the DevilutionX folks, who keep Diablo running today. To our supporters on Ko-fi, and to everyone leaving a heart or a kind comment under our posts.

Donate

Brutal Diablo will be free once released. Throw a coin and it goes into dev time, GPU hours and coffee.

This mod is a love letter to the original game, so nothing here is for sale. But every donation really helps us keep the development going. Thank you.

Donate on Ko-fi