mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 18:52:18 +00:00
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:
1 parent
3c2e924363
commit
e804351205
11 files changed
+388
-125
No files matched your search
@@ -23,6 +23,11 @@ import {
|
||||
originFor,
|
||||
packInstances,
|
||||
} from './pack.js';
|
||||
import {
|
||||
OVERLAY_DEPTH_FRAGMENT,
|
||||
OVERLAY_DEPTH_MODES,
|
||||
OVERLAY_DEPTH_VERTEX,
|
||||
} from '../overlayDepth.js';
|
||||
|
||||
const VERTEX_HEAD = /* glsl */ `
|
||||
attribute vec4 gevStyle;
|
||||
@@ -37,6 +42,7 @@ uniform float uGevOutlinePx;
|
||||
varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
${OVERLAY_DEPTH_VERTEX}
|
||||
`;
|
||||
|
||||
const VERTEX_PROJECT = /* glsl */ `
|
||||
@@ -66,6 +72,7 @@ gl_Position = projectionMatrix * mvPosition;
|
||||
vGevColor = gevColor;
|
||||
vGevLocal = gevCorner;
|
||||
vGevOutline = uGevOutlinePx / max(gevSizePx, 1e-3);
|
||||
vGevDepthFree = gevDistance < uGevDisableWithinM ? 1.0 : 0.0;
|
||||
`;
|
||||
|
||||
const VERTEX_UV = /* glsl */ `
|
||||
@@ -75,23 +82,18 @@ vMapUv = mix(gevUv.xy, gevUv.zw, uv);
|
||||
#endif
|
||||
`;
|
||||
|
||||
const VERTEX_DEPTH = /* glsl */ `
|
||||
#include <logdepthbuf_vertex>
|
||||
#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||||
if (gevDistance < uGevDisableWithinM) vFragDepth = 1.0;
|
||||
#endif
|
||||
`;
|
||||
|
||||
const FRAGMENT_HEAD = /* glsl */ `
|
||||
varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
${OVERLAY_DEPTH_FRAGMENT}
|
||||
`;
|
||||
|
||||
const fragmentColor = (point) =>
|
||||
point
|
||||
? /* glsl */ `
|
||||
#include <color_fragment>
|
||||
if (gevOverlayHidden()) discard;
|
||||
float gevRadius = length(vGevLocal) * 2.0;
|
||||
if (gevRadius > 1.0) discard;
|
||||
diffuseColor *= vGevColor;
|
||||
@@ -99,9 +101,16 @@ if (gevRadius > 1.0 - vGevOutline) diffuseColor.rgb = vec3(0.0);
|
||||
`
|
||||
: /* glsl */ `
|
||||
#include <color_fragment>
|
||||
if (gevOverlayHidden()) discard;
|
||||
diffuseColor *= vGevColor;
|
||||
`;
|
||||
|
||||
// Overlay uniforms of a mesh drawn outside an overlay (tests): no depth.
|
||||
const DETACHED_OVERLAY = Object.freeze({
|
||||
tGevSceneDepth: { value: null },
|
||||
uGevResolution: { value: [0, 0] },
|
||||
});
|
||||
|
||||
/** Patches three's MeshBasicMaterial shaders into the screen-space quad. */
|
||||
export function patchMoverShader(shader, uniforms, { point = false } = {}) {
|
||||
Object.assign(shader.uniforms, uniforms);
|
||||
@@ -117,7 +126,6 @@ export function patchMoverShader(shader, uniforms, { point = false } = {}) {
|
||||
);
|
||||
vertex = replace(vertex, '#include <project_vertex>', VERTEX_PROJECT);
|
||||
vertex = replace(vertex, '#include <uv_vertex>', VERTEX_UV);
|
||||
vertex = replace(vertex, '#include <logdepthbuf_vertex>', VERTEX_DEPTH);
|
||||
let fragment = replace(
|
||||
shader.fragmentShader,
|
||||
'void main() {',
|
||||
@@ -161,7 +169,7 @@ function atlasTexture(atlas, onLoad) {
|
||||
export function createMoverMesh(
|
||||
options,
|
||||
store,
|
||||
{ onTextureLoad = () => {} } = {},
|
||||
{ onTextureLoad = () => {}, overlayUniforms = DETACHED_OVERLAY } = {},
|
||||
) {
|
||||
const { capacity, kind, depthTest } = options;
|
||||
const point = kind === 'point';
|
||||
@@ -192,12 +200,23 @@ export function createMoverMesh(
|
||||
value: typeof depthTest === 'object' ? depthTest.disableWithinM : -1,
|
||||
},
|
||||
uGevOutlinePx: { value: point ? options.point.outlinePx : 0 },
|
||||
uGevDepthMode: {
|
||||
value:
|
||||
depthTest === 'always'
|
||||
? OVERLAY_DEPTH_MODES.always
|
||||
: OVERLAY_DEPTH_MODES.normal,
|
||||
},
|
||||
// Shared by every overlay: the scene depth and the target's size.
|
||||
tGevSceneDepth: overlayUniforms.tGevSceneDepth,
|
||||
uGevResolution: overlayUniforms.uGevResolution,
|
||||
};
|
||||
const material = new MeshBasicMaterial({
|
||||
map: point ? null : atlasTexture(options.sprite.atlas, onTextureLoad),
|
||||
transparent: true,
|
||||
alphaTest: 0.02,
|
||||
depthTest: depthTest !== 'always',
|
||||
// Drawn after tone mapping, with no depth buffer: the shader tests the
|
||||
// scene depth itself (overlayDepth.js).
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
side: DoubleSide,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user