frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: Curved Space Shader in Three.js (via 4D sphere projection)

https://github.com/bntre/CurvedSpaceShader
42•bntr•5h ago
I made a GLSL shader that bends 3D space using a 4D hypersphere projection.

The idea:

  1. Project a model onto a 4D sphere
  2. Rotate the sphere
  3. Project the model back to 3D
Code and details: https://github.com/bntre/CurvedSpaceShader

Curious what you think.

Comments

Sourabhsss1•3h ago
This is interesting...
tetris11•3h ago
I like it as a curiousity, but it only makes sense to me if I think of it 2D scene to 3D sphere.

Is 4D sphere the upper limit on this method, or can you project say 3D scene onto 5D sphere? (e.g a 1D line onto a 3D sphere analog)

bntr•3h ago
The 4D sphere makes sense here because its surface is 3-dimensional. That means I can project the model from 4D sphere back to 3D in a bijective (one-to-one) way.

You could project from 5D down to 3D, but the dimensional mismatch breaks the bijection - you'd lose information or overlap points. However, a 4D → 5D → 4D projection would preserve structure, though it gets harder to visualize.

I chose 3D ↔ 4D specifically because curved 3D space is much more intuitive and has direct physical meaning - it corresponds to positively curved space (see e.g. https://en.wikipedia.org/wiki/Shape_of_the_universe#Universe... )

saltwatercowboy•3h ago
Very cool. Have you tried applying it to a cube sphere/are the results are contiguous? I'd be interested in incorporating it into a hybrid planetary science/storymapping project I'm working on.
bntr•2h ago
I'm not entirely sure I understand the question. I doubt that any kind of sphere other than the abstract mathematical one (X²+Y²+...= 1) would be suitable for transformations like stereographic projection.
qwertox•3h ago
These projections, how do they make sense?

I can project a 3D item onto a 2D plane, but only observe it because I'm outside of that 2D plane. This is like expecting the 2D plane to see itself and deduce 3D-dimensionality from what it sees. Like a stickman. It would only be able to raycast from its eye in a circle. It could do so from multiple points on the plane, but still, how would it know that it is looking at the projection of a sphere?

bntr•2h ago
The surface of a 4D sphere (a 3-sphere) is itself 3-dimensional (just like the surface of an ordinary 3D ball is 2D). So when I use the hypersphere in intermediate computations, I’m not actually adding an extra dimension to the world.

What this transformation does give me is a way to imagine a closed, finite 3D space, where any path you follow eventually loops back to where you started (like a stickman walking on the surface of a globe). Whether or not that space “really” needs a 4th spatial dimension is less important than the intuition it gives: this curved embedding helps us visualize what a positively curved 3D universe might feel like from the inside.

fallinditch•2h ago
Good job, a lovely idea! It reminds me of AI morphing animation, I wonder if these techniques can be combined...
tasoeur•2h ago
I wonder if there’s something interesting visually if this shader could be explored immersively (VR). Could be worth prototyping it on my little app :-) (https://shader.vision).
bntr•1h ago
VR has come up a couple of times in response to my experiments - maybe it’s time I give it a try.

I once tried a cross-eye 4D view: https://github.com/bntre/40-js

ivanjermakov•1h ago
Because transformation happens in the vertex shaders, curvature would not work on low-poly objects. For this reason camera distortion is usually implemented in clip space (only after non-distorted frame is ready)
bntr•5m ago
Do you mean applying geometric distortion in the fragment shader? I'm not quite sure how that would work (I'm not so familiar with shaders at that level).

I've heard of true 3D bump mapping being done in fragment shaders (not just lighting), but I can't really imagine how more radical geometric distortion could be implemented there.

Duanemclemore•1h ago
This is rad. The game is especially cool. Congrats, OP!

This is the same math as this old program called Jenn3d[0] which I played around with almost twenty years ago. (Amazingly the site is still online!) The crazies who built it also built it to play Go in 3d projective space. I was never able to play Go with it, but I've been in to projective geometries since.

OP - if you want to try something else cool with 4d to 3d projective geometries, here's an idea I ran across working with 3d to 2d.

I make a tool for generating continuous groupings of repetitive objects in architectural computation. [1] When faced with trying to view the inside of lattices containing sets of solids which tile space continuously, I tried a few different methods (one unsuccessful but cool looking one here [2])

So when I created the sphere upon which to project the objects in the lattice, rather than just project the edges I made concentric spherical section planes and projected the intersection of those with the objects. [3] By using objects parallel to the projection plane to cut sections I was able to generate spacings between the final generated section lines that mapped how oblique the surface being cut was from the ray projecting from the centerpoint of the sphere to its surface.

Sorry OP, that's a long description. TL;DR - instead of projecting 3d mesh edges to a 4d sphere then back down to 3d space, what if you tried describing the meshes as the intersection of their 3d geometry with 4d hyperspheres parallel to the projection hypersphere? It would look more abstract, but I bet it would look cool as heck, especially navigating in 3d projective space!

[0] https://jenn3d.org/ [1] https://www.food4rhino.com/en/app/horta [2] https://vimeo.com/698774461 [3] https://vimeo.com/698774461

p.s. Also, if any actual geometers are reading this - I'd love to co-author a math paper that more rigorously considers what I explored / demonstrated with the drawings above. I have a whole set of them methodically stepping through the process, and could generate more at will. I also have a paper about it I can send on request (or if you can hunt down the Design Communication Association Conference Proceedings 2022).

meta-meta•40m ago
Nice! My partner predicted this in some album art she did for a friend. https://badbraids.bandcamp.com/album/supreme-parallel
jimmySixDOF•6m ago
For anyone interested in exploring Godot are working on a json spec for 4D Shapes for rendering and physics -- it's called G4MF (Good 4D Model Format) loosely based on Khronos glTF -- still a work in progress but there is playground editor support for x/y/z/w

https://github.com/godot-dimensions/g4mf

Hacking the Postgres Statistics Tables for Faster Queries

https://www.crunchydata.com/blog/hacking-the-postgres-statistics-tables-for-faster-queries
1•craigkerstiens•1m ago•0 comments

Shopify Polaris Web Components

https://www.shopify.com/partners/blog/polaris-unified-and-for-the-web
1•onnnon•1m ago•0 comments

Bielik v3 Small: Technical Report

https://arxiv.org/abs/2505.02550
1•PaulHoule•3m ago•0 comments

Oodle 2.9.14 and Intel 13th/14th gen CPUs

https://fgiesen.wordpress.com/2025/05/21/oodle-2-9-14-and-intel-13th-14th-gen-cpus/
1•frogblast•3m ago•0 comments

Google has a big AI advantage: it knows everything about you

https://www.theverge.com/tech/671201/google-personal-context-ai-advantage-data
2•donsupreme•3m ago•0 comments

We Have Ruined Childhood

https://www.nytimes.com/2019/08/17/opinion/sunday/childhood-suicide-depression-anxiety.html
2•skadamat•3m ago•0 comments

Anti-aging: Vitamin D shaves three years off your biological age

https://newatlas.com/aging/vitamin-d-anti-aging/
1•mmh0000•4m ago•0 comments

Meta is about to start rating more workers as 'below expectations'

https://www.businessinsider.com/internal-memo-meta-increases-employees-rated-below-expectations-2025-5
1•ra0x3•4m ago•0 comments

The rise, fall and comeback of Sam Altman

https://www.theguardian.com/technology/2025/may/21/every-person-that-clashed-with-him-has-left-the-rise-fall-and-spectacular-comeback-of-sam-altman
1•doener•5m ago•0 comments

Infrared contact lenses let you see in the dark

https://arstechnica.com/science/2025/05/infrared-contact-lenses-let-you-see-in-the-dark/
1•arunbahl•5m ago•0 comments

Bagel • Unified Model for Multimodal Understanding and Generation

https://github.com/ByteDance-Seed/Bagel
1•montyanderson•6m ago•0 comments

Initial CentOS Support for RISC-V

https://blog.centos.org/2025/05/initial-centos-support-for-risc-v/
2•fork-bomber•6m ago•1 comments

Personalized software is coming, but not today. Maybe tomorrow?

https://mattsayar.com/personalized-software-really-is-coming-but-not-today-maybe-tomorrow/
1•MattSayar•6m ago•0 comments

Picture Superiority Effect

https://en.wikipedia.org/wiki/Picture_superiority_effect
1•harperlee•8m ago•0 comments

DumPy: NumPy except it's OK if you're dum

https://dynomight.substack.com/p/dumpy
4•crescit_eundo•10m ago•0 comments

Is the Johny Ive announcement video AI generated?

https://old.reddit.com/r/OpenAI/comments/1ksjv37/is_the_johny_ive_announcement_video_ai_generated/
1•miles•11m ago•0 comments

Claude 4 Invite Contest

https://support.anthropic.com/en/articles/11408405-claude-4-invite-contest
1•Philpax•11m ago•0 comments

Why Everything Is 'Coded' Now

https://www.nytimes.com/2025/05/16/style/coded-right-left-politics.html
2•bookofjoe•11m ago•1 comments

Modern for Hacker News

https://chromewebstore.google.com/detail/modern-for-hacker-news/dabkegjlekdcmefifaolmdhnhdcplklo
1•bundie•11m ago•0 comments

A Brief History of JavaScript

https://deno.com/blog/history-of-javascript
1•mikece•11m ago•0 comments

How many species are there?

https://ourworldindata.org/how-many-species-are-there
1•thunderbong•12m ago•0 comments

CD / Blur [video]

https://www.youtube.com/watch?v=xDLxFGXuPEc
1•Klaster_1•13m ago•0 comments

Tablecruncher - A lightweight CSV editor for macOS, Windows and Linux

https://github.com/Tablecruncher/tablecruncher
1•RockstarSprain•13m ago•0 comments

OpenAI Will Build Data Centers in the UAE

https://www.nytimes.com/2025/05/22/technology/openai-uae-data-centers.html
1•pookieinc•14m ago•0 comments

Patent suit threatens system to keep Boston subway trolleys from crashing

https://www.universalhub.com/2025/long-delayed-system-keep-green-line-trolleys-crashing-could-be-delayed
1•ilamont•15m ago•0 comments

Contact lenses give people infrared vision – even with their eyes shut

https://www.nature.com/articles/d41586-025-01630-x
1•gnabgib•16m ago•0 comments

DumPy: NumPy except it's OK if you're dum

https://dynomight.net/dumpy/
7•mbforbes•17m ago•0 comments

The Last Nomads

https://www.thedial.world/articles/news/issue-28/georgia-adjara-highlands-nomads
1•Thevet•18m ago•0 comments

Meta launches program to encourage startups to use its Llama AI models

https://techcrunch.com/2025/05/21/meta-launches-program-to-encourage-startups-to-use-its-llama-ai-models/
1•taytus•19m ago•1 comments

DJI drones are everywhere. The U.S. may still ban them

https://restofworld.org/2025/dji-drones-china-us-ban/
2•ilamont•19m ago•0 comments