CartoDB / mobile-carto-libs

Internal dependencies for CARTO Mobile SDK
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

line-comp-op understanding #17

Open farfromrefug opened 3 years ago

farfromrefug commented 3 years ago

I am looking to achieve something like this https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.alta-via.fr%2Fguide%2Fimages%2Fstories%2Fconditions%2Fhiver-13-14%2F2014-02-03-envers-du-plan.jpg&f=1&nofb=1 The idea is to have contour lines change color based on the background. I was thinking of using "darken" to do that

The first thing is that i cant seem to get line comp op to work as expected:

And i think line-opacity breaks it while setting a color with alpha does not

mtehver commented 3 years ago

About comp-op. First, there are two kinds of comp-ops - feature level and layer level. line-comp-op is a feature level comp-op and applies comp-op operator to the previously rendered framebuffer, including all previously rendered layers and the features from the same layer rendered before.

Layer level comp-op (com-op in CartoCSS) forces the layer to be rendered into an 'offscreen' framebuffer and then after all the features have been rendered, the resulting offscreen framebuffer is composited to the original framebuffer.

SDK does support limited number of comp-ops compared to the original CartoCSS standard and I am not really sure they work as expected when alpha value is less than 1. Also, layer blending animations may create strange artifacts.

Regarding line-opacity, can you make an example? Using line opacity vs color with same alpha should work exactly same.

farfromrefug commented 3 years ago

@mtehver the best example is contours in this theme https://github.com/farfromrefug/new_carto_theme do you have contours mbtiles? i can share one for france. Also from what you explained is line-comp-op going to compose contours with landcover if they are different layers? (no sure i read it right)

mtehver commented 3 years ago

@farfromrefug Please share the contours mbtiles.

Regarding line-comp-op, correct. countours will be composed to the existing framebuffer. If the underlying opaque layer was landcover, then lines would be composed/blended with that.

farfromrefug commented 3 years ago

@mtehver here you go terrain_25m-contours10m.mbtiles: http://gofile.me/4pKGL/0CP2Qg9pF