This week, wanting to mix things up, I decided to focus on some superficial random generation. Always fun! So I worked on a random name generator, that I will be using to generate company and product names for the competitors in Software Inc. and an employee generator, which basically means I colorize and combine faces/hair/jackets/pants in to one texture, so that each employee looks a little unique.
The employee style generator, or creepy-on-the-fly generator, is basically a quick shader I wrote for Unity (which can be downloaded here) which starts with a base color, which is the skin color, and then adds layers on top of the base color, each layer being colorized individually. Specifically, the layers I add are textures for the face, hair, jacket (or blouse or what have you) and pants, and each of them has an alpha channel, so that they don’t overwrite the previous layer. I then have a class which keeps track of all the textures for each group and assigns them randomly.
The texture class also has Gradients for the skin, hair, jacket and pants to determine which colors can be used to colorize the textures and, effectively, which colors are more likely, by how much space they take up in the gradient. Gradients in Unity are extremely cool and allow you to visually edit color gradients to use directly in your scripts, I really recommend that you try them out!
The generator is far from finished. If I get someone competent to model the employee, I hope to use BlendShapes to morph the model between skinny/obese and woman/man. Currently, there are only male looks, not because I’m being sexist, but female hair is just harder to model and texture.
My random name generator uses a tree like structure to generate random strings of words. A generator can be loaded from a file with a very simple structure, eg.
Will create a generator that can generate the strings:
Hello Hi Hello. Hi. Hello, you Hi, you Hello, you. Hi, you.
It works by starting from the first node start (nodes are the ones with a hyphen in front of the name), it appends a random string from the list of strings below it (in this case there’s nothing to pick), it then picks a random node from the parenthesis of the current node (which can only be base in this case), and then it continues until it reaches the node stop.
I then have a generator for each type of software and for the companies. It’s a very simple algorithm, and as you can see in the picture above, the results can be pretty dumb, in a good way. The source can be downloaded here.