July 15, 2022
A few months ago the whole NFT craze blew up, the block chain market became saturated with pixel 2D art everywhere, while it was selling for crazy money,
What caught my curiosity was how artists were able to create 10,000 unique images so quickly?
So i decided to embarked on a small experimentation journey to try figure out how to generate 10k images myself.
after a lot of research, it turned out that generated random images was the easy part,
It was simply a collection of folders like hats, glasses, eyes, etc,
Python utilized a series of for loops to construct the image from the directories (i used pythons PIL package to help me composite the images), layer by layer, much like Photoshop layers,
the background would be first, the characters outline would be second, eyes 3rd, sunglasses 4th etc, They were combined to create a final, singular image,
the directories looked like this:
I assigned numbers at the beginning of each directory
Python would first sort the directories in the order i want the layers to be layered onto each other, for every directory python looked into,
there would be a bunch of basic asset layers that i created, all the naming kept simple ( 1.png, 2.png, 3.png etc ) i kept the naming simple like this because i needed python to randomly choose an image from everyone of the directories,
Python first counted the number of .pngs in each directory, then ran its random function to return a random number betweem 1 and the amount in that directory,
and whatever number it returned, would be the chosen png number.
The simple process for creating each image was as follows
python loops through all the directories in order
list and count the amount of pngs within the specific directory
then run pythons random function to choose a number betwen 1 and the amount of pngs within the specific directory,
once it is chosen it gets appended into a list of all the paths of chosen .pngs that will create the final single image using PIL.
It randomized every layer to create a "unique" image.
This was a very fun learning experience for me,
its just a bunch of for loops and pythons random choice functions, iv taken this script further and rebuilt a more complex version in Houdini that allows grouping of certain assets with each other,
so you could have races and sub races of that race for example, and i have added animation layers for the 2D version in Houdini.
here is an example of the 2D animated version im doing test runs on, it is 10 (can be as much as you want) unique images that have 1 of 3 animations added to it as a test,
every 25th frame Houdini plays one of these images with animation, once rendered out as a .png sequence, a separate script would convert each 25 frame increments as a .gif with a name that corresponds to the .json files that got generated duringrandomization,
It took me awhile to figure out how i could add animation to every image while telling Houdini to assign it to every 25th frame so that it updates in the view port, but it works and has a lot of fun potential.
PS -
We at Arcade Studio just finished working on a 3D NFT project called koolkidz.
I was responsible for building the generating tool in Houdini and a few command line tools to get this project out,
generating 5000 unique characters was a very challenging project but worth it in the end! check them out, they release on the 7th of march 2022 – https://opensea.io/collection/koolkidz-ac