fix(globe): Navara sprites, points and lines drawn after tone mapping

Review of Tasks 2–3: on Navara the overlays went through the look's
tone mapping and grading (magenta came out as 247/40/228, green as
147/228/89 in the cinematic look), where Cesium draws billboards and
polylines in the colours asked for.

src/globe/navara/overlay.js: a public Navara EffectDesc (gevOverlay)
inserted after toneMapping and before the gev sharpening, SMAA/FXAA and
final, whose pass renders one three scene over the tone-mapped input
buffer (in Navara's own Pass wrapper: Navara inserts a bare pass only
when it is an instance of its own postprocessing copy); it costs nothing
while the scene is empty. The chain has no depth buffer, so each overlay
material tests the scene depth itself (overlayDepth.js): its log depth
against Navara's MRT depth (RGBA packed), modes always / normal /
depth-fail, disableWithinM as a per-vertex escape. Sprites and points
(moverMesh.js) and line ribbons (lineMesh.js) live in that scene with
their per-frame work as overlay hooks; models stay Navara meshes, lit
and graded like the tiles. The sharpening now sits after the overlay
(Cesium's sharpen stage sharpens billboards too).

Also (review): Navara pixel dashes are measured in CSS pixels
(gl_FragCoord over uGevPixelRatio), and the line viewport uniform is
updated in place.

Measured: a magenta sprite draws 255/0/255. The contract suite's colour
checks are now within 40 of the asked colour on every channel on both
engines (were: dominant channels); Cesium 68/68, Navara 74/74 (its
sharpen-order check accepts the overlay between tone mapping and the
sharpening). Shell: cesium 23/23, cross 4/4; navara 23/25 — the two map
stack pictures from space fail on stddev 7.2/7.6 against 8, as on the
Task 3 commit run at the same hour (the cinematic sun follows the clock
into night over the reset view), not from this change.
This commit is contained in:
German Khokhlov committed 2026-10-16 19:04:57 +04:00
1 parent 3c2e924363
commit e804351205
11 files changed
+388 -125

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
// The depth test of gev's screen overlays on Navara (sprites, points and
// lines drawn after tone mapping, overlay.js): there is no depth buffer in
// the post-processing chain, so each fragment compares its own logarithmic
// depth with the scene's, read from Navara's MRT pass (depth packed to RGBA,
// as the sharpening reads it). Modes: 0 always drawn; 1 hidden where the
// scene is nearer (normal); 2 drawn only where the scene is nearer (a
// line's depth-fail copy). `vGevDepthFree` (set by the vertex shader) lets
// an instance skip the test (disableWithinM). No three imports: GLSL only.
export const OVERLAY_DEPTH_MODES = Object.freeze({
always: 0,
normal: 1,
fail: 2,
});
/** Fragment declarations: uniforms, the varying and gevOverlayHidden(). */
export const OVERLAY_DEPTH_FRAGMENT = /* glsl */ `
uniform sampler2D tGevSceneDepth;
uniform vec2 uGevResolution;
uniform float uGevDepthMode;
varying float vGevDepthFree;
bool gevOverlayHidden() {
if (uGevDepthMode < 0.5 || vGevDepthFree > 0.5 || uGevResolution.x < 1.0)
return false;
// three's unpackRGBAToDepth (RGBADepthPacking).
float scene = dot(
texture2D(tGevSceneDepth, gl_FragCoord.xy / uGevResolution),
vec4(255.0 / 256.0, 255.0 / 65536.0, 255.0 / 16777216.0, 1.0 / 16777216.0)
);
#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
float mine = log2(vFragDepth) * logDepthBufFC * 0.5;
#else
float mine = gl_FragCoord.z;
#endif
bool occluded = mine > scene + 2e-6;
return uGevDepthMode < 1.5 ? occluded : !occluded;
}
`;
/** Vertex declaration of the per-vertex escape from the depth test. */
export const OVERLAY_DEPTH_VERTEX = /* glsl */ `
varying float vGevDepthFree;
`;