Shared GLSL helper snippets injected into the Points / Lines / GSplats shaders.
Keeping the sanitize helpers in one place lets us:
Helpers:
isInvalidFloat(v)
sanitizePositive(v, fb)
sanitizeNonNegative(v, fb)
Inject by prepending GLSL_SANITIZE_FUNCTIONS to a shader source string before the main() block:
GLSL_SANITIZE_FUNCTIONS
const vertexShader = ` uniform vec2 uResolution; ${GLSL_SANITIZE_FUNCTIONS} void main() { ... }`; Copy
const vertexShader = ` uniform vec2 uResolution; ${GLSL_SANITIZE_FUNCTIONS} void main() { ... }`;
Shared GLSL helper snippets injected into the Points / Lines / GSplats shaders.
Keeping the sanitize helpers in one place lets us:
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_FUNCTIONSto a shader source string before the main() block: