itch.io is community of indie game creators and players

Devlogs

Character Customiser

Naughty Teddies Invade the Museum
A downloadable game for Windows, macOS, and Linux

Two decisions made early in the project came into conflict. First, I decided I wanted to draw animated textures for the main character's face. Later, I decided I wanted players to be able to customise how their character looks.

Do you see the conflict?

Having drawn (and implemented with code and keyframed animations in Godot) the textures, changing colours became far from trivial. Changing colours meant creating whole new sets of textures. To make the animations work, the mouth had one material, the eyelids another, and the rest of the character a third material. For each change of skin colour I would have to make 3 new textures. Because skin and clothing colours are on the same material, for each change in outfit colour, I would have to make a new texture for each skin colour.

I also wanted to provide 2 kinds of lips and 2 kinds of eyelashes for people to choose, which meant producing two mouth textures and two eyelid textures per skin colour.

I decided that 3 skin colours x 3 outfit options was an acceptable compromise between not letting the player customise their character and not having to make a million textures.

All in all, I made 29 textures to provide 3 skin colours, 3 outfit changes, long and short lashes, and 8 eye colours (the eyeballs are on a separate material, so options provided there didn't mean changing other textures too).

I wasn't too happy with the compromise, but working solo in my spare time, I wasn't prepared to throw away a lot of work on this project (which I was quite eager to get finished), so resolved to do better next time and plan ahead to give players better customisation options.

I got on with making the rest of game, quite settled on the decision. Until last week, when I saw a tweet by @tha_rami calling distinct skin colour options a fail. Oh no! This is my first real game, which I've worked long and hard on, and while I feel I could justify my limitations, the thought of Rami shaking his head at my game made me take another look at it.

I've had the last week off work, and wanted to use the time to finish the game, so I started digging into Godot to see if I could find a solution that didn't involve having to redo a lot of early work (which could have messy and time-consuming repercussions).


What I really needed, was a way to generate textures within Godot. And it took a week to figure out and implement, but I've done it!


On the Character Customisation scene, I added a ViewportContainer with 4 viewports - 1 for each material - and hid it, so it doesn't display, but is still updating.
Then I made a skin colour gradient, an eye colour gradient, and a full spectrum gradient for the clothes, with a slider for each item you can change the colour of (the way I'd UV unwrapped the character meant that the shoes, t-shirt, watch strap, and the bobble on the hat all had to be the same colour).

The viewports are set to the texture size, and each have a colour plate which can be changed to the colour picked from the gradient, with my drawn line work on a clear alpha background on top. When the player moves the colour slider, the colour plate is updated and the viewport takes a screenshot, which it then sends to the relevant material as its albedo texture.

A problem that stumped me was how to save the generated textures so that when the player loads their user file all of their customisations are still there. I tried a range of solutions before realising it wasn't necessary!
Because the Customisation scene is part of the User Select scene, it gets loaded every time the player selects their file to play. The best solution was to save the colour values and slider values to the user save file and generate them fresh when the player selects their file. The images are only ever stored in RAM, so they never touch storage and I don't have to worry about creating junk on the player's disk. At the end of the session, the images are cleared from memory, to be generated again when the game is loaded.

Also, because the Viewports are only in the User Select/Customisation scene and not in the Player scene being used as a RenderTexture, those extra draw calls are only happening on the menu, not affecting the performance of the game.

Download Naughty Teddies Invade the Museum
Leave a comment