# Why didn't NME execute as expected?

**URL:** <https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685>\
**Category:** Questions\
**Created:** [March 6, 2026, 6:48am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685 "2026-03-06T06:48:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalidaliW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dalidaliw/32/28108_2.png) [@dalidaliW](https://forum.babylonjs.com/u/dalidaliW)\
**Post date:** [March 6, 2026, 6:48am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/1 "2026-03-06T06:48:35Z")

</div>

> **[Babylon.js Node Material Editor](https://nme.babylonjs.com/#Y1HCZX)**
>
> Babylon.js Node material editor - shader-based materials editor for Babylon.js

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/3/43a325c3663eb831278b5d2a3e2d3d4b2656a257.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/9/59dd1f416a95b96e27d09639a5a37564e83d75f8.png)  
expected：

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/8/a86f6fbc1ecbbcf3a2fc8177a972148f6249cb32.png)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 6, 2026, 9:27am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/2 "2026-03-06T09:27:50Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/d/6d0d61fbd47a7af546840e1c4b22cd932e38c0a3.png)

> **[Babylon.js Node Material Editor](https://nme.babylonjs.com/#Y1HCZX%232)**
>
> Babylon.js Node material editor - shader-based materials editor for Babylon.js

The problem is that it will stay at the center of the screen, even when you move the box:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/7/e7264815c7a8d45bc1ee98c3c228b751d94a21d0.png)

Also, I didn’t handle the aspect ratio of the display:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/7/07b82bcb91c9e61fab89c4ea08d92ea885bfd5a3.png)

---

<div class="post-metadata">

**Author:** ![dalidaliW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dalidaliw/32/28108_2.png) [@dalidaliW](https://forum.babylonjs.com/u/dalidaliW)\
**Post date:** [March 6, 2026, 9:58am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/3 "2026-03-06T09:58:17Z")

</div>

> [@Evgeni\_Popov](#):
>
> 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 to generate a color.`position.length`
> 
> 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:
> 
> ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/d/6d0d61fbd47a7af546840e1c4b22cd932e38c0a3.png)
> 
> [Babylon.js Node Material Editor](https://nme.babylonjs.com/#Y1HCZX%232)
> 
> The problem is that it will stay at the center of the screen, even when you move the box:
> 
> ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/7/e7264815c7a8d45bc1ee98c3c228b751d94a21d0.png)
> 
> 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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 6, 2026, 10:12am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/4 "2026-03-06T10:12:44Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![fuyutami](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fuyutami/32/49210_2.png) [@fuyutami](https://forum.babylonjs.com/u/fuyutami)\
**Post date:** [March 7, 2026, 4:03pm UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/5 "2026-03-07T16:03:55Z")

</div>

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](https://nme.babylonjs.com/#Y1HCZX#3)

---

<div class="post-metadata">

**Author:** ![dalidaliW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dalidaliw/32/28108_2.png) [@dalidaliW](https://forum.babylonjs.com/u/dalidaliW)\
**Post date:** [March 9, 2026, 1:18am UTC](https://forum.babylonjs.com/t/why-didnt-nme-execute-as-expected/62685/7 "2026-03-09T01:18:16Z")

</div>

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
