kakaki soft

// MAKER'S JOURNAL · 6 min read · Krzysztof Pliszka

I'm Learning Blender

In My Stables, horses and other animals now have 3D models made in Blender. I don't sculpt them with a mouse, though. I describe them with numbers in scripts. Here is what I'm learning and how the game grows version by version.

Why Blender at all

In my previous post I wrote that the little people in my games are not made in a 3D program but in code. That is still true for most of the characters. A little person built from balls, rounded boxes and capsules (cylinders with half-spheres on the ends) looks friendly. For horses, though, that method fell short.

A horse built from capsules looked stiff, like a toy made of blocks. And a horse is muscles on the shoulders and hindquarters, a neck that flows smoothly into the body, big eyes, nostrils, ears with an inner side, a mane in locks and a long tail. Simple shapes can't do that well, so I started learning Blender, a free 3D graphics program.

To avoid misunderstanding: I am learning it, but I don't sculpt by hand in it. I make games alone, in my spare time, and My Stables has eight horse breeds, foals, cows and deer. Sculpting each by hand would be more than I can manage. But Blender can be driven with Python scripts. So I write a description of an animal, and the program does the rest.

How it works, in simple words

Imagine modelling clay. You make a horse from a few balls and rolls, then smooth the places where the pieces touch, until you have one lump. In a script I do the same, only with numbers: how thick the neck is, how long the head is, how strong the muscles are. Blender merges these shapes into one smooth body, with no seams and no parts poking through each other.

Then comes simplifying. The surface of a model is a mesh, a great many tiny triangles. More triangles look nicer but are heavier for a phone, so Blender reduces their number while the shape hardly changes.

I make every model at two levels of detail:

  • a precise one for close-ups, such as the camera right behind a rider;
  • a simpler one for everyday play, with a dozen horses on screen.

From a distance nobody notices the difference, and the game runs smoothly. At the end the model is saved as a small, compressed file that the browser loads when the game starts. A cow model is about 80 kilobytes and a deer about 62, less than many photos.

The horse tack is made automatically too. The saddle pad, girth and leg wraps are "shells" made on the horse's surface, so they fit every breed. All my rules live in the scripts, so I can run them again whenever I change something.

What I've learned, or my mistakes

Learning is largely a list of blunders.

Lumps and "shields". Where two shapes join, for example the neck and the body, ugly bulges like to appear. Once the hindquarters were pulled along by the tail in a trot, and a lump formed under it. Another time the end of one shape stuck out of the neck like a needle.

Finding them by counting, not by eye. By eye it is easy to miss something when you look at the same model for a long time. So I check the shapes with numbers: for every point of the mesh I work out how far it sticks out from its neighbours. Where it sticks out too much, there is a bump. Then I look at that spot up close.

A reference picture next to the render. For the stable hand I have a reference picture, and next to it I render what came out of Blender. A render is an image calculated from the model. I compare the two and fix the differences. They gave me notes I keep written down:

  • the shoulder and the sleeve should form one smooth line, with no boxy shoulders;
  • the head should be round, with big eyes and a spark of light in them;
  • the sole is part of the boot, not a separate block;
  • the elbows are slightly bent, because stiff arms look odd.

I also fixed the skin colour. The reference had a warm peach, and my render came out pale, because the colour toning in my preview differed from the game's. Once I matched it, the colours agreed.

My Stables, version by version

I make the game in small steps. Each version brings one concrete novelty, and before release I check it with tests that run the game without a window and make sure nothing breaks, for example old saved games.

Lead the Horse (version 0.9.0). The biggest step. The player can ride a horse in the view from behind, with the keyboard or by touch. You have your own character: the stable owner or the owner's child, with a look you set up in a menu. The child learns like the pupils, in a learning mode with the instructor's instructions. There are jumps, and at competitions you can enter yourself with "Enter yourself". There is also brushing and washing the horse up close, and riding around the stable, through meadows and forest tracks, past cows. The child rides out only with an instructor. The game gives no expert advice, and nothing bad ever happens to the horses.

Then came the versions with models from Blender:

  • 0.9.1: new models of all eight horse breeds, with saddle, bridle and leg wraps;
  • 0.9.2: a new stable hand, in a chibi style, with hands that have fingers;
  • 0.9.3: the player's character travels with the saved game between devices;
  • 0.9.4: foals, a horse rug and sleigh harness;
  • 0.9.5: cows and deer.

The horses now come from Blender, but I kept the old code generator as a backup, in case a model fails to load. I also recorded a new trailer on the new version.

Cows and deer: many animals in one go

Cows graze and deer leap on the meadows around the stable, so there can be many animals. I made one model per species, and the game draws many copies at once, each in a different place. For the graphics card that is one job, not dozens.

The graphics card also calculates the movement. Cows swish their tails and take turns grazing, and deer run away in leaps. The model carries "weights" that tell how strongly each part moves: the tail when swishing, the head when grazing, the legs when running.

The cows are spotted in several variants: different layouts of patches, black or brown. All of them sit in one model, and the game picks a variant for each cow and remembers it.

Here I hit a wall. A graphics card in a browser accepts only a limited amount of data for each point of a model, and the spot variants used too much. I had to "pack" them, squeezing several values into one. Then everything fit.

What's next

I would like the next characters, meaning riders, children and other roles, to come from Blender too, but for now only the stable hand does. I'm still refining the hands, the hardest part. I don't promise dates, because I do this in my spare time, for fun.

The most important lesson: even a new tool can enter a game in small steps. First one horse, then eight breeds, then foals, finally cows and deer. At every step something breaks, I fix it, and move on.

These games are made after hours, just for fun, by one person: Krzysztof Pliszka (kakaki soft). About the studio →

More journal entries