void LayeredMaterial::addMat(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgShading, boost::shared_ptr<Material> mat, LayeredBSDF *lbsdf, boost::shared_ptr<Texture<float> > opacity) const{ DifferentialGeometry dgS = dgShading; mat->GetShadingGeometry(sw, isect.dg.nn, &dgS); BSDF *bsdfmat=mat->GetBSDF(arena,sw,isect, dgS); float op = 1.0f; if (opacity) { // then need to mix with null op= opacity->Evaluate(sw, dgS); if (op<=0.0f) { // don't bother adding it return; } MixBSDF *mixbsdf = ARENA_ALLOC(arena, MixBSDF)(dgShading, isect.dg.nn, isect.exterior, isect.interior); mixbsdf->Add(op, bsdfmat); dgS = dgShading; mat->GetShadingGeometry(sw, isect.dg.nn, &dgS); // Why do we need to do this again? SingleBSDF *nullbsdf = ARENA_ALLOC(arena, SingleBSDF)(dgShading, isect.dg.nn, ARENA_ALLOC(arena, NullTransmission)(), isect.exterior, isect.interior); mixbsdf->Add(1.0f-op, nullbsdf); bsdfmat=mixbsdf; } lbsdf->Add(bsdfmat,op); return; }