// Display checker board background MaterialCell checkerBackgroundHit(Ray r, HitRecord hit) { // Find the t value where z = scene.camera.far hit.t = -scene.camera.far / r.dir.z; if (hit.t < 0) // Only put it on the background, not behind the camera too return black; hit.hitP = r.pointAtParameter(hit.t); hit.normal = new Double3D(0, 0, 1); hit.hitP.x = (hit.hitP.x > 0) ? hit.hitP.x : -hit.hitP.x + checkerFreq / 2; hit.hitP.y = (hit.hitP.y > 0) ? hit.hitP.y : -hit.hitP.y + checkerFreq / 2; if (hit.hitP.x % checkerFreq < checkerFreq / 2) // && p.x < scene.camera.windowRight) if (hit.hitP.y % checkerFreq < checkerFreq / 2) // && p.y < scene.camera.windowTop) return white; else return black; else if (hit.hitP.y % checkerFreq < checkerFreq / 2) // && p.y < scene.camera.windowTop) return black; else return white; }