maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.6k stars 711 forks source link

Render-to-texture at low frame rate for low end devices #3727

Open wipfli opened 8 months ago

wipfli commented 8 months ago

For low end devices, it might be beneficial to render the vector tiles to raster tiles once per zoom level and then use the raster tile shader for zoom/tilt/rotation.

One could use a render-to-texture approach similar to what is done in the terrain3d code path and feed the resulting textures to the raster shader.

The advantage of this approach would be that one could render the vector tiles at a much lower frame rate than the usual 60 Hz. For example, 2 Hz could be sufficient. Or one could even just rasterize at integer zoom levels. Like this, the work that the client device has to do should be much lower.

On the downside, text would probably look bad like always in raster tiles and fractional zoom styling would not really work.

cc @Pheonor and @prozessor13 since you have some experience with render-to-texture...

prozessor13 commented 8 months ago

from my perspective it is worth to test:

In this scenario, in theory, you have normal symbol-rendering ontop of a very fast terrain-mesh rendering.

wipfli commented 8 months ago

The fake source we could make with addProtocol.

How can I reduce the terrain mesh size to two triangles?

Is the texture renderer whenever the fractional zoom level changes?

prozessor13 commented 8 months ago

The fake source we could make with addProtocol.

hmm. did never tried this, but i think so. I would return a dummy terrainrgb tile with all zero values.

How can I reduce the terrain mesh size to two triangles?

for testing i would hack it in terrain.js, set meshSize to 2 or 4 https://github.com/maplibre/maplibre-gl-js/blob/main/src/render/terrain.ts#L148 and qualityFactor to 1 https://github.com/maplibre/maplibre-gl-js/blob/main/src/render/terrain.ts#L147

Is the texture renderer whenever the fractional zoom level changes?

there exists a render-to-texture cache, rerendering is done whenever necessary. (but i cannot remember on all details...)

mousebird commented 8 months ago

There are tradeoffs, such as more memory usage, but it's technically feasible. You've got other options too, like keeping the text as is and rendering the rest of the tile to an image.

The question is what sort of devices are you targeting? As is, the toolkit is pretty good on just about anything being produced in the last few years.