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

    Module rendering/shaders/glsl-lib

    Shared GLSL helper snippets injected into the Points / Lines / GSplats shaders.

    Keeping the sanitize helpers in one place lets us:

    • change the sanitize policy once (e.g., to also reject denormals) without hunting through three shader source strings;
    • test the GLSL-string content with a single regex assertion;
    • make the intent explicit at the call site.

    Helpers:

    • isInvalidFloat(v) — true if v is NaN or +/-Inf.
    • sanitizePositive(v, fb) — returns v if v > 0 and finite, else fb.
    • sanitizeNonNegative(v, fb) — returns v if v ≥ 0 and finite, else fb.

    Inject by prepending GLSL_SANITIZE_FUNCTIONS to a shader source string before the main() block:

    const vertexShader = `
    uniform vec2 uResolution;
    ${GLSL_SANITIZE_FUNCTIONS}
    void main() { ... }
    `;
    GLSL_SANITIZE_FUNCTIONS
    GLSL_NEAR_FADE_FUNCTIONS
    GLSL_PROJECTION_FUNCTIONS
    GLSL_LINE_SCALE
    GLSL_ELEMENT_ID_SPLIT
    GLSL_SORTED_INDEX
    GLSL_LINE_JOINT_CODE
    LINE_JOIN_MIN_HALF_WIDTH
    GLSL_LINE_JOIN