RED DESERT - How I recreated the Minecraft Acid Interstate
Jan 11, 2024Introduction
At some point in 2021, I came across a video on YouTube, titled 'Minecraft Acid Interstate V3'. I don't know why I found it so fascinating, but I did, and I found myself going back and watching it again and again. After a while though, I became even more fascinated with how the hell it worked, and so at some point in 2022 I decided to try and make it myself. I downloaded a random shaderpack (probably BSL), as well as the 'Acid Shaders', a shaderpack designed to give similar effects in any save file. At the time, I had no idea how the hell a shader worked, so instead I just copypasted the code from the acid shaders into the top of the main()
function of the files with the same names in BSL. It didn't work, of course, and so I promptly gave up and went back to doing whatever the hell I was doing in 2022.
Learning Shaders
Of course, I still went back to this video over and over again, and in summer 2023, I decided that this time would be different. This time I would learn how to make shaders. After some googling, I found the shaderLABS Discord, and from there, this tutorial. The first thing I did was flip the screen and invert the colours, which was simple enough.
After that, I tried making a box blur effect, which rendered nothing and froze my game.
A bit further into the tutorial, I got the hang of vertex shaders, and made a couple of effects you might recognize...
I continued the tutorial, made an attempt at adding shadows and lighting as described, couldn't get them to work, and left it, deciding that I would start work on an actual video once I had moved back to university.
Getting Started
After a few weeks back at uni, I got stuck in again, and after modifying BSL's shaders to add a simple rotation effect, I turned to the matter of how I would actually record the video. The original Acid Interstate videos all use a mod called Minema, but I decided I would make a point of using a modern version of the game, and do it on Fabric instead of Forge. Why? I don't know, I guess I just wanted to do things differently. To this end, I settled on the Replay Mod for recording, and after a bit of setup, I managed to put together my first proof-of-concept.
Now, you'll notice a couple of things. First of all, there's holes in the terrain. Second of all, there's a portal at the end. The holes in the terrain are because I hadn't disabled a feature of Minecraft called 'Frustum Culling'. What this does is choose not to render stuff which isn't visible to the player. Since in the vertex shader we are moving things around, stuff which was out of view is now in view, but still isn't being rendered. This was a pretty easy fix though, as a setting can be toggled in the shader.properties
file.
Portal Problems
The portal, however, was a bit more complicated. This portal used the immersive portals mod, but you'll notice that it doesn't rotate with the rest of the terrain. It turns out this is a feature that simply isn't supported in the mod, and the developer doesn't think it's worth the effort implementing, which is fair enough. I briefly considered trying to fix the mod myself, but after about 5 minutes staring blankly at the source code, I decided I had no idea what I was doing. Instead, I went back to YouTube, and found that in the description of Minecraft Acid Interstate V4, there was actually a GitHub repo with the shader code used in that video. I didn't find it to be much help though, and even now, having implemented the portals myself, I don't understand that code.
At this point, I was a bit stuck, but at the suggestion of our favourite recurring side character Mika, I opted to simply ignore the problem and not use any portals in my video. With that decision made, I got to work modifying Sildur's Vibrant Shaders (chosen because it's the only one I could get to work where the water doesn't look awful when distorted a lot), and soon encountered my second problem.
Terrain Troubles
If you look at the original Minecraft Acid Interstate videos, you'll notice the portals take the player from biome to biome seamlessly. This meant I had to get chunks of different kinds of terrain into one Minecraft world. In the past when editing Minecraft worlds I had used a piece of software called Amulet Editor, a pretty nifty modern alternative to MCEdit. It quickly became apparent though, that due to it being written in Python, it was not the tool for the task, taking minutes to render a top down view of the world, and even longer to copy paste terrain.
Instead, I decided to use WorldEdit, a Minecraft mod which lets you cut/paste terrain ingame, among other things. This seemed to work great, and while it still took a while to copy terrain, at least I could see what I was doing. However, after a few experiments, I decided to copy a large portion of terrain, and hit another snag - RAM. WorldEdit needs a lot of it. Trying to copy larger areas, Minecraft was actually running out of memory and crashing. In a last ditch effort, I closed every other app on my PC, and allocated all 16 of my gigabytes to Minecraft, and was just about able to copy and paste the terrain for the second part of the video as it currently stood. With two parts done, I recorded it, and uploaded it to YouTube as a proof of concept.
At this point, the workflow I had, while usable, was not great, and I decided to leave the project for a while, as my motivation was waning. That is, until Bruce himself (the creator of the original) commented on the video.
Attempt Two
Admittedly, I didn't get back to work immediately, but that comment hung around at the back of my mind, and eventually in December, I decided to have another crack at it. This time, instead of making it part by part, I decided to make all the terrain distortions and synchronise them first, and sort the terrain and portals later. So, over the course of an evening I did exactly that.
Portal Problems, Part Two
Next, though, I decided to have another crack at the portals. Searching the member list of the shaderLABS discord, I found that while Bruce had left the server at some point, RYRY1002, who had worked with Bruce's help to create Acid Interstate V4, was there, and so I messaged him asking if he could explain how the hell the portals worked. Well, lo and behold, he did!
Now, while this explanation didn't make the code any less magic to me, it gave me enough info to try and make it myself from scratch. It took 4 days of headscratching and asking for help in the shaderLABS discord, but eventually, I got them to work.
(Note that in the video shown here, shadows don't work with the portals, but I got this working at a later date)
Fundamentally, my implementation works the same as Riley/Bruce's, the only difference being that the way mine works is that it culls the two sides based on whether they are within the portal in screen space. This doesn't work properly if aren't more or less looking straight down the X axis, but that's fine, because in the video I'm trying to make you only ever look straight down the X axis.
Having got that working, it was time for...
Terrain Troubles - Part Two
With portals working and my distortions synchronised, all I had left to do was make some terrain. Now, it's worth noting that because I was home for Christmas, I was working from my laptop, which only has 8GB of RAM. This did not cut it for WorldEdit. I did my best to try and use it, but couldn't get my terrain to paste, no matter what I did. Amulet it is then!
However, because of how the portals worked, getting the terrain set up was even more of a chore. At each end of a section, I had to make the last 256 blocks of it half as wide, and then offset them to the side, so that both sides of the portal could have the same X coordinate and fit in render distance. Doing this with Amulet was hell, frankly, but luckily Mika pointed out that Amulet had to be using some kind of library to edit the terrain itself, and he was right. Introducing...
Amulet Core
a Python library for editing Minecraft worlds. It's a shame that most of the functionality is undocumented, so instead you have to go hunting through the Amulet Editor source code to work out how the hell they do anything. Many swear words were typed into comments that night. With about a day of trial and error, I managed to put together a somewhat janky python script which would copy terrain from a source world to a target world, chopping off the start and end to set up the transitions, and even placing the rails (mostly). It's far from perfect, but it works well enough that I can finish off each segment in game. I'll put the code on GitHub later, not that I recommend looking at it...
Home Stretch
So, I had the terrain, I had the distortions, I had the portal. Done, right? Well, not quite. First of all, I had to set the fog in game to dynamically reduce visibility when near portals, to hide the fact the segments were only half as wide. Then I didn't like the fog colour, so I had to do some rearranging in composite1.fsh
to make my fog the same colour as the sky, in the process accidentally causing an apocalypse in my Minecraft world...
Eventually, though, everything came together, and I hit record, left my laptop for 40 minutes (rendering in 4K is hard work for a Ryzen 5500U), came back and...nvm, I set the bitrate too high and the Replay Mod freaked out and artifacted a bunch.
Alright, I'll set the bitrate a bit lower, leave it for half an hour and...nvm, there's some weird green banding in the shadows. I could have spent a while diagnosing this, but instead I just turned off 'colored shadows' in the shader settings.
With that done, FINALLY, I had a final render I was happy with. So with that, let me proudly present RED DESERT, a project I spent way too long on.
Will this be the only Acid Interstate video I do? Probably not, I want to make a longer one more faithful to the style of the other Acid Interstate videos, maybe even including the cobblestone and torches that are also synced to the music.
If you've read this far, I thank you for sticking with it through this rambly mess, and I'll see you in 6 months when I find something worth writing about again.