Blue MoonGraphics

Ink and three bands

Endymion asked for a more cartoony Arcadia. Ink outlines came from two buffers the renderer already kept; flat light bands took a fork of it. Then the outlines in town came out red.

Log 147 min read

Skies of Arcadia already looks like a cartoon you could step into: bright sails, chunky silhouettes, characters drawn with big shapes and clean colours. Endymion thought the style holds up well, but asked whether the port could push it further, toward the cel-shaded look of an anime frame: dark ink lines around everything, and light that falls in a few flat steps instead of a smooth gradient. The console never did this. It’s a new option for the PC port, --cel-shade, and it’s off unless you ask for it.

OffOff. Hans, in the Ixa’taka village, telling the party how Centime’s crew crash-landed.
--cel-shade--cel-shade. Hans, in the Ixa’taka village, telling the party how Centime’s crew crash-landed.
Hans, in the Ixa’taka village, telling the party how Centime’s crew crash-landed. Port captures of the same frame, without and with the option. The text box is untouched.

The ink was nearly free

The port draws through aurora, a library that turns the GameCube’s graphics calls into modern GPU work. To mimic the console faithfully, aurora keeps two pictures beside the colour image of every frame: a depth buffer, which stores how far away the surface is at each pixel, and a buffer of normals, the direction each surface faces. Those two are exactly what an outline needs. A silhouette is a place where the depth jumps; a crease in a model, like the fold of a sleeve, is a place where the facing direction turns sharply. So the outlines didn’t need anything new from aurora. The port takes a snapshot of both buffers once the 3D scene is drawn, and one full-screen pass darkens the pixels where an edge is found.

The depth half has a neat property. The GameCube stores depth in a form where one over the distance to the camera changes in a straight line as you move across a flat surface on the screen. Take three pixels in a row on a floor: the middle one sits exactly halfway between its neighbours. At the edge of a model, the middle pixel is on the model and the next one is on the floor far behind it, so the middle pixel is much nearer than the average of its neighbours. That test needs no tuning for how big the room is, a floor running off into the distance never trips it, and only the nearer side of the edge is inked, so each line comes out one pixel wide on the model itself.

Two panels plot one over the distance to the camera for three neighbouring pixels. On a flat floor the three points lie on a straight line, so the middle pixel equals the average of its neighbours and gets no ink. At the edge of a model the middle pixel is on the model and one neighbour is on the floor behind it, so the middle pixel stands well above the average of its neighbours and is inked. 1 ÷ DISTANCE AT THREE NEIGHBOURING PIXELS A FLAT FLOOR near far left pixel right The middle pixel equals the average of its neighbours: no ink. THE EDGE OF A MODEL near far average model pixel floor The middle pixel is well above the average: ink it.
The test the ink pass makes at every pixel, drawn for this post. On a flat surface, one over the distance is a straight line across the screen; at a silhouette, the middle pixel stands out from the average of its neighbours.

Creases come from the normals: where a pixel’s facing direction turns more than about 50 degrees from its neighbour’s, it gets ink too. The lines also fade out over the far half of the view, so distant scenery doesn’t dissolve into noise.

Ink the scene, not the menus

The menus, the battle HUD, the minimap and the dialogue text are drawn over the 3D scene as flat 2D. They don’t write depth, so if the ink ran at the end of the frame it would trace the scene’s edges right through a text box. The pass has to run between the 3D and the 2D. Reading the decomp, the game’s graphics library (Sega’s Ninja, the same engine as the Dreamcast original) switches between a 3D camera and a flat 2D one through a handful of preset functions. So the port watches that switch, and inks the scene the first time a frame goes from 3D to 2D.

OffOff. The merchant in the Ixa’taka village shop, with the shop menu open.
--cel-shade--cel-shade. The merchant in the Ixa’taka village shop, with the shop menu open.
The merchant in the Ixa’taka village shop, with the shop menu open. Port captures. The menu’s text and frame stay clean; the ink lands on the merchant and the room.

Bands needed a fork

Flat light is a different problem. The GameCube lights in hardware, once per corner of each triangle, and blends the result across the face. That softness is a big part of the game’s gentle look, and it’s also why you can’t simply round the light off into steps afterwards: rounding a blended value just moves the gradient around. The light has to be worked out at every pixel, and only then put into bands. That happens inside the shaders aurora writes for each combination of graphics settings, so the port now carries its own small fork of aurora. With the option on, lit models are lit per pixel and each light falls into one of three flat bands; a shiny highlight becomes a crisp spot. With it off, aurora’s shaders are exactly the upstream ones.

Which models get bands turned out to be the game’s own decision. Reading the decomp, the game never sets lighting per model by hand: every chunk of a Ninja model names its vertex format, and one function turns that format into the light settings. Vertices with normals get diffuse light from the scene’s main light, plus a highlight; vertices with their own colours get that colour lit by the same light; and models with positions only get one flat colour over the whole model. The pre-lit scenery, the sky and the effects aren’t lit at all. So the bands touch just the models the game actually lights: the characters, ships and props. Painted scenery keeps its painted light. (That’s read from the code; the captures agree, but I haven’t measured every model.)

OffOff. The Little Jack beside a floating rock on the world map.
--cel-shade--cel-shade. The Little Jack beside a floating rock on the world map.
The Little Jack beside a floating rock on the world map. Port captures. Endymion’s verdict on this one was that the world map looks pretty good.

The outlines in town were red

The first round of test captures came from a save in the Lower City inn’s basement, the opening battle on Alfonso’s ship, and the world map. On the ship and the world map the ink was nearly black. In the basement it was red. Vyse had a red rim; so did the bench.

Comparing a pixel on an outline with the same pixel with the option off settled what was happening: the green and blue were darkened exactly as they should be, but the red channel was left completely alone, to the last digit. Something was putting the original red back.

The port can log every switch between the 3D and 2D cameras in a frame, with who asked for it. In the field, the first switch to 2D came from a pass the game runs after the scene: it copies the frame’s red channel into a texture, then draws that copy back over the screen as part of the field’s colour treatment. The copy happened before that pass switched to 2D, so it took the red channel from before the ink, and drawing it back restored the original red. Battles and the world map don’t do this, which is why only the field went red. The fix: the ink also runs just before any copy of the whole frame, so the copy carries the ink with it.

OffOff. Vyse in the Lower City inn’s basement with the fix in.
--cel-shade--cel-shade. Vyse in the Lower City inn’s basement with the fix in.
Vyse in the Lower City inn’s basement with the fix in. Port captures. Before it, these outlines were red.

Then the jungle

Endymion wanted to see on-foot gameplay, so the next captures replayed his own play sessions in the Ixa’taka village. Two things looked wrong.

The village is wrapped in foliage made of flat cards with leaf shapes cut out of them by transparency. To the ink pass, every leaf’s cut edge was a real jump in depth, so each leaf was traced against the leaf behind it, and the trees turned into black scribbles. The fix marks the pixels of these cut-out drawings in the normal buffer, and between two cut-out pixels the ink pass doesn’t look for depth edges. A canopy is now outlined where it meets the wall, the platform or the sky, and the leaves inside it are left alone.

BeforeBefore. Vyse running along a walkway in the Ixa’taka village.
AfterAfter. Vyse running along a walkway in the Ixa’taka village.
Vyse running along a walkway in the Ixa’taka village. Port captures, both with the option on, before and after the cut-out fix. The fern behind him lost its scribbles but keeps its edge against the wall.

Hans’s arm was the other one. The top band started at full light, and on top of the ambient light that pushed lit skin almost to white. The top band now stops at 0.8.

BeforeBefore. Hans with the option on, before and after lowering the top band.
AfterAfter. Hans with the option on, before and after lowering the top band.
Hans with the option on, before and after lowering the top band. Port captures.
Port, the opening battlePort, the opening battle. Vyse and a Valuan soldier trading blows on Alfonso’s ship, with the option on.
Vyse and a Valuan soldier trading blows on Alfonso’s ship, with the option on. The damage number and the name tag stay clean.

Trying it

Start the port with --cel-shade for both halves, or --cel-shade=lines or --cel-shade=bands for one. It’s a prototype: 3D that the game draws after its first switch to 2D (effects such as a save point’s sparkle) doesn’t get outlines yet, and I haven’t looked at every corner of the world with it. But the game takes to ink well, which probably shouldn’t be a surprise for a cast drawn this boldly in the first place.