tangram-es
tangram-es copied to clipboard
Enable setting of `blend_order` at the `draw` level (JS compatibility)
See: https://github.com/tangrams/tangram/pull/703.
Said @bcamper:
For styles drawn with non-opaque
blend modes, the blend_order
is used to determine the rendering order, and thus which features are drawn on top of each other where there are overlaps.
Because it has only been possible to set blend_order
at the style
level, a common pattern has developed where several very similar / template rendering styles are created, to achieve different visual layering:
polygons-overlay-low:
base: polygons
blend: overlay
blend_order: 1
polygons-overlay-mid:
base: polygons
blend: overlay
blend_order: 3
polygons-overlay-high:
base: polygons
blend: overlay
blend_order: 5
This is inefficient and unwieldy -- and inflexible, especially when mixing data on top of basemaps (which end up having to predefine certain fixed blend_order
"slots" for use by data overlays). This PR enables the blend_order
to be set at the draw
block level (following prior similar work for dash
, texture
, etc.). This allows for much more flexible blend_order
expressions, and a semantic use that aligns with the order
parameter used for geometry world order of opaque
-rendered features. For example:
styles:
polygons-overlay:
base: polygons
blend: overlay
layers:
overlays:
...
draw:
polygons-overlay:
blend_order: 3
sub-layer:
...
draw:
polygons-overlay:
blend_order: 7
Implementation notes: perviously, the engine enforced that each style was only rendered once per render pass. With this feature, the engine will now bucket geometries for a given style by their blend_order
, and then render styles one or more times (split up using these buckets), as dictated by the total number of unique, sorted blend_order
values currently visible in the scene.
Have you solved this problem?