feat(globe): Sharpen on Navara, on at 80 % by default

The contract gains render.setSharpen({ enabled, amount }) and
render.sharpen(). Navara draws it as a custom EffectDesc: Cesium's unsharp
mask (3x3 box blur, gamma 2.2 round trip so one amount matches Cesium)
right after tone mapping and before SMAA/FXAA, skipping sky and cloud
pixels by scene depth. The Cesium engine keeps the state only; Cesium mode
still sharpens with its own post stage, unchanged. The fake engine records
it and the contract suite checks it.

Without a viewer the Sharpen slider and toggle drive the engine with the
same slider-to-amount mapping. On Navara the defaults, presets and share
links read Cesium's 49 % as 80 %.
This commit is contained in:
German Khokhlov committed 2026-10-16 13:30:56 +04:00
1 parent ac081a008d
commit bb8c0b83c4
17 files changed
+521 -16

No files matched your search

+22 -3
View File
@@ -7,7 +7,11 @@
// destroy() removes everything the engine added; the view stays the caller's.
import * as geo from '../../geo/index.js';
import { createEngineEvent } from '../contract.js';
import {
SHARPEN_INITIAL,
createEngineEvent,
mergeSharpen,
} from '../contract.js';
import { cesiumFovy } from './cameraMath.js';
import { createCameraModel } from './cameraModel.js';
import { createNavaraCredits } from './credits.js';
@@ -64,13 +68,16 @@ function rayRaisedEllipsoid({ origin, direction }, height) {
* container?: HTMLElement,
* fetch?: typeof fetch,
* clock?: object,
* sharpen?: { set: (state: { enabled: boolean, amount: number }) => void, destroy: () => void },
* }} options `hooks` are internals.js; `container` defaults to the
* canvas's parent; `fetch` and `clock` are test seams.
* canvas's parent; `sharpen` draws render.setSharpen (sharpen.js; without
* it the engine only keeps the state) and the engine destroys it; `fetch`
* and `clock` are test seams.
* @returns {import('../contract.js').GlobeEngine}
*/
export function createNavaraEngine(
view,
{ hooks, container, fetch, clock } = {},
{ hooks, container, fetch, clock, sharpen: sharpenPort = null } = {},
) {
if (!view?.camera?.raw)
throw new TypeError('createNavaraEngine needs a view');
@@ -177,6 +184,7 @@ export function createNavaraEngine(
},
};
let sharpen = { ...SHARPEN_INITIAL };
let destroyed = false;
return {
kind: 'navara',
@@ -196,6 +204,16 @@ export function createNavaraEngine(
view.animation = Boolean(enabled);
},
isContinuous: () => view.animation === true,
setSharpen(options) {
const next = mergeSharpen(sharpen, options);
const changed =
next.enabled !== sharpen.enabled || next.amount !== sharpen.amount;
sharpen = next;
if (!changed || destroyed) return;
sharpenPort?.set({ ...next });
view.forceUpdate();
},
sharpen: () => ({ ...sharpen }),
},
surface,
input: input.input,
@@ -210,6 +228,7 @@ export function createNavaraEngine(
input.destroy();
credits.destroy();
maps.destroy();
sharpenPort?.destroy();
},
isDestroyed: () => destroyed,
};