Skip to content

Commit 416e4b5

Browse files
committed
Fixed erroneous clear of photon counter if mixed lights are used;
Improved hitSphere function
1 parent d276180 commit 416e4b5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Source/RenderPasses/ReSTIR_FG_Lite/GenerateInitialSamples.rt.slang

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ struct RayPayload
4848
bool hitSphere(const float3 center, const float radius, const float3 p)
4949
{
5050
float3 radiusTest = p - center;
51-
radiusTest = radiusTest * radiusTest;
52-
float radiusTestF = radiusTest.x + radiusTest.y + radiusTest.z;
53-
if (radiusTestF < radius * radius)
54-
return true;
55-
return false;
51+
return dot(radiusTest, radiusTest) < radius * radius;
5652
}
5753

5854
/* Collects all photons in a radius and estimates radiance.

Source/RenderPasses/ReSTIR_FG_Lite/ReSTIR_FG_Lite.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ void ReSTIR_FG_Lite::execute(RenderContext* pRenderContext, const RenderData& re
259259

260260
mpRTXDI->beginFrame(pRenderContext, mScreenRes);
261261

262+
//Clear Photon Counter before tracing the Photons for this frame
263+
pRenderContext->clearUAV(mpPhotonCounter->getUAV().get(), uint4(0));
264+
262265
//Trace Photons. Up to two passes may be executed, depending on the light types in the scene
263266
//(one for emissive triangles and one for analytic point/spot lights)
264267
tracePhotonsPass(pRenderContext, renderData, !mMixedLights && mHasAnalyticLights, !mMixedLights && mPhotonAnalyticRatio > 0);
@@ -432,9 +435,6 @@ void ReSTIR_FG_Lite::tracePhotonsPass(RenderContext* pRenderContext, const Rende
432435
{
433436
FALCOR_PROFILE(pRenderContext, "TracePhotons");
434437

435-
//Clear Photon Counter
436-
pRenderContext->clearUAV(mpPhotonCounter->getUAV().get(), uint4(0));
437-
438438
// Init Shader
439439
if (!mTracePhotonPass.pProgram)
440440
{

0 commit comments

Comments
 (0)