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

+56
View File
@@ -141,3 +141,59 @@ test('visual teardown restores owned fog and aircraft sensor state once', async
assert.equal(owner._irBoostActive, false);
owner.destroy();
});
test('on Navara, presets set the Sharpen slider to 80 % and the engine draws it', async (t) => {
const { VisualSettings } = await import('./visualSettings.js');
const priorDocument = globalThis.document;
globalThis.document = {
documentElement: { dataset: {} },
getElementById: () => null,
};
t.after(() => {
globalThis.document = priorDocument;
});
const sharpen = [];
const classList = { toggle() {} };
const element = (value) => ({ value, textContent: '', classList });
const elements = {
_bloomBtn: element(),
_bloomSlider: element('0'),
_bloomSliderRow: element(),
_bloomSliderValue: element(),
_sharpenBtn: element(),
_sharpenSlider: element('49'),
_sharpenSliderRow: element(),
_sharpenSliderValue: element(),
};
const owner = new VisualSettings({
viewer: null,
engine: {
kind: 'navara',
render: { setSharpen: (options) => sharpen.push(options) },
},
elements,
operations: {
_syncShareState() {},
_layoutRightPanels() {},
_setHudVariant() {},
_updateHudButtonState() {},
},
services: {
governorRequestRender() {},
holdContinuousRender() {},
releaseContinuousRender() {},
},
readHud: () => ({ getVariant: () => 'tactical', setMode() {} }),
});
owner._detectionUserOverridden = true;
owner._applyStylePresetDefaults('retro');
assert.equal(elements._sharpenSlider.value, '80');
assert.equal(elements._sharpenSliderValue.textContent, '80%');
// _setSharpenEnabled applies the slider again; the engine skips repeats.
assert.deepEqual(sharpen, [
{ amount: 1.7000000000000002 },
{ enabled: true },
{ amount: 1.7000000000000002 },
]);
owner.destroy();
});