Example #1
0
        internal static Color BaseSpecularColor(Color baseColor)
        {
            float h, s, v;

            Color_Util.ColorToHSV(baseColor, out h, out s, out v);
            Color fullValue = Color_Util.HSVToColor(h, s, 1f);

            fullValue.A = baseColor.A;
            return(Color.Lerp(baseColor, fullValue, 0.5f));
        }
        /// <summary>
        /// Adjusts base color lightness up if it's too close to the BlackLevel
        /// </summary>
        private static XnaHSL AdjustBaseColor(Color color, float blackLevel)
        {
            // Use HSV instead of HSL to have finer control over the saturation
            float h, s, v;

            Color_Util.ColorToHSV(color, out h, out s, out v);
            float adjustedV = BlackLevelAdjustment(v, blackLevel);
            // Adjust the saturation down if the color is brightened, so
            // extremely dark colors don't have strangely high saturation
            float adjustedS = adjustedV == 0 ? 0 : s * (v / adjustedV);
            Color adjusted  = Color_Util.HSVToColor(h, adjustedS, adjustedV);

            adjusted.A = color.A;

            return(new XnaHSL(adjusted));
        }