Esempio n. 1
0
        // Do we have to pass all these ugly arguments? ='(
        // If we want to multi-thread it: yes.
        private Vector3 DoFancyColorCalculations(Ray ray, Intersection intersect, short depth, bool drawDebugLine)
        {
            depth++; // increment our recursion depth.
            Vector3 color = new Vector3();

            Material material = intersect.GetMaterial();

            if (material.isMirror)
            {
                color = material.reflectiveness * Reflect(ray, intersect, depth, drawDebugLine);
            }
            if (material.isDielectic)
            {
                float reflection = GetSchlickReflection(intersect, ray);

                // Now do the magic:
                color += material.transparency * reflection * Reflect(ray, intersect, depth, drawDebugLine);       // reFLECT
                color += material.transparency * (1 - reflection) * Refract(ray, intersect, depth, drawDebugLine); //reFRACT
            }
            if (material.isShiny)
            {
                // Calculate reflection of shiny object
            }

            color += intersect.primitive.material.diffuseness
                     * scene.DirectIllumination(intersect, drawDebugLine)
                     * intersect.primitive.GetColor(intersect.intersectionPoint);
            return(color);
        }