/*
Copyright 2010, 2010 STARWest
See the file STARWest.txt for details about the STARWest research group
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/*
pbrt source code Copyright(c) 1998-2007 Matt Pharr and Greg Humphreys.
This file is part of pbrt.
pbrt is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. Note that the text contents of
the book "Physically Based Rendering" are *not* licensed under the
GNU GPL.
pbrt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
// mcmMatte.cpp*
#include "pbrt.h"
#include "material.h"
// mcmMatte Class Declarations
class mcmMatte : public Material {
public:
// mcmMatte Public Methods
mcmMatte(Reference > kd,
Reference > sig,
Reference > bump,
Reference > num,
Reference > temp) {
Kd = kd;
sigma = sig;
bumpMap = bump;
mcmNumeroDeLaSurface = num;
mcmTemperature = temp;
}
BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading) const;
private:
// mcmMatte Private Data
Reference > Kd;
Reference > sigma, bumpMap;
Reference > mcmNumeroDeLaSurface;
Reference > mcmTemperature;
};
// mcmMatte Method Definitions
BSDF *mcmMatte::GetBSDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading) const {
// Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_
DifferentialGeometry dgs;
if (bumpMap)
Bump(bumpMap, dgGeom, dgShading, &dgs);
else
dgs = dgShading;
BSDF *bsdf = BSDF_ALLOC(BSDF)(dgs, dgGeom.nn);
// Evaluate textures for _mcmMatte_ material and allocate BRDF
Spectrum r = Kd->Evaluate(dgs).Clamp();
float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
if (sig == 0.)
bsdf->Add(BSDF_ALLOC(Lambertian)(r));
else
bsdf->Add(BSDF_ALLOC(OrenNayar)(r, sig));
int num = mcmNumeroDeLaSurface->Evaluate(dgs);
bsdf->set_mcmNumeroDeLaSurface(num);
double temp = mcmTemperature->Evaluate(dgs);
bsdf->set_mcmTemperature(temp);
return bsdf;
return bsdf;
}
extern "C" DLLEXPORT Material * CreateMaterial(const Transform &xform,
const TextureParams &mp) {
Reference > Kd = mp.GetSpectrumTexture("Kd", Spectrum(1.f));
Reference > sigma = mp.GetFloatTexture("sigma", 0.f);
Reference > bumpMap = mp.GetFloatTexture("bumpmap", 0.f);
Reference > mcmNumeroDeLaSurface = mp.GetIntTexture("numero", -1);
Reference > mcmTemperature = mp.GetDoubleTexture("temperature", -1.);
return new mcmMatte(Kd, sigma, bumpMap, mcmNumeroDeLaSurface, mcmTemperature);
}