Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Render fill-extrusion layers #8431

Merged
merged 87 commits into from
Apr 27, 2017
Merged

Render fill-extrusion layers #8431

merged 87 commits into from
Apr 27, 2017

Conversation

lbud
Copy link
Contributor

@lbud lbud commented Mar 15, 2017

Opening this for tracking purposes as it's getting close enough to have a public living to-do list:

  • [functionality] implement transitions in light options
  • [bug] In 9514b62 I rewrote RenderItem to hold a vector of RenderTiles, rather than a single RenderTile, so that we can render a whole layer at a time (necessary for the offscreen texture approach used herein). In doing so I wrote a logic bug — need to comb over that rewrite 🔍
  • [bug] I suspect there may be a bug in the way we're handling zoom-and-property functions — investigate punted to Composite functions behave incorrectly with non-integer stops #8460 as it is not actually related
  • [bug] there are weird striping/zigzag artifacts on glfw and macOS, but not on ios. Need to investigate what's going on here
    • (update: was caused by using a 16-bit depth component resolution GL_DEPTH_COMPONENT16; changed to GL_DEPTH_COMPONENT which leaves resolution up to the implementation)
    • (update 2: this fixed the issue on MacOS/glfw but broke on iOS as GL_DEPTH_COMPONENT16 is the only valid depth internalformat for renderbufferStorage 🤔 — onward)
    • (resolution: GL version-specific)
  • [tests] un-ignore render tests + ensure all pass [not ready] Un-ignore fill-extrusion tests on native mapbox-gl-js#4519 🚀
  • ☝️ merge gl-js PR in sync with this
  • [tests] unit tests
  • [cleanup] this depends on the extrusions-native-tweaks branch of mapbox-gl-js, which makes a few changes to shaders — merge that + update dep here
  • [bug] many render tests are broken (opacity issue?); investigate
  • [cleanup] squash/clean up commits (apologies to reviewers 🙈) lost cause, will squash upon merging
  • [cleanup] revert committed changes in ./platform/glfw/main.cpp
  • [platform] address @1ec5's comments below + corresponding concerns across other generated platform code

@mention-bot
Copy link

@lbud, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @1ec5 and @ansis to be potential reviewers.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really looking forward to this feature! Thanks for all the hard work you've put into it both here and in GL JS.

I know it's pretty far down on the priority list, but I've left some premature comments about the iOS and macOS side of things, primarily regarding documentation. Take your time with that; the to-do items you've identified are more interesting anyways.

In addition, in order for the iOS and macOS SDKs to build, MGLFillExtrusionStyleLayer.h needs to be added to Mapbox.h, ios.xcodeproj, and macos.xcodeproj. See "Making a type or constant public" and "Adding a source code file" in this guide for details. Let me know if you have any questions.

painter.cp Outdated
@@ -0,0 +1,421 @@
#include <mbgl/renderer/painter.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file was committed by accident.

NS_ASSUME_NONNULL_BEGIN

/**
Controls the translation reference point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change might be worth making upstream:

Controls the translation reference point of a fill extrusion style layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1ec5 it might be — this language is copied from *-translate-anchor in every other layer type. I'll ticket this in that repo as a follow-up.

@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *fillExtrusionOpacity;

/**
Name of image in sprite to use for drawing images on extruded fills. For
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's no public concept of a spritesheet in the native SDKs, we override any documentation that says "sprite" to say "style image" instead in platform/darwin/scripts/style-spec-overrides-v8.json while we await mapbox/mapbox-gl-js#4086.


#if TARGET_OS_IPHONE
/**
The geometry's offset. Values are [x, y] where negatives indicate left and up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also use style-spec-overrides-v8.json to remove any sentence that talks about offsets or padding as arrays, because that isn't how they're exposed by the iOS and macOS SDKs. (They're CGVectors or NSEdgeInsets or UIEdgeInsets, not NSArrays.)

/**
The base color of the extruded fill. The extrusion's surfaces will be shaded
differently based on this color in combination with the root `light` settings.
If this color is specified as `rgba` with an alpha component, the alpha
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #6107 (comment), we override documentation to remove the phrase "as rgba, because that's CSS syntax, whereas alpha may be specified with -colorWithHue:saturation:brightness:alpha: or -colorWithWhite:alpha: instead of -colorWithRed:green:blue:alpha:.

* `MGLInterpolationModeExponential`
* `MGLInterpolationModeInterval`
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillExtrusionTranslate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #6098 (comment), we turn "translate" to "translation" using platform/darwin/scripts/cocoa-conventions-v8.json to prevent a call to the property's getter from looking like a call to an action method.

*/
@interface NSValue (MGLFillExtrusionStyleLayerAdditions)

#pragma mark Working with FillExtrusion Style Layer Attribute Values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/FillExtrusion/Fill Extrusion/

#if TARGET_OS_IPHONE
/**
The base color of the extruded fill. The extrusion's surfaces will be shaded
differently based on this color in combination with the root `light` settings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

light will in all likelihood be a property of MGLStyle; the word "root" is meaningless in the context of these SDKs.

### Example

```swift
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we'll want to fill in some example code here, via MGLDocumentationTests.swift, but that can be tail work.

/**
An extruded (3D) polygon.

You can access an existing fill-extrusion style layer using the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/fill-extrusion/fill extrusion/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1ec5 I am of the opinion (though not strongly) that this should remain hyphenated, I think, for clarity — do you have a strong feeling that it should be fill extrusion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as a noun phrase, it should be unhyphenated in prose. ("Fill-extrusion style layer" would be more natural as shorthand for "fill and extrusion style layer", like "zoom-property function" as shorthand for "zoom-and-property function".) Unlike in JavaScript, the hyphenated form fill-extrusion will never appear in the developer's code.

@anandthakker
Copy link
Contributor

I suspect there may be a bug in the way we're handling zoom-and-property functions — investigate

FYI, our handling of these underwent some recent changes (by @mollymerp and I) - happy to help 💭 / 🕵️

@lbud
Copy link
Contributor Author

lbud commented Mar 16, 2017

Thanks for the 👀 @1ec5! All platform-specific code committed thus far has been autogenerated with scripts/make targets so your attention is especially appreciated 🙇‍♀️ — adding to the list.

@1ec5 1ec5 added this to the ios-v3.6.0 milestone Mar 21, 2017
@1ec5 1ec5 added Core The cross-platform C++ core, aka mbgl feature GL JS parity For feature parity with Mapbox GL JS Google Maps parity For feature parity with the Google Maps SDK for Android or iOS MapKit parity For feature parity with MapKit on iOS or macOS labels Mar 21, 2017
@1ec5 1ec5 mentioned this pull request Mar 21, 2017
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to rerun make darwin-style-code to incorporate the changes in d682d56.

"doc": "The geometry's offset."
},
"fill-extrusion-color": {
"doc": "The base color of this layer. The extrusion's surfaces will be shaded differently based on this color in combination with the `light` settings. If this color is specified with an alpha component, the alpha component will be ignored; use `fill-extrusion-opacity` to set layer opacityco."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "opacityco".

@@ -50,6 +53,17 @@
"doc": "Name of image in style images to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512)."
}
},
"paint_fill-extrusion": {
"fill-extrusion-pattern": {
"doc": "Name of image in style images to use for drawing image fill-extrusions. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512)."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Image fills" sort of made sense for fill-pattern, but I'm not sure about "image fill-extrusions". How about "for drawing the surfaces of the extrusion"?

@lbud
Copy link
Contributor Author

lbud commented Apr 7, 2017

@jfirebaugh @kkaefer I'm trying to figure out one last thing here: there's a failing TileCover test on a few Bitrise platforms (though passing on Travis) — the returned tiles the same but are slightly out of order; this is the result of the changes in transform_state.cpp to scale the projection matrix vertically to meters per pixel (corresponding gl-js change: mapbox/mapbox-gl-js#3509).

Aside from that however this is ready for review (so please start reviewing whenever you feel ready) — the only thing that may change is that small part of transform_state.cpp. I'm not sure if this would be easier to review if I squashed or rearranged some commits, or if this is reviewable as-is — if I can make it easier for you let me know 🙏

@lbud
Copy link
Contributor Author

lbud commented Apr 7, 2017

Also tagging in @ivovandongen @1ec5 to do a pass over generated Darwin/Android code 🙏

Lauren Budorick added 3 commits April 26, 2017 16:52
…ill-extrusion layer with a further near clip plane, and leave the global projection matrix alone
…ssor conditional in types.hpp) in all cases
@lbud
Copy link
Contributor Author

lbud commented Apr 27, 2017

Recording the solution to the depth buffer issue for posterity's sake:
In an ideal world we'd be able to use 24-bit depth buffers everywhere to solve the artifacts issue, but in reality we can't count on anything better than GL ES 2.0 without extensions. The approach I'm going with here is compatible with core ES2 (16-bit depth buffers — removes all references to 24-bit depth buffers, even where supported): for the projection matrix used for fill-extrusions, set the near clip plane to 100 (a sort of arbitrary number that seems to suit our needs well). This way we don't waste a ton of unnecessary depth precision on very near space where we aren't actually rendering anything, and we have enough precision for the rest of the scene.

@ivovandongen
Copy link
Contributor

@lbud I get a failed UI test on FillExtrusionLayerTest#testSourceLayer:

org.junit.ComparisonFailure: expected:<[]> but was:<[composite]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.mapbox.mapboxsdk.testapp.style.FillExtrusionLayerTest.testSourceLayer(FillExtrusionLayerTest.java:90)
...

@tobrun
Copy link
Member

tobrun commented Apr 27, 2017

@lbud 695da93 resolves the failing test.

@lbud lbud merged commit f6e79d7 into master Apr 27, 2017
@lbud lbud deleted the extrusions branch April 27, 2017 22:56
@1ec5
Copy link
Contributor

1ec5 commented Apr 27, 2017

platform-specific getLight/setLight APIs can be added in follow-up PRs 🙏 😄

Android: #8841
iOS and macOS: #8840

@1ec5
Copy link
Contributor

1ec5 commented Jun 21, 2017

Looks like this PR rolled back #6619 (nfarina/calloutview#107): #9314.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl feature GL JS parity For feature parity with Mapbox GL JS Google Maps parity For feature parity with the Google Maps SDK for Android or iOS MapKit parity For feature parity with MapKit on iOS or macOS Tangram parity For feature parity with Tangram ES
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants