Exemplo n.º 1
0
    public override Color GetColor(RTRay ray, int depth)
    {
        HitRecord hit;

        if (scene.Hit(ray, 0.001f, 1000, out hit))
        {
            Vector3 n = hit.n;
            return(new Color((n.x + 1) * 0.5f, (n.y + 1) * 0.5f, (n.z + 1) * 0.5f));
        }

        return(RTCanvas.GetEnvironmentColor(ray));
    }
Exemplo n.º 2
0
    public override Color GetColor(RTRay ray, int depth)
    {
        HitRecord hit;

        if (scene.Hit(ray, 0.001f, 1000, out hit))
        {
            Vector3 target       = hit.p + hit.n + RTMath.RndInUnitSphere();
            float   absorptivity = 0.5f;
            return(absorptivity * GetColor(new RTRay().Set(hit.p, target - hit.p), depth + 1));
        }

        return(RTCanvas.GetEnvironmentColor(ray));
    }
    public override Color GetColor(RTRay ray, int depth)
    {
        HitRecord hit;

        if (scene.Hit(ray, 0.001f, 1000, out hit))
        {
            RTRay scattered;
            Color attenuation;
            if (depth < 50 && hit.material.Scatter(ray, hit, out attenuation, out scattered))
            {
                return(attenuation * GetColor(scattered, depth + 1));
            }
            else
            {
                return(Color.black);
            }
        }

        return(RTCanvas.GetEnvironmentColor(ray));
    }