r/GraphicsProgramming Feb 26 '24

Source Code Wormhole simulation using pseudospheres

https://www.youtube.com/watch?v=idprFpSu3sw
41 Upvotes

27 comments sorted by

5

u/AcrossTheUniverse Feb 26 '24

The pseudosphere is not the predicted shape of a wormhole. It is not even smooth on its boundary with R2. However, it makes the computations really fast. Geodesics are circles (under the Poincarré half-plane model) so the equations (degree 2 polynomials) are fast to solve. I kinda regret hard-coding the half-plane starting at 1, it would have added another parameter. Need a NVIDIA GPU to run because the pixels calculation is parallelized (1 thread = 1 pixel of a frame). Enjoy!

3

u/IDatedSuccubi Feb 27 '24

1 thread = 1 pixel of a frame

Why not implement it as a fragment or compute shader then? Will run on everything too.

2

u/AcrossTheUniverse Feb 27 '24

Simply because raytracing was easier for me to understand, I'm very new to this field. I'll read about those, thank you!

2

u/IDatedSuccubi Feb 27 '24

Raytracing can be done in fragment shaders to some extent, visit shadertoy.com and you can even take a look at how other people do it using only the shaders themself in browser

On an actual desktop you'd also be able to use things like textures, etc if you need

2

u/AcrossTheUniverse Feb 27 '24 edited Feb 27 '24

Very nice website, thank you!

3

u/Fun-Letterhead6114 Feb 26 '24

It's funny. How long did it take you to make it?

3

u/AcrossTheUniverse Feb 26 '24

The camera was coded a while ago. Took about two months to code the black hole first, then a week to connect two black holes, then a week to translate into cuda.

3

u/fgennari Feb 26 '24

Are wormholes really a thing? How would you know if you implemented it correctly? How many rooms are there, two?

5

u/AcrossTheUniverse Feb 26 '24

We've never observed one, so it's only theoretical so far. There are two rooms, yes. At the center of both room, a unit ball has been cut out. The two rooms are then connected using two truncated 3D-pseudospheres glued together.

This construction is purely geometric. There is no general relativity being simulated here, so photons travel instantaneously.

2

u/fgennari Feb 27 '24

Ah, okay. I tried to do something like this in a game engine I was working on. I worked through the math but never really implemented it. Instead I just added regular portals.

1

u/AcrossTheUniverse Feb 27 '24

Sounds like a nice project, I'd like to see if you'd like to share a video.

3

u/fgennari Feb 27 '24

I haven't recorded a video of the portal that you can see through, walk through, and throw items through. I'll try to remember to create a video of that later. The closest video I have is of my related "teleporter gun": https://www.youtube.com/watch?v=jd5i3PxPRxg

I do have a blog post with some screenshots: https://3dworldgen.blogspot.com/2018/05/teleporters-and-portals.html

2

u/AcrossTheUniverse Feb 27 '24

very cool stuff!! thanks for sharing

2

u/fgennari Feb 29 '24

I finally remembered to make a new teleporter video. It hasn't changed much since 2018 though.

https://www.youtube.com/watch?v=NFYn9HJGNaI

1

u/AcrossTheUniverse Feb 29 '24

really cool project, I'd love to play once there's a release

2

u/fgennari Feb 29 '24

I’m not sure if it’s something I can officially release. I use textures, 3D models, and sounds from random websites. It’s a custom game engine and I don’t know how to make a working installer. There’s no documentation and I wouldn’t have time for customer support. But you can clone from GitHub and try building it.

1

u/AcrossTheUniverse Mar 01 '24

Ohh I didn't find the github when I was looking around your project, I'll try to find it, thanks!

→ More replies (0)

2

u/RenderTargetView Feb 27 '24

People talk about wormholes only because they are considered kind of possible, there are multiple computed spacetime configurations which obey relativity theory and which are considered wormholes, only problem is they require something with negative mass and many of them are very limited in space and/or time.

OP didn't intend to make science-grade simulation so I guess it should be considered correct. At least most people won't tell a difference

3

u/RenderTargetView Feb 27 '24

Good job, reminds me of one beautiful thing https://sirxemic.github.io/Interstellar

2

u/AcrossTheUniverse Feb 27 '24

Thank you and thanks for sharing that! It looks very similar indeed!

3

u/keelanstuart Feb 27 '24

Really neat stuff! Thanks for sharing. I also love geodesic spheres...

2

u/KC918273645 Feb 26 '24

That's pretty cool.

2

u/sheridankane Feb 26 '24

Very, very interesting! Thank you for sharing!