home/ atoms/ glsl-strict-type-system

GLSL requires explicit float literals and exact vector sizes; int/float mixing is a compile error

GLSL has a strict type system: integer literals (e.g. 1) and float literals (e.g. 1.0) are distinct types. Mixing them in expressions like float x = 1 or 2 * st (int times vec2) is a compile-time type error. Vector operations also require matching sizes — vec3 cannot be combined with vec2 without explicit construction. The fix is: always write float literals with a decimal point (1.0, 0.5), match vector sizes explicitly, and cast integers with float(i).

Examples

float x = 1; → error. Fix: float x = 1.0;. 2 * st → error. Fix: 2.0 * st.

Assessment

Identify the type error in vec3 col = vec3(st, 0); and write the corrected expression.

“int/float type mismatch** | `float x = 1;`, `2 * st`, mixing `int` and `float`, wrong vec size | `ERROR: … cannot convert / no matching operator`”
context/ · L5-debug/glsl.md · chunk 1