Skip to content

Commit

Permalink
Make correct usage of frame for imageStore
Browse files Browse the repository at this point in the history
  • Loading branch information
mklefrancois committed Nov 23, 2022
1 parent 9ed7600 commit 003bab4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ray_tracing__advance/shaders/raytrace.rgen
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ void main()
}
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));
// First frame, replace the value in the buffer
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(prd.hitValue, 1.f));
}
else
{
// First frame, replace the value in the buffer
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(prd.hitValue, 1.f));
// 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));
}
}

0 comments on commit 003bab4

Please sign in to comment.