Beispiel #1
0
        /// <summary>
        /// Metoda pro vypocet okolniho procenta
        /// </summary>
        /// <param name="point">Vector umisteni</param>
        /// <param name="normal">Vector normal</param>
        /// <returns></returns>
        private double AmbientPercent(Vector point, Vector normal)
        {
            int unoccludedRays = 0;

            for (int n = 0; n < lightSamples; ++n)
            {
                Vector       hemisphereDir = Vector.RandomHemisphereDirection(normal);
                Ray          hemisphereRay = new Ray(point, hemisphereDir, Ray.InitialDepth);
                Intersection currentTry    = this.NearestShape(hemisphereRay);
                if (currentTry.T == Intersection.MaxT)
                {
                    ++unoccludedRays;
                }
            }

            return(((double)unoccludedRays / lightSamples) * AmbientLight);
        }