The output looks good to me.
Everything is symetrical (so each face is rendered the same) because the box is centered at origin, and you take position.length to generate a color.
How did you generate the expected output? Given that it’s a perfect circle even after projection, it should probably be done in screen space:
The problem is that it will stay at the center of the screen, even when you move the box:
Also, I didn’t handle the aspect ratio of the display:
Shouldn’t it be centered around the mesh instead of a certain point? Why are the six faces rendered separately in the cube
Here is a response provided by AI (which is better worded than anything I could come up with!) ![]()
The output is actually correct and expected — let me explain what’s happening.
Why is it centered on each face individually?
The position node in NME gives you the vertex position in object space (the local coordinate system of the mesh, where (0,0,0) is the mesh’s own center). When you compute position.length, you’re measuring the Euclidean distance from the mesh’s center to every point on its surface.
For a box centered at the origin, the point on each face that is closest to the center is the center of that face. For example, the front face (at z = 0.5) has its closest point to the origin at (0, 0, 0.5) — which is exactly the middle of that face. The iso-distance contours (position.length = constant) on that flat face are perfect circles… centered on the middle of that face.
This is why you see 6 separate circular gradients, one per face — you are essentially slicing a sphere (the iso-distance surface in 3D) with each of the 6 flat faces of the box, and each slice gives you a
circle centered on that face’s midpoint. By symmetry, all 6 faces look identical.
Why doesn’t it look like “one” circle on the whole cube?
Because position.length is a 3D spherical distance around the mesh center. The mesh center is the reference point — it is centered around the mesh. But the result is a 3D sphere wrapped around a box, not a 2D circle projected onto the screen. Each face independently shows its own cross-section of that sphere.
If you want a single 2D circular gradient that looks like a circle centered on the mesh as seen on screen, you need to work in clip/screen space — which is what the screenshot above was demonstrating. The trade-off is that the circle then stays fixed relative to the screen, not the mesh, when the camera or mesh moves.
So in short: your material is doing exactly what the math says it should do — it’s just a 3D spherical gradient, not a 2D screen-space one!
I tried to make a glowing sphere that stays at the center of a cube. You can move the camera and zoom, the sphere should remain the same size and stay at the center of the cube. https://nme.babylonjs.com/#Y1HCZX#3
What I need is to virtualize around the mesh, not around the six faces of the mesh. For NME, it seems to become more complex





