From 865a989c5e17b6c637e5f9625ae0e8b4aff82da2 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 3 Jun 2011 20:25:08 +0200 Subject: [PATCH] composite material improvements --- src/bsdfs/composite.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/bsdfs/composite.cpp b/src/bsdfs/composite.cpp index 763718ec..daad69c5 100644 --- a/src/bsdfs/composite.cpp +++ b/src/bsdfs/composite.cpp @@ -219,12 +219,17 @@ public: Spectrum sample(BSDFQueryRecord &bRec, Float &pdf, const Point2 &_sample) const { Point2 sample(_sample); if (bRec.component == -1) { - Float componentPDF; - int entry = m_pdf.sampleReuse(sample.x, componentPDF); - Spectrum result = m_bsdfs[entry]->sample(bRec, pdf, sample); + int entry = m_pdf.sampleReuse(sample.x); + m_bsdfs[entry]->sample(bRec, sample); 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 { /* Pick out an individual component */ for (size_t i=0; isample(bRec, sample); - result /= componentPDF; + int entry = m_pdf.sampleReuse(sample.x); + m_bsdfs[entry]->sample(bRec, sample); 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 { /* Pick out an individual component */ for (size_t i=0; i