Tour of WGSL

Operators

All the numeric types support a basic set of arithmetic operators:

  • addition: +
  • subtraction: -
  • multiplication: *
  • division: /

bool support short-circuiting and non-short-circuiting operators:

  • bitwise-and (LHS and RHS are both always evaluated): &

  • logical-and (RHS is only evaluated if the LHS is true): &&

  • bitwise-or (LHS and RHS are both always evaluated): |

  • logical-or (RHS is only evaluated if the LHS is false): ||