Blender, Godot, and My Own Damn Stupidity
Foreword⌗
I have recently spent a good deal of my time working on a clone of the (now defunt) onu.gg and eights.io websites. Two days ago, I decided that I’d like to try my hand at making the main menu a bit more interesting to look at, and decided that animating a simple loop to tile across the screen would be an okay way of going about that. As you will read below, this ended up taking far more time than I had origninally thought it would – mostly due to my own stupidity. Being the ever-pragmatic person that I am, I then decided to cash my sunk-cost in by ranting to my friend with the dramatic flare of a wizard whose finally gone and lost it.
When I started this blog, I didn’t really intend to post things like this, but this was exceptionally fun to write, I feel that it is a better representation of me than everything I’ve put on here so far, which sounds witheringly flat by comparison. I hope that you, whoever you may be, enjoy reading it as much as I did writing it.
Spade: Legitimately afraid to open source ono! now
Spade: Scores of internet men are going to laugh at me for this one
Cameron: (the embarassment)
Spade: [a picture of fifty-nine imported PNG assets in Godot, accompanied by fifty-nine manually set sprite frames]
Cameron: AHAHAH
Cameron: you poor bastard
Cameron: surely godot could’ve read some animation asset dumped from blender, no?
Cameron: (that’s a some-other-time problem)
Spade: So, you see, this is a sane assumption to make. This is the assumption of a reasonable man. I consider myself a reasonable man. I made this assumption.
Spade: Forsooth, today we both play the role of the fool
Spade: Allow me to regale you with my tale; the tale of the path I treaded today
Spade: T’was about two hours and thirty minutes past noon, and roughly about the same amount of time since I rose from my slumber
Spade: I found myself working feverishly, intent on fulfulling the promise I made to myself the night prior. Today, I would actually get work done
Spade: At this point I had labored for quite some time in Blender – as amateurs are wont to do – in an effort to produce a rather simple animation
Spade: It came time for the Blender to yield to me a concrete render hewn of my raw thoughtstuff, but before granting me the fruits of my labors, a question: MP4 or PNG?
Spade: Most inauspiciously, I opted for the MP4 format, and thrust it into Godot
Spade: Alas, Godot has no way to display an MP4 as a 2D Sprite, and, much to my chagrin, it will refuse to import an MP4, even to use for an Animated 2D Sprite!
Spade: Frustrated, but unshaken, I return to Blender at bid it compile for me the PNG rendition of my Art
Spade: Herein lies my second blunder: Blender outputs every frame of an animation as its own file when asked to produce a PNG render. I had originally thought I was going to be given a spritesheet
Spade: By now, I am somewhat disgruntled, but still unshaken. I figure that, at least this way, I can just make a GIF and cast that into the unholy abomination that we refer to as Godot
Spade: What nobody seems keen to tell you is that the “cannonical” way of weaving a GIF from the raw PNGs that Blender spits out involves GIMP
Spade: GIMP is incredibly fucking stupid. Until today, I didn’t even know that GIMP was capable of making GIF files
Spade: I wish I still didn’t know that GIMP was capable of making GIF files
Spade: For you see, my good Cameron, Blender exports every frame with what GIMP likes to call a “Zero-zero offset.” By consequence, each frame I loaded into GIMP required manual confirmation of whether I did or did not want to use this offset.
Spade: This simple animation, for the record, is fifty-nine frames in total
Spade: Now, here I have something to confess: I lied when I told you of my second blunder. Between you and I, it was actually my third
Spade: My true second blunder was that I was trying to put a GIF into Godot in the first place
Spade: FOR YOU SEE, MY GOOD CAMERON, THAT GODOT DOES NOT KNOW WHAT TO DO WITH A GIF FILE
Spade: IT HAS NEVER EVEN HEARD OF THIS “GIF” FORMAT THAT YOU SPEAK OF
Spade: IT DEMANDS THAT YOU TAKE YOUR PAGAN ANIMATION FORMATS ELSEWHERE, FILTHY HERETIC
Spade: And so, I took a deep breath… And boiling, but not shaken, I continued on
Spade: A sprite sheet, I pleaded. Surely, a sprite sheet would suffice. I could simply throw it into the Animated 2D Sprite node and be done with this whole thing
Spade: The cruel god Godot splits a malevolent grin: “Indeed you can,” he says, “indeed you can.”
Spade: And so I lace together a tapestry fit for this divine tyrant, and he dons it. Alas, my shader, my tiling shader… It tiles the whole damn sprite sheet
Spade: FOR YOU SEE, MY GOOD CAMERON, THAT ANIMATED 2D SPRITES ARE NOT ACTUALLY A COLLECTION OF PICTURES IN ACTUALITY, BUT MERELY A WINDOW INTO A SUBSECTION OF THE IMAGE, MUCH LIKE A CLIPPING MASK IN PHOTOSHOP
Spade: MY WHOLE FUCKING SCREEN WAS FILLED WITH THE ENTIRE FUCKING SPRITE SHEET REPEATING AD-INFINITUM
Spade: At this point, I am veritably livid. I thrash and I flail against the digital chains I’ve forged for myself, I curse the wretched sourcerers that gave rise to Godot…
Spade: And in my fit of agony, I stumble across the glint of something brilliant. My baby rage subsides, and I lean in to more thoroughly inspect that which I have stumbled upon
Spade: I click around, and almost immediately, the enormity of what I’ve found become apparent to me
Spade: Spectacular. Terrible. Powerful.
Spade: For you see, my good Cameron, a regular 2D Sprite is capable of accepting an “animated texture” resource – but, like all things of the digital realm, this power will come with an equally devastating cost
Spade: Firstly, in order to construct an animated texture resource, one cannot use a spritesheet, but must instead use individual pictures for every frame
Spade: Secondly, and much to my chagrin, there is no automatic way of crating an animated texture resource; after defining the number of frames your animated texture possesses, you must manually assign each frame its image and duration
Spade: I will reiterate: my animation contains fifty-nine frames in total
Spade: After ten minutes of work and an eternity of a prelude, my labor comes to an end
Spade: I look down at my keyboard and feel that it is a bloodied knife. It bears the sin of what I’ve done here today: the destruction of effeciency, the disregard for disk space, and the affront against my own sanity
Spade: At least the main menu background is animated, though