metadata
Wenzel Jakob 2011-06-03 20:26:04 +02:00
commit b15e23dd9d
1 changed files with 17 additions and 10 deletions

View File

@ -219,12 +219,17 @@ public:
Spectrum sample(BSDFQueryRecord &bRec, Float &pdf, const Point2 &_sample) const { Spectrum sample(BSDFQueryRecord &bRec, Float &pdf, const Point2 &_sample) const {
Point2 sample(_sample); Point2 sample(_sample);
if (bRec.component == -1) { if (bRec.component == -1) {
Float componentPDF; int entry = m_pdf.sampleReuse(sample.x);
int entry = m_pdf.sampleReuse(sample.x, componentPDF); m_bsdfs[entry]->sample(bRec, sample);
Spectrum result = m_bsdfs[entry]->sample(bRec, pdf, sample);
bRec.sampledComponent += m_bsdfOffset[entry]; bRec.sampledComponent += m_bsdfOffset[entry];
pdf *= componentPDF;
return result * m_bsdfWeight[entry]; if (bRec.sampledType & BSDF::EDelta) {
pdf = pdfDelta(bRec);
return fDelta(bRec);
} else {
pdf = Composite::pdf(bRec);
return f(bRec);
}
} else { } else {
/* Pick out an individual component */ /* Pick out an individual component */
for (size_t i=0; i<m_bsdfCount; ++i) { for (size_t i=0; i<m_bsdfCount; ++i) {
@ -247,12 +252,14 @@ public:
Spectrum sample(BSDFQueryRecord &bRec, const Point2 &_sample) const { Spectrum sample(BSDFQueryRecord &bRec, const Point2 &_sample) const {
Point2 sample(_sample); Point2 sample(_sample);
if (bRec.component == -1) { if (bRec.component == -1) {
Float componentPDF; int entry = m_pdf.sampleReuse(sample.x);
int entry = m_pdf.sampleReuse(sample.x, componentPDF); m_bsdfs[entry]->sample(bRec, sample);
Spectrum result = m_bsdfs[entry]->sample(bRec, sample);
result /= componentPDF;
bRec.sampledComponent += m_bsdfOffset[entry]; bRec.sampledComponent += m_bsdfOffset[entry];
return result * m_bsdfWeight[entry];
if (bRec.sampledType & BSDF::EDelta)
return fDelta(bRec)/pdfDelta(bRec);
else
return f(bRec)/pdf(bRec);
} else { } else {
/* Pick out an individual component */ /* Pick out an individual component */
for (size_t i=0; i<m_bsdfCount; ++i) { for (size_t i=0; i<m_bsdfCount; ++i) {