Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Billboards using `imageSubRegion` now render as expected. [#12585](https://github.com/CesiumGS/cesium/issues/12585)
- Improved scaling of SVGs in billboards [#13020](https://github.com/CesiumGS/cesium/issues/13020)
- Fixed unexpected outline artifacts around billboards [#13038](https://github.com/CesiumGS/cesium/issues/13038)
- Fixed image alignment in large billboard collections [#13042](https://github.com/CesiumGS/cesium/issues/13042)

#### Additions :tada:

Expand Down
25 changes: 8 additions & 17 deletions packages/engine/Source/Renderer/TextureAtlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,17 @@ TextureAtlas.prototype._resize = function (context, queueOffset = 0) {
toPack.push(queue[i]);
}

// At minimum, the texture will need to scale to accommodate the largest width and height
width = Math.max(maxWidth, width);
height = Math.max(maxHeight, height);
// At minimum, atlas must fit its largest input images. Texture coordinates are
// compressed to 0–1 with 12-bit precision, so use power-of-two size to align pixels.
width = CesiumMath.nextPowerOfTwo(Math.max(maxWidth, width));
height = CesiumMath.nextPowerOfTwo(Math.max(maxHeight, height));

if (!context.webgl2) {
width = CesiumMath.nextPowerOfTwo(width);
height = CesiumMath.nextPowerOfTwo(height);
}

// Determine by what factor the texture need to be scaled by at minimum
const areaDifference = areaQueued;
let scalingFactor = 1.0;
while (areaDifference / width / height >= 1.0) {
scalingFactor *= 2.0;

// Resize by one dimension
// Iteratively double the smallest dimension until atlas area is (approximately) sufficient.
while (areaQueued >= width * height) {
if (width > height) {
height *= scalingFactor;
height *= 2;
} else {
width *= scalingFactor;
width *= 2;
}
}

Expand Down
Loading
Loading