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