A 4D video game?

Started by Legend, Feb 27, 2018, 04:58 AM

previous topic - next topic

0 Members and 1 Guest are viewing this topic.


Hmmmm, I'm not sure if a rasterizor or a signed distance fields approach would work better for 4D geometry.

The equivalent of a triangle in 4D is a tetrahedron. Defining the world out of thousands/millions of tetrahedrons would work but 4D objects just have so much surface area. Take for example a cube in 3D. We can represent it with 12 triangles. Now look at a 4D hypercube. It needs 40 tetrahedrons to define its shape. This increased complexity is even more pronounced on other shapes. A sphere for example in 3D could have 320 triangles to make it look somewhat smooth while a hypershpere would need ~3,370 tetrahedrons to look as smooth. Ignoring the performance hit of needing to use a custom tetrahedron rasterizer, the geometry itself would be a huge resource hog.

Signed distance fields wouldn't have to deal with this. SDFs only use "linear" math so they work in any dimension and simple objects like hypercubes or hyperspheres would work as primitives. The hard part becomes optimizing the number of render voxels, not optimizing the scene.

So I think I'll start out with an SDF approach since it seems more likely to succeed. Plus it'd be simpler for me to program.


Spent my break today working on this. That's a render of a 4D hypercube!!!

No shading atm and needs a lot of work to look better as a 3D image, but it's fully functional (as long as you don't rotate anything). The image above is a hypercube a few meters from the camera and a bit to the left. This makes the side face exposed, producing that partial pyramid extrusion on the right of the image. Thought it was a glitch when it first appeared.


The framerate is close to single digits but here's shading and a shadow. It's a hypersphere on top of a hypercube table. The image of the hypersphere dips into the image of the table because it's closer to the camera for that area. The image of the shadow is inside the table's image and is 3D, not a flat ellipse.


Worked on this again last night, but i think it's time to put it on the shelf until I'm ready to dedicate a lot of time with it. The 4D engine is all set up and is ready to have a game built using it.

Graphics are currently way too slow and my test scene runs at 20 fps (without shadows). I'll need to really optimize the shader and use some hacks to get it running faster. Also playing the game in VR or at the very least in 3D is pretty important so increasing performance is my number 1 concern.

Rotations are working too. 4D is hard to think about because there are just so many ways to rotate and so few online articles giving specifics. I found a method to rotate a point by a 4D rotation and used that to engineer all the other functions a game needs.

With that I also set up a very basic physics engine. It is not even close to being capable of calculating true physics, but it's enough to keep objects from falling through the ground. All of my functions are set up using double precision floats since 4D geometry has more room for errors to build up.

Playing in 4D is interesting. Left right, up down, and forward backward quickly map to your brain. Ana and kata kinda map too, but it's just a game mechanic you get used to. Rotations are similar but take more time to adjust to. Ana and kata rotations are really confusing and hard to understand. Things move around the screen in a predictable way but the shape objects make as they rotate feels random.

So the short of it is that I'm really excited by this and it's definitly possible, both to create and to play. I'm suprised how quickly my brain was adapting to 4D geometry so maybe I'll need a more complex game to go with it.



Haha I'm not sure that'd actually work.

4D stuff is so cool to think about though since it just goes against everything you know about the world. Like it's impossible to tie a string into a knot in 4D since circular tubes don't fully constrict motion to 1 vector. Or that beings living in 4D space would almost always have circular symmetry since left/right and ana/kata are intermixable.

Go Up