Function roundToPower2

  • Rounds a given number up or down to a power of 2. Useful for working with textures.

    Parameters

    • number: number

      The number to round

    • roundUp: boolean = true

      If true, rounds the number to the smallest power of 2 greater or equal to the input, else, rounds the number to the greatest power of 2 smaller or equal to the input.

    Returns number

    Returns the rounded number