public static Color[] ToColorMap(float[,] values, IColorConnection colorSampler = null, OutputSocket colorRequestSocket = null) { int width = values.GetLength(0); int height = values.GetLength(1); Color[] colorMap = new Color[width * height]; Request request = new Request(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color c; if (colorSampler == null) { c = GetGreyscaleColor(values[x, y]); } else { request.X = x; request.Y = (values[x, y] + 1f) / 2f; request.Z = y; c = colorSampler.GetColor(colorRequestSocket, request); } colorMap[y * width + x] = c; } } return(colorMap); }
public static UnityEngine.Color GetInputColor(InputSocket socket, Request request) { if (!socket.IsConnected()) { return(UnityEngine.Color.magenta); } IColorConnection sampler = socket.GetConnectedSocket().Parent as IColorConnection; if (sampler == null) { return(UnityEngine.Color.magenta); } return(sampler.GetColor(socket.GetConnectedSocket(), request)); }