Exemplo n.º 1
0
        private Color _GetColor(int x, int y)
        {
            Color objectColor = _fillingInfo.GetPixelOfTexture(x, y);

            double[] objectColorVector = _GetVector(objectColor);

            Color lightColor = _fillingInfo.GetLightColor();

            double[] lightColorVector = _GetVector(lightColor);

            double[] L = _lightManager.GetVectorToLight(x, y);
            L = _Normalized(L);

            double[] NN = _fillingInfo.GetBumpedNormalVector(x, y);
            //double[] NN = new double[] { 0, 0, 1 };

            double cos = NN.Zip(L, (xx, yy) => xx * yy).Sum();

            if (cos <= 0)
            {
                return(Color.Black);
            }

            double[] res = objectColorVector.Zip(lightColorVector, (a, b) => (a * b * cos / 255))
                           .ToArray();

            return(Color.FromArgb(objectColor.A, (int)res[0], (int)res[1], (int)res[2]));
        }