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

Round one of changing shaders for data-driven styling #1257

Merged
merged 13 commits into from
Jun 11, 2015
Merged

Conversation

lucaswoj
Copy link
Contributor

@lucaswoj lucaswoj commented Jun 9, 2015

The first step to data driven styling is refactoring the shaders to allow per-feature colors. This pull request makes all three line shaders compatible with this functionality. It does not seem to degrade performance measurably -- all benchmarks still run at 60fps.

cc @jfirebaugh @ansis

for (var i = 0; i < elementGroups.groups.length; i++) {
vertex.bind(gl);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this call important? Why wasn't it here before?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ansis Can you explain what's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reckon this is only necessary if we are actually binding a buffer to the attribute.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the call is necessary either way

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Jun 9, 2015

@jfirebaugh What's the strategy here? Do you want to merge this PR once it gets 👍? Or do you want to do all shader changes in one PR? Or do you want to have everything end-to-end in one PR? I'd like to avoid doing this in a separate branch, as long as we can maintain backwards compatibility.

@jfirebaugh
Copy link
Contributor

Yes, let's get as far as we can with short-lived, backwards compatible branches. But let's also make all the uniform ⇢ attribute changes at once, so we can gauge the full performance effect, if any.

@ansis Can you take the lead on code reviewing shader changes?

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Jun 9, 2015

Got it @jfirebaugh. I'll keep hacking on that today.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Jun 9, 2015

I'm going to focus on support for the these style properties first because they are paint styles that only require simple shader changes

  • fill-color
  • fill-outline-color
  • line-blur
  • line-color
  • line-width
  • icon-halo-color
  • icon-halo-width
  • text-color
  • fill-opacity
  • line-opacity (linepattern only)
  • icon-opacity
  • text-halo-color
  • text-halo-width
  • text-halo-blur
  • line-gap-width

@lucaswoj lucaswoj changed the title Changed line color to a "varying" attribute in the shaders Round one of changing shaders for data-driven styling Jun 9, 2015
// - every shader has an `a_pos` attribute
//
// see: https://developer.mozilla.org/en-US/docs/Web/WebGL/WebGL_best_practices
this.bindAttribLocation(shader.program, 0, 'a_pos');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jfirebaugh @ansis @kkaefer Do you think this is sufficiently robust and explanatory for now? Or would you architect this differently?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that looks good

@jfirebaugh jfirebaugh added this to the 0.9 milestone Jun 11, 2015
@lucaswoj
Copy link
Contributor Author

Ok, I think this is ready for review!

This PR includes all the straightforward shader modifications for data driven styling. This means we only support a subset of the style properties we eventually want to support. The style properties enabled by this pull request are listed (above)[https://github.com//pull/1257#issuecomment-110443499].

The more complex changes needed to support other style properties (they all need different sorts of changes) should be ticketed out done in separate pull requests from here.

cc @jfirebaugh @ansis @kkaefer

@lucaswoj
Copy link
Contributor Author

Per if is looking great! (without per-vertex buffers)

duration: 3000
30.4 fps https://api.tiles.mapbox.com/mapbox-gl-js/v0.7.0/mapbox-gl.js
30.1 fps /debug/mapbox-gl.js
31.4 fps https://api.tiles.mapbox.com/mapbox-gl-js/v0.7.0/mapbox-gl.js
29.8 fps /debug/mapbox-gl.js

@ansis
Copy link
Contributor

ansis commented Jun 11, 2015

looks good! can you squash some of the lint and whitespace fixes?

@lucaswoj
Copy link
Contributor Author

@ansis Yes, I'll take a swing at it. I almost want to squash the whole PR into one commit... Its pretty messy. Call it a "learning experience."

@lucaswoj
Copy link
Contributor Author

Ok. I removed the egregious lint and whitespace fix commits.

@jfirebaugh jfirebaugh merged commit f5a34c6 into master Jun 11, 2015
@jfirebaugh jfirebaugh deleted the scales branch June 11, 2015 20:29
@jfirebaugh
Copy link
Contributor

Awesome.

@lucaswoj
Copy link
Contributor Author

🎆

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.

4 participants