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

    Module rendering/materials/mesh/shader-tsl

    Mesh material TSL factory — NodeMaterial counterpart to the GLSL3 pair in shader-glsl.ts.

    Draws a shaded indexed triangle surface:

    • view-anchored wrapped diffuse and specular terms, no scene light (spec §6.2)
    • stored view-space normals OR a screen-space-derivative flat normal, chosen at GRAPH BUILD time (the flatNormal config flag — the twin of the GLSL LUXAR_MESH_FLAT_NORMAL define)
    • per-node Gain/Offset/Gamma, with the same gammaOne / noGOG fast paths the sibling factories carry
    • per-vertex alpha as the sole coverage term, emitted per blending mode
    • the shared perspective near fade, evaluated PER FRAGMENT off vViewPos (a triangle spans depth, so a per-vertex value would smear the ramp across the face) — the twin of the GLSL fragment stage's perspectiveNearFade

    Unlike the three sibling factories there is no element texture, no aSortedIndex indirection and no quad expansion: position/normal are three's own attributes and the draw is an ordinary indexed one. The vertex stage is still traced inside a single Fn() with explicit .toVar() statements — the house rule from the depth-sorting spec's remediation, because as a free expression tree TSL materializes a shared subexpression at its FIRST traversal use, which can land inside a .select() branch and read uninitialized on the other path.

    The mesh fragment reads no fragcoord, which sidesteps the bottom-left reconstruction trap (vec2(x, screenSize.y - y)) entirely.

    MeshTSLConfig
    MeshTSLNodes
    meshWebGPUFactory
    buildMeshTSLNodesFromUniforms