tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.2k stars 290 forks source link

Introduce u_map_zoom #795

Closed predragdukanac closed 2 years ago

predragdukanac commented 2 years ago

Hi, development team! Maybe you would consider introducing another program uniform that would expose current map zoom level. It would take one additional line in view.js (line 340: program.uniform('1f', 'u_map_zoom', this.zoom);)

This comes handy when we want to apply slightly different shading for various zoom levels. At the moment, there is no handy way to acquire zoom level in shader block function.

matteblair commented 2 years ago

I believe u_map_position.z represents the current zoom value (https://tangrams.readthedocs.io/en/main/Syntax-Reference/shaders/#built-in-uniforms). Have you tried using that?

predragdukanac commented 2 years ago

You're quite right, thanks for your suggestion. I wasn't aware of the z-level within u_map_position. Thank you for the quick answer, please, ignore my proposal for additional code line.