public RealColor Add(RealColor value) { R += value.R; G += value.G; B += value.B; return(this); }
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)); }
public RealColor Multiply(RealColor value) { A *= value.A; R *= value.R; G *= value.G; B *= value.B; return(this); }
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); }
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); }
/// <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); }
public RealColor LambertianShade(Vector3 surfaceNormal, RealColor incomingColor, Vector3 direction, RealColor ambient) { return(RealColor.LambertianShade(this, surfaceNormal, incomingColor, direction, ambient)); }