-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
free TextureAtlasNode when billboard image is changed or destroyed / prevent texture atlas overflow (allow dynamic billboards) #9429
Conversation
Thanks for the pull request @Nadav42!
Reviewers, don't forget to make sure that:
|
- when resizing texture atlas and reached webgl max texture size then reset the atlas - on node free merge children with parent if all are empty
added visualization clips to the PR, need review |
…us load finished which ignores the index
…of other billboards
Hi, why did you closed the issue? Is there any other solution? |
this solution works fine, I switched to using my other solution that solves this without changing cesium code |
What did you do to solve it? |
I posted my solution here: |
I had the same issue of atlas overflow, but for a handful of generated images. Seems when a billboard is created with a Canvas element, it just keeps growing the atlas for no reason. |
Since you only have 18 constant images then yeah, providing cesium with the toDataUri() will make cesium cache it by the URL string so it will work just fine But in my case I need dynamic textures all different from each other (hundreds) so it won't work (the atlas will fill eventually) |
So is there a perfect solution to this problem? This is a very common function. Threejs and Babylon have dynamic textures. Why can't cesium implement them? |
related issues: #6477 #4413 #172 #2319
I want to make the TextureAtlas clear unused nodes (when no billboard is using that resource anymore).
this is in order to allow dynamic billboards with images that change very frequently, currently dynamic billboards are causing the TextureAtlas to fill very quickly and lead to atlas resize exception
WebGL: INVALID_VALUE: texImage2D: width or height out of range
The test I used for the clips
50 billboards generate random canvases of width and height between
100px-300px
, each billboard generates a new image 20 times per secondCurrent state of cesium
Rapidly changing dynamic billboard will quickly make the TextureAtlas run out of space and billboards will disappear or become black as shown in this clip:
cesium-dynamic-billboards-current-state.mp4
This can be visualized in the atlas by setting
billBoardCollection.debugShowTextureAtlas
totrue
, as shown in the following clip:cesium-atlas-visualization-current-state.mp4
State after pull request
I made it so billboard images that are no longer used are freed from the atlas, allowing dynamic billboards to work as they should:
cesium-dynamic-billboards-after-pr-state.mp4
This atlas visualization shows how new billboards use empty spaces freed by previous billboards:
cesium-atlas-visualization-after-pr-state.mp4
PR progress: