# A white halo on a Godot planet: one commit cut the edge's sharpest brightness drop from 188 to 40 (of 255)

> Source: <https://dev.to/nefayran/a-white-halo-on-a-godot-planet-one-commit-cut-the-edges-sharpest-brightness-drop-from-188-to-40-250f>
> Published: 2026-11-26 15:38:53+00:00

**Key takeaway:** Setting an explicit render_priority on a depth-untested transparent atmosphere shell and swapping an uncapped glow formula for 1.0 - exp(-col * rim * lit * strength) cut the edge's sharpest brightness drop from 188 to 40 of 255 and near-white pixels from 1,171 to 3.

The menu of our game shows a planet from orbit, and its blue atmosphere glow looked wrong: a white band, cut off against the sky in little steps. One commit, which changed the order in which things are drawn and the glow shader, took the sharpest brightness fall at the planet's edge from 188 to 40 (out of 255) and the near-white pixels around it from 1,171 to 3, measured on frames of the built game at 1440x900.

The game is [Planet Wanderer](https://allkeep.org/en/products?utm_source=devto&utm_medium=article&utm_campaign=2026-11-25-planet-edge-white-pixels), and it is an experiment: AI coding agents write it in Godot 4, and I direct them, play the builds and check what they measure. It is not released, so there is nothing to download yet, and its code is not public, so the file names below are for orientation only. The card on that page is where it lives for now.

From orbit, a planet with an atmosphere has a thin rim of lit air, thickest at the edge because that is where your line of sight crosses the most air. Our menu planet drew this rim with a shell of air around the ground, added on top of the picture.

On screen the rim was a bright, almost white band, and its outer edge ran in stair steps. The steps followed the hexagonal columns that the planet's ground is built from. Some cloud heaps near the edge were cut the same way.

The commit's comments put the stair-stepped band down to draw order: the glow was painted over after it was drawn. The white came from the old glow formula, `col * rim * lit * strength`, which had no upper limit, so the glow that survived clipped to white. The commit changed both.

A Godot 3D scene draws see-through things in an order, and the engine sorts them by distance unless you set a priority. Our air shell does not test depth and does not write depth. The galaxy backdrop behind the planet is not opaque to Godot: its shader writes ALPHA, so Godot sorts it with the transparent things, and centred on the camera it came last.

So the galaxy painted over the glow. The glow survived only on screen pixels where a solid ground column stood in front of the galaxy: the ground wrote depth there, and the farther galaxy failed the depth test. Those pixels follow the outline of the hex columns. A glow visible only where hex columns stand in front of it is a stair-stepped band. The surviving glow came from the uncapped formula and clipped to white, which is why the band was white.

The fix is one commit with four parts, plus new defaults:

`glow = 1.0 - exp(-col * rim * lit * strength)`.` if (b < surf_r)` that switched between "air over the ground" and "air at the rim" became a smooth blend over a 16 m band (8 m each side of the ground's edge). The old switch cut a visible ring against the hex edge.
The same commit lowered the menu's air strength from 4.2 to 2.0 and narrowed the air shell's span, its height over the ground, from 130 m to 70 m.

No run measures one part alone, so I credit the commit as a whole. Parts 2 to 4 are shader changes.

Part 1 is two lines (shortened; the comment is rewritten for this article):

``` js
const AIR_PRIORITY := 2   # after the galaxy and the cloud heaps (both 0) and another haze layer (1)
...
m.render_priority = AIR_PRIORITY
```

"Looks smoother" is hard to compare by eye between two screenshots, so the agents wrote a script, `tools/rim_measure.py`, and ran it on screenshots of the built game on Windows, before and after, same world and same window size.

For each frame it:

A white band cut off against the sky falls by over 100 in one pixel. A glow that fades out falls by a few tens. The script has 106 lines; its core, shortened:

```
# the comments below are written for this article; the code is shortened from rim_measure.py
for deg in np.arange(150.0, 300.0, 0.5):                    # lit side, 300 rays
    t = math.radians(deg)
    rs = np.arange(R * 0.92, R * 1.30, 0.5)
    v = sample(L, cx + rs * math.cos(t), cy + rs * math.sin(t))  # brightness along the ray
    out = v[rs >= R * 0.995]                                # outside the disc
    jumps.append(float(np.max(out[:-2] - out[2:])))         # biggest fall over one pixel (2 samples)
jump_p95 = np.percentile(jumps, 95)
ring = (rr > R * 1.0) & (rr < R * 1.25)                     # rr = distance from the disc centre
white = ((a[..., 0] > 225) & (a[..., 1] > 225) & (a[..., 2] > 225) & ring).sum()
```

It also prints `steps_px`, how far the glow's edge wanders between neighbouring rays, which is the stair-step measure itself. The design document records no `steps_px` values for these frames, so I give only the jump and the white count.

| Window | Jump before | Jump after | White pixels before | White pixels after | 
|---|---|---|---|---|
| 1440x900 | 188 | 40 | 1,171 | 3 | 
| 1920x1080 | 192 | 38 | 1,926 | 39 | 

The jump falls by a factor of about five at both sizes. The white-pixel count is the shakier number: an earlier after-fix run, made before the commit was recorded, gave 14 where this one gave 3 (next section). The larger window keeps 39 white pixels, and I do not know yet where they sit.

A comment in the game code says the jump went from 197 to 43 and the white pixels from 1,248 to 14. The table above is the one in the design document, from the exported builds. That comment sits inside the commit itself, so it comes from an earlier after-fix run, made before the commit was recorded, and nothing shows the build was the same. The jump differs by a few percent, but the after-fix white count is 3 in one and 14 in the other, about 4.7 times apart at 1440x900. So I would not trust the white-pixel count, and the 1,171 to 3, to better than a factor of five. I do not know why the after-fix count is 3 in one run and 14 in the other.

The agents also added a test, `test_orbit_edge.gd`. It does not render anything. It checks that the air shell's material uses `AIR_PRIORITY` and that `AIR_PRIORITY` is above 1, that the shader uses premultiplied alpha, that the hard `if (b < surf_r)` is gone, and that both menu defaults are 2.0 and 70. It never reads the galaxy's priority, so raising the galaxy's would bring the old order back with the test still green.

It would pass on a shader with the right keywords and a bad look. The measurement lives in the script, which reads any PNG frames of the same world and window; Windows is only where our frames were made.

For your own project, the part that carries over is small: put your see-through layers in an explicit order, and measure the edge with a script before you tune any colours.

A jump of 40 out of 255 is clearly better than 188. I do not know whether 40 is smooth. Our only threshold is "a glow that fades out falls by a few tens", which the agents wrote in the same commit as the numbers. The measurement also covers only the menu frame; the design document says the white rim also showed on the world-select and flight screens, and those were not measured.

If you have measured this: what brightness fall per pixel at a planet's edge is the point where a person stops seeing a step, and does it depend on the background behind it?
