changed the way that luminaire importance sampling works -- now, a sampling weight can be specified

metadata
Wenzel Jakob 2010-11-11 21:52:49 +01:00
parent 364d9bb13f
commit 2a53d3240f
3 changed files with 19 additions and 4 deletions

View File

@ -249,6 +249,12 @@ public:
/// Optional pre-process step before rendering starts
virtual void preprocess(const Scene *scene);
/**
* \brief Return the luminaire's sampling weight. This is used by
* the luminaire importance sampling routines in \ref Scene.
*/
inline Float getSamplingWeight() const { return m_samplingWeight; }
MTS_DECLARE_CLASS()
protected:
/// Create a new luminaire
@ -262,6 +268,7 @@ protected:
protected:
Transform m_worldToLuminaire, m_luminaireToWorld;
Float m_surfaceArea;
Float m_samplingWeight;
int m_type;
bool m_intersectable;
};

View File

@ -24,7 +24,13 @@ MTS_NAMESPACE_BEGIN
Luminaire::Luminaire(const Properties &props)
: ConfigurableObject(props), m_surfaceArea(0.0f) {
m_type = 0;
// Transformation from the luminaire's local coordinates to world coordiantes
m_luminaireToWorld = props.getTransform("toWorld", Transform());
// Importance sampling weight (used by the luminaire sampling code in \ref Scene)
m_samplingWeight = props.getFloat("samplingWeight", 1.0f);
m_worldToLuminaire = m_luminaireToWorld.inverse();
AssertEx(!m_luminaireToWorld.hasScale(), "toWorld transformation can't have scale factors!");
m_intersectable = false;
@ -33,6 +39,7 @@ Luminaire::Luminaire(const Properties &props)
Luminaire::Luminaire(Stream *stream, InstanceManager *manager)
: ConfigurableObject(stream, manager) {
m_surfaceArea = stream->readFloat();
m_samplingWeight = stream->readFloat();
m_type = (EType) stream->readInt();
m_intersectable = stream->readBool();
m_worldToLuminaire = Transform(stream);
@ -46,6 +53,7 @@ void Luminaire::serialize(Stream *stream, InstanceManager *manager) const {
ConfigurableObject::serialize(stream, manager);
stream->writeFloat(m_surfaceArea);
stream->writeFloat(m_samplingWeight);
stream->writeInt(m_type);
stream->writeBool(m_intersectable);
m_worldToLuminaire.serialize(stream);

View File

@ -297,7 +297,7 @@ void Scene::initialize() {
(*it)->preprocess(this);
/* Add with a probability proportional to the luminaire's power */
if (m_importanceSampleLuminaires)
m_luminairePDF.put((*it)->getPower().getLuminance());
m_luminairePDF.put((*it)->getSamplingWeight());
else
m_luminairePDF.put(1.0f);
}
@ -358,7 +358,7 @@ Float Scene::pdfLuminaire(const Point &p,
Float luminance;
if (m_importanceSampleLuminaires)
luminance = luminaire->getPower().getLuminance();
luminance = luminaire->getSamplingWeight();
else
luminance = 1.0f;
@ -373,7 +373,7 @@ Float Scene::pdfLuminaire(const Intersection &its,
Float luminance;
if (m_importanceSampleLuminaires)
luminance = luminaire->getPower().getLuminance();
luminance = luminaire->getSamplingWeight();
else
luminance = 1.0f;
@ -452,7 +452,7 @@ void Scene::pdfEmission(EmissionRecord &eRec) const {
const Luminaire *luminaire = eRec.luminaire;
Float luminance;
if (m_importanceSampleLuminaires)
luminance = luminaire->getPower().getLuminance();
luminance = luminaire->getSamplingWeight();
else
luminance = 1.0f;
/* Calculate the probability of importance sampling this luminaire */