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

+53
View File
@@ -379,6 +379,59 @@ export function createContractSuite(
}
},
],
[
'render.setSharpen: merges partial updates, rejects bad values, draws',
async () => {
const previous = engine.render.sharpen();
const same = (expected, label) => {
const actual = engine.render.sharpen();
ensure(
actual.enabled === expected.enabled &&
actual.amount === expected.amount,
`${label}: ${JSON.stringify(actual)} is not ${JSON.stringify(expected)}`,
);
};
ensure(
typeof previous.enabled === 'boolean' &&
Number.isFinite(previous.amount),
`sharpen() ${JSON.stringify(previous)} is not { enabled, amount }`,
);
try {
engine.render.setSharpen({ enabled: true, amount: 1.7 });
same({ enabled: true, amount: 1.7 }, 'after enabling');
engine.render.sharpen().amount = 0;
same({ enabled: true, amount: 1.7 }, 'sharpen() is a copy');
// A frame with the sharpening on draws without errors.
await settle(2);
engine.render.setSharpen({ amount: 0.5 });
same({ enabled: true, amount: 0.5 }, 'after an amount alone');
engine.render.setSharpen({ enabled: false });
same({ enabled: false, amount: 0.5 }, 'after disabling');
for (const bad of [
{ enabled: 'yes' },
{ amount: -0.1 },
{ amount: Number.NaN },
{ amount: '1' },
]) {
let error = null;
try {
engine.render.setSharpen(bad);
} catch (caught) {
error = caught;
}
ensure(
error instanceof TypeError,
`setSharpen(${JSON.stringify(bad)}) did not throw a TypeError`,
);
}
same({ enabled: false, amount: 0.5 }, 'after rejected values');
await settle(1);
} finally {
engine.render.setSharpen(previous);
await settle(1);
}
},
],
[
'camera.flyTo: duration 0 lands and completes before flyTo returns',
async () => {