fix point sources in the RTRT preview
parent
0dc517bfa4
commit
3de850f4e2
|
@ -31,10 +31,12 @@ MTS_NAMESPACE_BEGIN
|
|||
class MTS_EXPORT_RENDER PreviewWorker : public WorkProcessor {
|
||||
public:
|
||||
inline PreviewWorker(int blockSize, Point cameraO, Vector cameraTL,
|
||||
Vector cameraDx, Vector cameraDy, const VPL &vpl, Float minDist, bool coherent)
|
||||
Vector cameraDx, Vector cameraDy, const VPL &vpl, Float minDist, bool coherent,
|
||||
bool diffuseSources, bool diffuseReceivers)
|
||||
: m_blockSize(blockSize), m_cameraO(cameraO), m_cameraTL(cameraTL),
|
||||
m_cameraDx(cameraDx), m_cameraDy(cameraDy), m_vpl(vpl),
|
||||
m_minDist(minDist), m_coherent(coherent) {
|
||||
m_minDist(minDist), m_coherent(coherent), m_diffuseSources(diffuseSources),
|
||||
m_diffuseReceivers(diffuseReceivers) {
|
||||
}
|
||||
|
||||
void processIncoherent(const WorkUnit *workUnit, WorkResult *workResult,
|
||||
|
@ -68,6 +70,7 @@ private:
|
|||
Float m_minDist;
|
||||
const std::vector<const Shape *> *m_shapes;
|
||||
bool m_coherent;
|
||||
bool m_diffuseSources, m_diffuseReceivers;
|
||||
};
|
||||
|
||||
MTS_NAMESPACE_END
|
||||
|
|
|
@ -192,7 +192,7 @@ void VPLShaderManager::setVPL(const VPL &vpl) {
|
|||
for (int i=1; i<=sampleCount; ++i) {
|
||||
Vector dir;
|
||||
Point2 seed(i*invSampleCount, radicalInverse(2, i)); // Hammersley seq.
|
||||
if (vpl.type == ELuminaireVPL && vpl.luminaire->getType() & Luminaire::EOnSurface)
|
||||
if (vpl.type == ESurfaceVPL || vpl.luminaire->getType() & Luminaire::EOnSurface)
|
||||
dir = vpl.its.shFrame.toWorld(squareToHemispherePSA(seed));
|
||||
else
|
||||
dir = squareToSphere(seed);
|
||||
|
|
|
@ -108,9 +108,10 @@ void PreviewWorker::processIncoherent(const WorkUnit *workUnit, WorkResult *work
|
|||
EmissionRecord eRec(m_vpl.luminaire,
|
||||
ShapeSamplingRecord(m_vpl.its.p, m_vpl.its.shFrame.n), toIts);
|
||||
eRec.type = EmissionRecord::EPreview;
|
||||
value += m_vpl.P * bsdfVal * m_vpl.luminaire->f(eRec) *
|
||||
((m_vpl.luminaire->getType() == Luminaire::EOnSurface ?
|
||||
(Float) 1 : dot(m_vpl.its.shFrame.n, toIts)) / (length*length));
|
||||
value += m_vpl.P * bsdfVal * m_vpl.luminaire->f(eRec)
|
||||
* ((m_vpl.luminaire->getType() & Luminaire::EOnSurface ?
|
||||
dot(m_vpl.its.shFrame.n, toIts) : (Float) 1)
|
||||
/ (length*length));
|
||||
}
|
||||
block->setPixel(pos++, value);
|
||||
}
|
||||
|
@ -178,7 +179,7 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
|
|||
bool diffuseVPL = false, vplOnSurface = false;
|
||||
Spectrum vplWeight;
|
||||
|
||||
if (m_vpl.type == ESurfaceVPL && m_vpl.its.shape->getBSDF()->getType() == BSDF::EDiffuseReflection) {
|
||||
if (m_vpl.type == ESurfaceVPL && (m_diffuseSources || m_vpl.its.shape->getBSDF()->getType() == BSDF::EDiffuseReflection)) {
|
||||
diffuseVPL = true;
|
||||
vplOnSurface = true;
|
||||
vplWeight = m_vpl.its.shape->getBSDF()->getDiffuseReflectance(m_vpl.its) * m_vpl.P / M_PI;
|
||||
|
@ -324,7 +325,7 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
|
|||
/* Fast path */
|
||||
direct[idx] = (bsdf->getDiffuseReflectance(its) * vplWeight)
|
||||
* (std::max((Float) 0.0f, dot(wo, its.shFrame.n))
|
||||
* (vplOnSurface ? std::max(cosThetaLight.f[idx], (Float) 0.0f) * INV_PI : 0.0f)
|
||||
* (vplOnSurface ? std::max(cosThetaLight.f[idx], (Float) 0.0f) * INV_PI : 1.0f)
|
||||
* invLengthSquared.f[idx]);
|
||||
} else {
|
||||
wi.x = -primRay4.d[0].f[idx];
|
||||
|
@ -355,7 +356,7 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
|
|||
}
|
||||
}
|
||||
|
||||
if (EXPECT_TAKEN(ctLight > 0)) {
|
||||
if (EXPECT_TAKEN(ctLight >= 0)) {
|
||||
direct[idx] = (bsdf->fCos(BSDFQueryRecord(its, wo)) * vplWeight
|
||||
* ((vplOnSurface ? std::max(ctLight, (Float) 0.0f) : 1.0f) * invLengthSquared.f[idx]));
|
||||
} else {
|
||||
|
@ -402,7 +403,8 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
|
|||
|
||||
ref<WorkProcessor> PreviewWorker::clone() const {
|
||||
return new PreviewWorker(m_blockSize, m_cameraO, m_cameraTL,
|
||||
m_cameraDx, m_cameraDy, m_vpl, m_minDist, m_coherent);
|
||||
m_cameraDx, m_cameraDy, m_vpl, m_minDist, m_coherent,
|
||||
m_diffuseSources, m_diffuseReceivers);
|
||||
}
|
||||
|
||||
MTS_IMPLEMENT_CLASS(PreviewWorker, false, WorkProcessor)
|
||||
|
|
|
@ -545,10 +545,10 @@ void PreviewThread::rtrtRenderVPL(PreviewQueueEntry &target, const VPL &vpl) {
|
|||
for (int i=1; i<=sampleCount; ++i) {
|
||||
Vector dir;
|
||||
Point2 seed(i*invSampleCount, radicalInverse(2, i)); // Hammersley seq.
|
||||
if (vpl.type == ELuminaireVPL && vpl.luminaire->getType() == Luminaire::EDeltaPosition)
|
||||
dir = squareToSphere(seed);
|
||||
else
|
||||
if (vpl.type == ESurfaceVPL || vpl.luminaire->getType() & Luminaire::EOnSurface)
|
||||
dir = vpl.its.shFrame.toWorld(squareToHemispherePSA(seed));
|
||||
else
|
||||
dir = squareToSphere(seed);
|
||||
ray.setDirection(dir);
|
||||
|
||||
if (m_context->scene->rayIntersect(ray, its)) {
|
||||
|
@ -578,7 +578,9 @@ void PreviewThread::rtrtRenderVPL(PreviewQueueEntry &target, const VPL &vpl) {
|
|||
m_previewProc->configure(vpl, minDist, jitter,
|
||||
m_accumBuffer ? m_accumBuffer->getBitmap() : NULL,
|
||||
target.buffer->getBitmap(),
|
||||
m_context->previewMethod == ERayTraceCoherent);
|
||||
m_context->previewMethod == ERayTraceCoherent,
|
||||
m_context->diffuseSources,
|
||||
m_context->diffuseReceivers);
|
||||
m_mutex->unlock();
|
||||
|
||||
ref<Scheduler> sched = Scheduler::getInstance();
|
||||
|
|
|
@ -72,7 +72,8 @@ void PreviewProcess::processResult(const WorkResult *result, bool cancelled) {
|
|||
}
|
||||
|
||||
void PreviewProcess::configure(const VPL &vpl, Float minDist, const Point2 &jitter,
|
||||
const Bitmap *source, Bitmap *target, bool coherent) {
|
||||
const Bitmap *source, Bitmap *target, bool coherent, bool diffuseSources,
|
||||
bool diffuseReceivers) {
|
||||
BlockedImageProcess::init(m_film->getCropOffset(), m_film->getCropSize(), m_blockSize);
|
||||
m_source = source;
|
||||
m_target = target;
|
||||
|
@ -80,6 +81,8 @@ void PreviewProcess::configure(const VPL &vpl, Float minDist, const Point2 &jitt
|
|||
m_vpl = &vpl;
|
||||
m_minDist = minDist;
|
||||
m_coherent = coherent;
|
||||
m_diffuseSources = diffuseSources;
|
||||
m_diffuseReceivers = diffuseReceivers;
|
||||
|
||||
/* It is not necessary to shoot normalized rays. Instead, interpolate:
|
||||
here, we generate the upper left corner ray as well as the
|
||||
|
@ -104,7 +107,8 @@ void PreviewProcess::configure(const VPL &vpl, Float minDist, const Point2 &jitt
|
|||
|
||||
ref<WorkProcessor> PreviewProcess::createWorkProcessor() const {
|
||||
return new PreviewWorker(m_blockSize, m_cameraO, m_cameraTL,
|
||||
m_cameraDx, m_cameraDy, *m_vpl, m_minDist, m_coherent);
|
||||
m_cameraDx, m_cameraDy, *m_vpl, m_minDist, m_coherent,
|
||||
m_diffuseSources, m_diffuseReceivers);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ public:
|
|||
PreviewProcess(const Scene *scene, int sceneResID, int blockSize);
|
||||
|
||||
void configure(const VPL &vpl, Float minDist, const Point2 &jitter,
|
||||
const Bitmap *source, Bitmap *target, bool coherent);
|
||||
const Bitmap *source, Bitmap *target, bool coherent,
|
||||
bool diffuseSources, bool diffuseReceivers);
|
||||
inline int getRayCount() const { return m_numRays; }
|
||||
inline const Scene *getScene() const { return m_scene; }
|
||||
|
||||
|
@ -42,6 +43,8 @@ private:
|
|||
const VPL *m_vpl;
|
||||
Float m_minDist;
|
||||
bool m_coherent;
|
||||
bool m_diffuseSources;
|
||||
bool m_diffuseReceivers;
|
||||
};
|
||||
|
||||
#endif /* __PREVIEW_PROC_H */
|
||||
|
|
Loading…
Reference in New Issue