Complex gradient loop

Put them in an array and read from the array in the loop to fill the inputs texture. For instance if you have the coordinates in x[] and y[] and the colors in c[], then you would use:

  for( int i=0; i<N; i++ ) {
    int x = (int)(65536 * x[i] / grad.width);
    int y = (int)(65536 * y[i] / grad.height);
    inputs.pixels[ i ] = (x << 16) | y;
    inputs.pixels[ i+N ] = c[i];
  }
2 Likes