*/
@Override
public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
WavelengthPacket lambda, double ru, double rv, double rj) {
ScatteredRay sr = null;
Color col = lambda.getColorModel().getWhite(lambda);
for (Material e : inner) {
sr = e.scatter(x, v, adjoint, lambda, rnd.next(), rnd.next(), rnd.next());
if (sr == null) break;
v = sr.getRay().direction();
col = col.times(sr.getColor());
}
if (sr == null) {
return null;
} else if (sr.getRay().direction().dot(x.getNormal()) < 0.0) {
return ScatteredRay.diffuse(sr.getRay(), col, 1.0);
} else {
return ScatteredRay.transmitDiffuse(sr.getRay(), col, 1.0);
}
}