Exemplo n.º 1
0
 /**
 * Moves the colors in the specified array to non-linear space. The original
 * colors are not modified.
 *
 * @param color an array of colors in linear space
 * @return a new array of the same colors in non-linear space
 */
 public static Color[] unlinearize(Color[] color)
 {
     Color[] output = new Color[color.Length];
     for (int i = 0; i < color.Length; i++)
         output[i] = color[i].copy().toNonLinear();
     return output;
 }
Exemplo n.º 2
0
 /**
 * Encode the specified colors using Ward's RGBE technique. The returned
 * array contains one int for each color in the original array.
 *
 * @param color array of colors to encode
 * @return array of encoded colors
 */
 public static int[] encodeRGBE(Color[] color)
 {
     int[] output = new int[color.Length];
     for (int i = 0; i < color.Length; i++)
         output[i] = color[i].toRGBE();
     return output;
 }
Exemplo n.º 3
0
 /**
 * Quantize the specified colors to 8-bit RGB format. The returned array
 * contains 3 bytes for each color in the original array.
 *
 * @param color array of colors to quantize
 * @return array of quantized RGB values
 */
 public static byte[] quantizeRGB8(Color[] color)
 {
     byte[] output = new byte[color.Length * 3];
     for (int i = 0, index = 0; i < color.Length; i++, index += 3) {
         float[] rgb = color[i].getRGB();
         output[index + 0] = (byte) MathUtils.clamp((int) (rgb[0] * 255 + 0.5f), 0, 255);
         output[index + 1] = (byte) MathUtils.clamp((int) (rgb[1] * 255 + 0.5f), 0, 255);
         output[index + 2] = (byte) MathUtils.clamp((int) (rgb[2] * 255 + 0.5f), 0, 255);
     }
     return output;
 }
Exemplo n.º 4
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     c = pl.getColor("color", c);
     return true;
 }
Exemplo n.º 5
0
 public void ScatterPhoton(ShadingState state, Color power)
 {
 }
Exemplo n.º 6
0
 public ConstantShader()
 {
     c = Color.WHITE;
 }
Exemplo n.º 7
0
 /**
 * Undoes the premultiplication of the specified color array. The original
 * colors are not modified.
 *
 * @param color an array of premultiplied colors
 * @param alpha alpha values corresponding to the colors
 * @return an array of unpremultiplied colors
 */
 public static Color[] unpremult(Color[] color, float[] alpha)
 {
     Color[] output = new Color[color.Length];
     for (int i = 0; i < color.Length; i++)
         output[i] = color[i].copy().mul(1 / alpha[i]);
     return output;
 }