예제 #1
0
 public RealColor Add(RealColor value)
 {
     R += value.R;
     G += value.G;
     B += value.B;
     return(this);
 }
예제 #2
0
        public void Tint(RealColor value)
        {
            Multiply(value.A);
            float other = 1 - value.A;

            Add(new RealColor(value.R * other, value.G * other, value.B * other));
        }
예제 #3
0
 public RealColor Multiply(RealColor value)
 {
     A *= value.A;
     R *= value.R;
     G *= value.G;
     B *= value.B;
     return(this);
 }
예제 #4
0
        public static RealColor Average(IEnumerable <RealColor> values)
        {
            RealColor col = Black.Copy();

            foreach (RealColor val in values)
            {
                col.Add(val);
            }
            col.Multiply(1f / (float)values.Count());
            return(col);
        }
예제 #5
0
        public static RealColor Average(RealColor[] values)
        {
            RealColor col = Black.Copy();

            for (int x = 0; x < values.Length; x++)
            {
                col.Add(values[x]);
            }
            col.Multiply(1f / (float)values.Length);
            return(col);
        }
예제 #6
0
        /// <summary>
        /// Lambertian shades a base color.
        /// </summary>
        /// <param name="baseColor"></param>
        /// <param name="surfaceNormal"></param>
        /// <param name="incomingColor"></param>
        /// <param name="direction"></param>
        /// <returns>base * ambient * Dot(normal, direction)</returns>
        public static RealColor LambertianShade(RealColor baseColor, Vector3 surfaceNormal, RealColor incomingColor, Vector3 direction, RealColor ambient)
        {
            float u = Vector3.Dot(surfaceNormal, direction);

            if (u < 0f)
            {
                return(baseColor.Copy());
            }
            RealColor diffuse = baseColor.Copy().Multiply(ambient).Multiply(u);

            diffuse.Add(baseColor);
            //diffuse.Clamp();
            return(diffuse);
        }
예제 #7
0
 public RealColor LambertianShade(Vector3 surfaceNormal, RealColor incomingColor, Vector3 direction, RealColor ambient)
 {
     return(RealColor.LambertianShade(this, surfaceNormal, incomingColor, direction, ambient));
 }