
Non-Euclidean Worlds Engine [video] - garis
https://www.youtube.com/watch?v=kEB11PQ9Eo8
======
AntonyGarand
I researched a similar effect few years ago when I was trying to replicate
part of the game `AntiChamber` in Unity.

At the time, I found out about Stencil Buffers, which did let us create a cube
with various different rooms on the different faces:
[https://www.youtube.com/watch?v=5DKIP9N-OB4](https://www.youtube.com/watch?v=5DKIP9N-OB4)

Since then, there has been more "Portals" technique released, among which this
blog post which seems to achieve a similar result:
[http://tomhulton.blogspot.com/2015/08/portal-rendering-
with-...](http://tomhulton.blogspot.com/2015/08/portal-rendering-with-
offscreen-render.html)

Another game which uses a different type of geometry is HyperRogue:
[https://www.youtube.com/watch?v=2DtUJ_x_2Hc](https://www.youtube.com/watch?v=2DtUJ_x_2Hc)

It has a hyperbolic plane instead of a regular rectangular one.

------
modeless
I've played a couple of games that use these concepts for gameplay. They are
both very cheap and totally worth the money:

Antichamber [1] is a first person puzzle game. Mind-bending. Overwhelmingly
positive reviews on Steam.

Unseen Diplomacy [2] is a room-scale VR game using this technique to allow
free walking (or crawling) around a much larger area than your room.

[1]
[https://store.steampowered.com/app/219890/Antichamber/](https://store.steampowered.com/app/219890/Antichamber/)

[2]
[https://store.steampowered.com/app/429830/Unseen_Diplomacy/](https://store.steampowered.com/app/429830/Unseen_Diplomacy/)

------
32bitkid
I'm glad to see other people working on this kind of stuff. The old Descent
games had a related—although more primitive—rendering engine that could be
(ab)used to similar effect that was a lot of fun back in the mid-90's. Some of
the home-brew levels back in the day exploited this for some pretty mind-
bending overlapping non-euclidian level design.

As for myself, I've been working on a 2d-space combat game set on the surface
of a Poincaré Disk as a hobby over the past few years, not sure i'll ever do
anything with it for real, but it's fun.

~~~
lsh
Duke Nukem 3D/Shadow Warrior and the Build engine also achieved a number of
their effects and mechanisms similar to the video. In fact, the very first
level in the first episode of Duke Nukem 3D where you're on a rooftop, pick up
the pistol, shoot the fan and drop down the shaft is a perfect example - that
rooftop and the street level you drop into are connected seamlessly by a short
tunnel that transports you. Water surfaces were also used in this effect and
the 'underwater' parts were often entirely other parts of the map.

I always thought of them of as pre 'true' 3D engine hacks, but it was so cool
to see them again in that video. Cooler still that it's essentially the same
trick being used in Portal and I never tweaked to it

------
EamonnMR
The Marathon engine could sort of do this. It was similar to the doom engine
in that maps where laid out as polygons on a flat plane, but different in that
you could have overlapping polygons, which allowed the devs to do something
like this:
[https://www.youtube.com/watch?v=9WxeeiqWrn4](https://www.youtube.com/watch?v=9WxeeiqWrn4)

~~~
abricot
In the Duke Nukem 3D level editor you could also put two rooms in the same
space, making the same effect.

------
mey
Prey (2006) modified a version of the Doom 3 engine to add portals as well as
shifting gravity for similar effects. I don't recall if it did size changes as
well.

Demo/trailer
[https://www.youtube.com/watch?v=zpQRePtEpRw](https://www.youtube.com/watch?v=zpQRePtEpRw)

[https://en.wikipedia.org/wiki/Prey_(2006_video_game)](https://en.wikipedia.org/wiki/Prey_\(2006_video_game\))

[https://en.wikipedia.org/wiki/Id_Tech_4](https://en.wikipedia.org/wiki/Id_Tech_4)

This tech predates Valve's Portal, although I doubt it is the first attempt at
this.

~~~
TeMPOraL
> _I don 't recall if it did size changes as well._

AFAIR it did; there was one point at which you emerged inside a semi-
transparent container, at ~1/10 of your original size, and a full-sized alien
was looking at you.

> _This tech predates Valve 's Portal, although I doubt it is the first
> attempt at this._

Portal was inspired by Narbacular Drop (2005).

[https://en.wikipedia.org/wiki/Narbacular_Drop](https://en.wikipedia.org/wiki/Narbacular_Drop)

------
vinkelhake
The old Unreal engine was based on portal rendering. The game itself didn't
use too much in the ways of non-euclidian geometry, but there were plenty of
custom maps and demos of it. Most, if not all, of the stuff in this video
could probably be recreated in that old tech.

Not meant as a middlebrow dismissal, this is neat stuff and I wished it was
explored more in games!

[https://www.youtube.com/watch?v=AEVSUIECY9Y](https://www.youtube.com/watch?v=AEVSUIECY9Y)

~~~
TazeTSchnitzel
As was Duke Nukem 3D. Here's a video about making a simple demo engine based
around the concept, which shows off a little non-Euclidean geometry:
[https://youtube.com/watch?v=HQYsFshbkYw](https://youtube.com/watch?v=HQYsFshbkYw)

------
knolan
This was also used in a part of the Stanley Parable. The narrator growing
impatient at your insubordination draws a yellow line for you to follow but as
it winds down a cluttered office corridor strange things happen.

------
jostmey
The author outlines a compelling use case at the end of the video definitely
worth listening to! VR is limited to the space in your bedroom, so how can you
compress an entire level into just one room?

------
boardwaalk
I'd like to see something like this used in MMORPG or similar, where non-
Euclidean spaces are used to expand and shrink spaces to solve problems like
overcrowding/undercrowding/travel times, as opposed to using instancing and
fast travel.

I've always thought the "go to" solutions of instancing and fast travel were
such immersion breakers for actually feeling you're in a virtual world rather
than a glorified lobby.

Although, perhaps a non-Euclidean space would have downsides. It would be an
interesting experiment at least. Playing with non-linear time (and not just
"bullet time") in a multiplayer scenario would be interesting too.

------
wcoenen
One transition option I was still missing: a tunnel with parity
transformation, like stepping through a mirror where you would end up as your
mirror self.

------
snazz
The code, for all who are interested:
[https://github.com/HackerPoet/NonEuclidean](https://github.com/HackerPoet/NonEuclidean)

It unfortunately seems to be Windows-only, though.

~~~
goldenkey
Shouldn't be hard to port since it uses cross-platform GLFW for most of the
input/windowing stuff.

[https://www.glfw.org/](https://www.glfw.org/)

The only Windows-specific stuff is a bunch of MessageBox and other minor calls

------
iaw
The effect of the room demo was pretty remarkable.

~~~
scrumper
Yes! I was a bit disappointed when he explained it was just portals and a
clever rendering hack rather than actually modeling non-Euclidean space
natively, then I was delighted when he showed the room-scale VR example.

~~~
wcoenen
> rather than actually modeling non-Euclidean space natively

In mathematics such non-Euclidean spaces are called manifolds. A manifold is
defined as a set of Euclidean-like regions that are connected by transition
map functions. That formalism is basically the same thing as these portals.

[https://en.wikipedia.org/wiki/Manifold](https://en.wikipedia.org/wiki/Manifold)

~~~
thfuran
Except that that method wouldn't let you have, for example, a hyperbolic plane
that could be traversed without obstruction.

~~~
wcoenen
I think you could actually approximate an unobstructed hyperbolic plane to
arbitrary precision with portals. In this game, the hyperbolic plane is
represented as a tiling of hexagons and heptagons:
[https://www.youtube.com/watch?v=lX5eCfRSCKY&t=742s](https://www.youtube.com/watch?v=lX5eCfRSCKY&t=742s)

If you take this model but upgrade each cell to a little 3D euclidean region,
then you could completely surround it by portals that connect it to the
neighbouring cells. The edges of the portals wouldn't be visible. The smaller
the euclidean cells, the better the approximation to the hyperbolic plane.

~~~
zenorogue
For easy computations assume octagonal cells. Their vertices will have 135
degrees each. The edges of the portal will be visible because the left and
right images do not match (since 3*135 ≠ 360). And a object (as long as it is
modelled as an Euclidean 3D object, not a point) will not be able to go
through such a vertex.

------
DoctorOetker
There's a short segment where CNLohr shows how he recompiles the code on the
fly by using TCC (Tiny C Compiler). That seems rather useful to me, but I
don't fully understand what determines which variables of state are persistent
across recompilation. I have never used TCC before, but from a rudimentary
search I learn you can pass a flag to compile & execute such that C can be
used as if it was a scripting language. He mentions storing the environment in
environment variables. Is he literally storing the position and orientation of
the camera in the shell environment variables? or am I missing some other way
to choose what parts of the state are persistent across on-the-fly
recompilation?

~~~
xashor
Here is an example level [0]. You can see some scripts in there enclosed by
InitScript { … }, RunScript { … }. This gets parsed, compiled and called in
[1]. In [2] you have your scripthelpers.h, defining what parts of the engine
the script can see. On a first glance I don't see support for persistence
across recompilation for scripting variables, and things like
position/orientation of the camera are simply stored in the engine and not
recompiled.

For a similar approach, see e.g. Interactive Programming in C [3], which
relies on re-loading a shared (recompiled) library. But this step could also
be done by recompiling via tcc. There the persistent data lives just in the
heap and pointers to it get passed to the next version of the library.

[0]
[https://github.com/cnlohr/noeuclid/blob/0831b9ce21620704257a...](https://github.com/cnlohr/noeuclid/blob/0831b9ce21620704257a4b60ce5ae1c65123654e/rooms.txt)
[1]
[https://github.com/cnlohr/noeuclid/blob/0831b9ce21620704257a...](https://github.com/cnlohr/noeuclid/blob/0831b9ce21620704257a4b60ce5ae1c65123654e/GameMap.cpp#L55)
[2]
[https://github.com/cnlohr/noeuclid/blob/a8e1e038829686f39d48...](https://github.com/cnlohr/noeuclid/blob/a8e1e038829686f39d489ea0cd6756fef338ea9c/scripthelpers.h)
[3]
[https://nullprogram.com/blog/2014/12/23/](https://nullprogram.com/blog/2014/12/23/)

------
evdev
You could do the overlapping space part of this in the game Descent/Descent 2
since building the levels involved actually directly creating the space
partition data structure. I always thought it was incredibly cool and
underused.

------
remram
This is simply multiple Euclidian regions stiched together by portals. Seems
very limited compared to _actual_ non-Euclidian renderers like
[https://www.youtube.com/watch?v=0pmSPlYHxoY](https://www.youtube.com/watch?v=0pmSPlYHxoY)

------
trakl
While it can be useful (or not) on the applications described, this is not
non-euclidean. It is pure euclidean, but defined in steps.

I agree that is visually exciting and all that jazz, but this has nothing to
do with Non-Euclidean Geometry... My surprise is that I though this video will
give some 3D intuition on this topic, but nay.

~~~
adrusi
This is noneuclidean, in that it violates the axioms of euclidean geometry.

1\. A straight line may be drawn between any two points.

2\. Any terminated straight line may be extended indefinitely.

3\. A circle may be drawn with any given point as center and any given radius.

4\. All right angles are equal.

5\. If two straight lines in a plane are met by another line, and if the sum
of the internal angles on one side is less than two right angles, then the
straight lines will meet if extended sufficiently on the side on which the sum
of the angles is less than two right angles.

It follows from those axioms that the sum of the angles of any triangle is
180°, but in that 3-room house, for instance, you could draw a triangle with 3
right angles, so it must violate the axioms.

~~~
zenorogue
The phrase "non-euclidean geometry" does not mean "any geometry that violates
the Euclid axioms" but specifically that the parallel postulate is replaced.
traki is right.

~~~
trakl
I've got to reconsider given adrusi's comment, I think he's actually right.
The parallel postulate is what makes the sum of angles of any triangle to be
180º.

~~~
zenorogue
Other Euclid's axioms should still hold in non-Euclidean geometry, but with
portals and walls, they do not. Mathematicians who are experts in non-
Euclidean geometry would agree that portals do not yield non-Euclidean
geometry, e.g. Henry Segerman
[http://twitter.com/henryseg/status/970797060369846273](http://twitter.com/henryseg/status/970797060369846273)
(see also
[http://twitter.com/marctenbosch/status/301331439725719552](http://twitter.com/marctenbosch/status/301331439725719552)
).

------
natestemen
I could imagine something like this being an amazing tool for teaching people
about non-euclidean geometries and how things like distance can be so
contorted in other spaces. In particular I'm thinking teaching people about
special and general relativity where things can very quickly become very hard
to visualize.

Really cool.

~~~
SiempreViernes
Check out "a slower speed of light", relativistic open source game demo made
in unity: [http://gamelab.mit.edu/games/a-slower-speed-of-
light/](http://gamelab.mit.edu/games/a-slower-speed-of-light/)

Unfortunately the movement is rather hard on the eyes, relativistic motion is
not what you are used to after all.

------
karrotwaltz
The first time I ever seen this portal gimmick in a game was in the Wheel of
Time game (released in 99), although it was used only once in the whole game
my mind was blown.

------
user982
What game is the black and white clip at 04:13 from?

~~~
anonova
Fragments of Euclid: [https://nusan.itch.io/fragments-of-
euclid](https://nusan.itch.io/fragments-of-euclid)

~~~
user982
Thanks. The crosshatch shader threw me off, but it looks like that can be
toggled.

------
yzh
I have a feeling that Jonathan Blow will enjoy playing with engine and work
something brilliant on top of it.

~~~
tobr
Considering that all of Blow’s games have used his own engine, and he’s
actively building a new engine using his own programming language, it seems
rather unlikely that he would suddenly scrap all that work and use this engine
instead.

------
orblivion
That pillar is like a validation of my OCD.

------
rsk
I wonder if there is 3d render for 4d space. 4d space can give such wormholes
for free in 3d, same as 2d space can be folded in 3d.

------
davidw
I spend too much time with urban politics: I see Euclidean and think of
zoning.

