more cleanups
parent
9e922042c3
commit
02764afe0d
|
@ -120,6 +120,8 @@ private:
|
|||
|
||||
/*! @{ */
|
||||
|
||||
#define MTS_CLASS(x) x::m_theClass
|
||||
|
||||
/**
|
||||
* \brief This macro must be used in the declaration of
|
||||
* all classes derived from \ref Object.
|
||||
|
|
|
@ -93,9 +93,14 @@ inline bool RadianceQueryRecord::rayIntersect(const RayDifferential &ray) {
|
|||
/* Only search for an intersection if this was explicitly requested */
|
||||
if (type & EIntersection) {
|
||||
scene->rayIntersect(ray, its);
|
||||
if (type & EOpacity)
|
||||
// alpha = its.isValid() ? 1 : (1 - scene->getAttenuation(
|
||||
// Ray(ray.o, ray.d, 0, its.t, ray.time)).average());
|
||||
if (type & EOpacity) {
|
||||
if (its.isValid())
|
||||
alpha = 1.0f;
|
||||
else if (medium == NULL)
|
||||
alpha = 0.0f;
|
||||
else
|
||||
alpha = 1-medium->tau(ray).average();
|
||||
}
|
||||
if (type & EDistance)
|
||||
dist = its.t;
|
||||
type ^= EIntersection; // unset the intersection bit
|
||||
|
|
|
@ -74,11 +74,7 @@ public:
|
|||
|
||||
/* Perform the first ray intersection (or ignore if the
|
||||
intersection has already been provided). */
|
||||
if (rRec.rayIntersect(ray)) {
|
||||
ray.mint = 0; ray.maxt = rRec.its.t;
|
||||
}
|
||||
|
||||
if (!its.isValid()) {
|
||||
if (!rRec.rayIntersect(ray)) {
|
||||
/* If no intersection could be found, possibly return
|
||||
radiance from a background luminaire */
|
||||
if (rRec.type & RadianceQueryRecord::EEmittedRadiance)
|
||||
|
@ -142,7 +138,8 @@ public:
|
|||
bsdf->pdf(bRec) : 0;
|
||||
|
||||
/* Weight using the power heuristic */
|
||||
const Float weight = miWeight(lRec.pdf * fracLum, bsdfPdf * fracBSDF) * weightLum;
|
||||
const Float weight = miWeight(lRec.pdf * fracLum,
|
||||
bsdfPdf * fracBSDF) * weightLum;
|
||||
Li += lRec.value * bsdfVal * weight;
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +170,6 @@ public:
|
|||
Ray bsdfRay(its.p, its.toWorld(bRec.wo), ray.time);
|
||||
bool hitLuminaire = false;
|
||||
if (scene->rayIntersect(bsdfRay, bsdfIts)) {
|
||||
bsdfRay.mint = 0; bsdfRay.maxt = bsdfIts.t;
|
||||
/* Intersected something - check if it was a luminaire */
|
||||
if (bsdfIts.isLuminaire()) {
|
||||
lRec = LuminaireSamplingRecord(bsdfIts, -bsdfRay.d);
|
||||
|
@ -192,11 +188,12 @@ public:
|
|||
/* If a luminaire was hit, estimate the local illumination and
|
||||
sample weight using the power heuristic */
|
||||
if (hitLuminaire && (rRec.type & RadianceQueryRecord::EDirectSurfaceRadiance)) {
|
||||
lRec.value = lRec.luminaire->Le(lRec);
|
||||
Float lumPdf = scene->pdfLuminaire(its, lRec);
|
||||
lRec.value = its.Le(-bsdfRay.d);
|
||||
Float lumPdf = scene->pdfLuminaire(its.p, lRec);
|
||||
if (bRec.sampledType & BSDF::EDelta)
|
||||
lumPdf = 0;
|
||||
const Float weight = miWeight(bsdfPdf * fracBSDF, lumPdf * fracLum) * weightBSDF;
|
||||
const Float weight = miWeight(bsdfPdf * fracBSDF,
|
||||
lumPdf * fracLum) * weightBSDF;
|
||||
Li += lRec.value * bsdfVal * weight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,11 +108,13 @@ public:
|
|||
const int nSamples = 10000;
|
||||
Float luminance = 0, timeSample = 0;
|
||||
RadianceQueryRecord rRec(scene, sampler);
|
||||
|
||||
/* Estimate the overall luminance on the image plane */
|
||||
for (int i=0; i<nSamples; ++i) {
|
||||
Point2 sample, lensSample;
|
||||
RayDifferential eyeRay;
|
||||
sampler->generate();
|
||||
rRec.newQuery(RadianceQueryRecord::ERadiance);
|
||||
rRec.newQuery(RadianceQueryRecord::ERadiance, camera->getMedium());
|
||||
if (needsLensSample)
|
||||
lensSample = rRec.nextSample2D();
|
||||
if (needsTimeSample)
|
||||
|
@ -124,6 +126,7 @@ public:
|
|||
|
||||
luminance += m_subIntegrator->Li(eyeRay, rRec).getLuminance();
|
||||
}
|
||||
|
||||
m_averageLuminance = luminance / nSamples;
|
||||
m_quantile = (Float) normalQuantile(1-m_pval/2);
|
||||
Log(EInfo, "Configuring for a %.1f%% confidence interval, quantile=%f, avg. luminance=%f",
|
||||
|
@ -162,7 +165,7 @@ public:
|
|||
|
||||
block->snapshot(offset.x, offset.y);
|
||||
while (!stop) {
|
||||
rRec.newQuery(RadianceQueryRecord::ECameraRay);
|
||||
rRec.newQuery(RadianceQueryRecord::ECameraRay, camera->getMedium());
|
||||
if (needsLensSample)
|
||||
lensSample = rRec.nextSample2D();
|
||||
if (needsTimeSample)
|
||||
|
@ -221,6 +224,7 @@ public:
|
|||
++pixelsRendered;
|
||||
}
|
||||
} else {
|
||||
/* Use a basic grid traversal */
|
||||
for (y = sy; y < ey; y++) {
|
||||
for (x = sx; x < ex; x++) {
|
||||
sampler->generate();
|
||||
|
@ -229,7 +233,7 @@ public:
|
|||
|
||||
block->snapshot(x, y);
|
||||
while (!stop) {
|
||||
rRec.newQuery(RadianceQueryRecord::ECameraRay);
|
||||
rRec.newQuery(RadianceQueryRecord::ECameraRay, camera->getMedium());
|
||||
if (needsLensSample)
|
||||
lensSample = rRec.nextSample2D();
|
||||
if (needsTimeSample)
|
||||
|
@ -293,10 +297,12 @@ public:
|
|||
Spectrum Li(const RayDifferential &ray, RadianceQueryRecord &rRec) const {
|
||||
return m_subIntegrator->Li(ray, rRec);
|
||||
}
|
||||
|
||||
Spectrum E(const Scene *scene, const Point &p, const Normal &n, Float time,
|
||||
Sampler *sampler, int irrSamples, bool irrIndirect) const {
|
||||
return m_subIntegrator->E(scene, p, n, time, sampler, irrSamples, irrIndirect);
|
||||
|
||||
Spectrum E(const Scene *scene, const Point &p, const
|
||||
Normal &n, Float time, const Medium *medium, Sampler *sampler,
|
||||
int nSamples, bool includeIndirect) const {
|
||||
return m_subIntegrator->E(scene, p, n, time, medium,
|
||||
sampler, nSamples, includeIndirect);
|
||||
}
|
||||
|
||||
void serialize(Stream *stream, InstanceManager *manager) const {
|
||||
|
|
|
@ -288,32 +288,31 @@ public:
|
|||
E = hs->getIrradiance();
|
||||
}
|
||||
|
||||
Spectrum E(const Scene *scene, const Point &p, const Normal &n,
|
||||
Float time, Sampler *sampler, int irrSamples, bool irrIndirect) const {
|
||||
Spectrum E(const Scene *scene, const Point &p, const Normal &n, Float time,
|
||||
const Medium *medium, Sampler *sampler, int nSamples, bool handleIndirect) const {
|
||||
Spectrum EDir(0.0f), EIndir(0.0f);
|
||||
RadianceQueryRecord rRec(scene, sampler);
|
||||
LuminaireSamplingRecord lRec;
|
||||
|
||||
/* Direct illumination */
|
||||
for (int i=0; i<irrSamples; i++) {
|
||||
rRec.newQuery(RadianceQueryRecord::ERadianceNoEmission);
|
||||
|
||||
if (scene->sampleAttenuatedLuminaire(p, lRec, time, rRec.nextSample2D())) {
|
||||
for (int i=0; i<nSamples; i++) {
|
||||
if (scene->sampleAttenuatedLuminaire(p, time, medium, lRec, rRec.nextSample2D())) {
|
||||
Float dp = dot(lRec.d, n);
|
||||
if (dp < 0)
|
||||
EDir -= lRec.value * dp;
|
||||
}
|
||||
}
|
||||
|
||||
rRec.newQuery(RadianceQueryRecord::ERadianceNoEmission, medium);
|
||||
rRec.its.p = p;
|
||||
rRec.its.geoFrame = rRec.its.shFrame = Frame(n);
|
||||
|
||||
if (irrIndirect) {
|
||||
if (handleIndirect) {
|
||||
if (!m_irrCache->get(rRec.its, EIndir))
|
||||
handleMiss(RayDifferential(), rRec, EIndir);
|
||||
}
|
||||
|
||||
return (EDir / (Float) irrSamples) + EIndir;
|
||||
return (EDir / (Float) nSamples) + EIndir;
|
||||
}
|
||||
|
||||
const Integrator *getSubIntegrator() const {
|
||||
|
|
|
@ -107,6 +107,8 @@ public:
|
|||
m_camera->generateRayDifferential(sample, lensSample, 0.0f, eyeRay);
|
||||
if (m_scene->rayIntersect(eyeRay, its)) {
|
||||
const BSDF *bsdf = its.shape->getBSDF();
|
||||
if (!bsdf)
|
||||
continue;
|
||||
if (!bsdf->getType() == BSDF::EDiffuseReflection)
|
||||
continue;
|
||||
if (m_irrCache->get(its, E))
|
||||
|
@ -122,7 +124,8 @@ public:
|
|||
for (unsigned int k=0; k<m_hs->getN(); k++) {
|
||||
HemisphereSampler::SampleEntry &entry = (*m_hs)(j, k);
|
||||
entry.dist = std::numeric_limits<Float>::infinity();
|
||||
rRec.newQuery(RadianceQueryRecord::ERadianceNoEmission | RadianceQueryRecord::EDistance);
|
||||
rRec.newQuery(RadianceQueryRecord::ERadianceNoEmission
|
||||
| RadianceQueryRecord::EDistance, m_camera->getMedium());
|
||||
rRec.depth = 2;
|
||||
rRec.extra = 1; // mark as irradiance cache query
|
||||
entry.L = integrator->Li(RayDifferential(its.p, entry.d, 0.0f), rRec);
|
||||
|
|
|
@ -51,14 +51,14 @@ void SampleIntegrator::serialize(Stream *stream, InstanceManager *manager) const
|
|||
}
|
||||
|
||||
Spectrum SampleIntegrator::E(const Scene *scene, const Point &p, const Normal &n, Float time,
|
||||
const Medium *medium, Sampler *sampler, int irrSamples, bool irrIndirect) const {
|
||||
const Medium *medium, Sampler *sampler, int nSamples, bool handleIndirect) const {
|
||||
Spectrum E(0.0f);
|
||||
LuminaireSamplingRecord lRec;
|
||||
RadianceQueryRecord rRec(scene, sampler);
|
||||
Frame frame(n);
|
||||
|
||||
sampler->generate();
|
||||
for (int i=0; i<irrSamples; i++) {
|
||||
for (int i=0; i<nSamples; i++) {
|
||||
rRec.newQuery(RadianceQueryRecord::ERadianceNoEmission, medium);
|
||||
|
||||
/* Direct */
|
||||
|
@ -69,14 +69,14 @@ Spectrum SampleIntegrator::E(const Scene *scene, const Point &p, const Normal &n
|
|||
}
|
||||
|
||||
/* Indirect */
|
||||
if (irrIndirect) {
|
||||
if (handleIndirect) {
|
||||
Vector d = frame.toWorld(squareToHemispherePSA(rRec.nextSample2D()));
|
||||
++rRec.depth;
|
||||
E += Li(RayDifferential(p, d, time), rRec) * M_PI;
|
||||
}
|
||||
sampler->advance();
|
||||
}
|
||||
return E / (Float) irrSamples;
|
||||
return E / (Float) nSamples;
|
||||
}
|
||||
|
||||
void SampleIntegrator::cancel() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Import('env', 'plugins')
|
||||
|
||||
plugins += env.SharedLibrary('#plugins/homogeneous', ['homogeneous.cpp'])
|
||||
#plugins += env.SharedLibrary('#plugins/homogeneous', ['homogeneous.cpp'])
|
||||
#plugins += env.SharedLibrary('#plugins/heterogeneous', ['heterogeneous.cpp'])
|
||||
#plugins += env.SharedLibrary('#plugins/heterogeneous-flake', ['heterogeneous-flake.cpp'])
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <mitsuba/render/luminaire.h>
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/subsurface.h>
|
||||
#include <mitsuba/render/medium.h>
|
||||
#include <set>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
Loading…
Reference in New Issue