surface mirror (float samples = 1, samplecone = 0) { /* STEP 1 Make a copy of the surface normal one unit in length */ vector i = normalize(I); normal n = normalize(N); /* STEP 2 Nothing fancy with the apparent opacity */ Oi = Os; /* STEP 3 Only raytrace reflections from the front surface */ if(n.-i >= 0) { vector reflectRay = reflect(i, n); color gatherColor = 0,hitc = 0; float numhits = 0; gather("illuminance", P, reflectRay, samplecone * PI/180, samples, "surface:Ci", hitc) { gatherColor += hitc; numhits += 1; } /* Find the average color */ gatherColor /= numhits; Ci = gatherColor * Cs * Oi; } else Ci = Cs * Oi; }