This repository contains GL shaders which are shared by Mapbox GL JS and Mapbox GL Native.
Some variables change type depending on their context:
uniformattribute (in the vertex shader) and an accompanying varying (in both the vertex and fragment shaders).attributes and uniforms then calculate the value using interpolationWe abstract over this functionality using pragmas.
#pragma mapbox: define highp vec4 color
main() {
#pragma mapbox: initialize highp vec4 color
...
gl_FragColor = color;
}
This program defines a variable within main called color, initialize the value of color, then sets gl_FragColor to the value of color.
Pragmas take the following form.
#pragma mapbox: (define|initialize) (lowp|mediump|highp) (float|vec2|vec3|vec4) {name}
When using pragmas, the following requirements apply.
define and initialize pragmasdefine pragmas must be in file scopeinitialize pragmas must be in function scopeattributes are not accessible from the fragment shaderThe util.glsl file is automatically included in all shaders by the compiler.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.