Closed bcamper closed 7 years ago
Note: one motivation for this feature from the Mapzen cartography perspective is easier support for additional textures in the future, such as expanded road shields for US states and countries, where it is impractical to fit all these shields into a single texture (and/or some textures may be loaded lazily at run-time, only when those regions are visited).
@matteblair could you please take a look to ensure this will work from the ES perspective.
Tangram ES support being tracked in https://github.com/tangrams/tangram-es/issues/1645.
This PR relaxes the requirement that a
points
-based style be bound to only one (or no) texture.With this change, a scene author can freely re-assign (or un-assign) the texture that the style is bound to, within a
draw
group, using thetexture
parameter.For example:
This change is fully backwards compatible with existing
styles
: if a style has set atexture
, this simply becomes the default value, but that value can then be overridden if desired withinlayers
.If no
texture
value is set for the final mergeddraw
group (either because it was not set by thestyle
or by a parent layer'sdraw
group, or it was explicitly un-set in a childdraw
group withtexture: null
), then the feature will be drawn with the built-in points style (e.g. as regularpoints
would be drawn, with no texture bound).Extending the example above:
Internally, this feature uses the recently added "mesh variant" concept, where the same style can create sub-meshes that each have their own uniform state or vertex layouts. All vertex layouts must be compatible with the same underlying shader program, but a variant can set a vertex attribute to a static value to lower memory consumption, if that attribute has a suitable default value. For this PR, the variants will vary the uniform texture sampler that is bound for sprites, and the vertex layout can set static values of zero for point outlines where they are not needed.