Skip to content

Commit

Permalink
[splatting] Removing the splatting of training samples
Browse files Browse the repository at this point in the history
KNN lookups of the guiding distributions have proven to be
more effective than splatting training samples to share/propagate
information through the guiding field
  • Loading branch information
sherholz-intel committed Nov 15, 2022
1 parent 8233282 commit 651b22c
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 187 deletions.
31 changes: 2 additions & 29 deletions openpgl/api/api.cpp
Expand Up @@ -16,8 +16,6 @@
#include "data/SampleData.h"
#include "data/SampleDataStorage.h"

#include "sampler/Sampler.h"

#include <cstring>

using namespace openpgl;
Expand Down Expand Up @@ -185,30 +183,6 @@ extern "C" OPENPGL_DLLEXPORT void pglFieldReset(PGLField field)OPENPGL_CATCH_BE
}
OPENPGL_CATCH_END()

/*
extern "C" OPENPGL_DLLEXPORT PGLRegion pglFieldGetSurfaceRegion(PGLField field, pgl_point3f position, PGLSampler* sampler)OPENPGL_CATCH_BEGIN
{
const openpgl::Point3 pos(position.x, position.y, position.z);
SamplerC gSampler(sampler);
float sample1D = gSampler.next1D();
auto *gField = (GuidingField *)field;
const IRegion* gRegion = gField->getSurfaceGuidingRegion(pos, sample1D);
return (PGLRegion) gRegion;
}
OPENPGL_CATCH_END(nullptr)
extern "C" OPENPGL_DLLEXPORT PGLRegion pglFieldGetVolumeRegion(PGLField field, pgl_point3f position, PGLSampler* sampler)OPENPGL_CATCH_BEGIN
{
const openpgl::Point3 pos(position.x, position.y, position.z);
SamplerC gSampler(sampler);
float sample1D = gSampler.next1D();
auto *gField = (GuidingField *)field;
const IRegion* gRegion = gField->getVolumeGuidingRegion(pos, sample1D);
return (PGLRegion) gRegion;
}
OPENPGL_CATCH_END(nullptr)
*/

extern "C" OPENPGL_DLLEXPORT PGLSurfaceSamplingDistribution pglFieldNewSurfaceSamplingDistribution(PGLField field)OPENPGL_CATCH_BEGIN
{
auto *gField = (IGuidingField *)field;
Expand Down Expand Up @@ -446,11 +420,10 @@ extern "C" OPENPGL_DLLEXPORT int pglPathSegmentGetNumSamples(PGLPathSegmentStora
return gPathSegmentStorage->getNumSamples();
}

extern "C" OPENPGL_DLLEXPORT size_t pglPathSegmentStoragePrepareSamples(PGLPathSegmentStorage pathSegmentStorage, const bool spaltSamples, PGLSampler* sampler, const bool useNEEMiWeights, const bool guideDirectLight, const bool rrAffectsDirectContribution)
extern "C" OPENPGL_DLLEXPORT size_t pglPathSegmentStoragePrepareSamples(PGLPathSegmentStorage pathSegmentStorage, const bool useNEEMiWeights, const bool guideDirectLight, const bool rrAffectsDirectContribution)
{
auto *gPathSegmentStorage = (openpgl::PathSegmentDataStorage *)pathSegmentStorage;
SamplerC gSampler(sampler);
return gPathSegmentStorage->prepareSamples(spaltSamples, &gSampler, useNEEMiWeights, guideDirectLight, rrAffectsDirectContribution);
return gPathSegmentStorage->prepareSamples(useNEEMiWeights, guideDirectLight, rrAffectsDirectContribution);
}

extern "C" OPENPGL_DLLEXPORT pgl_vec3f pglPathSegmentStorageCalculatePixelEstimate(PGLPathSegmentStorage pathSegmentStorage, const bool rrAffectsDirectContribution)
Expand Down
10 changes: 2 additions & 8 deletions openpgl/data/PathSegmentDataStorage.h
Expand Up @@ -6,7 +6,6 @@
#include "../openpgl_common.h"
#include "PathSegmentData.h"
#include "SampleData.h"
#include "../sampler/Sampler.h"
#include "../spatial/Region.h"

#define OPENPGL_PATHSEGMENT_STORAGE_USE_ARRAY
Expand Down Expand Up @@ -159,7 +158,7 @@ struct PathSegmentDataStorage
m_max_distance = maxDistance;
}

size_t prepareSamples(const bool splatSamples, Sampler* sampler, const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true)
size_t prepareSamples(const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true)
{
const float minPDF {0.1f};
const openpgl::Vector3 maxThroughput {10.0f};
Expand Down Expand Up @@ -203,7 +202,7 @@ struct PathSegmentDataStorage
openpgl::Vector3 dir = openpgl::Vector3(currentPathSegment.directionIn.x, currentPathSegment.directionIn.y, currentPathSegment.directionIn.z);
float pdf = std::max(minPDF,currentPathSegment.pdfDirectionIn);
uint32_t flags{0};
const IRegion* regionPtr = (const IRegion*)currentPathSegment.regionPtr;
//const IRegion* regionPtr = (const IRegion*)currentPathSegment.regionPtr;
//OPENPGL_ASSERT(regionPtr != nullptr);
bool insideVolume = currentPathSegment.volumeScatter;
if(insideVolume)
Expand Down Expand Up @@ -286,11 +285,6 @@ struct PathSegmentDataStorage
dsd.pdf = pdf;
dsd.distance = distance;
dsd.flags = flags;
//m_sampleStorage.emplace_back(dsd, regionPtr);
if(sampler && regionPtr !=nullptr && splatSamples)
{
regionPtr->splatSample(dsd,sampler->next2D());
}
#if defined(OPENPGL_PATHSEGMENT_STORAGE_USE_ARRAY)
if(m_sample_idx+1 <= m_max_sample_size)
{
Expand Down
1 change: 0 additions & 1 deletion openpgl/data/SampleDataStorage.h
Expand Up @@ -6,7 +6,6 @@
#include "../openpgl_common.h"

#include "SampleData.h"
#include "../sampler/Sampler.h"

#include <tbb/concurrent_vector.h>

Expand Down
19 changes: 0 additions & 19 deletions openpgl/include/openpgl/cpp/Field.h
Expand Up @@ -7,7 +7,6 @@

#include "Region.h"
#include "Device.h"
#include "Sampler.h"
#include "SampleStorage.h"

#include <string>
Expand Down Expand Up @@ -102,24 +101,6 @@ struct Field
/// Checks if the guiding information of the Field is valid (e.g., contains no invalid directional distributions).
bool Validate() const;

/**
* @brief Returns the spatial surface Region containing the approximation of the local incident radiance Distribution.
*
* @param position
* @param sampler
* @return Region
*/
//Region GetSurfaceRegion(pgl_point3f position, Sampler* sampler);

/**
* @brief Returns the spatial volume Region containing the approximation of the local incident radiance Distribution.
*
* @param position
* @param sampler
* @return Region
*/
//Region GetVolumeRegion(pgl_point3f position, Sampler* sampler);

friend struct openpgl::cpp::SurfaceSamplingDistribution;
friend struct openpgl::cpp::VolumeSamplingDistribution;
private:
Expand Down
1 change: 0 additions & 1 deletion openpgl/include/openpgl/cpp/OpenPGL.h
Expand Up @@ -14,7 +14,6 @@
#include "PathSegmentStorage.h"
#include "Region.h"
#include "SampleData.h"
#include "Sampler.h"
#include "SampleStorage.h"
#include "SurfaceSamplingDistribution.h"
#include "VolumeSamplingDistribution.h"
Expand Down
1 change: 0 additions & 1 deletion openpgl/include/openpgl/cpp/PathSegment.h
Expand Up @@ -5,7 +5,6 @@

#include "../openpgl.h"
#include "Region.h"
#include "Sampler.h"

namespace openpgl
{
Expand Down
13 changes: 3 additions & 10 deletions openpgl/include/openpgl/cpp/PathSegmentStorage.h
Expand Up @@ -5,7 +5,6 @@

#include "../openpgl.h"
#include "PathSegment.h"
#include "Sampler.h"
#include "SampleData.h"

namespace openpgl
Expand Down Expand Up @@ -40,14 +39,12 @@ struct PathSegmentStorage
/**
* @brief Generates and internally stores -radiance- samples from the the collected path segments.
*
* @param splatSamples If the samples generated samples should be spatially jittered (i.e., to share information with neighboring cells). DEPRECATED
* @param sampler The RNG used during splatting. DEPRECATED
* @param useNEEMiWeights If the direct illumination should be multiplied with the mis weights for NEE.
* @param guideDirectLight If the gererated samples should include direct illumination.
* @param rrAffectsDirectContribution If the Russian roulette probability needs to be integrated into the direct illumination.
* @return size_t The number of generated samples.
*/
size_t PrepareSamples(const bool& splatSamples = false, Sampler* sampler = nullptr, const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true);
size_t PrepareSamples(const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true);

/**
* @brief Calculates the color estimate of the random walk/path from the path segments.
Expand Down Expand Up @@ -174,14 +171,10 @@ OPENPGL_INLINE void PathSegmentStorage::Clear()
pglPathSegmentStorageClear(m_pathSegmentStorageHandle);
}

OPENPGL_INLINE size_t PathSegmentStorage::PrepareSamples(const bool& splatSamples, Sampler* sampler, const bool useNEEMiWeights, const bool guideDirectLight, const bool rrAffectsDirectContribution)
OPENPGL_INLINE size_t PathSegmentStorage::PrepareSamples(const bool useNEEMiWeights, const bool guideDirectLight, const bool rrAffectsDirectContribution)
{
OPENPGL_ASSERT(m_pathSegmentStorageHandle);
//OPENPGL_ASSERT(&sampler.m_samplerHandle);
if(sampler)
return pglPathSegmentStoragePrepareSamples(m_pathSegmentStorageHandle, splatSamples, &sampler->m_samplerHandle, useNEEMiWeights, guideDirectLight, rrAffectsDirectContribution);
else
return pglPathSegmentStoragePrepareSamples(m_pathSegmentStorageHandle, splatSamples, nullptr, useNEEMiWeights, guideDirectLight, rrAffectsDirectContribution);
return pglPathSegmentStoragePrepareSamples(m_pathSegmentStorageHandle, useNEEMiWeights, guideDirectLight, rrAffectsDirectContribution);
}

OPENPGL_INLINE pgl_vec3f PathSegmentStorage::CalculatePixelEstimate(const bool rrAffectsDirectContribution) const
Expand Down
41 changes: 0 additions & 41 deletions openpgl/include/openpgl/cpp/Sampler.h

This file was deleted.

2 changes: 0 additions & 2 deletions openpgl/include/openpgl/cpp/SurfaceSamplingDistribution.h
Expand Up @@ -219,8 +219,6 @@ OPENPGL_INLINE bool SurfaceSamplingDistribution::SupportsApplyCosineProduct() co
OPENPGL_INLINE Region SurfaceSamplingDistribution::GetRegion() const
{
OPENPGL_ASSERT(m_surfaceSamplingDistributionHandle);
//OPENPGL_ASSERT(sampler);
//OPENPGL_ASSERT(&sampler->m_samplerHandle);
PGLRegion regionHandle = pglSurfaceSamplingGetRegion(m_surfaceSamplingDistributionHandle);
return Region(regionHandle);
}
Expand Down
2 changes: 0 additions & 2 deletions openpgl/include/openpgl/cpp/VolumeSamplingDistribution.h
Expand Up @@ -223,8 +223,6 @@ OPENPGL_INLINE bool VolumeSamplingDistribution::Init(const Field* field, const p
OPENPGL_INLINE Region VolumeSamplingDistribution::GetRegion() const
{
OPENPGL_ASSERT(m_volumeSamplingDistributionHandle);
//OPENPGL_ASSERT(sampler);
//OPENPGL_ASSERT(&sampler->m_samplerHandle);
PGLRegion regionHandle = pglVolumeSamplingGetRegion(m_volumeSamplingDistributionHandle);
return Region(regionHandle);
}
Expand Down
5 changes: 0 additions & 5 deletions openpgl/include/openpgl/field.h
Expand Up @@ -13,7 +13,6 @@

#include "common.h"
#include "config.h"
#include "sampler.h"
#include "samplestorage.h"
#include "region.h"
#include "surfacesamplingdistribution.h"
Expand Down Expand Up @@ -49,10 +48,6 @@ OPENPGL_CORE_INTERFACE void pglFieldUpdate(PGLField field, PGLSampleStorage samp

OPENPGL_CORE_INTERFACE void pglFieldReset(PGLField field);

//OPENPGL_CORE_INTERFACE PGLRegion pglFieldGetSurfaceRegion(PGLField field, pgl_point3f position, PGLSampler* sampler);

//OPENPGL_CORE_INTERFACE PGLRegion pglFieldGetVolumeRegion(PGLField field, pgl_point3f position, PGLSampler* sampler);

OPENPGL_CORE_INTERFACE PGLSurfaceSamplingDistribution pglFieldNewSurfaceSamplingDistribution(PGLField field);

OPENPGL_CORE_INTERFACE bool pglFieldInitSurfaceSamplingDistribution(PGLField field, PGLSurfaceSamplingDistribution surfaceSamplingDistribution, pgl_point3f position, float* sample1D);
Expand Down
4 changes: 1 addition & 3 deletions openpgl/include/openpgl/pathsegmentstorage.h
Expand Up @@ -13,7 +13,6 @@

#include "common.h"
#include "region.h"
#include "sampler.h"
#include "samplestorage.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -50,11 +49,10 @@ OPENPGL_CORE_INTERFACE int pglPathSegmentGetNumSegments(PGLPathSegmentStorage pa

OPENPGL_CORE_INTERFACE int pglPathSegmentGetNumSamples(PGLPathSegmentStorage pathSegmentStorage);

OPENPGL_CORE_INTERFACE size_t pglPathSegmentStoragePrepareSamples(PGLPathSegmentStorage pathSegmentStorage, const bool spaltSamples, PGLSampler* sampler, const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true);
OPENPGL_CORE_INTERFACE size_t pglPathSegmentStoragePrepareSamples(PGLPathSegmentStorage pathSegmentStorage, const bool useNEEMiWeights = false, const bool guideDirectLight = false, const bool rrAffectsDirectContribution = true);

OPENPGL_CORE_INTERFACE pgl_vec3f pglPathSegmentStorageCalculatePixelEstimate(PGLPathSegmentStorage pathSegmentStorage, const bool rrAffectsDirectContribution = true);


OPENPGL_CORE_INTERFACE const PGLSampleData* pglPathSegmentStorageGetSamples(PGLPathSegmentStorage pathSegmentStorage, size_t &nSamples);

//OPENPGL_CORE_INTERFACE void pglPathSegmentStorageAddSegment(PGLPathSegmentStorage pathSegmentStorage, PGLPathSegment sample);
Expand Down
25 changes: 0 additions & 25 deletions openpgl/include/openpgl/sampler.h

This file was deleted.

40 changes: 0 additions & 40 deletions openpgl/sampler/Sampler.h

This file was deleted.

0 comments on commit 651b22c

Please sign in to comment.