Example #1
0
BSDF* GlassMaterial::get_bsdf(const DifferentialGeometry &dg, MemoryPool &pool) const {
	BSDF *bsdf = pool.alloc<BSDF>(dg, refr_index);
	Colorf refl = reflect->sample(dg);
	if (!refl.is_black()){
		bsdf->add(pool.alloc<SpecularReflection>(refl,
			pool.alloc<FresnelDielectric>(1.f, refr_index)));
	}
	Colorf trans = transmit->sample(dg);
	if (!trans.is_black()){
		bsdf->add(pool.alloc<SpecularTransmission>(trans,
			pool.alloc<FresnelDielectric>(1.f, refr_index)));
	}
	return bsdf;
}
Example #2
0
BSDF* MixMaterial::get_bsdf(const DifferentialGeometry &dg, MemoryPool &pool) const {
	//Get the BSDFs from the materials we're mixing and scale their component BxDFs to
	//create a new BSDF that combines the two
	BSDF *bsdf = pool.alloc<BSDF>(dg);
	Colorf s = scale->sample(dg).normalized();
	BSDF *a = mat_a->get_bsdf(dg, pool);
	for (int i = 0; i < a->num_bxdfs(); ++i){
		bsdf->add(pool.alloc<ScaledBxDF>((*a)[i], s));
	}
	BSDF *b = mat_b->get_bsdf(dg, pool);
	for (int i = 0; i < b->num_bxdfs(); ++i){
		bsdf->add(pool.alloc<ScaledBxDF>((*b)[i], 1 - s));
	}
	return bsdf;
}