Expand description
A software model of the parts of MapLibre GL JS’s WebGL pipeline used to draw fills, lines and circles, so CPU renders match it pixel-for-pixel.
- Primitives are sampled at pixel centres with the top-left rule, like a GPU rasteriser; there is no other antialiasing.
- The framebuffer is 8-bit premultiplied RGBA; every fragment is blended
with
src + dst * (1 - src.a)and rounded to 8 bits, like WebGL. - Line geometry is a port of
LineBucket.addLineand the line / line-SDF shaders; fill outlines modelgl.LINESwith thefill_outlineshader; dashes use a port ofLineAtlas.
References are to maplibre-gl-js src/data/bucket/line_bucket.ts,
src/render/line_atlas.ts, src/render/draw_fill.ts and src/shaders/*.
Structs§
- Clip
- Per-tile stencil clip: a pixel belongs to the tile if its centre is in
[x0, x1) × [y0, y1)(top-left rule on the tile quad). - Dash
- Framebuffer
- Line
Builder - Line
Vertex - One line vertex as the line shaders see it after attribute decoding.
- Vert
Enums§
Constants§
Functions§
- raster_
gl_ line - Fragments of a 1 px aliased
gl.LINESsegment (diamond-exit style: start inclusive, end exclusive along the major axis), with the perpendicular distance from each pixel centre to the line, which is what thefill_outlineshader’slength(v_pos - gl_FragCoord.xy)evaluates to. - raster_
polygon - Pixel-centre coverage of one polygon (exterior + holes, even-odd), the same pixels earcut triangles cover under the top-left rule.
- raster_
triangle - Rasterise a triangle, calling
frag(x, y, varyings)for each covered pixel centre insideclip. Varyings are interpolated linearly (no perspective). - smoothstep