00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "mattetranslucent.h"
00025 #include "bxdf.h"
00026 #include "lambertian.h"
00027 #include "orennayar.h"
00028 #include "paramset.h"
00029
00030 using namespace lux;
00031
00032
00033 BSDF *MatteTranslucent::GetBSDF(const DifferentialGeometry &dgGeom,
00034 const DifferentialGeometry &dgShading, float u) const {
00035
00036 DifferentialGeometry dgs;
00037 if (bumpMap)
00038 Bump(bumpMap, dgGeom, dgShading, &dgs);
00039 else
00040 dgs = dgShading;
00041
00042 BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
00043
00044 SWCSpectrum R(Kr->Evaluate(dgs).Clamp(0.f, 1.f));
00045 SWCSpectrum T(Kt->Evaluate(dgs).Clamp(0.f, 1.f));
00046 float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
00047
00048 if (!R.Black()) {
00049 if (sig == 0.)
00050 bsdf->Add(BSDF_ALLOC(Lambertian)(R));
00051 else
00052 bsdf->Add(BSDF_ALLOC(OrenNayar)(R, sig));
00053 }
00054 if (!T.Black()) {
00055 if (sig == 0.)
00056 bsdf->Add(BSDF_ALLOC( BRDFToBTDF)(BSDF_ALLOC(Lambertian)(T)));
00057 else
00058 bsdf->Add(BSDF_ALLOC( BRDFToBTDF)(BSDF_ALLOC(OrenNayar)(T, sig)));
00059 }
00060 return bsdf;
00061 }
00062 Material* MatteTranslucent::CreateMaterial(const Transform &xform,
00063 const TextureParams &mp) {
00064 boost::shared_ptr<Texture<Spectrum> > Kr = mp.GetSpectrumTexture("Kr", Spectrum(1.f));
00065 boost::shared_ptr<Texture<Spectrum> > Kt = mp.GetSpectrumTexture("Kt", Spectrum(1.f));
00066 boost::shared_ptr<Texture<float> > sigma = mp.GetFloatTexture("sigma", 0.f);
00067 boost::shared_ptr<Texture<float> > bumpMap = mp.GetFloatTexture("bumpmap", 0.f);
00068 return new MatteTranslucent(Kr, Kt, sigma, bumpMap);
00069 }