Make correct usage of frame for imageStore

This commit is contained in:
mlefrancois 2022-11-23 11:21:31 +01:00
parent 9ed7600eb4
commit 003bab42a5

View file

@ -104,16 +104,16 @@ void main()
} }
prd.hitValue = hitValues / NBSAMPLES; prd.hitValue = hitValues / NBSAMPLES;
// Do accumulation over time if(pcRay.frame == 0)
if(pcRay.frame >= 0)
{
float a = 1.0f / float(pcRay.frame + 1);
vec3 old_color = imageLoad(image, ivec2(gl_LaunchIDEXT.xy)).xyz;
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(mix(old_color, prd.hitValue, a), 1.f));
}
else
{ {
// First frame, replace the value in the buffer // First frame, replace the value in the buffer
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(prd.hitValue, 1.f)); imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(prd.hitValue, 1.f));
} }
else
{
// Do accumulation over time
float a = 1.0f / float(pcRay.frame + 1);
vec3 old_color = imageLoad(image, ivec2(gl_LaunchIDEXT.xy)).xyz;
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(mix(old_color, prd.hitValue, a), 1.f));
}
} }