{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/2454","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl-js","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/2454/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/2454/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/2454/events","html_url":"https://github.com/mapbox/mapbox-gl-js/pull/2454","id":148761547,"number":2454,"title":"implement zoom and data driven functions","user":{"login":"ansis","id":1421652,"avatar_url":"https://avatars.githubusercontent.com/u/1421652?v=3","gravatar_id":"","url":"https://api.github.com/users/ansis","html_url":"https://github.com/ansis","followers_url":"https://api.github.com/users/ansis/followers","following_url":"https://api.github.com/users/ansis/following{/other_user}","gists_url":"https://api.github.com/users/ansis/gists{/gist_id}","starred_url":"https://api.github.com/users/ansis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansis/subscriptions","organizations_url":"https://api.github.com/users/ansis/orgs","repos_url":"https://api.github.com/users/ansis/repos","events_url":"https://api.github.com/users/ansis/events{/privacy}","received_events_url":"https://api.github.com/users/ansis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-15T20:29:49Z","updated_at":"2016-04-15T20:41:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/pulls/2454","html_url":"https://github.com/mapbox/mapbox-gl-js/pull/2454","diff_url":"https://github.com/mapbox/mapbox-gl-js/pull/2454.diff","patch_url":"https://github.com/mapbox/mapbox-gl-js/pull/2454.patch"},"body":"fixes https://github.com/mapbox/mapbox-gl-js/issues/2428\r\n\r\nFor zoom+data driven functions, the buffers contain the values for four stops. Each shader reads all four values and uses a uniform, like `u_radius_t` to interpolate between the stops. Attributes with one component, like `radius`, are packed into a vec4. Attributes with more than one component are passed as separate glsl attributes.\r\n\r\nSince functions may have more than four zoom stops the buffers may not hold all the stops. It adds the four nearest stops to the buffers (two stops before the tile's zoom, two stops after). The uniform used for interpolation accounts for this.\r\n\r\nZoom+data driven functions currently look like this:\r\n```js\r\n\"circle-radius\": {\r\n    stops: [\r\n        [0, { stops: [[0,  2], [100, 10]], property: 'mapbox' }], \r\n        [6, { stops: [[0,  20], [100, 100]], property: 'mapbox' }]\r\n    ]   \r\n},  \r\n\"circle-color\": {\r\n    stops: [\r\n        [0, { stops: [[0, 'red'], [100, 'violet']], property: 'mapbox' }], \r\n        [6, { stops: [[0, 'blue'], [100, 'green']], property: 'mapbox' }]\r\n    ]   \r\n} \r\n```\r\n\r\nThe current implementation does not require that all the data subfunctions have the same stops or the same 'property' value. We may want to add that restriction to make UIs for editing functions simpler. Does this function definition look ok, or does anyone have other ideas?\r\n\r\nI'll fix style validation after we settle on a format.\r\n\r\nhttps://github.com/mapbox/mapbox-gl-function/tree/zoom-and-data implements the mapbox-gl-function part of this.\r\n\r\n:eyes: @lucaswoj @jfirebaugh "},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/comments/210638092","html_url":"https://github.com/mapbox/mapbox-gl-js/pull/2454#issuecomment-210638092","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/2454","id":210638092,"user":{"login":"ansis","id":1421652,"avatar_url":"https://avatars.githubusercontent.com/u/1421652?v=3","gravatar_id":"","url":"https://api.github.com/users/ansis","html_url":"https://github.com/ansis","followers_url":"https://api.github.com/users/ansis/followers","following_url":"https://api.github.com/users/ansis/following{/other_user}","gists_url":"https://api.github.com/users/ansis/gists{/gist_id}","starred_url":"https://api.github.com/users/ansis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansis/subscriptions","organizations_url":"https://api.github.com/users/ansis/orgs","repos_url":"https://api.github.com/users/ansis/repos","events_url":"https://api.github.com/users/ansis/events{/privacy}","received_events_url":"https://api.github.com/users/ansis/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T20:41:40Z","updated_at":"2016-04-15T20:41:40Z","body":"example: http://bl.ocks.org/ansis/raw/00c2af09ba26e3e56c055a9ad24876b4/#1.5/38.9/-77.0"}}