'glsl arithmetic operator

Why does this line:

float x = 1 - gl_Color.x;

give:

(26): error: Could not implicitly convert operands to arithmetic operator


Solution 1:[1]

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

float x = 1.0 - gl_Color.x;

instead

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris Dodd