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

Add data driven styling for circle-color and circle-radius #1932

Merged
merged 32 commits into from
Apr 12, 2016

Conversation

lucaswoj
Copy link
Contributor

@lucaswoj lucaswoj commented Jan 14, 2016

This branch adds data-driven styling for circle-color.

screen shot 2016-04-06 at 11 55 07 am

map.addLayer({
    "id": "random-points",
    "type": "circle",
    "source": "geojson-random-points",
    "paint": {
        "circle-radius": 5,
        "circle-opacity": 0.5,
        "circle-color": {
            stops: [[0, 'red'], [100, 'violet']],
            property: 'mapbox'
        }
    }
});

map.addLayer({
    "id": "random-points-outline",
    "ref": "random-points",
    "paint": {
        "circle-radius": 10,
        "circle-color": {
            stops: [[0, 'white'], [100, 'black']],
            property: 'mapbox'
        }
    }
}, 'random-points');

Follow Up Tasks

  • merge mapbox-gl-function branch
  • merge mapbox-gl-style-spec branch
  • merge mapbox-gl-test-suite branch
  • add data-driven styling for all paint properties (except for fill layers, blocked on Switch to tesselated fill rendering with earcut #1606)
  • refactor Bucket class into smaller units

@lucaswoj lucaswoj force-pushed the data-driven-styling branch 3 times, most recently from 263def1 to 27e0443 Compare January 14, 2016 20:58
@lucaswoj lucaswoj force-pushed the data-driven-styling branch 2 times, most recently from 666f7ca to 4e58abc Compare January 19, 2016 22:07
@lucaswoj lucaswoj force-pushed the data-driven-styling branch 3 times, most recently from 2b01616 to 4520a6f Compare January 27, 2016 21:46
@lucaswoj lucaswoj mentioned this pull request Jan 27, 2016
@lucaswoj lucaswoj closed this Feb 10, 2016
@lucaswoj lucaswoj reopened this Feb 17, 2016
@lucaswoj lucaswoj force-pushed the data-driven-styling branch from 4520a6f to 2da2bdb Compare February 17, 2016 22:22
@lucaswoj lucaswoj mentioned this pull request Feb 18, 2016
5 tasks
@lucaswoj lucaswoj force-pushed the data-driven-styling branch 3 times, most recently from b3e4975 to c9b0d8f Compare March 3, 2016 00:22
@lucaswoj lucaswoj force-pushed the data-driven-styling branch 5 times, most recently from 44bd38e to be1e88a Compare March 10, 2016 00:58
@lucaswoj lucaswoj changed the title Add data driven styling for circle-color [DO NOT MERGE] Add data driven styling for circle-color Mar 11, 2016
@lucaswoj lucaswoj force-pushed the data-driven-styling branch 2 times, most recently from 1072da4 to ce7fc2b Compare March 15, 2016 20:14
Lucas Wojciechowski and others added 21 commits April 12, 2016 14:39
Using macros and preprocessor directives is the glsl way of doing this.
After this the .glsl files are now valid glsl. I think it's clearer to
have both variations explicitly written in glsl than having string
replacement.
This replaces a per-attribute `isDisabled` function with paint property
key. All data-driven attributes must now depend on only a single paint
property.

The `a_color` attribute used to depend on both the `circle-color` and
`circle-opacity` paint properties. This splits them up into two
attributes/uniforms, each of which only depends on one paint property.

I think it will be simpler to have all attributes be based on a single
style property. We will need to split up:
- a_color, which depends on -color and -opacity
- u_linewidth, which depends on line-width and line-width-gap
This prepares the shaders for the switch to data driven styling where
opacity and color need to be passed to the shader independent of
eachotehr.

remove the `additionalOpacity` parameter from `util.premultiply`
A function of the layer, globalProperties, featureProperties is simpler
than a string of code that gets joined into a function.

This separates the vertex push method for core attributes from the push
methods for data-driven attributes. This will let us:
- use a regular function for adding core attributes to buffers
- and either:
    - generate a separate method for data driven attributes
    - or optimize adding attributes without code generation

Data driven properties need to be evaluated once per feature, not once
per vertex. This means we can evaluate them outside the main vertex loop
and then add the same value for every vertex.

The hot loop for lines, fills and symbols will be:
for (var i = startIndex; i < endIndex; i++) {
    ...
}

If it's too slow in the current implementation we could add new
StructArray methods for setting a single value for a range of elements.
If we need to generate code it would be nice to contain that to
StructArray.
Now that paint attributes are added separately, we can switch to using
regular functions instead of code strings that are joined into a method.

This removes more code generation and it reduces the responsibility of
the `Bucket` parent class.
It's simpler to just add directly to the arrays.
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
since it no longer needs access to anything in Bucket

Set attribute pointers using info from the array type.
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.

6 participants