static Color RayColor(Ray r) { var t = HitSphere(new Vec3(0, 0, -1), 0.5f, r); if (t > 0.0f) { var n = (r.at(t) - new Vec3(0, 0, -1)); n.Normalize(); return(new Color((n.x + 1) * 0.5f, (n.y + 1) * 0.5f, (n.z + 1) * 0.5f)); } Vec3 normalizeDirection = r.direction; normalizeDirection.Normalize(); t = 0.5f * (normalizeDirection.y + 1); return(new Color(1.0f) * (1 - t) + new Color(0.5f, 0.7f, 1.0f) * t); }