Ejemplo n.º 1
0
        public int RenderPixel(int X, int Y)
        {
            if (Background == null)
            {
                return(0);
            }
            double r = Background.R(X, Y) * 255;
            double g = Background.G(X, Y) * 255;
            double b = Background.B(X, Y) * 255;

            if (Light != null)
            {
                double cos          = 0;
                Vector lightVector  = Light.VectorToLight(X, Y, Function[X, Y]);
                Vector normalVector = BumpMap != null?BumpedVector(X, Y) : Function.GradientVector(X, Y);

                if (lightVector.Z > 0)
                {
                    cos = lightVector * normalVector;
                }

                r *= Light.R * cos;
                g *= Light.G * cos;
                b *= Light.B * cos;
            }

            return(RGB2Int((int)r, (int)g, (int)b));
        }