Enable setting of blend_order at the draw level#703
Conversation
|
@matteblair just wanted to run this by you, in case it poses any gotchas on the ES side... I think it's worthwhile given the way this (anti-)pattern has evolved (seeing some dataviz cases where 10+ of these types of styles are being created). On the JS side, it is a fairly natural extension of a recent move towards more "bucketing" internally of different style variations (different texture bindings, use of constant attributes in some cases, etc.). I know this is not quite the same on the ES side, but believe there is some similar behavior for managing sprite/texture batching etc. (?) |
|
Created ES issue in tangrams/tangram-es#2039. |
|
Thanks for the heads up. This won't be trivial to implement in Tangram ES, but I don't think there's anything fundamentally preventing it. |
|
This is also true for |
|
@matteblair @tallytalwar Interesting, thanks. Are there particular challenges (for my knowledge benefit) for this in the ES rendering pipeline? On JS, the change that "opened up" a lot of these changes was adding a concept of having different "variants" of meshes per style, instead of requiring exactly one mesh. When a style was rendered for a tile, it would render all the mesh variants, but they could change certain state, such as uniform values, texture bindings, etc. This was originally added for the line offset feature. I was then able to repurpose this for several related features, like moving Doing this for Does that make sense? (May or may not be directly applicable in the ES case.) |
For styles drawn with non-
opaqueblend modes, theblend_orderis 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_orderat thestylelevel, a common pattern has developed where several very similar / template rendering styles are created, to achieve different visual layering: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 theblend_orderto be set at thedrawblock level (following prior similar work fordash,texture, etc.). This allows for much more flexibleblend_orderexpressions, and a semantic use that aligns with theorderparameter used for geometry world order ofopaque-rendered features. For example: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, sortedblend_ordervalues currently visible in the scene.