Dynamic Texture Atlas

Hi,

After some discussion in https://github.com/AnalyticalGraphicsInc/cesium/pull/54, we decided to revisit our texture atlas packing algorithm so it supports incremental additions. Right now, it needs to know all the images up front. It basically sorts them by height, then packs then left to right, top to bottom -
https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Renderer/TextureAtlas.js. Adding an image later requires recreating the entire atlas.

Instead, we plan to keep a free list of rectangles in the atlas, heuristically pick one when an image is added, and put the subdivided rectangle remainders back on the free list. If a suitable rectangle can’t be found, then the atlas needs to be recreated like std::vector. I’ll call it amortized constant time without proof :). I also won’t make any formal claims about optimal use of atlas space; however, in trivial cases when the images are all the same size, it will be very good like the current algorithm.

Texture atlas packing is actually the bin packing problem, which is NP hard. Jukka Jylank has great writeups on it, http://clb.demon.fi/files/RectangleBinPack.pdf and
http://clb.demon.fi/projects/even-more-rectangle-bin-packing. The algorithm we propose is similar to http://blackpawn.com/texts/lightmaps/default.html and http://codesuppository.blogspot.com/2009/04/texture-packing-code-snippet-to-compute.html.

Ian is doing the implementation work.

Patrick

I forgot to attach my notes.

Patrick

Hi Patrick,
I am a software developer working at CAE. Recently I am working to generate contents to use in Cesium. We have a performance issue when we load our scene.
I have access to Cesium model tiller version 4.5.5 to generate cesium tile.
I have two simple objs that sharing a simple jpg image. When I generate 3d tile using model tiller. It produced tileset with some b3dm files. Unfortunately, I saw that each b3dm has its own copy of the image inside the glb content. We know that glb files support external referencing like gltf.
Before implementing a post processing that will modify the glbs inside b3dm files to use external referencing, I have two questions.

  1. Does Cesium render engine support glb external referencing or not? I mean when it tries to load two b3dm files into the memory that they have a similar external reference, does it import the reference two times or only once?

  2. I know that Cesium for optimisation is generating a texture atlas. In the above case, when it is generating the atlas does it duplicate the same texture or not?

Thanks for your support