Skip to content

Increase number raster layers that can be added to a view #2568

@jailln

Description

@jailln

Context

Currently, the number of layers we can add to a view is limited for several reasons:

  1. This hard limit of 15.
  2. The max number of texture units supported by the gpu, computed here (i.e. max number of textures that can be passed to the shader in one rendering pass).
  3. The following method that counts the number of textures per tile.

Current GPUs with WebGL2 generally have a max number of texture units >= 32. The method 3 is quite conservative by approximating the number of textures based on the crs and by taking the worst case scenario. In this context, the limit is quickly reached: between 5 to 10 layers from my tests, which is quite limiting for users.

Description of the proposal

The proposal is to overcome these limits, by implementing a method to bind more textures to the layer.

Identified use-cases

Adding more layers to the view.

Implementation

This is only a proposition and should be discussed / specified.

Regarding the methods to pass more textures to the shader, I've found two possibilities:

  • Use texture arrays (see this tutorial for instance)
  • Create a texture atlas

Texture arrays are available since WebGL 2 and iTowns supports WebGL 2 and dropped WebGL 1 support so it seems to be a good option. However, mind the following issue (that may not be a concern since we have our own implementation of loop unrolling in iTowns).

Regarding the above-mentionned limits:

  • Limit 1. : I'm not sure it is still meaningfull. The getColorAtIdUv method is not used anymore and I don't really understand why there would be such a limit of 15. I tried removing it and it works well. I'm curious on having your opinion on this @Desplandis @HoloTheDrunk @gchoqueux
  • Limit 2. : seems legit. Could be removed if we use texture arrays though ? If we use texture atlases, we may use it to know when to start creating atlases (when the number of textures added to a tile is greater than this limit).
  • Limit 3. : This computation seems quite conservative and we could remove it and compute the real number of texture per material in LayeredMaterial.addColorTile if we use texture atlases. In the case of texture arrays I think we won't need it.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions