Skip to content

Commit 0df5c4e

Browse files
fix fireflies
1 parent a5cdf7e commit 0df5c4e

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
230230
}
231231

232232
//
233-
retval.maxSensorSamples = MaxFreeviewSamples;
234233
for (const auto& sensor : m_globalMeta->m_global.m_sensors)
235234
{
236-
if (retval.maxSensorSamples<sensor.sampler.sampleCount)
237-
retval.maxSensorSamples = sensor.sampler.sampleCount;
235+
if (maxSensorSamples<sensor.sampler.sampleCount)
236+
maxSensorSamples = sensor.sampler.sampleCount;
238237
}
239238
}
240239

@@ -1060,13 +1059,13 @@ void Renderer::initSceneResources(SAssetBundle& meshes, nbl::io::path&& _sampleS
10601059
// Mantissa is only 23 bits, and primary sample space low discrepancy sequence will start to produce duplicates
10611060
// near 1.0 with exponent -1 after the sample count passes 2^24 elements.
10621061
// Another limiting factor is our encoding of sample sequences, we only use 21bits per channel, so no duplicates till 2^21 samples.
1063-
initData.maxSensorSamples = core::min(0x1<<21,initData.maxSensorSamples);
1064-
if (cachedQuantizedDimensions>=quantizedDimensions && cachedSampleCount>=initData.maxSensorSamples)
1062+
maxSensorSamples = core::min(0x1<<21,maxSensorSamples);
1063+
if (cachedQuantizedDimensions>=quantizedDimensions && cachedSampleCount>=maxSensorSamples)
10651064
sampleSequence.createBufferView(m_driver,std::move(cachebuff));
10661065
else
10671066
{
10681067
printf("[INFO] Generating Low Discrepancy Sample Sequence Cache, please wait...\n");
1069-
cachebuff = sampleSequence.createBufferView(m_driver,quantizedDimensions,initData.maxSensorSamples);
1068+
cachebuff = sampleSequence.createBufferView(m_driver,quantizedDimensions,maxSensorSamples);
10701069
// save sequence
10711070
io::IWriteFile* cacheFile = m_assetManager->getFileSystem()->createAndWriteFile(sampleSequenceCachePath);
10721071
if (cacheFile)
@@ -1078,7 +1077,7 @@ void Renderer::initSceneResources(SAssetBundle& meshes, nbl::io::path&& _sampleS
10781077
}
10791078
std::cout << "\tpathDepth = " << pathDepth << std::endl;
10801079
std::cout << "\tnoRussianRouletteDepth = " << noRussianRouletteDepth << std::endl;
1081-
std::cout << "\tmaxSamples = " << initData.maxSensorSamples << std::endl;
1080+
std::cout << "\tmaxSamples = " << maxSensorSamples << std::endl;
10821081
}
10831082
}
10841083
std::cout << std::endl;
@@ -1131,6 +1130,7 @@ void Renderer::deinitSceneResources()
11311130

11321131
pathDepth = DefaultPathDepth;
11331132
noRussianRouletteDepth = 5u;
1133+
maxSensorSamples = MaxFreeviewSamples;
11341134
}
11351135

11361136
void Renderer::initScreenSizedResources(uint32_t width, uint32_t height)
@@ -1147,7 +1147,6 @@ void Renderer::initScreenSizedResources(uint32_t width, uint32_t height)
11471147
size_t scrambleBufferSize=0u;
11481148
size_t raygenBufferSize=0u,intersectionBufferSize=0u;
11491149
{
1150-
// TODO
11511150
m_staticViewData.pathDepth = pathDepth;
11521151
m_staticViewData.noRussianRouletteDepth = noRussianRouletteDepth;
11531152

@@ -1706,7 +1705,7 @@ bool Renderer::render(nbl::ITimer* timer, const bool beauty)
17061705
// because of direct to screen resolve
17071706
|GL_FRAMEBUFFER_BARRIER_BIT|GL_TEXTURE_UPDATE_BARRIER_BIT
17081707
);
1709-
m_raytraceCommonData.samplesComputed += getSamplesPerPixelPerDispatch();
1708+
m_raytraceCommonData.samplesComputed = (m_raytraceCommonData.samplesComputed+getSamplesPerPixelPerDispatch())%maxSensorSamples;
17101709
}
17111710

17121711
// TODO: autoexpose properly

examples_tests/22.RaytracedAO/Renderer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
9696

9797
struct InitializationData
9898
{
99-
InitializationData() : lights(),lightCDF(), maxSensorSamples(MaxFreeviewSamples) {}
99+
InitializationData() : lights(),lightCDF() {}
100100
InitializationData(InitializationData&& other) : InitializationData()
101101
{
102102
operator=(std::move(other));
@@ -116,7 +116,6 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
116116
nbl::core::vector<float> lightPDF;
117117
nbl::core::vector<uint32_t> lightCDF;
118118
};
119-
uint32_t maxSensorSamples;
120119
};
121120
InitializationData initSceneObjects(const nbl::asset::SAssetBundle& meshes);
122121
void initSceneNonAreaLights(InitializationData& initData);
@@ -186,6 +185,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
186185
} sampleSequence;
187186
uint16_t pathDepth;
188187
uint16_t noRussianRouletteDepth;
188+
uint32_t maxSensorSamples;
189189

190190
// scene specific data
191191
nbl::core::vector<::RadeonRays::Shape*> rrShapes;

include/nbl/builtin/glsl/material_compiler/common.glsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,7 @@ nbl_glsl_MC_eval_pdf_aov_t nbl_glsl_MC_instr_bxdf_eval_and_pdf_common(
824824
}
825825
#endif
826826
// microsurface normal must always be in the upper hemisphere
827-
is_valid = is_valid && microfacet.inner.isotropic.NdotH>=0.0;
828-
829-
// TODO: remove the alpha check, implementation should be numerically stable enough to handle roughness tending to 0, also it doesnt do anything for anisotropic roughnesses right now!
827+
is_valid = is_valid && microfacet.inner.isotropic.NdotH>0.0;
830828
if (is_valid && a2>NBL_GLSL_MC_ALPHA_EPSILON)
831829
{
832830
const uint ndf = nbl_glsl_MC_instr_getNDF(instr);

include/nbl/builtin/glsl/material_compiler/common_invariant_declarations.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct nbl_glsl_MC_precomputed_t
5050

5151
#include <nbl/builtin/glsl/bxdf/common.glsl>
5252

53-
#define NBL_GLSL_MC_ALPHA_EPSILON 1.0e-12
53+
#define NBL_GLSL_MC_ALPHA_EPSILON 1.0e-8
5454

5555
struct nbl_glsl_MC_interaction_t
5656
{

0 commit comments

Comments
 (0)