Hello everyone,
This week end I've been working on automating the rendering process for the creation of the Titan dogs NFTs.
This includes the following steps:
- Creating a JSON file of 10,000 unique Titan Dogs.
- Verify rarity of attributes.
- Render each element of the JSON list into Photoshop.
- Save as PNG file in dedicated folder.
Lots to do right? But very exciting tasks! And we're getting to the end of the NFT generation phase.
So, as planned, I started with the JSON creation.
I first created a smaller file with a list of all attributes and their corresponding rarity.
I completed it with my design rules in mind.
Those rules being:
- Only one pattern possible per titan.
- Only one base color possible per titan.
I originally wanted the background to be one of the main colors currently applied but changed my mind along the way.
With this set of attributes I then looped through them, taking into account the rarity. I made sure to shuffle the created titans after each attribute was added for a better mix.
After a successful attempt with 100 titans, it was time to generate the 10,000 unique variations! And then...
Crash!
Turns out my computer is not built to make loops 10,000 times. Who would have thought. I opted for another method, 10 loops of 1,000 titans. I added color randomness along the way so no tokens are the same.
I added them all into one file to loop through it in the next phase.
I checked rarity by counting the number of titans which feature the same color on all parts. I could verify that the randomness I added did not mess up with the overall color rarity.
Now came the time to take that list of titans and script commands for Photoshop in order to hide/show corresponding layers.
I faced trouble on my very first task: hiding all layers.
I had originally create a series of loops that would trickle down the Photoshop DOM (document object model, basically the document structure) hiding layers as they go. But this script would take at least 5 minutes to complete. Sometimes I even ended the whole process thinking it had crashed.
I simply could not spend so much time hiding all layers, because I would have to do it 10,000 time for the renders down the line.
To resolve this I ended up using something called "Action reference" instead of cycling through the layers. With this method I was able to gather all Ids of all layers, select one after the other, then set the visibility to false. Not sure why this technique was so much faster but it worked. I could move on to showing the correct layers now.
This part took less time, but I did do some tweaking by the end as some groups and layers in Photoshop had slightly different name or position. It only works if all attributes share the same layer structure.
Below you can see the first attempt that didn't render the dog, nor the colors...
And finally, the magic happened (After debugging...)
The very first Titan Dog rendered automatically! You can see one arm with not pattern to test out the asynchronous pattern generation.
Then I just added a save to PNG file. Easy!
With that out of the way, I launched the render from the 10,000 titan list. And then...
Crash!
Again.
Remember, the machine does not like looping through an object of 10,000 items.
So I tricked it again, made 10 JSON files of 1,000 titans and looped through each one of them. Here we go!
Rendering in progress!
Little hiccup, the rendering time... I can see from the creation date that it takes 2 minutes to render a single image. That means 10,000 images would take... 333,3 hours... or 13.875 days.
Two weeks to render it all. Arg. Frustrating!
I'm leaving the computer on as I don't see any other way but I'll try to think of an alternative in the mean time.
Just writing this article I'm over 50 Titan dogs!

EDIT:
Quick update. I revised my code and the Photoshop layers to use only "Action reference" and I'm up to 10 titans generated per minute! I could be finished in 16 hours...
I'm never using Photoshop DOM again! ;-D
So what is next?
I'll work next on creating the website with the "candy machine" that mints a random Titan.
I'll also plan the road map and the marketing strategy to bring more people over.
I'm still trying to come up with the right price tag for those NFTs. I'll spend some time looking at other project to get inspired.
Anyway, this was two fun days. Can't wait for the render to complete. It's like waiting for the Christmas presents!
On that note, Happy Holidays everyone.
Thanks for passing by,
See you on the otherside,
Jrej
PS: My favorite so far!