Glare

Glare is the map effects plugin's light for dark styles. The colours you name shine the way street lamps do through a camera lens, casting streaks out of every light. By default, the lights are the major roads of the loaded style. In the playground below, pick the Street lights use case:

Turning it on

Glare is off until glare.intensity is above 0. The other knobs have defaults that work on the TomTom dark styles:

import { MapEffects } from '@tomtom-org/maps-sdk-plugin-map-effects';

const effects = new MapEffects(map);
effects.updateConfig({ glare: { intensity: 0.8, length: 48 } });
Knob Range Default
glare.intensity, glare.threshold 0–1 0 (off), 0.3
glare.length (CSS px) 4–120 32
glare.rays 2–8, in steps of 2 4
glare.angle (degrees) 0–180 45
glare.only list of style colour knobs, groups and CSS colours ['colors.roadMajor']
glare.onlyTolerance 0–1 0.15

The ranges of glare.length and glare.onlyTolerance end where a slider would. setKnob refuses a value below the minimum, and a value above the maximum still applies.

Choosing the lights

glare.only lists the colours that count as lights. It takes the same entries as bloom.only: style colour knobs, groups of them and CSS colours. Each name is read from the loaded style, so the lights follow a recolour or a style switch.

import { setKnob } from '@tomtom-org/maps-sdk/map';
import { effectKnobCatalogue } from '@tomtom-org/maps-sdk-plugin-map-effects';

setKnob(effects, effectKnobCatalogue, 'glare.only', ['colors.roadMajor', 'pois.label.color']); // roads and place labels
setKnob(effects, effectKnobCatalogue, 'glare.only', ['#1a73e8']);                               // the colour your routes are drawn in
setKnob(effects, effectKnobCatalogue, 'glare.only', []);                                        // every bright pixel

The glare keys on colour, so a light's shape decides what you see. A small light, such as an icon or a dot, becomes a star. A lit line, such as a road, gets a soft sheen along its length, because the streaks from every point on it overlap.

Shaping the streaks

glare.rays sets how many streaks each light casts, and glare.angle turns them:

Glare with bloom

Glare runs before a bloom scoped by colour, so the bloom glows along the streaks too. To light the major roads as street lamps would, scope both effects to the same colour:

effects.updateConfig({
    glare: { intensity: 0.8, length: 48 },
    bloom: { intensity: 0.5, radius: 10, threshold: 0.3, only: ['colors.roadMajor'] },
});

How it renders

The glare is two stages of the GPU chain. It runs after your passes and the depth of field, and before a scoped bloom:

  1. The first stage keys each pixel on the lights' colours and cuts it at glare.threshold, as a scoped bloom does.
  2. The second stage draws the streaks out of the lights along each ray, then lays them over the picture in screen mode at glare.intensity.

Related guides and examples

Related guides

Related examples