Make sure that all vector components are greater than some number

I have vec2one containing the x and y coordinates. I need them to be more than 16. My first attempt:

if (gl_FragCoord.xy > 16.0) {
  // do something..
}

Unable to compile with "no matching operand" error.

It works if I compare each vector size separately.

if ((gl_FragCoord.x > 16.0) && (gl_FragCoord.y > 16.0))
  // do something..
}

Is there a better way to check all elements of a vector at once?

+4
source share
1 answer

Here is a function for comparing by components , which creates a logical vector, and then another to test the components of a Boolean vector :

if (all(greaterThan(gl_FragColor.xy, vec2(16.0))) {
    /* ... */
}
+6
source

Source: https://habr.com/ru/post/1688456/


All Articles