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 #include "dynload.h"
00030
00031 using namespace lux;
00032
00033
00034 BSDF *Matte::GetBSDF(const TsPack *tspack, const DifferentialGeometry &dgGeom,
00035 const DifferentialGeometry &dgShading) const {
00036
00037 DifferentialGeometry dgs;
00038 if (bumpMap)
00039 Bump(bumpMap, dgGeom, dgShading, &dgs);
00040 else
00041 dgs = dgShading;
00042
00043
00044 SWCSpectrum r = Kd->Evaluate(tspack, dgs).Clamp(0.f, 1.f);
00045 float sig = Clamp(sigma->Evaluate(tspack, dgs), 0.f, 90.f);
00046 BxDF *bxdf;
00047 if (sig == 0.)
00048 bxdf = BSDF_ALLOC(tspack, Lambertian)(r);
00049 else
00050 bxdf = BSDF_ALLOC(tspack, OrenNayar)(r, sig);
00051 SingleBSDF *bsdf = BSDF_ALLOC(tspack, SingleBSDF)(dgs, dgGeom.nn, bxdf);
00052
00053
00054 bsdf->SetCompositingParams(compParams);
00055
00056 return bsdf;
00057 }
00058 Material* Matte::CreateMaterial(const Transform &xform,
00059 const TextureParams &mp) {
00060 boost::shared_ptr<Texture<SWCSpectrum> > Kd = mp.GetSWCSpectrumTexture("Kd", RGBColor(.9f));
00061 boost::shared_ptr<Texture<float> > sigma = mp.GetFloatTexture("sigma", 0.f);
00062 boost::shared_ptr<Texture<float> > bumpMap = mp.GetFloatTexture("bumpmap");
00063
00064 CompositingParams cP;
00065 FindCompositingParams(mp, &cP);
00066 return new Matte(Kd, sigma, bumpMap, cP);
00067 }
00068
00069 static DynamicLoader::RegisterMaterial<Matte> r("matte");