Rendering Minecraft in Blender

I’ve been having an on and off love affair with Blender for three years now. While it’s true that the interface is bordering on user-hostile once you begin to understand the Blender way of doing things it is an incredibly capable piece of software.

Recently I stumbled upon Mineways, a free, open-source program which allows you to export sections of your Minecraft worlds for rendering or 3D printing. Being quite a fan of Minecraft (my wife and I had our Minecraft avatars on our wedding cake) I thought I’d have a play with it and see what I could make.

I did it Mineways

The Mineways program itself is incredibly easy to use. Open up a world file, chose the maximum height and depth you would like in the final scene, ctrl-click (right-click) and drag over the section you would like to export and then export an OBJ file for rendering.

Mineways

Once Mineways has finished exporting you’ll be left with several files:

  • An OBJ file which we’ll open in Blender
  • An MTL file which specifies the materials for the model
  • Three PNGs of Minecraft textures in RGB, RGBA and Alpha versions

It’s probably good housekeeping to put all of those files into a folder to keep everything organised and then we’re ready to get into Blender.

Will it blend?

So first up you’ll need to download and install Blender (the current version is 2.74 at the time of writing). Next if you are completely unfamiliar with the software I would recommend you go and make a mug to get up to speed with navigating the interface. You may also find that using a mouse makes it easier to navigate although it is possible with a multitouch trackpad (which is how I use it).

Now that you have Blender installed and you know your way around it a little lets get started. Create a new file in Blender, you should have a scene with a cube in the middle of it. Right click on the cube to select it, press “x” on the keyboard and click on the delete option that appears under your cursor. This should leave you with an empty scene ready to import your model. To import the OBJ file select File > Import > Wavefront (.obj) and then navigate to the OBJ file created by Mineways.

You should now see your model in all it’s greyish beauty. To see a textured preview change the viewport shading mode to texture by pressing “alt+z” (option+z), to switch back press “z” to go to Wireframe mode and “z” again to get back to Solid mode.

Blender Viewport Shading Modes

Now to see how it renders we need to set up at least one light and one camera. Fortunately the default Blender scene contains a camera and a sun lamp so you should be nearly ready to go. Adjust your view by rotating, panning and zooming until you have a good view of the model. Then from the View menu at the bottom left of the panel you’re working in select View > Align View > Align Active Camera to View.

Now we’re ready for our first render. Select the camera icon from the panel on the right to access the render settings. Set your resolution in the panel and then press the Render button. The output may look a little like this.

Blender internal renderer

My render came out particularly strangely as the world file I was working from came from a modded version of minecraft (ATlauncher). Mineways is only designed for “vanilla” (non-modified) minecraft worlds so it converts blocks it doesn’t recognise into bedrock. In this case it also got confused by the variety of trees available and made some trunks out of coal ore and some leaf blocks into wood blocks.

It’s fair to say that I was a little disappointed with this render but worry not things will get better. Blender has two built in renderers – the code that computes how the final image should look. Currently we are using Blender Render which is the original renderer for Blender and our other option is to use Cycles. The differences between them are many but essentially it boils down to Cycles being based on the physical world and therefore generally creating more realistic looking renders.

A new Cycle

There are definitely things we could do to improve the output in Blender Render but I’m going to suggest we jump ship to Cycles and get this render looking nice and smooth. Unfortunately however you can’t just switch to Cycles and carry on rendering. You have to recreate all the textures in your scene using nodes.

For most objects you just need to create a diffuse shader that uses an image texture as an input for the colour and then assign filename-RGBA.png as the texture. You can either do this in the materials tab on the right or in the node editor.

minecraft-diffuse-texture-nodes-cycles

For objects that have transparency (leaves, flowers, grass, etc.) you’ll need to add a mix shader between the diffuse shader and the material output. Then you’ll need to connect a transparent shader to the first shader input of the mix shader and control its factor with filename-alpha.png.

minecraft-texture-nodes-cycles

Having made those changes you should get something like this.

Full colour Minecraft render

It takes a while to get all the materials set up and the render can take a long time (this image took about seven hours with a thousand samples) but the results speak for themselves.

If you want to increase the “realism” you can experiment with lighting and add emission shaders to textures that should be light sources. In the image below the environment is set to black, the lava is a mix of diffuse and emission shaders and there is a dim moonlight from above.

Lava Emission Shader in Cycles

Switching to cycles won’t solve any issues with incorrect or missing textures though, so for now it’s probably best to stick to vanilla minecraft worlds. I’d really like to make some nice renders of the particle accelerators and nuclear power stations that my friends and I have built in the previous games so it may become the subject of a future post.

Beyond Minecraft

If you want to experiment further you can make your own textures and assign them to whichever objects you like. I tried another version using a mix shader that combined diffuse and glossy shaders to produce a material similar to a hard plastic.

Hard white plastic cycles nodes

I then added a plane beneath the minecraft model, scaled it so it expanded beyond the view of the camera and assigned the same texture to it. I also used a plane out of shot to the right with an emission shader to simulate the light of a soft box. The result is the bright and clean renders below.

minecraft-white-render

Close up of Mix shader in Cycles

A quick bonus

The day after I posted this I found a YouTube video that explains how to render minecraft items in Blender. It’s really quick and easy to follow, best of all you can use it with cycles by creating a diffuse shader with the colour input set to the image.

Minecraft Iron Sword

Peeking behind the curtain

Recently I’ve begun experimenting with things I would have thought impossible a few years ago. The python script I wrote last week and the data scraping project that I’ve yet to write about have both made me realise that none of this stuff is witchcraft. With my hosting renewal coming up I started wondering about moving from shared hosting to a VPS.

For the last decade my personal sites and email accounts have been hosted with the same shared hosting company. They have always provided me with excellent service for a reasonable price and I’ve always been happy to recommend them to my clients. Now that my requirements have reduced a little and I’ve been seeing VPS offered for a fraction of the cost I thought it worth investigating.

It’s probably worth noting that none of my sites are high traffic or high importance. They consist of this blog and its predecessor, a domain I bought for my wedding, a development server and my mostly dormant company site. I’m not sure that I’d be confident deploying a client’s site on a VPS yet but for my needs it works just fine.

New adventures in hosting

For my first foray into configuring my own hosting I chose to go with Digital Ocean’s $10 VPS. I had some teething troubles with their one-click WordPress installer so I decided to roll my own by following their excellent documentation.

All of that got this site up and running and allowed me to use WordPress’ auto update feature. The only thing left to do was to get a mail server set up. I decided to take the easy option and went with Zoho. All you have to do is create a CNAME record for the domain to prove to Zoho that you own it and then you need to set two MX records and it’s good to go.

The whole kit and caboodle

Having been encouraged by getting this blog working I span up another droplet and went through the first three tutorials again to get a LAMP stack up and running. This time I remembered to create a snapshot of it so in future I can just create a droplet with my preferences in one click.

Once it was up and running I looked at the content I needed to migrate:

  • Company site: A few php files
  • Old blog: A WordPress site
  • Development server: Several sites, mostly php but a few also require MySQL databases
  • Wedding site: A holding page

I guessed that it would be possible to host all of these on one droplet, as they’re all fairly low traffic sites. I looked into setting up virtual hosts in apache and was relieved to find that again Digital Ocean’s documentation didn’t let me down.

I had decided that there was no point continuing with the old blog as I hadn’t posted in it for over a year. However I wanted to be a good net citizen and not break any old inbound links. So I decided to import the content of the old blog here and set up a redirect for old links. To redirect all requests from one domain to another all you need is these two lines in the .htaccess file on the old domain.

RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Having set up four virtual hosts, transferred all of the required files, set up my .htaccess file and pointed my name servers at Digital Ocean my hosting was done. Setting up Zoho for each domain was a little laborious but as they provide free mail servers I’m not about to complain.

Was it worth it?

Compared to standard shared hosting you’ll have a lot more passwords to keep track of, you’ll spend most of your time in terminal rather than a web based control panel and you are your own tech support. It’s definitely not for everyone and your mileage may vary but I learnt a lot from the process and have cut my hosting bill by about 66%.