4d

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

4d

Post by raidho36 »

Lately I was into making a 4d game. Of course it's a complicated matter so I made some research, and I'd wanted to share.

So let's start with basics: what's 4d? Just a generic eucledan space with one extra spatial timension, making up for total 4 spartial dimensions, hence the name. Most people either not know about it completely or have a misconception about it driven by entertainment facilities' misuse of the term. Either way, none of us ever experienced 4th spartial dimension. The reason to that is so simple it's ridiculous: real world only have 3 spartial dimensions*. Even if it's there - theoretically - it must be uniform at all times unless under some extreme nearly fictional circuimstances; we can never spot or measure it, as if it never was there in the first place.
* We're not talking about fuckload-dimensional superstrings theory here - these guys can't even get their shit together.

From the programming perspective, making a 4d game is hardly different from making a 3d game - just an extra dimension, nothing special. You can easily deal with numerous dimensions like it's noone's business. If you're having a text-only game that only displays objects like a list with their coordinates for each dimension right of their name, player don't have to visualize anything, because everything would be highly abstract, yet multiple dimensions are "perceived" just fine, if slightly odd at the beginning. However, normally you still need to visualize it for people, and this is where the problems arise.

The thing with 4th dimension is that, according to the eucledan space definition, it is perpendecular to all other dimensions, simultaneously. First three axis fit into this rule easily: X is perpendecular to Y, and Z is perpendecular to XY plane. But try to imagine an axis that's perpendecular to all X, Y and Z axis at the same time, or better yet, that's perpendecular to the XYZ volume. The thing that you will probably end up with is an axis that's at an angle to the other three, but that won't do - it wouldn't be perpendecular to at least one of the axis, therefore not matching the definition. Or maybe a virtual axis represented by infinite amounts of 3d slices of the 4d space, but that would be exactly like representing 3d space with infinite amounts of 2d slices. Ever tried to see 3d brain scan by using 2d scan slices and only viewing one at a time? Besides, the space is contiguous, not split apart, so that won't do either. That's just it - because you've never actually experienced it and hardly even have any idea what it's like, you can't really picture it.

And then, human eyes are physically incapable of perceiving 4th dimension. In fact, it's incapable of perceiving 3rd dimension either, but brain uses tricks to emulate perception of depth on top of plain 2d imagery that comes from eyes. So maybe we could come up with the same trick for emulating perception of 4th dimensions on top of 3d? Well, emulating 3d requires two (or more) 2d eyes. Then, emulating 4d requires miltiple 3d eyes, while we only have one virtual not entirely suited for the task 3d eye, and that's another problem - it's like trying to see into 3d with a single 2d eye, or, for better analogy, it's like trying to see into 3d with a pair of 1d eyes (think of a hairline-thick slot in a cardboard through which you would be looking).

It's possible (and quite easy actually) to project the 4d object onto 3d volume (just like you project 3d object onto 2d plane). But how do you see the 4th dimension in it? Demos with rotating tesseract aren't exactly helpful because you can't really see the 4th dimension, it instead looks like the object is being twisted and distorted. And I've never seen a demo there the 4d object wouldn't rotate but instead would move along the 4th dimension. And of course, projection does works correctly, but there's no explanation how to look at it, so you're stuck with distorted 3d object rather than rotating 4d object.

So how do you see 4d objects? Supposedly, 4th axis position affects the projected points position the same way as 3rd axis. The further the object away from you by the 4th axis, the smaller it will appear, and the perspective will also change, while it will stay in place in 3 basic dimensions. With 3d vision, it will naturally look like the object is deformed, just like if you were trying to see 3d object with 2d vision, and what do you know - any 3d game is an example of that: once you stop thinking of these shapes as 3d shapes with one dimension "invisible", they instantly starting to look like distorted 2d shapes. So, to actually see if it's further or closer in 4th dimension you would need at least two 3d eyes to monitor the object from different 4d positions, that is to see it in "stereo 4d" that gives feel of 4d, just like stereo 3d gives feel of 3d. One thing to note is that in 4d, objects that are closer to you on 4th dimension would obstruct the view on objects that are further away respecively, even if in 3d former would appear further and latter would appear closer. Another note is that there will also be vergence and parallax observed while object is moving on the 4rd axis, yet in basic 3 dimensions there would be no parallax and vergence because the object doesn't moves.

The problem here is, as already mentioned, that the eye is incapable of perceiving depth, and adding more 2d eyes just gives better feel of 3d rather than makes extra 3d eyes. You may argue about it, but it's still ultimately the true fact. If a square on the 2d screen has shrinked, how can you tell if it was moved further away or just decreased in size? Same goes with 4d. One possible solution is to resort to simplier 4d, such is restricting all objects to uniform size and shape, but of course it's unsuitable for just about everything. Another solution to that is to turn 2d eyes into 3d eyes by training them to perceive depth. Of course that only possible with resorting to tricks: using only what eye is capable to perceive - light intensity. So if we trade color and light perception for depth perception, we can then train the eyes to see the objects' depth by their intensity - closer objects would appear brighter. If you're going to have these eyes to see 4d, you'd need to train them not to rely on vergence and parallax when determining objects' depth, since in regular 3d space there's no 4d vergence and parallax - so you'd show both eyes same picture. After that, you can get your "stereo 4d" thing, where each eye can sees different 3d projection of 4d space. But that way, you would only have spartial vision of the objects, you won't see the light, shadows, object color and texture, pretty much everything but it's shape*. And of course I haven't tried it and it's only theoretical, but hey, you can train your brain to modulate and process incoming data in any way you want it, it's just takes time... and constant load. It won't do if you're going to practice seeing 4d for an hour a day and the rest time you're gonna see the regular 3d, to really train your brain to do that you'd need to view 4d imagery 24 hours a day.
* Now that I think of it, what light, reflections and refractions gonna look like in 4d?..

On top of that, navigating in 4d is another massive bump you're gonna trip on. You can, of course, map 2 extra buttons to move along 4th axis, and that'll do it if you have fixed camera. It's pretty much mandatory for strafing into 4th dimension anyway. But if player can move the camera, you would also need 2 extra axis for looking around in 4d, and of course these 2 axis gonna work differently than regular two in 3d space, for they aren't rotation axis, they are rotation planes. Actually, all 4 of them are rotation planes in 4d, but first two work as normal. If that got you confused, here's an analogy: in 2d both axis rotated about virtual axis, in 3d two out of three axis are rotated about real axis, and in 4d two axis are rotated about another two axis, a plane. While there's only 3 possible rotation axis in 3d, there's 6 possible rotation planes in 4d. If we discard depth-aligned rotations (rotating the camera about it's line of sight axis), that makes 2 axis for 3d and 4 planes for 4d. Your basic limited degree of freedom looking around rotation planes would be XY (rotation plane is ZU - yawwing), YZ (YU plane - pitching), UX (ZY plane - 4d yawwing) and UY (ZX plane - 4d pitching).

Looking around alone would take up both analog sticks on your controller, and moving around would take another two (or 8 keys). Of course you can resort to only "forward" and "backwards" keys, but... yeah, you're not gonna have your 4d entity controlled easily. And speaking of controlling direction you're going, mankind doesn't even have a words for describing 4th dimension. For basic three axis we got up and down for Z, left and right for X, front and back for Y, but seriously, what do you call a direction along 4th axis? And I didn't called it by name, I called it by number, because so far there's even hardly any conventions what do you call that axis, in different sources it could be U or V or W. Human race is so not into 4th dimension it barely got anything about it besides math theory that coincidentally covers 4d space, because it's general and it covers R-spaces, with dimensions count ranging from 1 to infinity.

And if that wasn't enough, even if you maneged to get your 4d space up and running, what do you fill it with? You'd need to seriously be able to think in 4d to create a 4d geometry, let alone 4d scenery. You have better chances cloning yourself a T-Rex out of it's fossilated shit than finding a 4d level designer. And this is where it all ends - the world doesn't lives in 4d. Luckily for me and my little 4d game, it's 4d world is an empty void, and only objects are shining dots, which have same representation in any-dimensional space - a dot.

So what use all this would have? Probably none. My research report ends here. Thanks for reading.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: 4d

Post by Davidobot »

Very interesting, I read through the whole thing. When you make your 4D game, will you mind sharing it with us?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: 4d

Post by raidho36 »

Sure, why not.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: 4d

Post by xXxMoNkEyMaNxXx »

I've done some work with 4D:
viewtopic.php?f=5&t=32782

Not sure if I got the cubic roots thing right though. (If you happen to be looking through time at the surface of a triangle with vertices sliding linearly between event pairs, it can end up crossing your gaze three times)

My 4D level designer was random numbers.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: 4d

Post by raidho36 »

Seeing how everything gets warped wildly into hyperboloids and tores under any non-unit 4d angle, I can't help but think you did something wrong. Check one of those default 4d rotation demos, that's what it should look like.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: 4d

Post by xXxMoNkEyMaNxXx »

Well, I'm rotating your viewing angle instead of the object. I don't know if anyone has done this before, but I agree with you, it doesn't look right. What's happening, is that I solved the equation for the intersection of the four dimensional ray in the direction of the pixel with an animated triangle defined by three event pairs, "moving" linearly from the first to the second (they don't have to be at the same time). I think that the 4D shape might be under-defined, because you need four points to describe a 4D plane. Have you seen the videos of space time like a loaf of bread? The event-pair triangles (I thought of them as triangular prisms through time) were my loaves and I was trying to cut them on a 4D plane.

Also, I'm not sure what you mean by "those default 4D rotation demos". Give me a link?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: 4d

Post by raidho36 »

Well, I'm rotating your viewing angle instead of the object
What would be the difference between multiplying unit projection matrix by rotated modelview matrix and multiplying rotated projection matrix by unit modelview matrix? There should be no measureable difference between rotating an object in front of the camera and rotating camera about an object in front of it.
Have you seen the videos of space time like a loaf of bread?
Yeah I've discussed it in the chapter about perceiving the 4d space. Instead of rendering 3d slices, you should render 3d projection of 4d space. You're not rendering 3d by 2d slices, right?
What's happening, is that I solved the equation for the intersection of the four dimensional ray in the direction of the pixel with an animated triangle defined by three event pairs, "moving" linearly from the first to the second (they don't have to be at the same time).
Uhm, where did you even get that idea? It's obviously not a projection, but even for a slice, it's really weird and I don't follow it's logic.
I don't know if anyone has done this before
Give me a link?
Many people did. Hence (relatively) vast amounts of 4d videos, though many of them displaying 3d slice of a 4d space rather than 3d projection of 4d space.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: 4d

Post by xXxMoNkEyMaNxXx »

I find my program a great deal more interesting to look at than that :P

I found that I do have similar rotations in my program by using the numpad keys 1-6, so it's not entirely wrong.
Uhm, where did you even get that idea?
I thought of the idea. My thinking: "Why not represent animated 3D meshes as 4D meshes?" Then I argued with myself about whether or not the triangle defined by six events in spacetime was ambiguous in 4D. I did make it a little while ago now, but its trippiness must have some significance.
User avatar
ejmr
Party member
Posts: 302
Joined: Fri Jun 01, 2012 7:45 am
Location: South Carolina, U.S.A.
Contact:

Re: 4d

Post by ejmr »

Interesting ideas. I just wanted to add that a few weeks ago I read "Visualizing Quaternions", and while it is not entirely about 4D I would definitely recommend it to anyone thinking about using quaternions for calculating SO(4).
ejmr :: Programming and Game-Dev Blog, GitHub
南無妙法蓮華經
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: 4d

Post by xXxMoNkEyMaNxXx »

Quaternions are the shiz.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest