mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Cesium effects port draws screenModulation, the marker sweep
The adapter's effects port now has screenModulation: a contract sector shades points, billboards (labels among them) and icon sets in their own vertex shaders, swapped into this scene's command list as the primitives update, and tints models on the CPU after every owner has written its colour. Geometry and picks are unchanged. It is the sweep the cyber HUD already draws, carried into src/render/cesium/screenModulation.js and driven by a sector instead of document settings; nothing is installed until a sector is set, and disposal gives everything back. The capability is advertised on the Cesium version the command swap is tested against; diagnostics list the pass while it draws, and listeners hear when it starts or stops (a native shader it cannot take stops it). A set asks for a frame unless it changes nothing drawn: the same sector, or only the angle of a sweep while no shaded marker was in view. cyberSonarSector() gives the sector for the cyber sweep; the app switches to the port in the next commit. Conformance: the screenModulation check runs on Cesium; new checks read the pixels (in the band an icon draws, outside it and at radius 0 it dims to the floor, strength 1 draws it in the colour, clearing restores it) and check the member is absent without the capability.
This commit is contained in:
1 parent
ab678443ce
commit
85a04b1367
11 files changed
+1573
-10
No files matched your search
Vendored
+40
-3
@@ -18,12 +18,17 @@
|
||||
*
|
||||
* Building the port changes nothing in the scene; the first `bloom` call
|
||||
* takes the scene's bloom stage, and disposal gives it back as it was.
|
||||
* There is no `screenModulation`: GEV's sweep shades each icon and label
|
||||
* in its own shader, not the frame.
|
||||
* `screenModulation` is no stage: it shades each marker in its own shader
|
||||
* (`screenModulation.js`), so the map, lines and shapes draw as they are.
|
||||
* Like the rest, it changes nothing in the scene until a sector is set.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { provideUnboundEffects } from '../rendererOf.js';
|
||||
import { listenerList, uncaught } from './common.js';
|
||||
import {
|
||||
createCesiumScreenModulation,
|
||||
screenModulationSupported,
|
||||
} from './screenModulation.js';
|
||||
|
||||
/** Below this a style, bloom or sharpen draws nothing, so it runs no pass. */
|
||||
const OFF = 0.001;
|
||||
@@ -136,6 +141,20 @@ export function createCesiumEffects(
|
||||
let disposed = false;
|
||||
const started = performance.now();
|
||||
|
||||
/** Whether the modulation pass drew when listeners last heard. */
|
||||
let modulationListed = false;
|
||||
const modulation = capabilities.has('screenModulation')
|
||||
? createCesiumScreenModulation(scene, {
|
||||
frame,
|
||||
// The pass stopped drawing on its own (a shader it cannot take).
|
||||
onChange: () => {
|
||||
if (gone() || modulation.draws() === modulationListed) return;
|
||||
modulationListed = modulation.draws();
|
||||
listeners.fire(port.diagnostics());
|
||||
},
|
||||
})
|
||||
: null;
|
||||
|
||||
// Disposed, or the scene went first and took its stages with it.
|
||||
const gone = () => disposed || scene.isDestroyed?.() === true;
|
||||
|
||||
@@ -332,6 +351,7 @@ export function createCesiumEffects(
|
||||
? ['bloom']
|
||||
: []),
|
||||
...(sharpenStage?.enabled ? ['sharpen'] : []),
|
||||
...(modulation?.draws() ? ['screenModulation'] : []),
|
||||
],
|
||||
}),
|
||||
on(event, cb) {
|
||||
@@ -340,6 +360,17 @@ export function createCesiumEffects(
|
||||
},
|
||||
};
|
||||
|
||||
if (modulation)
|
||||
port.screenModulation = (sector) => {
|
||||
if (gone()) return;
|
||||
modulation.set(sector ?? null);
|
||||
// Its own render demand: a sweep moving where nothing is shaded asks
|
||||
// for no frame. Listeners hear when the pass starts or stops.
|
||||
if (modulation.draws() === modulationListed) return;
|
||||
modulationListed = modulation.draws();
|
||||
listeners.fire(port.diagnostics());
|
||||
};
|
||||
|
||||
function assignParams(record, params) {
|
||||
for (const [key, value] of Object.entries(params ?? {})) {
|
||||
if (!(key in record.values)) continue;
|
||||
@@ -356,6 +387,7 @@ export function createCesiumEffects(
|
||||
disposed = true;
|
||||
stopClock();
|
||||
listeners.clear();
|
||||
modulation?.dispose();
|
||||
// A destroyed scene took its stages with it.
|
||||
if (scene.isDestroyed?.()) {
|
||||
styles.clear();
|
||||
@@ -419,7 +451,12 @@ provideUnboundEffects((viewer) => {
|
||||
)
|
||||
return null;
|
||||
return createCesiumEffects(scene, {
|
||||
capabilities: new Set(['styles', 'bloom', 'sharpen']),
|
||||
capabilities: new Set([
|
||||
'styles',
|
||||
'bloom',
|
||||
'sharpen',
|
||||
...(screenModulationSupported() ? ['screenModulation'] : []),
|
||||
]),
|
||||
frame: sceneFrame(scene),
|
||||
report: uncaught,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user