From 26968f4903b59e8fa5528b6197ac181f1ce86ce0 Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Fri, 16 Oct 2026 14:34:17 +0400 Subject: [PATCH] fix(ui): the Cesium engine's render.sharpen() mirrors the sharpen stage VisualEffects sends its sharpen state to engine.render.setSharpen when a viewer exists too; the Cesium engine keeps it as state, and the Cesium stage itself is unchanged. --- src/ui/visualEffects.js | 10 +++++----- src/ui/visualEffects.test.mjs | 26 ++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/ui/visualEffects.js b/src/ui/visualEffects.js index b23f9ebbf..461276e20 100644 --- a/src/ui/visualEffects.js +++ b/src/ui/visualEffects.js @@ -32,12 +32,11 @@ export class VisualEffects { createStage = (options) => new PostProcessStage(options), }) { this.viewer = viewer; - // Cesium sharpens with its own post stage below; an engine without a - // viewer (Navara) sharpens in its render pipeline. + // Cesium sharpens with its own post stage below, and the engine's + // render.sharpen() mirrors that stage (the Cesium engine keeps the state + // only); an engine without a viewer (Navara) sharpens in its pipeline. this.engineRender = - !viewer && typeof engine?.render?.setSharpen === 'function' - ? engine.render - : null; + typeof engine?.render?.setSharpen === 'function' ? engine.render : null; this.requestRender = requestRender; this.holdRender = holdRender; this.releaseRender = releaseRender; @@ -118,6 +117,7 @@ export class VisualEffects { }); this.sharpenStage.enabled = false; this.viewer.scene.postProcessStages.add(this.sharpenStage); + this.engineRender?.setSharpen({ enabled: false }); this.applySharpenIntensity(sharpenIntensity); } diff --git a/src/ui/visualEffects.test.mjs b/src/ui/visualEffects.test.mjs index a564008ca..2fbf94378 100644 --- a/src/ui/visualEffects.test.mjs +++ b/src/ui/visualEffects.test.mjs @@ -223,14 +223,32 @@ test('without a viewer the engine sharpens with the same amount scale', () => { effects.destroy(); }); -test('with a viewer the Cesium stage sharpens and the engine is left alone', () => { - let calls = 0; - const f = fixture({ render: { setSharpen: () => calls++ } }); +test('with a viewer the Cesium stage sharpens and the engine mirrors its state', () => { + let state = { enabled: false, amount: 1 }; + const engine = { + render: { + setSharpen: (options) => { + state = { ...state, ...options }; + }, + sharpen: () => ({ ...state }), + }, + }; + const f = fixture(engine); f.effects.initPostProcess(0.49); + assert.deepEqual(engine.render.sharpen(), { + enabled: false, + amount: f.effects.sharpenStage.uniforms.amount, + }); f.effects.applySharpenIntensity(0.8); f.effects.setSharpenEnabled(true); - assert.equal(calls, 0); assert.equal(f.effects.sharpenStage.uniforms.amount, sharpenAmount(0.8)); + assert.equal(f.effects.sharpenStage.enabled, true); + assert.deepEqual(engine.render.sharpen(), { + enabled: true, + amount: sharpenAmount(0.8), + }); + f.effects.setSharpenEnabled(false); + assert.equal(engine.render.sharpen().enabled, false); f.effects.destroy(); });