Arithmetic operator glsl

stupid question in glsl why this line:

float x = 1 - gl_Color.x;

gives:

(26): error: Could not implicitly convert operands to arithmetic operator
+5
source share
1 answer

GLSL (before #version 120) does not allow implicit conversions between integers and floating point. 1is an integer, and gl_Color.xis a float, so you get an error. You need

float x = 1.0 - gl_Color.x;

instead

+18
source

All Articles