CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
179 stars 65 forks source link

some hillshade rendering issues #506

Open farfromrefug opened 2 years ago

farfromrefug commented 2 years ago

Hi, I am working again on hillshading. The reasoning is to make smaller hillshade mbtiles with a better rendering. For reference the technique used is this https://medium.com/@frederic.rodrigo/optimization-of-rgb-dem-tiles-for-dynamic-hill-shading-with-mapbox-gl-or-maplibre-gl-55bef8eb3d86

Now in the process of working on this i discovered rendering issues with hillshading in carto. It does not only happen with optimised mbtiles. So until maxzoom it draws fine. But when i start to overzoom i start to see some errors in some areas. And when i zoom a lot it goes into "line" mode. What bugs me the most is the artifacts appearing in some regions. As a comparaison in the last screenshots, it works just fine in mabpox.

I wondering if it comes from the fact that carto creates a "normal" image before rendering it with a shader. I think mapbox does it all in a shader. TBH i am a bit lost with the whole tile(image) processing in carto for now. Wondering, while overzooming, is the normal map created on a scaled image or on the original image?

Screenshot 2022-06-27 at 11 02 58 Screenshot 2022-06-27 at 11 03 08 Screenshot 2022-06-27 at 11 03 20 Screenshot 2022-06-27 at 11 03 28 Screenshot 2022-06-27 at 11 03 37 Screenshot 2022-06-27 at 11 03 43
mtehver commented 2 years ago

@farfromrefug I think I may know the reason here - SDK automatically upscales bitmaps after 'maxzoom' is reached. In case of hillshading, this may cause artifacts and should be likely implemented differently. I need to think about this a bit more, though.

farfromrefug commented 2 years ago

@mtehver i tested your changes and it works perfectly. I had to make a quick fix on exageration though.On overzoom exageration was "increasing" https://github.com/Akylas/mobile-sdk/commit/b07c869187dabad03e8478acd1df2e5d8763a0fe I did not create a PR cause my code there is different. Let me know if you want me to create one

Thanks!!!!!

EDIT: i am not sure if it a regression. But i see my app hanging when i quickly zoom in/out. Not happening without hillshade. Will try to run some test with older versions. Do you have any idea? PS: i can share hillshade mbtiles if you need

farfromrefug commented 1 year ago

@mtehver i can confirm your last changes on hillshade made the app much slower. It keeps on hanging. I rollback to a build before and it is smooth again. Haven´t looked at the code yet to see what might be happening

mtehver commented 1 year ago

@farfromrefug Is this noticeable at all zoom levels? Processing became more expensive at 'overzoomed' tiles, for other tiles should be roughly the same. I will see if this can be optimized.

farfromrefug commented 1 year ago

@mtehver i would say all but I need to test further.

farfromrefug commented 1 year ago

@mtehver i compared with all framework and the difference is obvious. It is much slower whatever the zoom level, even not overzoomed