Skip to content
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

v2.0.0 #10160

Merged
merged 161 commits into from
Dec 8, 2020
Merged

v2.0.0 #10160

merged 161 commits into from
Dec 8, 2020

Conversation

karimnaaji
Copy link
Contributor

⚠️ Breaking changes

  • mapbox-gl-js is no longer under the 3-Clause BSD license. By upgrading to this release, you are agreeing to Mapbox terms of service. Refer to LICENSE.txt for the new licensing terms and details. For questions, contact our team at https://support.mapbox.com.
  • Beginning with v2.0.0, a billable map load occurs whenever a Map object is initialized. Before updating an existing implementation from v1.x.x to v2.x.x, please review the pricing documentation to estimate expected costs.
  • Deprecate Internet Explorer 11, no longer supported from this release. (#8283, #6391)
  • Support for unlocked pitch up to 85°. The default maxPitch is increased from 60° to 85° which can result in viewing above the horizon line. By default, this area will be drawn transparent but a new sky layer can be added to the map in order to fill this space. The legacy behavior can be achieved by simply adding maxPitch: 60 to the map options when instantiating your map.

✨ Features and improvements

  • Add 3D terrain feature. All layer types and markers can now be extruded using the new terrain root level style-spec property or with the function map.setTerrain(). (#1489)
  • Add support for unlocked pitch up to 85° (previously 60°). (#3731)
  • Add a new sky layer acting as an infinite background above the horizon line. This layer can be used from the style-spec and has two types: atmospheric and gradient.
  • Add a free form camera API, allowing for more complex camera manipulation in 3D, accessible using map.getFreeCameraOptions() and map.setFreeCameraOptions().
  • Improve performance by adopting a two-phase tile loading strategy, prioritizing rendering of non-symbol layers first.
  • Improve performance by avoiding parsing vector tiles that were already aborted.
  • Improve performance by adopting a preemptive shader compilation strategy. (#9384)
  • Improve performance by disabling fade-in animation for symbols and raster tiles on initial map load.
  • Improve performance by defaulting to 2 workers on all platforms. (#3153)
  • Improve performance by loading tiles on the main thread at initial map load.
  • Improve performance by using better worker task scheduling.

🐞 Bug fixes

  • Avoid reloading raster and raster-dem tiles when the RTLTextPlugin loads.
  • Add runtime evaluation of label collision boxes for more accurate symbol placement at fractional zoom levels and tilted views.
  • Fix tile cache size for terrain DEM sources.
  • Prevent holding on to DEM memory on the worker.
  • Reduce memory used by fill-extrusions.

🛠️ Workflow

  • Run render tests in browser.

karimnaaji and others added 30 commits November 30, 2020 15:51
* DEM terrain: spec and support for raster.

* Terrain render tests. Source cache used only for terrain loads lower res.

- Fix the code making the source cache be reused for hillshade and terrain:
 If reused, load only hillshade required resolution. If only for terrain,
 load lower resolution sufficient for terrain. To be tweaked.

- Render tests that use terrain (no hillshade) need lower res tiles. Added
 to the tests.

- Orthogonal issue: test getImage request didn't have cancel() (should as it is
 of type Cancellable).

* Map.setTerrain API

* 3d terrain: DEM error and lower tile zoom overlap render test

* 3D terrain render test: reproducible overlap issue

Current approach is problematic as it doesn't resolve low zoom tiles  error overlapping on top of near zoom in every case. Different type of rendering terrain is needed - to be copied from draped approach.

* Terrain render to texture

For each rasterized tile, multiple framebuffers are used: while the prototype implemented rendering all the rasterized layers first to one framebuffer and then rendering all the non rasterized layers on top of it, to the approach here keeps the order of  layers: continuous sequence of rasterized layers gets rendered to the same framebuffer, the framebuffer gets rendered to the screen, after that one or more non-rasterized layers get rendered and so on...
This keeps the layer order but requires 6 time more GPU memory for color attachments for street style used in debug terrain-debug.html page. Although this approach is not final and benchmarking will tell if it is production code candidate, it is following style order and needs to be implemented and analyzed.

* Raster and render-tests/terrain/error-overlap fixes.

Fix raster shader:
- raster render to texture and drape over terrain fixed not to have holes and issues with satellite.html and render tests.
- remove hacky stencil approach in draw_raster (stencil out > 3 tile zoom levels) to disable overlap. Instead, one proxy tile gets one raster piece and proxy tiles are not overlapping.
- append deeper tile cover to disable holes while zooming out.
- split u_tl_scale_dd_dem to self documenting uniforms.

render-tests/terrain/error-overlap:
Test verifies fix for multiple overlap issues when children have significantly different values compared to parent. Also, it verifies tile skirt as data is setup so that we would see holes if no tile skirts are used.

* Remove multiple framebuffers used for one tile

The approach taken was to cache every tile framebuffer and one tile could have multiple: for every continuous segment of layers that get draped to texture.
Measurements show this to be extremelly slow as e.g. street style would result to 7 framebuffers per tile (e.g. road, bridge symbols divide draped layers to segments).

This is removed here as well as any attempt to cache tile rendering results with idea to avoid tile rendering if it didn't change. This will get introduced in later patches.

* Hillshade support

After proxy implementation, it got simple compared to prototype: 2d ortho mapping of hillshade tile to proxy tile is defined in proxy.posMatrix and that is sufficient for rendering prepred hillshade texture to proty tile's fbo.

* Line layer support

Order of layers defined in style is preserved when rendering.non-draped layers (e.g. symbols) split layer list to draped layers sublists that get rasterized and then composited to existing tile render over terrain. After such, draped sublist, symbol draw to screen follows and the new draped layers raster.

* Testing and fix for render to texture & line-translate using zero elevation

Added render tests use 0 elevation and we expect to get the same result when render to texture is used as without terrain. Expectations are created using style without terrain.

Render tests expose issue with aligned matrix usage in raster: added render tests, without fix in draw_raster.js, were suffering from pixel fraction offset. Another issue (incorrect line width is still noticeable) and tests are failing.

* Fix issue with failing render test on Intel

non-terrain shader was created with terrain define in painrter.js, nothing HW dependent.

Update expectations given that previous patcvh stopped using aligned matrix for terrain.

* Line layer fix width and opacity

Disable distant line fade (v_gamma_scale) aliasing approach when using render to texture. This way we et almost identical results when rendering to texture vs immediate render mode for lines.
Cleanup in terrain.js (symbol related code from prototype should not be included in this PR).

* Rebase terrain render tests

following the explanation here: internal-4#issuecomment-597844847

* Refactor terrain source update

Terrain source cache update shopuld happen before style driven update (as update there is skipped if terrain updates source cache).
This ensure also that visible coordinates are not altered from within terrain cache update, as it was before: no need to check if tile is present.
Additional deep cover for terrain is marked as covered (SourceCache._coveredTiles) to avoid hillshade prepare preparing these coordinates, too.

* ProxySourceCache documentation

Extend mapping of higher zoom level coordinates to proxy coordinates to all types of souerce caches.

* overlap handling approach not needed anymore

* Stencil mode for raster overlap and raster transparency support

* Processed review comments

Processed comments mapbox-gl-js-internal/4#discussion_r393836986. Thanks @karimnaaji.

* Review comments processed

Comments internal-4#pullrequestreview-375999464 processed.
Thanks @mpulkki-mapbox.

* Performance fix on zoom > 20

Making proxy source cache to have  maxzoom equal to map's maxzoom ensures that framebuffers always get the same size.

* Review comments fix.
* Elevation: CPU side access internal API.

Unit test creates DEM tiles programatically, covers wrap, tile loading and elevation interpolation.

* Elevate camera for camera center elevation

Enable variable Z tile cover for terrain, regardless the pitch.
Modify far plane calculation to avoid clipping the content.
Modify LOD to include all the tiles between camera and center (no holes in near) by using MAX_VALUE for height in all collision bounding boxes. Temporarily as it is to be replaced by height.
Render tests had tile 15 in back replaced by tile 14 as it gets out of tile cover otherwise.

* Fix initial state

If terain tiles get loaded when map is already displayed, it is needed to run Transform._calcMatrices. Move center calculation and recalculate matrices is center elevation changed.
…ternal-10)

* box collision and aligned to viewport symbols

Placement on terrain for symbols aligned to viewport. CollisionBox gets elevation of anchor.
TODO: occlusions of symbols by terrain.
Render test added is to be changed after occlusion by terrain work.

* Road label placement and rendering

Doesn't support labels that are map aligned (pitch with map). Those are to be draped.

* road label placement render test. Exaggeration styling property.

Terrain exaggeration is implemented here as it simplified work on tweaking hand drawn terrain elevation and occlusion of road labels.
Unit test for terrain styling and validation.

* Occlusion for symbols

Render depth to texture and sample depth texture to check if symbol anchor is occluded or not. If ocludded, move all symbol vertices out of view volume.

Helper code used to develop this: https://gist.github.com/astojilj/abd2fd384e084ec5233cc09e59deab76 is not included in code base as additional "debugging" code:
behavior is covered by render-tests and depth framebuffer render to color texture can be inspected using external tools.

Assert that elevation is taken into account for all placement.

* Fix review comments, flakiness issues with render tests on CI.

Added render test exposed assert with vertical text placement.

* collision render test: reduce complexity
Add sky layer, using both gradient and atmosphere sky types.

* Add scattering shader and offscreen capture render pipeline
- Add cubemap geometry and UVs
- Add demo page
* Enable face culling during skybox passes
* WIP style spec skybox layer
* v0 of skybox style layer
* v0 of horizontal skybox gradients
* Enforce depth fail on fragment covered by the ground plane
- Setup depth states for skybox rendering
- Reorder draw calls for skyboxes to be drawn after opaque and before translucent: This forces the skybox drawn
fragment to be discarded during depth testing, since the skybox vertices depth is the maximum possible depth value
* Dither gradient shader
* azimuth gradients
* v0 of radial gradients
* Remove linear gradients and associated properties
* Frustum culling for skybox
* Prefix stylespec props with sky- instead of skybox-
- Rename skybox-radial-extent to sky-radial-progress for consistency with
line-progress
- Rename skybox-center-* to sky-sun, to be more explicit about what it
represents
- Rename SkyboxLayer to SkyLayer for consistency with specs properties
- Rename cubemap to skybox for consistency
* Rename 'atmospheric' style specs to 'atmosphere'
* Add a dedicated debug page for skybox
* Add style specs prop 'sky-opacity'
* Reduce memory footprint of atmospheric skybox capture
Change the format from RGBA to RGB, since the alpha channel is unused
* skybox.html: Fade out sky as zooming out
* Consolidate sun direction calculation
- Same code path for gradient and scattering shader capture
- Normalize direction in the CPU instead of fragment shader for gradient
- Remove SunCalc dependency: We decided that the user can directly use
that library outside of mapbox gl, and plug the results in the style spec
* Add degToRad, radToDeg helper functions
* Move sun disk and dithering to runtime scattering shader
- Moving this in the runtime shader allows us to vastly reduce the size of the
framebuffers used to render the scattering algorithm (1024x1024 -> 128x128);
this is a reduction of ~64 in pixel processing
* Test adding sky to the terrain demo
* Increase default max pitch to 85 to allow for skybox render tests
* Add sky-atmosphere-* style spec
* Better mix sun disk with sky color
- Document sun angular angle
- Improve smoothstep antialiasing
* Collapse azimuth and angle into a singular sky-sun-direction property
* Add some unit tests
Add render and some unit tests
Update render tests
* Make better utilization of texture space
Prevent wasting texture space for areas that are not visible after the cubemap generation
* Increase threshold for fragile terrain test
* Temporal and chromatic dithering
* Render tests for gradients
* Adjust precision qualifiers for mobile
* Premultiply sky-opacity to prevent blending overflow
* Revised docs
* Wrap frame counter

Co-authored-by: Arindam Bose <arindam.bose@mapbox.com>
* Depth first tile enumeration and rendering. Optional optimization drape all and then place symbols while zooming/panning the map.
* Overlap handling / clipping for vector tiles
* terrain-debug.html debug option for drape first. simplify occlusion render-test (orthogonal change).
* Terrain RTT framebuffer pool size: 20 -> 5 as it behaves the best on desktop and iPhone X.
* Simple FPS counter for terrain-debug. Continuous repaint option ad FPS count in UI.
* A quick attempt to fix flaky collision-occlusion render test.
Cleanup to always use frustum ray-intersections

Address review comments

Use vertical half-fov that accounts for padding

Add unit tests

Fix lint errors
For each building, centroid coordinate is calculated and fed to vertex shader, for each vertex.
If vertex is on top (roof or wall top), sample centroid elevation.
If centroid elevation lower than vertex elevation, roof at least 2.5 meters height above base.
Additional check for isEntirelyOutside also for roof area to hide occasional artefacts.
The most advanced part is handling behavior on tile edges:
In such case, both pieces of the building need to have the same centroid (in order to have uniform roof elevation). Instead of calculating centroid, selected point is center of the area on tile edge where both building parts overlap (intersect tile edge).

While sampling for roof, use ruggedness to decide on roof elevation

dem to meter and terrain slope. Roof per feature, not ring.

Fixes issue on borders when buildings have multiple disconnected pieces (and that happens when on border).
Free 3 bits of centroid x and y, to be used for building size in follow up patch.

Pass building size for centroid roof calculation

Lower bottom edge (if on ground) 5m to hide space under walls.

Get wider sample, if there is space, to get better slope estimate.

pattern and render tests

Abandon flast roofs on tile border approach

It is complicated, expensive, leading to unpredictive results. This would need to include joinging pieces of buildings and sampling dem on cpu side

Make centroid vertex array optional

Enable flat roof calculation and use the memory storage only if and when terrain gets enabled. Render tests enable terrain on start or dynamically after load.

Ensure 0 during a_centroid_pos attribute buffer initialization

When activating terrain, or for fill extrusions that don't need flat roofs, centroidVertexBuffer is null and vertex attrib array is disabled. Setup the generic state when the vertex attrib array is disabled: ensure it is 0 as it could be reset by 3rd party custom layer.

Codegen for fill extrusion centroid attributes
First version is sampling center of every tile, no AABB for tiles yet. WIP.
2D LOD also changed to use distance to camera.
Sharper LOD drop for distant tiles.
3rd coordinate is in meters: updated frustum clipping.
Debug draw: when terrain is enabled, draw proxy tiles, separatelly elevating square corners.
_findTileCoveringTileID changed to use visible and loaded tiles. Optimizations with key calculation and lookup bring updateTileBinding from 5ms -> less than 2ms for the benchmark. Further optimizations (reusing previous pass binding) are possible.

LOD: batch elevation for tile. Lint, flow and tests fixes.

Fetch elevation for five tile points in one call. No additional buffer:

Minor render test modifications, partly orthogonal: use lower tilt where possible for performance reasons.
Extreme ruggedness > 900m for 1km tile is rare: https://download.osgeo.org/qgis/doc/reference-docs/Terrain_Ruggedness_Index.pdf
We could use const maxRuggedness = 0.1 / meterToTile additionally: for now, sampling tile corners and center with no additional buffer: the idea is to identify cases and amount of maxRuggedness buffer needed in follow up patches.

LOD retain logic: use lower than cover zoom children + various tests

Unit test tile cover test when using elevation data (transform_test.js).
Toggling terrain on off fix and render test. Earlier, sourcecache._cache tiles were also used and there was no case that center elevation is not up to date due to sourceCache not updated. terrain/raster verifies toggling on off.

Document tile cover and cut off for distance angles. Remove shortcuts / premature optimization.

Document and refactor distToSplitScale

Also revert expectation change for some of the terrain render tests - works like in original patch.
…of custom defines for a given layer

Add some documentation

Refactor circle to use dynamic defines

Fix lint errors

Flow: 1 Arindam: 0

Dont use .includes

docs-lint rules are weird

Update src/render/painter.js

Co-authored-by: Karim Naaji <karim.naaji@gmail.com>
Setting lower zoom to transform sometimes leads to center change (in constrain function). Instead, clone transform instead of restoring the same object to avoid side effects. Remove unecessary _calcMatrices invocation from Transform.clone().

Fixes: mapbox-gl-js-internal/issues/32
The cause was in broken logic of _findTileCoveringTileID: in one of the paths it didn't check if returned tile is loaded (as it should lookup for renderable tiles only).
Moved proxy source update from updateTileBinding (happens on every render frame) to update (called when all other sources are updated).

Couldn't figure out economical way to make useful and reproducile test for this. Instead assert inconsistencies in lookup cache. Measured and this even seems beneficial (as proxy cache is not reset on every render call).

Fixes: internal-31
Include coordinate elevation in calculating point proxymity: even points that are distant horizontally, could get close due to pitch and their different elevation.
Heatmap circles are porallel to ground (following terrain for every fragment withing the  radius seemed wrong and performance sensitive).
The result looks nice (anyway better than to have the coordinates anchored to sea level) and it follow 3d terrain.
- [x] render test for image
- [x] image over wrap line render test, with and without terrain
- [x] video and image debug page

Fixes: internal-3d-67
* Performance, lookup and distance to center sorting fixes

Performance: use elevation when calculating cover for all sources. This reduces nubler of tiles processed.
Lookup: reset lookup cache after every source cache update: tiles might get removed and lookup cache state is invalid. This caused issue if using getElevation during update.
Distance to center sorting fixes: distance to center didn't take wrap into account and case when tile zoom < max zoom: distance to center sorting was working in most of the cases except in the one here: thanks @mpulkki-mapbox.

* Disable tilecover elevation usage for the elevation

... this is moved to a separate PR. Requires removal of deep cover, backfill of holles, morphing while loading etc.
flaky and failing render test fixes.

* A bit less tile to load around 60-73 (the heaviest range) pitch.
* Fix broken shader statement on arm mali architecture
internal-38
For unknown reason exp(vec2) did not work on arm mali-t760
This is fixed by replacing for exp(float) instead.

* Fix incorrect comment

* Add comment about the issue
* symbols that pitch with map: rendering and collision

Sample elevation per vertex when rendering. This makes every glyph aligned to terrain surface. Pass inverted label plane matrix to convert vertex pos from label plane to tile coordinates.
Return and interpolate elevation along path for each glyph. This is done only for pitchwithMap case for proper collision calculation. Debug render (delayed update) is not covered here: that has low priority.

Fixes: internal-3d-81

* terrain: fix regression with overscaled tile id returned in cover.

This was submitted in internal-16

Revert original expectations for collision-lines-occlusion and line-pattern/pitch-terrain.

text-pitch-alignment/map-text-rotation-alignment-map-terrain is modified to expose the regression (otherwise mopst of the overscale symbols are not visible).
* Couple terrain dem cover to proxy cover

Reduce number of DEM tiles loaded: previously used deep cover wasn't only there to hide holes when zooming in out but was also masking the issue that for dem tiles of size 256 and 128 we were not loading optimal tile cover that corresponds to grid size (as deep cover covered range whole zoom range). Deep cover is here removed.

Couple proxy and terrain tile cover: this should be a minimum od dem tiles needed for given grid size. To make sure it is the same always, make roundZoom (false) behavior of terrain tile to act the same as for proxy cover.

Remove complexity of approach that was sharing high res hillshade also for terrain: it is never the case that the same tile used for hillshade is optimal tile for terrain and while deep cover was enabling this, there is no saving if using same source cache for both terrain and hillshade. The approach / feature would be formulated like this:
1. if using same dem source for terrain and hillshade, hillshade comes for free but uses terrain dem zoom level (terrain-debug.html page is modified to demo this).
2. if defining separate raster-dem sources in style for hillshade and terrain, hillshade would use the same zoom level as in 2D map.

Add missing dem tiles to render tests. Remove unecessary error-overlap const tiles, remove their color profile, to prevent inconsistencies when running render test in browser. Fix occasional flakyness by using dedicated set of tiles for 14.5 and 15 zoom tests.

* Remove approach promoting dem source cache tiles from _cache to _tiles.

Hacky approach was altering cover used for hillshade rendering and causing artifacts. cover should be managed only by source cache.
* Add tile coverage freeze debug toggle
Useful to debug an navigate around LOD in distant tiles as well as surrounding area
astojilj and others added 15 commits December 7, 2020 13:13
Co-authored-by: Arindam Bose <arindam.bose@mapbox.com>
fix internal-372

512 raster tiles from the v4 API need to be requested using the '@2x'
suffix.
* Adding some comments

* Adding some comments
* robust buffer check

* Add unit tests for prevPowerOfTwo

* Fix height querying overflow when tileSize != returned image size
…379)

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>

Co-authored-by: Karim Naaji <karim.naaji@gmail.com>
Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>
* Fix internal-373: LOD: application using traffic source blocks (3000+ tiles) when tilted
A source which has min zoom of 6 - if tilting camera around zoom level 6 we try to return
tiles of zoom 6 all the way to horizon, leading to 3000+ tile requests and performance hit.
* More style spec docs tweaks

* Why cant I spell the correctly ever

Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>

* Update sky-atmosphere-color documentation

Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>
* Reflect new max pitch value in docs

* Update more references of old pitch value
For locations behind the camera, set both components of their projected
points to MAX_VALUE for consistency. It's not completely clear that this
is a good approach.
… load. (internal-385)

* first draft

* post to gett

* removing the comments and the headers

* renaming

* removing the access token

* Fix Lint

* Calling mapLoadEvent in Authenticate function

* Cleanup the raster and vector files

* Addressing PR comments

* Adding code protection comment

* Update src/ui/map.js

Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>

* combine 401 and missing mapbox access token

Co-Authored-By: Sanaz Golbabaei <sanaz.golbabaei@gmail.com>

* making the session path non-optional

* Adding production changes

* Fixing the unit test failure

* Adding unit tests for mapbox.test.js

* Fixing missing parameter for mapLoadEvent

* Update warning text for v2 (internal-393)

* Update src/ui/map.js

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>

Co-authored-by: Asheem Mamoowala <asheem.mamoowala@mapbox.com>
Co-authored-by: Arindam Bose <arindam.bose@mapbox.com>
Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
@karimnaaji karimnaaji requested a review from a team December 8, 2020 14:21
@sabman
Copy link

sabman commented Dec 8, 2020

Can we please reference the relevant link for more information about this:

Beginning with v2.0.0, a billable map load occurs whenever a Map object is initialized

@snickell
Copy link

snickell commented Dec 9, 2020

If anyone is looking for an open source project (to contribute to or use) derived from mapbox-gl-js, please consider: https://github.com/maps-gl/maps-gl

MapsGL's primary short-term goal is avoiding fragmentation, providing a skeleton for people to collab on figuring out where we go next to maintain an open, stable, happy, meritocratic community fork to support the excellent open source work mapbox-gl-js v1 contributed to the world.

UPDATE: as of Dec 8, we'll release @maps-gl/maps-gl@1.13 to NPM in the next couple days, providing a simple transition path for those required to migrate off mapbox-gl@latest in short order to maintain legal compliance. Semver does provide some safety here from accidental not-licensed upgrades to mapbox-gl@2, but its probably better safe than sorry.

Upgrading should be a simple package.json changing of the package name to @maps-gl/maps-gl, as both v1.13s will be compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.