00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdafx.h"
00027 #include "materials/matte.h"
00028 #include "paramset.h"
00029 #include "reflection.h"
00030 #include "diffgeom.h"
00031 #include "texture.h"
00032
00033
00034 BSDF *MatteMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
00035 const DifferentialGeometry &dgShading,
00036 MemoryArena &arena) const {
00037
00038 DifferentialGeometry dgs;
00039 if (bumpMap)
00040 Bump(bumpMap, dgGeom, dgShading, &dgs);
00041 else
00042 dgs = dgShading;
00043 BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
00044
00045
00046 Spectrum r = Kd->Evaluate(dgs).Clamp();
00047 float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
00048 if (sig == 0.)
00049 bsdf->Add(BSDF_ALLOC(arena, Lambertian)(r));
00050 else
00051 bsdf->Add(BSDF_ALLOC(arena, OrenNayar)(r, sig));
00052 return bsdf;
00053 }
00054
00055
00056 MatteMaterial *CreateMatteMaterial(const Transform &xform,
00057 const TextureParams &mp) {
00058 Reference<Texture<Spectrum> > Kd = mp.GetSpectrumTexture("Kd", Spectrum(0.5f));
00059 Reference<Texture<float> > sigma = mp.GetFloatTexture("sigma", 0.f);
00060 Reference<Texture<float> > bumpMap = mp.GetFloatTexture("bumpmap", 0.f);
00061 return new MatteMaterial(Kd, sigma, bumpMap);
00062 }
00063
00064