Shaoru Ian Huang

What is Voxelize?


June 9, 2024

TLDR: Build your own Minecraft with Voxelize!

What is Voxelize?

Voxelize is a full stack library to create voxel games in the web. You can create your own voxel game within less than 500 lines of code, and with these 500 lines of code, you will already have:

  • multiplayer
  • block breaking/placing
  • different block types
  • day/night cycles
  • basic perlin-noise terrain

Here's me building the above game in 37 minutes.

And that is just around 500 lines of code (407 lines). There is so much more you can do, such as:

  • make tiny robots that can follow you around
  • put a video onto a face and watch it like a TV
  • create a zoom clone where you call your friends in a Minecraft-like environment
  • define custom blocks that aren't just six faces
  • or even build your own 3D AI image generation pipelines
a beautiful sunset of Voxelize

This blog post serves as an introduction to the capabilities of Voxelize, and hopefully after reading this through, ideas will start popping into your mind and get you excited to build with Voxelize! For a more detailed guide to build a Voxelize game, please read the Voxelize docs.

1. Immersive terrain generation

Voxelize comes with fully customizable multi-staged terrain generation. The terrain generation along with the chunk meshing is done in multiple threads using rayon, so it is very performant and can generate impressive terrains. Here is an attempt at creating multi-biome terrain, inspired by Minecraft's Caves and Cliffs update:

each color represents a biome • twitter

And here's the same terrain, but rendered at a decently large radius of chunks (I believe 12 or 14 chunks?):

ENTROPY • Daniel Caesar • twitter

You might also notice how there are trees generated. Voxelize has L-system tree support! Took me a bit to implement it here, but you can define your own patterns, and Voxelize will generate trees for you based on that. I promise I will write a blog post about L-systems soon, hold me accountable.

barebones L-system trees to visualize the patterns
another demo of impressive voxelize constant 60+fps performance • twitter
rivers using perlin noise (another blog post idea! remind me)
this is what i would imagine other planets to look like twitter

2. Bots (artificial life)

You can also implement more complicated logic to create artificial creatures in Voxelize! Here's an example where I used A* pathfinding and some procedural character animation to implement tiny bots that just follow me everywhere:

i have more followers in voxelize than on twitter twitter

I took this class in high school called Honors AI, in which my teacher introduced as to the flocking algorithm. Essentially, with three types of calculations between the boids (birds): cohesion, separation, and alignment, you can simulate a very rudimentary version of birds flying in the sky or fish swimming in the sea. Junior year me was fascinated by this, and this has been my go-to demo for programming in Cursor too. Back then, I implemented a 3D version of flocking in python.

3D bird simulation • youtube

In March of 2024, I decided to port my implementation of flocking into Voxelize, and it worked out flawlessly:

boids in the sky (and bonus bots at the end) twitter

Notice how when I walked into the crowd of boids, they were pushed away from me! That's Voxelize's server-side physics engine doing its magic, which under the hood runs a rapier physics simulation for all entities. Though to note, the physics with blocks is handled separately with my custom AABB physics engine.

3. Block entities

One of the coolest things about Voxelize is that you can have "entities" that are static blocks. What this means is that you can store custom data (JSON) for individual blocks, and render them differently. This is especially useful for gameplay design. Think about a Minecraft furnace, how does it "store" the data that two pork chops are cooking with a piece of coal? Block entities. And Voxelize has full support for it too!

Here are some really cool use cases for block entities:

  1. Image Blocks on The data would be the image URLs.
even though they are the same block type, these two wallpapers are displaying completely different images hosted on imgur twitter
  1. A more sophisticated version of this would be rendering signs, the block entity data would be the custom text with color.
well this is more like a wallpaper + sign demo twitter
  1. And most recently, I implemented the:

3.1 The AI image-gen pipeline

This one was soooo cool!

generating different styles by chaining prompt blocks together twitter

The idea is that you can place down "prompt blocks" and assign prompts to them, which would be their block entity data. The blocks are then connected together with "chains" (my version of redstone), and linked to multiple image displays. The prompt block on the left would directly generate the left image, while the right prompt block would generate whatever the left prompt block generated + the additional piece of prompt it has.

On the button press, I use bfs to quickly search through to find the tree of blocks starting from the button, and send that to a "transport server" (which is just a node.js server that also has protocol with the rust Voxelize backend) to generate the image with, and finally update the block entities' data, which would then be reflected automatically back in any Voxelize client.

I was experimenting with trying to implement red stone in Minecraft, but then I was just awed by @tldraw's demo, so I combined the two together and this is just sooo amazing. Check out live here at (well you're on it! just go to my lab.)

that's me in van goph style apparently
i love art

4. Photomosaic (or voxelmosaic?)

This was one of the first experiments I had with Voxelize back in 2021. Essentially, you can take an image of a dog, for example, and build an entire wall of blocks in Voxelize algorithmically that, when you walk further away and look back, will look like your image.

invincible wallpaperoriginal picture
mona lisa voxelized in real time (+ a bunch of other voxelmosaics)twitter
my OG voxelmosaic demo of a cow and a dolphintwitter

The algorithm is fairly simple. When I get an image, I downsize it to the desired dimensions (in blocks), loop through each pixel in this downsized image, and for each block's side-texture I calculate the average rgb value, and finally, and finally I loop through each pixel to get the closest block texture rgb through a kd-tree (or some nearest neighbor algorithm). Check out the source code here. Definitely not the fastest way to do it, but it does the trick very well.

4. And more!

There are genuinely too many things that you can build with Voxelize, so I'm just gonna drop a bunch of images and videos below to entertain your imagination:

(putting images first because they're not as cool)

custom block shapes that i use as "link blocks" on
i set up a cron job to build a wall of my github contribution

And the fun stuff begins:

great friend of mine @baltaazr ported a minecraft map to voxelize twitter
custom block shape support with physics, in other words blocks can shape differently depending on the environment they're in twitter
cool race condition bug encountered during dev (no music sadly) twitter
player-to-player collision twitter
you could even implement mobile spectator mode! (again no music) twitter
multiplayer deployed on a 4gb ram potato droplet twitter
bobby twitter

Thanks for reading!

I hope by this point you see how much there is to be built with Voxelize, and there are a lot more to come.

I post weekly updates of Voxelize on my twitter, along with other cool stuff I'm building at Cursor, feel free to reach out for any interesting discussions. Stay tuned!

P.S. you can play Voxelize online on my personal portfolio. Join, turn left, and check out any worlds I've made! Builder's Wonderland v1 and v2 are all built by strangers online, and Ian's Lab is where you can try out my AI prompt-to-image pipeline.

June 9, 2024