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

Custom GPU passes

addPass runs your own full-screen fragment shader inside the map effects plugin's GPU chain. Every effect drawn over the chain (bloom, grade, fog, edge blur, tint, vignette) then works on your picture. Use it for a stylisation, such as a watercolour, a posterise or 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');

Effects on top of everything

An effect that belongs on top of everything, such as film grain, scanlines or a watermark, needs no pass. Lay your own element over the map, above the effects container.

Related guides and examples

Related guides

Related examples