-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s̶y̶m̶b̶o̶l̶-̶c̶l̶i̶p̶ dynamic-filtering with pitch
and distance-from-camera
expressions
#10795
Conversation
…ing using notUsed state in debug buffers
This Observable hosts a playground for prototyping styles with this prop https://observablehq.com/@arindam-mapbox/symbol-clipping-playground |
035ec77
to
0f9e5b3
Compare
) * WIP dynamic filter splitting stage 1 * Add tests for isDynamicFilter * More test cases for isDynamicFilter * Existing static filters get passed through unmodified. * WIP extracting static filters * Working case -> any translation * More tests for case -> any conversion * Add support for match branches * WIP: V0 of adding collapsing of dynamic expressions to true * more test cases * tests and some more refactoring * remove temory inspection code from unit tests * Fix dynamic filter detection * Fix failing spec test * Units tests hopefully :green: now * Add test to cover for `null` in expressions * Address CR comments and reduce number of temporary allocations * remove gl-matrix as dependency of style-spec and inline a matrix multiplication function * Fix lint issues * Add better error messages for expression compilation failures * Ensure location parameter is passed down * Remove symbol-clip from the style-spec * Remove unused property-expression type * Move filterSpec to v8.json and replace symbol-clip with dynamic filter * Fix unit tests * Fix most flow errors * finally flow is happy * Add expression validation code * Add api-supported tests for validation * Fix some failing unit tests * Ensure layer._featureFIlter is updated on main thread as well * Ensure layerType is passed down to validation * Fix flow and linting * Fix unit tests * Pass 1 of addressing CR comments * Add basic placementTime metric * Move to using total placement time * Fix lint errors * simplify placement time tracking * Fix silent conflict in with SymbolInstanceStruct changes * try benchmarking with filter splitting algorithm removed * Fix versions microbenchmark page * Revert "try benchmarking with filter splitting algorithm removed" This reverts commit 865f354. * Simplify by calculating distance using tile coordinates of the symbol directly * Use new specific centerDistanceMatrix * Sign flipping for consistency * add new debug page with distance visualizer * First set of pure distance based render tests * Pitch thresholding tests * Fix lint errors * More tests * Add first batch of point symbol render tests * Increase threshold * Increase allowed threshold for the correct tests 🤦 * remove flaky collision debug boxes instead * Move geojson test data to be in separate files instead of inlined into styles * Update flaky render test expectation * Fix distanceMatrix comment Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com> * Switch to linear scale and update line placement tests * Update point placement tests * Update test expectations * Fix lint error * Remove flaky collision boxes Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com>
pitch
and distance-from-camera
expressionspitch
and distance-from-camera
expressions
I like the line-based distance metric! |
pitch
and distance-from-camera
expressionspitch
and distance-from-camera
expressions
Co-authored-by: Karim Naaji <karim.naaji@gmail.com>
Ran the |
0f46785
to
441d53a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @arindam1993 ! LGTM 🟢
* main: Add touch pan blocker to gesture handling for touch devices (#11116) Address accessibility issues (#11064) add support for non-mercator projections (#11124) Image fallback expressions within paint properties (#11049) Replaces EPSG:4326 with OGC:CRS84 in GL JS `LngLat` doc (#11072) Add globe view support to heatmap shaders (#11120) Exclude flaky test (#11118) consistify YOUR_MAPBOX_ACCESS_TOKEN as placeholder string (#11113) Allow adding multiple layers to `map.on()` event handler (h/t @omerbn) (#11114) render-test-flakiness:clear worker storage (#11111) upgrade to supercluster v7.1.4, earcut v2.2.3, vt-pbf v3.1.3, geojson-rewind v0.5.1 (#11110) Added v1.13.2 changelog entry (#11108) One weird JSON.parse() trick (#11098) Fixed doc usage of map.getCenter (#11093) s̶y̶m̶b̶o̶l̶-̶c̶l̶i̶p̶ dynamic-filtering with `pitch` and `distance-from-camera` expressions (#10795) Update link to transpiling guide (#11096) Cherry pick 2.5.1 changelog (#11099) Fix an iOS15 issue where Safari tab bar interrupts panning (#11084) Fix conditional check for isFullscreen to accommodate Safari (#11086) Render tests for #11041 (#11070)
VERY nice feature but i can't get it to run, not even on your playground: properties.js:374 Uncaught TypeError: Cannot read properties of undefined (reading 'value') Can you add a example (Full code or include it somewhere in the Mapbox examples) ? Thx |
@CptHolzschnauz We're currently putting together some examples, they'll be live with our launch within a few days. |
Thx. Whatever i try, i can't see any filter effect on my layer. This amazing feature deserves a fully working example. |
If someone finds this thread: |
Lots changed with the design and implementation of this since I first started this, leaving behind the original post under
----------OLD-------------
for documentation.The first part(#10923) was changing it so the user doesn't have to write their own separate
filter
andsymbol-clip
expressions. Instead this allows the user to write one singlefilter
expression that then gets split during the filter compilation into separatefilter
anddynamicFilter
expressions.The
filter
part is evaluated in the worker just like before, whereas thedynamicFilter
part is evaluated continuously during placement.The next part was adding all of this new filter validation logic to the
style-spec
package(#10977)The last part was tweaking the distance metric slightly and making it slightly different from fog (#11065).
Instead of being a distance measured from a point, its now a distance measured from a line passing through the center, perpendicular to the bearing.
@mapbox/map-design-team @mapbox/gl-native
------------------ OLD-------------------------
This PR adds a new
boolean
spec-property for thesymbol
layer that lets the user define clipping constraints based on the current state of the camera.When this property is
true
for a given symbol, the symbol gets hidden, and when itsfalse
it gets displayed. Thus to keep it backwards compatible isfalse
by default.The primary goal of this is to be able to control-ably reduce symbol density in the far distance when the map is pitched.
With this in mind this spec property:
Supports data-driven styling
Supports
zoom
,pitch
anddistance-from-camera
expressionsHas NO restrictions on where in the expression
zoom
,pitch
anddistance-from-camera
can appear (Currently we only supportzoom
as a top-level param to aninterpolate
expression)pitch
expression returns the pitch in degreesdistance-from-camera
expression returns the distance of the symbol from the camera in the sameviewport size normalized
units that are used fornear
andfar
distance measurements for fog.Demo:
With the following code:
Screen.Recording.2021-06-07.at.3.17.27.PM.mov
This hides all POI labels in the far-distance, and lets street labels show through. This works because clipping takes place before collisions, thus the screen real-estate freed manually up by carefully crafted constraints can be filled with more pertinent information automatically by the placement engine.
How this works
This expression is evaluated on the main thread during
placement
, if the symbol needs to be clipped it early-exits and completely skips placing it. For a collision box debug-view rendering it gets treated it as an "unused" symbol, same as rejected placement locations fortext-variable-anchor
based symbols are treated.What about performance?
Still very early, but framerate for the case I described above in the Demo seems much better. At high pitch viewport-aligned symbols at a far distance overlap a LOT and that places a lot of load on the collision evaluation. This skips all of that work.
A particularly bad case:
Before:
After:
Launch Checklist
@mapbox/map-design-team
@mapbox/static-apis
if this PR includes style spec API or visual changes@mapbox/gl-native
if this PR includes shader changes or needs a native portmapbox-gl-js
changelog:<changelog> Add the ability to use
["pitch"]and
["distance-from-center"]expressions in
filterfield of
symbollayers. </changelog>