fixed the dipole serialization code
parent
e23e84b81f
commit
eabc3f17bc
|
@ -396,9 +396,11 @@ public:
|
||||||
Float actualRadius = m_radius / std::sqrt(m_sampleMultiplier * 20);
|
Float actualRadius = m_radius / std::sqrt(m_sampleMultiplier * 20);
|
||||||
blueNoisePointSet(scene, m_shapes, actualRadius, points, sa, aabb, job);
|
blueNoisePointSet(scene, m_shapes, actualRadius, points, sa, aabb, job);
|
||||||
|
|
||||||
/* 2. gather irradiance in parallel */
|
/* 2. Gather irradiance in parallel */
|
||||||
|
const Sensor *sensor = scene->getSensor();
|
||||||
ref<IrradianceSamplingProcess> proc = new IrradianceSamplingProcess(
|
ref<IrradianceSamplingProcess> proc = new IrradianceSamplingProcess(
|
||||||
points, 1024, m_irrSamples, m_irrIndirect, job);
|
points, 1024, m_irrSamples, m_irrIndirect,
|
||||||
|
sensor->getShutterOpen() + 0.5f * sensor->getShutterOpenTime(), job);
|
||||||
|
|
||||||
/* Create a sampler instance for every core */
|
/* Create a sampler instance for every core */
|
||||||
ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()->
|
ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()->
|
||||||
|
@ -411,8 +413,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int samplerResID = sched->registerMultiResource(samplers);
|
int samplerResID = sched->registerMultiResource(samplers);
|
||||||
|
int integratorResID = sched->registerResource(
|
||||||
|
const_cast<Integrator *>(scene->getIntegrator()));
|
||||||
|
|
||||||
proc->bindResource("scene", sceneResID);
|
proc->bindResource("scene", sceneResID);
|
||||||
|
proc->bindResource("integrator", integratorResID);
|
||||||
proc->bindResource("sampler", samplerResID);
|
proc->bindResource("sampler", samplerResID);
|
||||||
scene->bindUsedResources(proc);
|
scene->bindUsedResources(proc);
|
||||||
m_proc = proc;
|
m_proc = proc;
|
||||||
|
@ -423,6 +428,7 @@ public:
|
||||||
samplers[i]->decRef();
|
samplers[i]->decRef();
|
||||||
|
|
||||||
sched->unregisterResource(samplerResID);
|
sched->unregisterResource(samplerResID);
|
||||||
|
sched->unregisterResource(integratorResID);
|
||||||
if (proc->getReturnStatus() != ParallelProcess::ESuccess)
|
if (proc->getReturnStatus() != ParallelProcess::ESuccess)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -26,18 +26,20 @@ MTS_NAMESPACE_BEGIN
|
||||||
/* Parallel irradiance sampling implementation (worker) */
|
/* Parallel irradiance sampling implementation (worker) */
|
||||||
class IrradianceSamplingWorker : public WorkProcessor {
|
class IrradianceSamplingWorker : public WorkProcessor {
|
||||||
public:
|
public:
|
||||||
IrradianceSamplingWorker(int irrSamples, bool irrIndirect)
|
IrradianceSamplingWorker(int irrSamples, bool irrIndirect, Float time)
|
||||||
: m_irrSamples(irrSamples), m_irrIndirect(irrIndirect) {
|
: m_irrSamples(irrSamples), m_irrIndirect(irrIndirect), m_time(time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IrradianceSamplingWorker(Stream *stream, InstanceManager *manager) {
|
IrradianceSamplingWorker(Stream *stream, InstanceManager *manager) {
|
||||||
m_irrSamples = stream->readInt();
|
m_irrSamples = stream->readInt();
|
||||||
m_irrIndirect = stream->readBool();
|
m_irrIndirect = stream->readBool();
|
||||||
|
m_time = stream->readFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialize(Stream *stream, InstanceManager *manager) const {
|
void serialize(Stream *stream, InstanceManager *manager) const {
|
||||||
stream->writeInt(m_irrSamples);
|
stream->writeInt(m_irrSamples);
|
||||||
stream->writeBool(m_irrIndirect);
|
stream->writeBool(m_irrIndirect);
|
||||||
|
stream->writeFloat(m_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<WorkUnit> createWorkUnit() const {
|
ref<WorkUnit> createWorkUnit() const {
|
||||||
|
@ -50,8 +52,8 @@ public:
|
||||||
|
|
||||||
void prepare() {
|
void prepare() {
|
||||||
m_scene = static_cast<Scene *>(getResource("scene"));
|
m_scene = static_cast<Scene *>(getResource("scene"));
|
||||||
m_integrator = static_cast<SamplingIntegrator *>(m_scene->getIntegrator());
|
|
||||||
m_sampler = static_cast<Sampler *>(getResource("sampler"));
|
m_sampler = static_cast<Sampler *>(getResource("sampler"));
|
||||||
|
m_integrator = static_cast<SamplingIntegrator *>(getResource("integrator"));
|
||||||
m_scene->wakeup(NULL, m_resources);
|
m_scene->wakeup(NULL, m_resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +62,6 @@ public:
|
||||||
const PositionSampleVector &positions = *static_cast<const PositionSampleVector *>(workUnit);
|
const PositionSampleVector &positions = *static_cast<const PositionSampleVector *>(workUnit);
|
||||||
IrradianceSampleVector *result = static_cast<IrradianceSampleVector *>(workResult);
|
IrradianceSampleVector *result = static_cast<IrradianceSampleVector *>(workResult);
|
||||||
const SamplingIntegrator *integrator = m_integrator.get();
|
const SamplingIntegrator *integrator = m_integrator.get();
|
||||||
Float time = m_scene->getSensor()->getShutterOpen();
|
|
||||||
|
|
||||||
result->clear();
|
result->clear();
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ public:
|
||||||
its.p = sample.p;
|
its.p = sample.p;
|
||||||
its.shFrame = Frame(sample.n);
|
its.shFrame = Frame(sample.n);
|
||||||
its.shape = m_scene->getShapes()[sample.shapeIndex].get();
|
its.shape = m_scene->getShapes()[sample.shapeIndex].get();
|
||||||
its.time = time;
|
its.time = m_time;
|
||||||
its.hasUVPartials = false;
|
its.hasUVPartials = false;
|
||||||
|
|
||||||
result->put(IrradianceSample(
|
result->put(IrradianceSample(
|
||||||
|
@ -83,7 +84,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<WorkProcessor> clone() const {
|
ref<WorkProcessor> clone() const {
|
||||||
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect);
|
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect, m_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
MTS_DECLARE_CLASS()
|
MTS_DECLARE_CLASS()
|
||||||
|
@ -95,6 +96,7 @@ private:
|
||||||
ref<SamplingIntegrator> m_integrator;
|
ref<SamplingIntegrator> m_integrator;
|
||||||
int m_irrSamples;
|
int m_irrSamples;
|
||||||
bool m_irrIndirect;
|
bool m_irrIndirect;
|
||||||
|
Float m_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PositionSampleVector::load(Stream *stream) {
|
void PositionSampleVector::load(Stream *stream) {
|
||||||
|
@ -144,10 +146,10 @@ std::string IrradianceSampleVector::toString() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
IrradianceSamplingProcess::IrradianceSamplingProcess(PositionSampleVector *positions,
|
IrradianceSamplingProcess::IrradianceSamplingProcess(PositionSampleVector *positions,
|
||||||
size_t granularity, int irrSamples, bool irrIndirect,
|
size_t granularity, int irrSamples, bool irrIndirect, Float time,
|
||||||
const void *data)
|
const void *data)
|
||||||
: m_positionSamples(positions), m_granularity(granularity),
|
: m_positionSamples(positions), m_granularity(granularity),
|
||||||
m_irrSamples(irrSamples), m_irrIndirect(irrIndirect) {
|
m_irrSamples(irrSamples), m_irrIndirect(irrIndirect), m_time(time) {
|
||||||
m_resultMutex = new Mutex();
|
m_resultMutex = new Mutex();
|
||||||
m_irradianceSamples = new IrradianceSampleVector();
|
m_irradianceSamples = new IrradianceSampleVector();
|
||||||
m_irradianceSamples->reserve(positions->size());
|
m_irradianceSamples->reserve(positions->size());
|
||||||
|
@ -161,7 +163,7 @@ IrradianceSamplingProcess::~IrradianceSamplingProcess() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<WorkProcessor> IrradianceSamplingProcess::createWorkProcessor() const {
|
ref<WorkProcessor> IrradianceSamplingProcess::createWorkProcessor() const {
|
||||||
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect);
|
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect, m_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelProcess::EStatus IrradianceSamplingProcess::generateWork(WorkUnit *unit, int worker) {
|
ParallelProcess::EStatus IrradianceSamplingProcess::generateWork(WorkUnit *unit, int worker) {
|
||||||
|
|
|
@ -194,7 +194,7 @@ class IrradianceSamplingProcess : public ParallelProcess {
|
||||||
public:
|
public:
|
||||||
IrradianceSamplingProcess(PositionSampleVector *positions,
|
IrradianceSamplingProcess(PositionSampleVector *positions,
|
||||||
size_t granularity, int irrSamples, bool irrIndirect,
|
size_t granularity, int irrSamples, bool irrIndirect,
|
||||||
const void *data);
|
Float time, const void *data);
|
||||||
|
|
||||||
inline IrradianceSampleVector *getIrradianceSampleVector() {
|
inline IrradianceSampleVector *getIrradianceSampleVector() {
|
||||||
return m_irradianceSamples.get();
|
return m_irradianceSamples.get();
|
||||||
|
@ -223,6 +223,7 @@ private:
|
||||||
size_t m_samplesRequested, m_granularity;
|
size_t m_samplesRequested, m_granularity;
|
||||||
int m_irrSamples;
|
int m_irrSamples;
|
||||||
bool m_irrIndirect;
|
bool m_irrIndirect;
|
||||||
|
Float m_time;
|
||||||
ref<Mutex> m_resultMutex;
|
ref<Mutex> m_resultMutex;
|
||||||
ProgressReporter *m_progress;
|
ProgressReporter *m_progress;
|
||||||
AABB m_aabb;
|
AABB m_aabb;
|
||||||
|
|
Loading…
Reference in New Issue