Cloud-Top Tangent Fringe Fix (TVC Release 5)
by bmaju - 2026-11-05
License: MIT (see LICENSE.txt)
https://spacedock.info/mod/4792

What it fixes
-------------
With True Volumetric Clouds Release 5, a dotted 1-pixel red/white/cyan line
can appear along the top of a planet's cloud layer, seen around the planet
limb from low orbit. It becomes dotted and fades out as you climb.

Cause
-----
TVC renders each altitude interval of a body's cloud stack separately. When
the top interval is covered by a single layer, it is drawn with the
single-layer raymarch pass, which misbehaves where the view ray grazes the
top of the cloud shell. Intervals covered by two or more layers use the
overlap pass, which does not show the artifact. Cloud density does not
matter.

How the fix works
-----------------
For each body, the top cloud layer is copied as a near-empty (density 1e-7)
thin slab that ends at the layer's own top altitude. The top interval then
holds two layers and is drawn with the overlap pass. Below the slab the
clouds are drawn exactly as without the fix. The copy has no 2D layer, sound,
particles, lightning, droplets or wet-surface effects.

Bodies covered
--------------
Tuned entries (slab only on the top layer):
- StockVolumetricClouds: Kerbin, Eve, Duna, Laythe
- OPM volumetric clouds: Tekto, Thatmo, Sarnus, Urlum, Neidon
- OPX-JoolPlus: Jool
- bmaju's CustomizedQuackPack: Blas
- bmaju's CustomizedSilanSystem 1.0.9+: Erbtus, Lovell

Generic fallback (any other body with TVC V5 volumetric clouds, or a listed
body whose cloud config is different): a 1 km slab is added to the top of
every V5 layer of that body. Module Manager cannot tell which layer is the
highest, so all of them get one. Particle-only layers, layers below the
surface and ring layers are skipped. Bodies without V5 volumetric clouds
cannot show the artifact and are not touched.

Install
-------
Copy GameData/CloudTopTangentFringeFix into your KSP GameData folder.
Requires Module Manager. Safe to install together with bmaju's
ModpackPatches v1.0.21+ (each slab is only added once).

Notes
-----
- Tuned altitudes are hard-coded for the cloud configs listed above. If one
  of those packs changes its top altitude, update the matching entry.
- Do not lower the copy's raymarch settings to save performance: layers in
  one overlap interval are drawn together, so the real clouds get coarser too.
- OPX-JoolPlus copies its Jool layers into every EVE_CLOUDS root in GameData.
  This patch only adds Jool's slab in the StockVolumetricClouds root, but the
  duplication itself is not fixed here.

Tested with: KSP 1.12.5, EVE Redux / TVC 3.2.2.0 (Release 5), Scatterer
0.908, Deferred 1.3.5.0, MunGlow 4.7.0.66.
