Exemple #1
0
        /// <summary>
        /// Computes the distribution of microfacets with the given normal.
        /// </summary>
        /// <param name="normal">The normal vector of the microfacets, in shading space.</param>
        /// <returns>The fraction of microfacets that are oriented with the given normal.</returns>
        public float NormalDistribution(Vector3 normal)
        {
            float tan2Theta = ShadingSpace.TanThetaSqr(normal);

            if (float.IsInfinity(tan2Theta))
            {
                return(0);
            }

            float cos4Theta = ShadingSpace.CosThetaSqr(normal) * ShadingSpace.CosThetaSqr(normal);

            float e = tan2Theta * (
                ShadingSpace.CosPhiSqr(normal) / (AlphaX * AlphaX)
                + ShadingSpace.SinPhiSqr(normal) / (AlphaY * AlphaY)
                );

            return(1 / (MathF.PI * AlphaX * AlphaY * cos4Theta * (1 + e) * (1 + e)));
        }