Search code examples
openglglsl

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

  • 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