Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Billboard transparency #4886

Merged
merged 17 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Change Log
* `TerrainProvider` now optionally exposes an `availability` property that can be used to query the terrain level that is available at a location or in a rectangle. Currently only `CesiumTerrainProvider` exposes this property.
* Added `sampleTerrainMostDetailed` to sample the height of an array of positions using the best available terrain data at each point. This requires a `TerrainProvider` with the `availability` property.
* Added 2D and Columbus View support for models using the RTC extension or whose vertices are in WGS84 coordinates. [#4922](https://github.com/AnalyticalGraphicsInc/cesium/pull/4922)
* Transparent parts of billboards, labels, and points no longer overwrite parts of the scene behind them. [#4886](https://github.com/AnalyticalGraphicsInc/cesium/pull/4886)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this.

* Added `blendOption` property to `BillboardCollection`, `LabelCollection`, and `PointPrimitiveCollection`. The default is `BlendOption.OPAQUE_AND_TRANSLUCENT`; however, if all billboards, labels, or points are either completely opaque or completely translucent, `blendOption` can be changed to `BlendOption.OPAQUE` or `BlendOption.TRANSLUCENT`, respectively, to increase performance by up to 2x.

### 1.29 - 2017-01-02

Expand Down
302 changes: 185 additions & 117 deletions Source/Scene/BillboardCollection.js

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions Source/Scene/BlendOption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*global define*/
define([
'../Core/freezeObject'
], function(
freezeObject) {
'use strict';

/**
* Determines how opaque and translucent parts of billboards, points, and labels are blended with the scene.
*
* @exports BlendOption
*/
var BlendOption = {
/**
* The billboards, points, or labels in the collection are completely opaque.
* @type {Number}
* @constant
*/
OPAQUE : 0,

/**
* The billboards, points, or labels in the collection are completely translucent.
* @type {Number}
* @constant
*/
TRANSLUCENT : 1,

/**
* The billboards, points, or labels in the collection are both opaque and translucent.
* @type {Number}
* @constant
*/
OPAQUE_AND_TRANSLUCENT : 2
};

return freezeObject(BlendOption);
});
17 changes: 17 additions & 0 deletions Source/Scene/LabelCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define([
'../Core/Matrix4',
'../Core/writeTextToCanvas',
'./BillboardCollection',
'./BlendOption',
'./HorizontalOrigin',
'./Label',
'./LabelStyle',
Expand All @@ -28,6 +29,7 @@ define([
Matrix4,
writeTextToCanvas,
BillboardCollection,
BlendOption,
HorizontalOrigin,
Label,
LabelStyle,
Expand Down Expand Up @@ -440,6 +442,9 @@ define([
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each label from model to world coordinates.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
* @param {Scene} [options.scene] Must be passed in for labels that use the height reference property or will be depth tested against the globe.
* @param {BlendOption} [options.blendOption=BlendOption.OPAQUE_AND_TRANSLUCENT] The label blending option. The default
* is used for rendering both opaque and translucent labels. However, if either all of the labels are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve performance by up to 2x.
*
* @performance For best performance, prefer a few collections, each with many labels, to
* many collections with only a few labels each. Avoid having collections where some
Expand Down Expand Up @@ -533,6 +538,16 @@ define([
* @default false
*/
this.debugShowBoundingVolume = defaultValue(options.debugShowBoundingVolume, false);

/**
* The label blending option. The default is used for rendering both opaque and translucent labels.
* However, if either all of the labels are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve
* performance by up to 2x.
* @type {BlendOption}
* @default BlendOption.OPAQUE_AND_TRANSLUCENT
*/
this.blendOption = defaultValue(options.blendOption, BlendOption.OPAQUE_AND_TRANSLUCENT);
}

defineProperties(LabelCollection.prototype, {
Expand Down Expand Up @@ -732,8 +747,10 @@ define([

billboardCollection.modelMatrix = this.modelMatrix;
billboardCollection.debugShowBoundingVolume = this.debugShowBoundingVolume;
billboardCollection.blendOption = this.blendOption;
backgroundBillboardCollection.modelMatrix = this.modelMatrix;
backgroundBillboardCollection.debugShowBoundingVolume = this.debugShowBoundingVolume;
backgroundBillboardCollection.blendOption = this.blendOption;

var context = frameState.context;

Expand Down
Loading