diff --git a/src/layers/firms/rendering.js b/src/layers/firms/rendering.js index 55d93dae4..d78010fb3 100644 --- a/src/layers/firms/rendering.js +++ b/src/layers/firms/rendering.js @@ -466,7 +466,7 @@ export function createRendering({ if (!layerState._viewer || layerState._icons) return; const set = drawOf(layerState._viewer).icons({ id: `firms:${++iconSets}:icons`, - // Blended in one pass, in order, as the detections overlap. + // Blended as one translucent pass, as its billboards were. blend: 'translucent', horizonCull: true, show: layerState._enabled && !(layerState._handoffHeat >= 1), diff --git a/src/layers/shipwrecks/index.js b/src/layers/shipwrecks/index.js index 51b37ecfe..c2c2db281 100644 --- a/src/layers/shipwrecks/index.js +++ b/src/layers/shipwrecks/index.js @@ -380,8 +380,7 @@ export function createShipwrecksLayer({ // sprite layers (`SPRITE_LAYER_ORDER`). _markers = drawOf(viewer).icons({ id: 'shipwrecks:markers', - // Blended in one pass, in order: the wrecks added last (the - // largest) on top. + // Translucent, as its billboards were. blend: 'translucent', drawOrder: spriteDrawOrder(SHIPWRECKS_LAYER_ID), show: false, diff --git a/src/layers/vessels/rendering.js b/src/layers/vessels/rendering.js index 6e114985f..89dd8b647 100644 --- a/src/layers/vessels/rendering.js +++ b/src/layers/vessels/rendering.js @@ -145,8 +145,8 @@ export function createRendering({ if (!viewer || state.icons) return; const set = drawOf(viewer).icons({ id: `ais-vessels:${++instances}`, - // Blended in one pass, in order, each chevron keeping its outline - // over the ones under it. + // Translucent, as its billboards were: overlapping chevrons keep + // their outlines rather than the first one's fill. blend: 'translucent', horizonCull: true, drawOrder: spriteDrawOrder?.('ais') ?? 0, diff --git a/src/render/cesium/iconSetPrimitive.js b/src/render/cesium/iconSetPrimitive.js index 4d62243af..c7e1534d1 100644 --- a/src/render/cesium/iconSetPrimitive.js +++ b/src/render/cesium/iconSetPrimitive.js @@ -327,9 +327,10 @@ const EARTH_BOUNDS = new Cesium.BoundingSphere( * a newly loaded image, for a layer that does not render continuously. * `cull` says whether rows past the ellipsoid's horizon are hidden (by * default always). `translucent` says whether every row is drawn in one - * alpha-blended pass, in row order, the last on top (Cesium's - * `BlendOption.TRANSLUCENT`), in place of an opaque pass and a translucent - * one (by default never). `pickObject` builds a row's pick object around the + * alpha-blended pass, as Cesium's `BlendOption.TRANSLUCENT` billboards + * are, in place of an opaque pass and a translucent one (by default + * never); under order-independent translucency, overlapping rows blend + * together, as those billboards do. `pickObject` builds a row's pick object around the * `primitive` drill picks hide it by (by default `{ id, iconSet, meta, * primitive }`). */ @@ -795,9 +796,8 @@ export class IconSetPrimitive { }), ), ]; - // Every row in one pass, blended in row order: equal depths pass, and - // depth is written in place of sorting, as Cesium's translucent - // billboards do. + // Every row in one blended pass, equal depths passing and depth written + // in place of sorting, as Cesium's translucent billboards are drawn. this._singleCommand = command( Cesium.Pass.TRANSLUCENT, this._programs.single, diff --git a/src/render/cesium/setBlend.test.mjs b/src/render/cesium/setBlend.test.mjs index 7a1b0d1ad..433cf13cd 100644 --- a/src/render/cesium/setBlend.test.mjs +++ b/src/render/cesium/setBlend.test.mjs @@ -172,3 +172,31 @@ test('a blended host turns only its own commands, in render passes, each frame', 'wrapped once', ); }); + +test('a host that draws the blend itself keeps its commands as made, and others turn back', () => { + const [mine] = commands(); + let blend = 'additive'; + let drawsIt = false; + const host = blendHost( + { + update: (fs) => fs.commandList.push(mine), + drawsBlend: (asked) => drawsIt && asked === 'translucent', + }, + () => blend, + ); + const frame = () => { + const frameState = { commandList: [], passes: { render: true } }; + host.update(frameState); + return frameState.commandList[0]; + }; + const given = { renderState: mine.renderState, pass: mine.pass }; + assert.notEqual(frame().renderState, given.renderState, 'turned to additive'); + blend = 'translucent'; + drawsIt = true; + const drawn = frame(); + assert.equal(drawn.renderState, given.renderState, 'as made'); + assert.equal(drawn.pass, given.pass); + blend = undefined; + drawsIt = false; + assert.equal(frame().renderState, given.renderState, 'still as made'); +});