Rotate texture in shader according to underlaying geometry
rwrx opened this issue · 3 comments
Hello, I am trying to accomplish texture rotation in Tangram according to geometry rotation as is done in Mapnik, for example this is OpenTopoMap styling for pitch texture:
I am trying to achieve this in Tangram style, but I am not sure whether it is possible to rotate texture based on geometry orientation (in this case landuse polygon) and then render it correctly in Shader. Currently I only get this:
This is styling I use:
texture-scale-pitch:
base: polygons
blend: overlay
blend_order: -1
texcoords: true
shaders:
uniforms:
u_customtexture: images/otm-symbols-modified/sports-soccer.svg
blocks:
color: |
color = texture2D(u_customtexture, v_texcoord);
Is it possible in Tangram styling to achieve what can be achieved in Mapnik?
I always wondered how Mapnik rendered the sports pitches!
@bcamper @tallytalwar @matteblair Does Tangram support data driven texture rotation and fitting?
Unfortunately you can't really do this with Tangram right now. The supported texture UV mapping types are here: https://tangrams.readthedocs.io/en/latest/Overviews/Materials-Overview/#mapping
I've previously been interested in adding an Oriented Bounding Box mapping type that would help with this case. However, ultimately I think it would still be of limited value, without a way to account for polygons broken up over tiles, e.g. without explicit hints in the feature data, the client has no way to know to adjust the UVs to correctly span a pitch or similar polygon that crosses tile boundaries.
Thank you for your answer. I thought that it will be impossible to achieve, but I had a little hope. So I will close this issue.

