-
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
Simplify data-driven paint attributes implementation #3527
Conversation
getPaintValue(name, globalProperties, featureProperties) { | ||
const value = super.getPaintValue(name, globalProperties, featureProperties); | ||
if (name === 'fill-extrusion-color') { | ||
value[3] = 1; |
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.
Could we do this in the vertex shader instead?
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.
Yes, thought about that too. I just placed it here temporarily.
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.
Looking at the vertex shader, it seems that fill-extrusion-color
alpha value is not used there at all. So we could simply remove this code. @lbud does this sound right?
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.
The reason for this is that if you provide an rgba color in the style, we premultiply it in StyleDeclaration, but we don't render using the alpha channel, so providing a non-opaque rgba value leads to unexpected color results. We decided the best of several not-great approaches here would be to deliberately ignore the alpha channel before premultiplying.
After #3523 I believe we have a regular naming convention for the attribute/uniform name -- it's the name of the paint property with the layer type prefix removed. I haven't looked at the |
Yes, noticed about attribute/uniform name convention too — I figured this was the reason you asked for #3523. :) I'm still unsure about deriving type/multipliers — we can do it for colors, but for things like circle-blur and fill-extrusion-height, converting them to float doubles the memory requirement (16 -> 32 bits), and picking the right |
71a4f4f
to
c04f3e7
Compare
957c467
to
1d06cd2
Compare
@lucaswoj @jfirebaugh @lbud @ansis this PR is ready for review. It didn't accomplish everything that was planned in #3525 fully, but instead led me to significantly improve the clarity of data-driven-properties code (and -107 lines net!). Performance also slightly improved — from 6.1ms to 5.5ms on the Streets z13 benchmark. Buffer bench results are unchanged. All commits are self-contained and pass tests. I suggest merging this now and following up with the points below in other PRs:
|
95407bf
to
4fcb5c9
Compare
} else if (layer.isPaintValueZoomConstant(attribute.property)) { | ||
self.addDataDrivenAttribute(name, attribute); | ||
} else { | ||
self.addDataAndZoomDrivenAttribute(name, attribute, layer, zoom); |
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.
In the codebase we use the terminology property functions
, zoom functions
, and zoom and property functions
."data-driven" is a broader designation that may include unrelated features in the future.
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.
We could call these methods addZoomAttribute
, addPropertyAttribute
, and addZoomAndPropertyAttribute
This looks great! I have couple thoughts on terminology in |
It's definitely easier to understand In gl-native, the implementation is going to center entirely around paint properties. We use code generation to create a unique type for each paint property, which can provide to C++ the data that's in the style specification. Having unique types allows the use of C++ structural metaprogramming techniques to define generic operations over tuples of paint properties. There will be an equivalent of In the initial implementation, I'm not going to use multipliers. I'm also going to use |
which generates 100x smaller cache keys, making program lookups much faster
382f70a
to
0d16d21
Compare
A work in progress, closes #3525. cc @jfirebaugh @lucaswoj
The tests are failing because of
bucket.test.js
, which is mocked in a very complex way so I can't figure out how to fix a few of its failing assertions yet.