Ejemplo n.º 1
0
 public override bool Hit(Ray ray, double t_min, double t_max, ref ShadeRec sr)
 {
     if (!hitable.Hit(ray, t_min, t_max, ref sr))
     {
         return(false);
     }
     sr.normal = -sr.normal;
     return(true);
 }
Ejemplo n.º 2
0
        public override bool Hit(Ray ray, double t_min, double t_max, ref ShadeRec sr)
        {
            Ray moved = new Ray(ray.original - offset, ray.direction, ray.time);

            if (!Object.Hit(moved, t_min, t_max, ref sr))
            {
                return(false);
            }
            sr.p += offset;
            return(true);
        }
Ejemplo n.º 3
0
        public override bool Hit(Ray ray, double t_min, double t_max, ref ShadeRec sr)
        {
            ShadeRec temp_record  = new ShadeRec();
            bool     hit_anything = false;
            double   closest      = t_max;

            foreach (Hitable h in list)
            {
                if (!h.Hit(ray, t_min, closest, ref temp_record))
                {
                    continue;
                }
                hit_anything = true;
                closest      = temp_record.t;
                sr           = temp_record;
            }

            return(hit_anything);
        }
Ejemplo n.º 4
0
        public override bool Hit(Ray ray, double t_min, double t_max, ref ShadeRec sr)
        {
            ShadeRec sr1 = new ShadeRec(), sr2 = new ShadeRec();

            if (boundary.Hit(ray, -double.MaxValue, double.MaxValue, ref sr1))
            {
                if (boundary.Hit(ray, sr1.t + 0.0001, double.MaxValue, ref sr2))
                {
                    sr1.t = Mathf.Range(sr1.t, t_min, t_max);
                    if (sr1.t < t_min)
                    {
                        sr1.t = t_min;
                    }
                    if (sr2.t > t_max)
                    {
                        sr2.t = t_max;
                    }
                    if (sr1.t >= sr2.t)
                    {
                        return(false);
                    }
                    if (sr1.t < 0)
                    {
                        sr1.t = 0;
                    }
                    double distance_inside_boundary = (sr2.t - sr1.t) * ray.direction.Magnitude();

                    double hit_distance = -(1 / density) * Math.Log(Mathematics.Random.Get());
                    if (hit_distance < distance_inside_boundary)
                    {
                        sr.t        = sr1.t + hit_distance / ray.direction.Magnitude();
                        sr.p        = ray.GetPoint(sr.t);
                        sr.normal   = new Vector3D(1, 0, 0);
                        sr.material = phase_function;
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
 public abstract bool Hit(Ray ray, double t_min, double t_max, ref ShadeRec sr);