public override bool Hit(Ray ray, float t_min, float t_max, ref HitRecord rec) { var temp_record = new HitRecord(); var hit_anything = false; var closest = t_max; foreach (var h in list) { if (!h.Hit(ray, t_min, closest, ref temp_record)) { continue; } hit_anything = true; closest = temp_record.t; rec = temp_record; } return(hit_anything); }
public override bool Hit(Ray ray, float t_min, float t_max, ref HitRecord rec) { HitRecord rec1 = new HitRecord(), rec2 = new HitRecord(); if (boundary.Hit(ray, -float.MaxValue, float.MaxValue, ref rec1)) { if (boundary.Hit(ray, rec1.t + 0.0001f, float.MaxValue, ref rec2)) { rec1.t = Mathf.Range(rec1.t, t_min, t_max); if (rec1.t < t_min) { rec1.t = t_min; } if (rec2.t > t_max) { rec2.t = t_max; } if (rec1.t >= rec2.t) { return(false); } if (rec1.t < 0) { rec1.t = 0; } float distance_inside_boundary = (rec2.t - rec1.t) * ray.direction.length(); float hit_distance = -(1 / density) * Mathf.Log(Mathematics.Random.Get()); if (hit_distance < distance_inside_boundary) { rec.t = rec1.t + hit_distance / ray.direction.length(); rec.p = ray.GetPoint(rec.t); rec.normal = new Vector3(1, 0, 0); // arbitrary rec.material = phase_function; return(true); } } } return(false); }
public override bool Hit(Ray ray, float t_min, float t_max, ref HitRecord rec) { //if (Renderer.main.hit[ray.id] == 1)return false; var temp_record = new HitRecord(); var hit_anything = false; var closest = t_max; foreach (var h in list) { if (!h.Hit(ray, t_min, closest, ref temp_record)) { continue; } hit_anything = true; closest = temp_record.t; rec = temp_record; } // if (!hit_anything)Renderer.main.hit[ray.id]= 1; return(hit_anything); }
public abstract bool Hit(Ray ray, float t_min, float t_max, ref HitRecord rec);