This is the documentation of version 0.62.3. Go to the latest version, 1.0.0-rc.5.

Custom GPU passes

addPass runs a full-screen fragment shader of yours inside the map effects plugin's GPU chain, so every effect the plugin draws over the chain — bloom, grade, fog, edge blur, tint, vignette — then works on your picture. That is the slot for a stylisation: a watercolour, a posterise, a colour lookup. The demo below paints the map in watercolour, then lets bloom, a contrast grade and a vignette work on the painting.

Your own GPU passes

effects.addPass({
    id: 'posterise',
    fragment: `uniform float uLevels;
        void main() {
            vec4 colour = texture(uSource, vUv);
            fragColor = vec4(floor(colour.rgb * uLevels) / uLevels, colour.a);
        }`,
    uniforms: { uLevels: 5 },
});

effects.removePass('posterise');

The map needs canvasContextAttributes: { preserveDrawingBuffer: true }, since the chain reads the map canvas back (Usage).

Effects on top of everything

An effect that belongs on top of everything — film grain, scanlines, a watermark — needs no pass: lay your own element over the map, above the effects container.

Passes are code rather than settings, so getConfig() does not list them.

Related guides and examples

Related guides

Related examples