Пример #1
0
    public override bool Scatter(RTRay ray, HitRecord hit, out Color attenuation, out RTRay scattered)
    {
        Vector3 reflected = RTMath.Reflect(ray.direction.normalized, hit.n);

        scattered   = new RTRay().Set(hit.p, reflected + fuzz * RTMath.RndInUnitSphere());
        attenuation = albedo;
        return(Vector3.Dot(scattered.direction, hit.n) > 0);
    }
Пример #2
0
    public override bool Scatter(RTRay ray, HitRecord hit, out Color attenuation, out RTRay scattered)
    {
        Vector3 target = hit.p + hit.n + RTMath.RndInUnitSphere();

        scattered   = new RTRay().Set(hit.p, target - hit.p);
        attenuation = albedo;
        return(true);
    }
Пример #3
0
    public RTRay GetRay(float s, float t)
    {
        Vector3 rd     = RTMath.RndInUnitSphere() * len_radius;
        Vector3 offset = u * rd.x + v * rd.y;

        RTRay ray = new RTRay();

        ray.Set(origin + offset, leftBottomCorner + horizontal * s + vertical * t - origin - offset);
        return(ray);
    }
Пример #4
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));
    }