Sign#
Originally the result of sign(x)
would be:
-1 if x < 0,
1 if x > 0
and
0 if x == 0
However, if the last case is not needed it is better to use conditional form instead of sign()
.
fragColor.x = sign(t.x) * t.y; // three cycles
{mov, pck, tstgez, mov}
{mov, pck, tstgez, mov}
{sop, sop}
-->
fragColor.x = (t.x >= 0.0 ? 1.0 : -1.0) * t.y; // two cycles
{mov, pck, tstgez, mov}
{sop, sop}