00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PBRT_MC_H
00025 #define PBRT_MC_H
00026
00027
00028 extern COREDLL void RejectionSampleDisk(float u1, float u2, float *x, float *y);
00029 COREDLL Vector UniformSampleHemisphere(float u1, float u2);
00030 COREDLL float UniformHemispherePdf(float theta, float phi);
00031 COREDLL Vector UniformSampleSphere(float u1, float u2);
00032 COREDLL float UniformSpherePdf();
00033 COREDLL Vector UniformSampleCone(float u1, float u2, float costhetamax);
00034 COREDLL Vector UniformSampleCone(float u1, float u2, float costhetamax,
00035 const Vector &x, const Vector &y, const Vector &z);
00036 COREDLL float UniformConePdf(float costhetamax);
00037 COREDLL void UniformSampleDisk(float u1, float u2, float *x, float *y);
00038 inline Vector CosineSampleHemisphere(float u1, float u2) {
00039 Vector ret;
00040 ConcentricSampleDisk(u1, u2, &ret.x, &ret.y);
00041 ret.z = sqrtf(max(0.f,
00042 1.f - ret.x*ret.x - ret.y*ret.y));
00043 return ret;
00044 }
00045 inline float CosineHemispherePdf(float costheta, float phi) {
00046 return costheta * INV_PI;
00047 }
00048 extern COREDLL Vector SampleHG(const Vector &w, float g, float u1, float u2);
00049 extern COREDLL float HGPdf(const Vector &w, const Vector &wp, float g);
00050
00051 inline float BalanceHeuristic(int nf, float fPdf, int ng,
00052 float gPdf) {
00053 return (nf * fPdf) / (nf * fPdf + ng * gPdf);
00054 }
00055 inline float PowerHeuristic(int nf, float fPdf, int ng,
00056 float gPdf) {
00057 float f = nf * fPdf, g = ng * gPdf;
00058 return (f*f) / (f*f + g*g);
00059 }
00060 #endif // PBRT_MC_H