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 "matte.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 *Matte::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 BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
00042
00043
00044 SWCSpectrum r(Kd->Evaluate(dgs).Clamp(0.f, 1.f));
00045 float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
00046 if (sig == 0.)
00047 bsdf->Add(BSDF_ALLOC(Lambertian)(r));
00048 else
00049 bsdf->Add(BSDF_ALLOC(OrenNayar)(r, sig));
00050 return bsdf;
00051 }
00052 Material* Matte::CreateMaterial(const Transform &xform,
00053 const TextureParams &mp) {
00054 boost::shared_ptr<Texture<Spectrum> > Kd = mp.GetSpectrumTexture("Kd", Spectrum(1.f));
00055 boost::shared_ptr<Texture<float> > sigma = mp.GetFloatTexture("sigma", 0.f);
00056 boost::shared_ptr<Texture<float> > bumpMap = mp.GetFloatTexture("bumpmap", 0.f);
00057 return new Matte(Kd, sigma, bumpMap);
00058 }