LayeredMaterial: the atlas should not be systematically used
We use texture atlases to avoid sending too many textures the shader.
For example, if we have 10 color layers on a map, we would have
| Item | With atlas | Without atlas |
|---|---|---|
| Color layer | 1 texture (the atlas) | 10 textures |
| Elevation layer | 1 texture + 8 neighbour textures | 1 texture + 8 neighbour textures |
| Colormaps | 1 texture | 1 texture |
| Total | 11 textures | 20 textures |
However, WebGL allows up to MAX_TEXTURE_IMAGE_UNITS per fragment shader.
This means that if we have fewer texture that image units allowed, we don't actually need to use an atlas, and we can use the textures directly. This would save a lot of memory (as textures atlases are huge), and a lot of GPU time (they take time to render).
For example, on my laptop, MAX_TEXTURE_IMAGE_UNITS = 32. This means I can use up to 22 color layers + 1 elevation layer (with stitching) + color maps without needing an atlas.
Edited by Sébastien Guimmara