private double TestRay(Ray ray, Scene scene) { ISect isect = MinIntersection(ray, scene); if (ISect.IsNull(isect)) { return(0); } return(isect.Dist); }
private Color TraceRay(Ray ray, Scene scene, int depth) { ISect isect = MinIntersection(ray, scene); if (ISect.IsNull(isect)) { return(Color.Background); } return(Shade(isect, scene, depth)); }
private ISect MinIntersection(Ray ray, Scene scene) { ISect min = ISect.Null; foreach (SceneObject obj in scene.Things) { ISect isect = obj.Intersect(ray); if (!ISect.IsNull(isect)) { if (ISect.IsNull(min) || min.Dist > isect.Dist) { min = isect; } } } return(min); }