Every set blends as its blend says on the Cesium renderer

Each frame drawn, a set's host turns the draw commands it gave to the set's
blend before the scene sorts them: opaque draws every command in the
opaque pass unblended with depth writes; translucent alpha-blends every
command without depth writes; additive adds colour times alpha without
depth writes, still depth-tested, after the opaque commands and before the
order-independent translucent pass. Ground commands only blend
differently. Lines, shapes, models, quads, meshes and GPU icons take every
blend, live through setOptions (models do not load again); GPU icons no
longer refuse opaque or additive. The contract documents the semantics and
the checks draw.sets.blend and draw.models.blend read the pixels. The
package boundaries own setBlend.js and screenCluster.js.
This commit is contained in:
Sameh Khamis committed 2026-11-11 16:49:27 -08:00
1 parent a4a4366b13
commit b741b0d5f5
11 files changed
+674 -15

No files matched your search

+16 -2
View File
@@ -38,6 +38,7 @@ import { clusterScreenPoints } from '../../geo/screenCluster.js';
import { provideUnboundDraw } from '../rendererOf.js';
import { blobUrl, listenerList, toCartesian, uncaught } from './common.js';
import { createGpuIcons, GPU_ICON_CAPABILITIES } from './gpuIcons.js';
import { blendHost } from './setBlend.js';
import { createModelSets } from './drawModels.js';
import { materialTexture } from './internals.js';
import { createMeshSets } from './drawMeshes.js';
@@ -127,11 +128,15 @@ const displayConditionOf = (range) =>
? new Cesium.DistanceDisplayCondition(range[0], range[1])
: undefined;
/** Cesium's point blending for a set's `blend`. */
/**
* Cesium's point blending for a set's `blend`: additive ones are built
* translucent, a command a set, and added where they draw (`setBlend.js`).
*/
const pointBlendOf = (blend) =>
({
opaque: Cesium.BlendOption.OPAQUE,
translucent: Cesium.BlendOption.TRANSLUCENT,
additive: Cesium.BlendOption.TRANSLUCENT,
})[blend] ?? Cesium.BlendOption.OPAQUE_AND_TRANSLUCENT;
/**
@@ -560,7 +565,8 @@ export function createCesiumDraw({
Object.assign(spec, options);
// What clamped items clamp to, how points blend, and whether ground
// primitives pick, are built into them. Models clamp nothing, only
// points and icons build in the blend, and only shapes and lines have ground
// points and icons build in the blend (every set's commands are
// turned to it each frame, `setBlend.js`), and only shapes and lines have ground
// primitives: other kinds are not rebuilt for those (models would
// load again).
if (
@@ -710,6 +716,8 @@ export function createCesiumDraw({
// Named for code that finds a set's host among the scene's primitives
// (`uploadProbe.js`).
host.drawSetId = record.spec.id;
// `blend`: its commands turned to the set's blend each frame drawn.
blendSetHost(record, host);
// Only old ground primitives wait for the new ones: the rest of the old
// host goes now, as the new host's own parts draw at once.
if (
@@ -743,6 +751,11 @@ export function createCesiumDraw({
if (!old) orderHosts();
}
/** A set's host drawn in the set's `blend`, as it is each frame. */
function blendSetHost(record, host) {
blendHost(host, () => record.spec.blend ?? undefined);
}
/**
* `SetSpec.drawOrder`: the sets' hosts stacked in the scene's primitives
* by their draw order. Of opaque billboards and points that skip the
@@ -1002,6 +1015,7 @@ export function createCesiumDraw({
blendOption: pointBlendOf(record.spec.blend),
});
record.clusterHost = host;
blendSetHost(record, host);
scene.primitives.add(host);
}
host.removeAll();