I'm trying to experiment with 3D spherical geometry in Unity, but it seems like Unity objects are inherently set in flat space. My first idea was to create a class inheriting from Transform that would override most of the methods, but I discovered that the transform member of a game object is read only so I cannot replace it with my custom class. I know this sort of thing is possible because the game Hyperbolica is being built in Unity using curved space. I have the math all figured out, I'm just not experienced with Unity. Anyone have other ideas for things I could try?


The editor coordinate system will always be in 3D Cartesian coordinates in a flat Euclidean spacetime, but you're under no obligation to use those coordinates for evaluating your game logic or rendering.

You can add an additional Transform4D component to your objects/entities, and refer to its custom coordinate values instead.

Each frame, you can set the position/orientation/scale of the built-in Transform component to a 3D projection of your Transform4D from your player's current viewpoint to handle the local neighbourhood around the player where space is "almost flat"

Or you can use your Transform4D to compute 4-dimensional positions for each of your mesh's vertices, and send them to the GPU as a texture coordinate channel. A custom shader then reads these and projects your 4D object using this channel, instead of the 3D position values provided by the engine.

I played around with some hypersphere exploration back in the Flash days and the situation was similar: the native coordinate system was only flat Euclidean (and 2D!), but if you're willing to compute your own vertex positions you can project any arbitrary space you can think of into that canvas.

| improve this answer | |
  • \$\begingroup\$ Awesome, I'm going to try sending custom data to the GPU. My plan is to represent position and orientation with a single 4D rotation, and to represent that rotation with two quaternions through isoclinic decomposition. Then I want to send those quaternions to the GPU in place of position and normal vectors. Now I'm just trying to figure out how to do that in Unity. \$\endgroup\$ – A. Kriegman Aug 1 at 14:13
  • \$\begingroup\$ We can help you with the mesh attributes and shader code if you want to post questions about those next steps, but you might have to explain the 4D math you have in mind. A lot of game developers treat quaternions like a black box, and have never ventured outside of flat Euclidean space. So including clear formulas/diagrams in your question can help us bridge that gap and get you a solution that works for your approach. \$\endgroup\$ – DMGregory Aug 1 at 14:19
  • \$\begingroup\$ Maybe you can help me with what I'm trying to figure out right now. I'm trying to write a shader that does some custom math after the model and view matrices are applied and before the projection matrix. Any idea how to do that? \$\endgroup\$ – A. Kriegman Aug 1 at 16:33
  • \$\begingroup\$ Yes, but the comments aren't the right place to go into detail. Want to post this as a new question, showing what you've done so far? \$\endgroup\$ – DMGregory Aug 1 at 16:35
  • \$\begingroup\$ Done gamedev.stackexchange.com/questions/184839/… thank you! \$\endgroup\$ – A. Kriegman Aug 1 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.