Luxar Viewer API Documentation - v2026.10.19
    Preparing search index...

    Module rendering/picking/mesh/provoking-vertex

    Align the WebGL backend's flat-varying provoking vertex with WebGPU's.

    A flat varying is sourced from ONE corner of the triangle, and the two backends do not default to the same one:

    Backend Convention
    OpenGL ES 3.0 (glslVersion: GLSL3) last vertex of the primitive, fixed by spec
    Core WGSL mesh pick @interpolate(flat, first) first-vertex sampling

    That only becomes observable when a flat varying differs BETWEEN a triangle's corners — which, in the shipped materials, is exactly one case: the mesh pick shader's vElementId, whose source is gl_VertexID / vertexIndex (spec §6.5). Left alone, the same click on the same triangle (i0, i1, i2) reports i2 on WebGL and i0 on core WebGPU. Compatibility-mode WebGPU uses flat, either, which still reports a corner of the same triangle.

    WEBGL_provoking_vertex lets the WebGL side adopt core WebGPU's first-vertex rule, so the two agree wherever the extension exists. Where it does not, PickingSystem cyclically rotates each mesh index triple, so GL's last vertex becomes the original first vertex without changing winding or geometry — WebGL and core WebGPU therefore always agree exactly. Compatibility-mode WebGPU's either sampling (above) is the one case that still only satisfies the weaker "a corner of the front-most triangle" contract, not an exact match, and stands as a documented §6.4 exception.

    provokingVertexWEBGL is not scoped to a program or a draw call; it changes the convention for the whole context. That is safe because every OTHER flat varying in the shipped materials is a per-instance constant — point and gsplat quads and line segments all carry the same id, sharpness and cap flags at every corner of their expanded quad, so which corner supplies the value is unobservable. Mesh is the only geometry whose flat inputs vary within a primitive, hence the only one that can see the flip at all.

    alignProvokingVertexWithWebGPU