Skip to content

Commit da9deae

Browse files
we dont need modified light radiances (Redundant data)
1 parent 8ecd4e4 commit da9deae

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Renderer::Renderer(IVideoDriver* _driver, IAssetManager* _assetManager, scene::I
8989
}
9090
{
9191
#ifndef DISABLE_NEE
92-
constexpr auto additionalGlobalDescriptorCount = 7u;
92+
constexpr auto additionalGlobalDescriptorCount = 6u;
9393
#else
9494
constexpr auto additionalGlobalDescriptorCount = 4u;
9595
#endif
@@ -410,7 +410,6 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
410410
continue;
411411

412412
retval.lights.emplace_back(std::move(newLight));
413-
retval.lightRadiances.push_back(emitter.area.radiance);
414413
retval.lightPDF.push_back(weight);
415414
}
416415
}
@@ -564,34 +563,24 @@ void Renderer::finalizeScene(Renderer::InitializationData& initData)
564563
auto inPDF = initData.lightPDF.begin();
565564
double partialSum = *inPDF;
566565

567-
auto radianceIn = initData.lightRadiances.begin();
568-
core::vector<uint64_t> compressedRadiance(m_staticViewData.lightCount,0ull);
569-
auto radianceOut = compressedRadiance.begin();
570-
auto divideRadianceByPDF = [UINT_MAX_DOUBLE,weightSumRcp,&partialSum,&outCDF,&radianceIn,&radianceOut](uint32_t prevCDF) -> void
566+
auto computeCDF = [UINT_MAX_DOUBLE,weightSumRcp,&partialSum,&outCDF](uint32_t prevCDF) -> void
571567
{
572-
double inv_prob = NAN;
573568
const double exactCDF = weightSumRcp*partialSum+double(FLT_MIN);
574569
if (exactCDF<UINT_MAX_DOUBLE)
575-
{
576-
uint32_t thisCDF = *outCDF = static_cast<uint32_t>(exactCDF);
577-
inv_prob = UINT_MAX_DOUBLE/double(thisCDF-prevCDF);
578-
}
570+
*outCDF = static_cast<uint32_t>(exactCDF);
579571
else
580572
{
581573
assert(exactCDF<UINT_MAX_DOUBLE+1.0);
582574
*outCDF = 0xdeadbeefu;
583-
inv_prob = 1.0/(1.0-double(prevCDF)/UINT_MAX_DOUBLE);
584575
}
585-
auto tmp = (radianceIn++)->operator*(inv_prob);
586-
*(radianceOut++) = core::rgb32f_to_rgb19e7(tmp.pointer);
587576
};
588577

589-
divideRadianceByPDF(0u);
578+
computeCDF(0u);
590579
for (auto prevCDF=outCDF++; outCDF!=initData.lightCDF.end(); prevCDF=outCDF++)
591580
{
592581
partialSum += double(*(++inPDF));
593582

594-
divideRadianceByPDF(*prevCDF);
583+
computeCDF(*prevCDF);
595584
}
596585
}
597586

@@ -819,7 +808,7 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
819808

820809
//
821810
constexpr uint32_t descriptorUpdates = 5;
822-
constexpr uint32_t descriptorUpdateCounts[descriptorUpdates] = {3u,9u,2u,2u,3u};
811+
constexpr uint32_t descriptorUpdateCounts[descriptorUpdates] = {2u,9u,2u,2u,3u};
823812
constexpr uint32_t descriptorUpdateMaxCount = *std::max_element(descriptorUpdateCounts,descriptorUpdateCounts+descriptorUpdates);
824813

825814
//
@@ -879,9 +868,8 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
879868
{
880869
createFilledBufferAndSetUpInfoFromVector(infos+0,initData.lightCDF);
881870
createFilledBufferAndSetUpInfoFromVector(infos+1,initData.lights);
882-
createFilledBufferAndSetUpInfoFromVector(infos+2,initData.lightRadiances);
883871

884-
setDstSetAndDescTypesOnWrites(m_additionalGlobalDS.get(),writes,infos,{EDT_STORAGE_BUFFER,EDT_STORAGE_BUFFER,EDT_STORAGE_BUFFER},4u);
872+
setDstSetAndDescTypesOnWrites(m_additionalGlobalDS.get(),writes,infos,{EDT_STORAGE_BUFFER,EDT_STORAGE_BUFFER},4u);
885873
}
886874
m_driver->updateDescriptorSets(descriptorUpdateCounts[0],writes,0u,nullptr);
887875
#endif

examples_tests/22.RaytracedAO/Renderer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
5656

5757
struct InitializationData
5858
{
59-
InitializationData() : mdiFirstIndices(), lights(),lightRadiances(),lightCDF(),globalMeta(nullptr) {}
59+
InitializationData() : mdiFirstIndices(), lights(),lightCDF(),globalMeta(nullptr) {}
6060
InitializationData(InitializationData&& other) : InitializationData()
6161
{
6262
operator=(std::move(other));
@@ -67,15 +67,13 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
6767
{
6868
mdiFirstIndices = std::move(other.mdiFirstIndices);
6969
lights = std::move(other.lights);
70-
lightRadiances = std::move(other.lightRadiances);
7170
lightCDF = std::move(other.lightCDF);
7271
globalMeta = other.globalMeta;
7372
return *this;
7473
}
7574

7675
nbl::core::vector<uint32_t> mdiFirstIndices;
7776
nbl::core::vector<SLight> lights;
78-
nbl::core::vector<nbl::core::vectorSIMDf> lightRadiances;
7977
union
8078
{
8179
nbl::core::vector<float> lightPDF;

examples_tests/22.RaytracedAO/raytraceCommon.glsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ layout(set = 1, binding = 5, std430, row_major) restrict readonly buffer Lights
1919
{
2020
SLight light[];
2121
};
22-
layout(set = 1, binding = 6, std430, row_major) restrict readonly buffer LightRadiances
23-
{
24-
uvec2 lightRadiance[]; // Watts / steriadian / steradian in rgb19e7
25-
};
2622
#endif
2723

2824
layout(set = 2, binding = 0, row_major) uniform StaticViewData

0 commit comments

Comments
 (0)