Ejemplo n.º 1
0
        public Color GetColor(Scene scene, Surfel surfel)
        {
            if (surfel.material == null)
            {
                return(backgroundColor);
            }

            return(directIntegrator.GetColor(scene, surfel) + indirectIntegrator.GetColor(scene, surfel));
        }
Ejemplo n.º 2
0
        private Color TraceRecursive(Scene scene, Surfel surfel, int depth)
        {
            if (depth >= RenderConfig.rayDepth)
            {
                return(new Color(0f));
            }
            var dir = surfel.ray.Reflect(surfel.normal);
            var p   = surfel.point + surfel.normal * RenderConfig.bias;
            var ray = new Ray(p, dir);

            if (Raycaster.Raycast(ray, out surfel))
            {
                var dot = Vector3.Dot(surfel.normal, dir);
                return(dot * (directIntegrator.GetColor(scene, surfel) + TraceRecursive(scene, surfel, depth + 1)));
            }
            return(new Color(0f));
        }
Ejemplo n.º 3
0
        private Color TraceRecursive(Scene scene, Surfel surfel, int depth)
        {
            if (depth >= RenderConfig.rayDepth)
            {
                return(new Color(0f));
            }
            var p     = surfel.point + surfel.normal * RenderConfig.bias;
            var color = new Color(0f);

            for (var i = 0; i < RenderConfig.numberOfRayPerLight; i++)
            {
                var dir = Mathf.CosineSampleHemisphere(surfel.normal, Mathf.CreateSample());
                var ray = new Ray(p, dir);
                if (Raycaster.Raycast(ray, out var hit))
                {
                    var dot = Vector3.Dot(surfel.normal, dir);
                    color += dot * (directIntegrator.GetColor(scene, hit) + TraceRecursive(scene, hit, depth + 1));
                }
            }
            return(color / RenderConfig.numberOfRayPerLight);
        }