예제 #1
0
 /// <summary>
 /// Calculates the color of a vertex using a directional light.
 /// </summary>
 /// <param name="vertex">The world position of the vertex to light.</param>
 /// <param name="normal">The world normal of the vertex to light.</param>
 /// <param name="targetLight">The reference light..</param>
 public static Color CalculateColorDirectional(Vector3 vertex, Vector3 normal, Light targetLight, VlmBakeOptions options = null)
 {
     if (!targetLight)
     {
         return(DefaultColor);
     }
     return(CalculateColorDirectional(vertex, normal, targetLight.transform.forward, targetLight.color, targetLight.intensity, targetLight.shadows != LightShadows.None, targetLight.shadowStrength, options));
 }
예제 #2
0
        /// <summary>
        /// Calculates the color of a vertex using a directional light.
        /// </summary>
        /// <param name="vertex">The world position of the vertex to light.</param>
        /// <param name="normal">The world normal of the vertex to light.</param>
        /// <param name="lightForward">The forward direction of the light.</param>
        /// <param name="lightColor">The color of the light.</param>
        /// <param name="lightIntensity">The intensity of the light.</param>
        /// <param name="lightShadowStrength">The strength of the lights shadows.</param>
        /// <param name="shadows">Whether the light casts shadows.</param>
        /// <param name="options">The bake options to use.</param>
        public static Color CalculateColorDirectional(Vector3 vertex, Vector3 normal, Vector3 lightForward, Color lightColor, float lightIntensity, bool shadows, float lightShadowStrength, VlmBakeOptions options = null)
        {
            bool isShadowed = false;

            if (shadows && (options == null || options.RecieveShadows))
            {
                isShadowed = TestForShadowInfiniteDistance(vertex, lightForward);
            }

            Color color = lightColor * lightIntensity * CalculateIntensityDirectional(normal, lightForward);

            color.a = 1.0f;

            return(isShadowed ? Color.Lerp(color, DefaultColor, lightShadowStrength) : color);
        }
예제 #3
0
        /// <summary>
        /// Calculates the color of a vertex using a spot light.
        /// </summary>
        /// <param name="vertex">The world position of the vertex to light.</param>
        /// <param name="normal">The world normal of the vertex to light.</param>
        /// <param name="lightPosition">The position of the light.</param>
        /// <param name="lightForward">The forward direction of the light.</param>
        /// <param name="lightColor">The color of the light.</param>
        /// <param name="lightIntensity">The intensity of the light.</param>
        /// <param name="lightRange">The range of the light.</param>
        /// <param name="lightConeAngle">The cone angle of the spot light.</param>
        /// <param name="shadows">Whether the light casts shadows.</param>
        /// <param name="lightShadowStrength">The strength of the lights shadows.</param>
        /// <param name="options">The bake options to use.</param>
        public static Color CalculateColorSpot(Vector3 vertex, Vector3 normal, Vector3 lightPosition, Vector3 lightForward, Color lightColor, float lightIntensity, float lightRange, float lightConeAngle, bool shadows, float lightShadowStrength, VlmBakeOptions options = null)
        {
            float atten = CalculateIntensitySpot(vertex, lightPosition, lightForward, lightRange, lightConeAngle);

            bool isShadowed = false;

            if (atten > 0.0f && shadows && (options == null || options.RecieveShadows))
            {
                isShadowed = TestForShadow(vertex, normal, lightPosition);
            }

            Color color = CalculateLightColor(vertex, normal, lightPosition, lightColor, lightIntensity) * atten;

            return(isShadowed ? Color.Lerp(color, DefaultColor, lightShadowStrength) : color);
        }