00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_MICROFACET_H
00024 #define LUX_MICROFACET_H
00025
00026 #include "lux.h"
00027 #include "bxdf.h"
00028 #include "spectrum.h"
00029
00030 namespace lux
00031 {
00032
00033 class Microfacet : public BxDF {
00034 public:
00035
00036 Microfacet(const SWCSpectrum &reflectance, Fresnel *f,
00037 MicrofacetDistribution *d);
00038 SWCSpectrum f(const Vector &wo, const Vector &wi) const;
00039 float G(const Vector &wo, const Vector &wi,
00040 const Vector &wh) const {
00041 float NdotWh = fabsf(CosTheta(wh));
00042 float NdotWo = fabsf(CosTheta(wo));
00043 float NdotWi = fabsf(CosTheta(wi));
00044 float WOdotWh = AbsDot(wo, wh);
00045 return min(1.f, min((2.f * NdotWh * NdotWo / WOdotWh),
00046 (2.f * NdotWh * NdotWi / WOdotWh)));
00047 }
00048 SWCSpectrum Sample_f(const Vector &wo, Vector *wi,
00049 float u1, float u2, float *pdf, float *pdfBack = NULL) const;
00050 float Pdf(const Vector &wo, const Vector &wi) const;
00051 private:
00052
00053 SWCSpectrum R;
00054 MicrofacetDistribution *distribution;
00055 Fresnel *fresnel;
00056 };
00057
00058
00059 }
00060
00061 #endif // LUX_MICROFACET_H
00062