Hey, I am jelle and after making a bunch of 2D and 3D games, I was ready for the next step. Now what is there beyond the 3rd dimension? Well, the 4th dimension of course! Get ready for some hyper dimensional travel! You may say, Isn’t the fourth dimension just time?? You could look at it that way, But that is not what I mean. We all live in a 3 dimensional world where we can move forwards, backwards, left, right up and down, or in other words: along the X, Y and Z axis. Three perpendicular directions that can describe every place in our universe. What if… There was a fourth axis that we could move along, perpendicular to all 3 other axis: a W-axis. And define objects with those 4-dimensional coordinates Of course, We simple humans can’t perceive these objects fully, but what we can do is Look at some sort of 3D projection, or section of those objects. There are a number of different ways to visualise these 4D objects. One very practical and useful way is to create a 3D section of the 4D shape, similar to what the upcoming game “Miegakure” does. To understand this, I had to get to the source of this concept, A short novel named: Flatland. Flatland tells the story of a 2 dimensional being trying to understand the 3rd dimension. So you are living on a plane and are trying to grasp the concept of a 3D object, in this Case a sphere. The only thing we can see is the 2D section of that sphere, so a circle. When the sphere moves along the 3rd dimension, all we can see is a growing and shrinking circle, until it suddenly disappears. By layering all those sections we can kind of understand what a 3D sphere could look like. From there we can use the same way of thinking for the 4th dimension. So instead of taking a 2D section of a 3D object, We can take a 3D section of a 4D object. I could create a 4 dimensional object, and then set the w axis to a certain value, the resulting shape would then be something that could be displayed with the 3 remaining axis. Now, how was I going to create this abstract geometry and how was going to put it in a Game, where all I have is a mathematical equation that defines its shape. If only I created something that does that exact thing but with some other kind of mathematical functions, I don’t know something like: Fractals. We’re going to use ray marching again! For those of you who need a reminder or have never heard of ray marching, a ray marcher is a rendering method that draws shapes based on distances from the camera. Those distances are defined as formulas. So What I had to do is define the objects As 4 dimensional formulas and let the camera Make a 3D section of those shapes at a certain W position. Tadaa: my first 4D object, a Hypersphere! Well it looks like a regular sphere but the radius of the sphere is not just determined by the x, y and Z direction, now there is a W axis a well. So if we move our w position with a slider, we can see the sphere growing and shrinking, just like the 2d equivalent earlier, where the circle grows and shrinks when we move the sphere back and forth. Of course none of this looks very exiting, it’s just a round thing that grows and shrinks. The cool things start when we create other objects like a Hypercube and rotate them as well. Because we Are now creating 4D shapes, we suddenly have 3 more rotational axis we can play with, the xw, yw and zw planes! Aha, this looks promising! Let’s create some more shapes like a duo cilinder, a 5 cell and 16 cell ! Placing these elements in the scene wasn’t very easy with my old ray marching script, so I gave it an update similar to how Sebastian did it in his video, where each object can Be placed with an empty game object and a script attached to it. Of course I had to give it an upgrade to allow the 4 dimensional movement and rotation by defining those in the inspector. Now placing objects was as easy as click and drag! Wonderfull. There was one problem tough, The rotation didn’t seem to work the same way as in the inspector… I dug into some unity meta code and realised that the order in which the rotations are applied is very important, so after switching those around. The rotation did what it had to do. I was getting exited and placed way too many objects in the scene, resulting in terrible frame rates. I hadn’t even created a single level yet, and I was already pushing the game to it’s limits. So I needed some way to optimise all of this: Then, I remembered that the performance of Ray marching is heavily dependant on the resolution of the game. If I could lower the resolution, without having it look like a dirty low res game, The game would run much smoother. That reminded me of a beautiful indie game called “A short hike”. That game was rendered at a very low resolution to get more of a pixelated look, while still remaining a full 3D game. So, I just did the same thing! I let the camera render to a low res render texture and set up a second camera that would look at that rendered texture. Badabing, badaboem, 4 times the frame rate! This meant I had to keep everything very simple and clear, I had planned to use my little astronaut from one of my previous games, and he was in need of an upgrade to withstand travelling through the 4th dimension, so I did! A Nic big neck brace! We wouldn’t want a whiplash! I added a cell shader so the colors would be better defined and more clear. I also created an invisible capsule that follows the player around to cast a shadow on the ray marched objects. To decorate the scene, I added some 4 dimensional trees and rocks. The ground plane was given a waving pattern controlled by a sin wave that was defined by all 4 axis. So moving W axis would create cool wavy effects. Because all the shapes were raymarched, I could very easily apply boolean operators on them, like union, intersect and substract. Allowing me to create more complex shapes! Like floating islands! Which were various objects intersecting with the 4D planes. This gave me a great idea for the gameplay. Let me explain: You play as the little astronaut who wants to get back to his ship! But there are of course numerous obstacles in the way! Luckily there are these convenient buttons in place that let you turn certain objects into a different boolean operator, so for example, that cube that is blocking your way, could suddenly become a hole to get through! I created a button and an orb that you could place on the button. However, the orb also lives in the fourth dimension, so the button would only be active at certain w locations, with you can see above the slider. This created many opportunities for cool puzzles! Like a doorway that would appear or a slope that would change shape and become its inverse. I created 8 levels in total, each of them building on the previous one, but all with the same goal of getting to your ship! You have to traverse the world and look for pathways throughout the fourth dimension by moving the slider. If you don’t see anything, it’s probably somewhere along the 4th dimension! I added a start and level select screen, and with all of that the game was done. I released the game on Itch.io and you can play it now for free, I’ve also added the 4D framework on GitHub so you can make your own 4D boolean games! Be sure to like the video if you enjoyed this journey into the 4th dimension and subscribe if you want to see more in the future. And I’ll see you guys next time, where I will contemplate the meaning of life. Video Information
This video, titled ‘Making a 4D Game – 4D Explorer’, was uploaded by Jelle Vermandere on 2020-05-07 15:00:26. It has garnered 1411655 views and 55234 likes. The duration of the video is 00:07:39 or 459 seconds.
I made a game where you can travel through 4 spacial dimensions! slide along and solve puzzles with different 4D booleans. If you liked this video, be sure to subscribe so you won’t miss the next video! Play the game here: https://jellever.itch.io/4dexplorer Source files: https://github.com/Jellevermandere/4D-Raymarching My previous video about raymarching fractals: https://youtu.be/0jwkZKDOzfc
Sources where I learned from: Lazy engineer: https://www.youtube.com/watch?v=4TI1onWI_IM&t=1s Raymarching: https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm A short hike: http://ashorthike.com Miegakure: https://miegakure.com Flatland: https://en.wikipedia.org/wiki/Flatland
This game is made with raymarching, by adding a 4th value to each vector, the shapes can be defined by 4 dimensions. The camera then takes a section at a certain w position. The resulting shapes can be rendered in 3d —————————– Music by: incomptech.filmmusic.io —————————— Follow me everywhere! Personal website: http://www.jellever.be Instagram: https://www.instagram.com/jellevermandere/ Itch.io: https://www.jellever.itch.io/ And loads more! Just google me 😉 —————————– playlists:
Game Devlogs: https://bit.ly/JelleVerYTGames
Drawings: https://bit.ly/JelleVerYTDrawings
Animations: https://bit.ly/JelleVerYTAnimations ————————————————
Programs used: Blender, Unity, Visual studio, Procreate