Skip to content

Commit f90ed6e

Browse files
fix accumulation bug
1 parent 0709a0b commit f90ed6e

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

examples_tests/22.RaytracedAO/closestHit.comp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void main()
100100
// TODO: finish MIS
101101
vec3 acc;
102102
const uvec3 accumulationLocation = uvec3(outPixelLocation,sampleID%staticViewData.samplesPerPixelPerDispatch);
103-
const bool first_accumulating_path_vertex = accumulationLocation.z!=0u||get_path_vertex_depth()==2u;
104-
const bool notFirstFrame = pc.cummon.rcpFramesDispatched!=1.f;
103+
const bool first_accumulating_path_vertex = get_path_vertex_depth()==2u&&accumulationLocation.z!=0u;
105104
if (record_emission_common(acc,accumulationLocation,emissive*throughput,first_accumulating_path_vertex))
106105
storeAccumulation(acc,accumulationLocation);
107106
}

examples_tests/22.RaytracedAO/raygen.comp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,14 @@ void main()
7272
);
7373
}
7474

75-
7675
vec3 acc;
7776
uvec3 accumulationLocation = uvec3(outPixelLocation,0u);
78-
const bool notFirstFrame = pc.cummon.rcpFramesDispatched!=1.f;
79-
if (record_emission_common(acc,accumulationLocation,emissive*float(staticViewData.samplesPerPixelPerDispatch),true) || !notFirstFrame)
77+
const bool firstFrame = pc.cummon.rcpFramesDispatched==1.f;
78+
if (record_emission_common(acc,accumulationLocation,emissive*float(staticViewData.samplesPerPixelPerDispatch),true) || firstFrame)
8079
storeAccumulation(acc,accumulationLocation);
8180

82-
if (notFirstFrame) //TODO: plop the accumulation into autoexposure histogram
83-
{
84-
}
85-
else // clear accumulation totally if beginning a new frame
86-
while (++accumulationLocation.z!=staticViewData.samplesPerPixelPerDispatch)
87-
storeAccumulation(vec3(0.0),accumulationLocation);
81+
if (firstFrame) // clear accumulation totally if beginning a new frame
82+
for (uint i=1u; i<staticViewData.samplesPerPixelPerDispatch; i++)
83+
imageStore(accumulation,ivec3(outPixelLocation,i),uvec4(0u));
8884
}
8985
}

0 commit comments

Comments
 (0)