Shader uniform type mismatch handling in Love2D
0 reputation · 16 Aug 2021, 05:14 UTC
Shader uniform type mismatch handling in Love2D
The goal is to diagnose intermittent rendering artifacts that appear when a uniform is bound with a Lua value of an incompatible type. For example, setting a GLSL float uniform with a Lua string or passing a table with fewer elements than required for a vector uniform.
Constraints include the fact that Love2D’s love.graphics.setShader API does not document explicit type checking. On some desktop OpenGL drivers the binding silently succeeds, producing no console output, while on WebGL or mobile GL ES the same call may generate a warning, an error, or no observable effect. Additionally, if the uniform is not referenced in the shader, the engine logs a warning only at compile time, further obscuring the issue.
Unresolved behavior: does Love2D guarantee consistent error reporting across platforms when a uniform type mismatch occurs? How can a developer reliably detect and handle such mismatches to avoid silent failures?
Specific questions:
- What is the documented behavior of
love.graphics.setShaderwhen the Lua value type does not match the declared GLSL uniform type? - Under what circumstances does Love2D emit warnings or errors for these mismatches on desktop, WebGL, and mobile builds?
- What best‑practice patterns can be employed to enforce type safety for shader uniforms across all supported platforms?