'<' : Wrong operand types. when comparing vec4 with vec4 constant

Hi,

I am having trouble in android with version 100 when trying to compare a vec4 from texture2D and a vec4 constant
as:

lowp vec4 L = texture2D(imgTexture, textureCoord);
if(L< vec4(0.5))
{
    ...
    ...

An error is returned during shader’s compilation

'<' : Wrong operand types. No operation '<' exists that takes a left-hand operand of type '4-component vector of float' and a right operand of type '4-component vector of float' (and there is no acceptable conversion)
  1 compilation errors. No code generated.

But when I compare with vec4(0.0) or vec4(1.0) no error is shown.

Any advice?

It isn’t meaningful to compare vectors.

You can perform element-wise comparisons with the functions lessThan, lessThanEqual, greaterThan, and greaterThanEqual. These return boolean vectors (bvec4 etc), which can’t be used as the condition of an if statement.

What GClements said.

Depending on what logic you’d like to apply here, consider wrapping that condition with the any() or all() functions, which map a bool vector to a bool scalar result. For instance:

    if ( any( lessThan( L, vec4(0.5) ) ) )
    {

OpenGL ES GLSL 1.00 Specification :

Big thanks for this clarification, to Dark_Photon and GClements