fix(textureatlas): Allocate texture space more incrementally on resize #13042
+79
−63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Texture coordinates are currently compressed to 12-bit precision, effectively on a 4096x4096 grid. Perhaps that could be revisited at some point, but in the meantime billboard-related code must be very careful with texture coordinates in large atlases. This PR makes two changes, intended to improve texture atlases along those lines:
Previously as current candidate atlas size became larger, the resize algorithm would use a larger multiplier to select the next candidate size, (2x, 4x, 8x, 16x, ...). In the particular case of #5154 this created a 2K-by-8K atlas, which required 16x more memory than required and (more visibly) flew past the 4096px limit at which Cesium's texture compression can precisely address pixels in the atlas.
Preview:
This PR should fully fix the cause of the clipped dots (
•••) at the top of the icon. The unwanted vertical line visible on the left side of the icon happens to be somewhat improved by this PR, but that also has additional causes left for an upcoming PR.Issue number and link
Testing plan
I'm looking through existing examples with one or more billboards. For each relevant example, compare computed texture atlas size before vs. after. Check that atlas size is "reasonable", i.e. not >> 2x the total area of the input images.
Author checklist
CONTRIBUTORS.mdCHANGES.mdwith a short summary of my changePR Dependency Tree
This tree was auto-generated by Charcoal