Skip to content

Commit

Permalink
Merge pull request #8325 from AnalyticalGraphicsInc/fix-billboard-64k
Browse files Browse the repository at this point in the history
Fix webgl errors when rendering over 64k billboards
  • Loading branch information
mramato authored Oct 28, 2019
2 parents 098bbe7 + 9dfd41d commit 6d22551
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ We’ve consolidated all of our website content from cesiumjs.org and cesium.com
* Fixed a bug where `scene.sampleHeightMostDetailed` and `scene.clampToHeightMostDetailed` would not resolve in request render mode. [#8281](https://github.com/AnalyticalGraphicsInc/cesium/issues/8281)
* Fixed seam artifacts when log depth is disabled, `scene.globe.depthTestAgainstTerrain` is false, and primitives are under the globe. [#8205](https://github.com/AnalyticalGraphicsInc/cesium/pull/8205)
* Fix dynamic ellipsoids using `innerRadii`, `minimumClock`, `maximumClock`, `minimumCone` or `maximumCone`. [#8277](https://github.com/AnalyticalGraphicsInc/cesium/pull/8277)
* Fixed rendering billboard collections containing more than 65536 billboards. [#8325](https://github.com/AnalyticalGraphicsInc/cesium/pull/8325)

##### Deprecated :hourglass_flowing_sand:
* `OrthographicFrustum.getPixelDimensions`, `OrthographicOffCenterFrustum.getPixelDimensions`, `PerspectiveFrustum.getPixelDimensions`, and `PerspectiveOffCenterFrustum.getPixelDimensions` now take a `pixelRatio` argument before the `result` argument. The previous function definition will no longer work in 1.65. [#8237](https://github.com/AnalyticalGraphicsInc/cesium/pull/8237)
Expand Down
7 changes: 4 additions & 3 deletions Source/Renderer/VertexArrayFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,13 @@ import VertexArray from './VertexArray.js';
destroyVA(this);
var va = this.va = [];

var numberOfVertexArrays = defined(indexBuffer) ? Math.ceil(this._size / (CesiumMath.SIXTY_FOUR_KILOBYTES - 1)) : 1;
var chunkSize = CesiumMath.SIXTY_FOUR_KILOBYTES - 4; // The 65535 index is reserved for primitive restart. Reserve the last 4 indices so that billboard quads are not broken up.
var numberOfVertexArrays = (defined(indexBuffer) && !this._instanced) ? Math.ceil(this._size / chunkSize) : 1;
for ( var k = 0; k < numberOfVertexArrays; ++k) {
var attributes = [];
for (i = 0, length = allBuffers.length; i < length; ++i) {
buffer = allBuffers[i];
var offset = k * (buffer.vertexSizeInBytes * (CesiumMath.SIXTY_FOUR_KILOBYTES - 1));
var offset = k * (buffer.vertexSizeInBytes * chunkSize);
VertexArrayFacade._appendAttributes(attributes, buffer, offset, this._instanced);
}

Expand All @@ -321,7 +322,7 @@ import VertexArray from './VertexArray.js';
attributes : attributes,
indexBuffer : indexBuffer
}),
indicesCount : 1.5 * ((k !== (numberOfVertexArrays - 1)) ? (CesiumMath.SIXTY_FOUR_KILOBYTES - 1) : (this._size % (CesiumMath.SIXTY_FOUR_KILOBYTES - 1)))
indicesCount : 1.5 * ((k !== (numberOfVertexArrays - 1)) ? chunkSize : (this._size % chunkSize))
// TODO: not hardcode 1.5, this assumes 6 indices per 4 vertices (as for Billboard quads).
});
}
Expand Down

0 comments on commit 6d22551

Please sign in to comment.