frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

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

https://github.com/bntre/CurvedSpaceShader
68•bntr•1y 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•1y ago
This is interesting...
tetris11•1y 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•1y 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•1y 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•1y 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•1y 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•1y 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•1y ago
Good job, a lovely idea! It reminds me of AI morphing animation, I wonder if these techniques can be combined...
tasoeur•1y 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•1y 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•1y 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•1y 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.

ivanjermakov•1y ago
Fragment shader distortion suffers from another issue: heavy distortions require higher resolutions and (depending on distortion type) higher field of view. Even more radical distortions would require cubemaps of undistorted frames to handle fragmens from behind the camera.

This answer suggests some other ideas on implementing lens distortion: https://stackoverflow.com/a/44492971

bntr•1y ago
Thanks! The cube mapping idea is really interesting — I didn’t know about that approach. However, I doubt it would help in my case, where the distortion is strong enough to flip the depth order of objects.

Maybe these methods could be combined somehow, but it seems simpler to use subdivision (as also mentioned in that thread) — perhaps selectively, for objects near the periphery where distortion is strongest.

Duanemclemore•1y 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•1y ago
Nice! My partner predicted this in some album art she did for a friend. https://badbraids.bandcamp.com/album/supreme-parallel
jimmySixDOF•1y 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

bntr•1y ago
Thanks! I didn’t know about G4MF — looks cool. What I’ve missed more often, though, is 5×5 matrices for real 4D transformations.
bobsmooth•1y ago
God I wish I could understand 4D geometry.
talkingtab•1y ago
While the demo is great, and the 4D stuff is very cool, for me the amazing thing is the code to do this. Three.js opens a door to using webgl & webgpu, and shaders open yet more doors.
bntr
•
1y ago
Thanks for the kind words and for sharing your thoughts! I actually remember Jenn3d as well — the animations always reminded me of some kind of shimmering foam.

Unfortunately, I couldn’t quite grasp the method you’re describing — perhaps I’m missing some illustrations. (By the way, links [2] and [3] seem to point to the same video, and I’m not sure they match your description.)

It sounds like you’re suggesting a way to slice objects into almost-repetitive sections, so the brain can reconstruct a fuller picture — a bit like how compound eyes work in insects.

Duanemclemore•1y ago
That's so strange. For some reason it gave me the link for a completely different video...

Anyway - here's

[2] https://vimeo.com/757057720

and [3] https://vimeo.com/757062988

Yeah, jenn was really rad. It's red meat to me when anyone's working on these kinds of projections.

Since without the proper explanation the whole "concentric spherical section planes" thing is unclear (and actually, they wouldn't be section "planes" in the first place), here's the paper I was referencing:

https://www.academia.edu/129490488/Visualizing_Space_Group_H...

(see pg. 3 for a visual explanation that I hope helps.)

I intersected the objects in the lattice with spheres to create lines, then projected those to the outer sphere and down to the 2d plane. In the same way, you could use concentric hyperspheres to intersect a 3d object serially, then project those intersections back to 3d space...

bntr•1y ago
Thanks — your method makes more sense now. I’m not very familiar with architectural design problems, so I didn’t fully grasp how this technique helps build a more complete understanding of the internal structure of composed objects. The final image reminds me of a kind of holographic source.

When I think in that direction, it seems more appropriate not to add spatial dimensions (like 4D), but to add animation to your method (shifting or rotating the original composed object). That might help an untrained viewer better understand the usefulness of the final projection.

Behind Every Dad Bod Is a Healthy Dad Brain

https://www.nytimes.com/2026/06/06/opinion/dad-brain-health-fatherhood.html
1•mutator•4m ago•0 comments

Modular morals: Mapping the organization of the moral brain (2024)

https://www.sciencedirect.com/science/article/pii/S0278262624000782
1•nativeit•4m ago•0 comments

I built a Discord status for Claude Code

https://www.npmjs.com/package/vibecoder-discord-presence
2•yunexx•8m ago•0 comments

1982 World Championship Double Decker Bus Racing (1982) [video]

https://www.youtube.com/watch?v=7QFhuunZH2E
1•austinallegro•8m ago•0 comments

Try out my version of 1M checkboxes

https://joeheyming.github.io/checkboxes/
1•joeheyming•9m ago•1 comments

Agentic AI solved coding and exposed every other problem in SE

https://venturebeat.com/technology/agentic-ai-solved-coding-and-exposed-every-other-problem-in-so...
1•msolujic•9m ago•0 comments

China has approved the first invasive brain-computer chip

https://www.technologyreview.com/2026/06/01/1138133/china-world-first-brain-chip/
2•sudo_cowsay•12m ago•0 comments

We May Be Entering a Second Axial Age

https://www.noemamag.com/we-may-be-entering-a-second-axial-age/
1•simonebrunozzi•14m ago•0 comments

AI friends too cheap to meter

https://jasmi.news/p/ai-friends
1•simonebrunozzi•18m ago•0 comments

Oxford Uni student data pwned yet again, this time via career platform breach

https://www.theregister.com/security/2026/06/06/oxford-university-data-pwned-again-by-career-plat...
3•Bender•21m ago•0 comments

Show HN: A List of AI Neolabs

https://neolabs-7o2.pages.dev/
2•warthog•21m ago•0 comments

Ask HN: I made an image watermarking tool. What are the issues open-sourcing it?

1•minimaxir•21m ago•0 comments

UK exam watchdog frets over smart specs turning GCSEs into Google searches

https://www.theregister.com/personal-tech/2026/06/07/uk-exam-watchdog-frets-over-smart-specs-turn...
1•Bender•22m ago•0 comments

Stronger Search Architectures Can Substitute for Larger LLMs

https://ttanv.github.io/levi/
1•ttanv•22m ago•0 comments

Do GLP-1 pills work as well as injections? Here's what studies show

https://ktla.com/news/nationworld/do-glp-1-pills-work-as-well-as-injections-heres-what-studies-sh...
1•Bender•23m ago•0 comments

It doesn't always have to be Linux [video]

https://media.ccc.de/v/gpn24-611-it-doesn-t-always-have-to-be-linux-an-intro-to-freebsd
2•birdculture•24m ago•0 comments

Should we ditch the idea of three meals a day?

https://www.theguardian.com/books/2026/jun/07/should-we-ditch-the-idea-of-three-meals-a-day
1•homarp•24m ago•1 comments

Ask HN: Debugging failure in large interconnected back end systems

1•Ifedayo_s•28m ago•0 comments

Quantum Information as Everything

https://vlatkovedral.substack.com/p/quantum-information-as-everything
1•ljosifov•31m ago•0 comments

Programmable artificial RNA condensates in mammalian cells

https://www.nature.com/articles/s41565-026-02164-7
1•PaulHoule•31m ago•0 comments

Why I care so much about energy per token

https://ziraph.com/blog/energy-per-token-vanity-sanity-reality
1•ABS•32m ago•0 comments

The Read Model Zoo: Projections Beyond Tables

https://docs.eventsourcingdb.io/blog/2026/06/08/the-read-model-zoo-projections-beyond-tables/
1•goloroden•32m ago•0 comments

Ideogram 4.0 Technical Details: Open model at the forefront of design

https://ideogram.ai/blog/ideogram-4.0/
1•simonpure•33m ago•0 comments

No Model Will Save Us: Pope Leo, the Miserostat, and AI's Woke Coders

https://www.wmbriggs.com/post/61049/
2•B1FF_PSUVM•34m ago•0 comments

Billions spent and hypothetical returns: the AI boom explained with six charts

https://www.theguardian.com/technology/2026/jun/07/billions-spent-hypothetical-returns-the-ai-boo...
5•billybuckwheat•34m ago•0 comments

ChatGPT app hits 1B monthly active users in record time

https://www.reuters.com/technology/chatgpt-app-hits-1-billion-monthly-active-users-record-time-da...
1•geox•37m ago•0 comments

Why isn't the U.S. better at soccer?

https://www.natesilver.net/p/why-isnt-the-us-better-at-soccer
21•7777777phil•41m ago•12 comments

Show HN: CodeSage Pro – an AI copilot that reads the problem on the page

https://chromewebstore.google.com/detail/codesage-pro-—-universal/cbkkghdedpjamcicmnfpihehmgjemmhi
1•rsingh867•42m ago•0 comments

When robots take over jobs, who decides what they do?

https://lorenzopieri.com/robotic_commons/
2•lorepieri•43m ago•0 comments

Ask HN: What is happening with the Meta Ads dashboard?

1•ramon156•45m ago•0 comments