From eaf294dd2eed3423f7f27967fd5441059fd5b809 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Wed, 10 Feb 2021 22:21:34 +0100 Subject: Use two images for accumulation (TAA style) --- shaders/compute.comp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'shaders') diff --git a/shaders/compute.comp b/shaders/compute.comp index 01a0f71..f09bb7f 100644 --- a/shaders/compute.comp +++ b/shaders/compute.comp @@ -9,6 +9,8 @@ const uint LAMBERTIAN_MATERIAL = 0; const uint METAL_MATERIAL = 1; const uint DIELECTRIC_MATERIAL = 2; +const vec3 light_position = vec3(10, -25, 0); + struct material { vec4 albedo; float fuzz; @@ -67,7 +69,8 @@ layout(set = 0, binding = 0) buffer Inputs { uint[3] padding; }; -layout(set = 0, binding = 1, rgba8) uniform image2D output_image; +layout(set = 0, binding = 1, rgba8) uniform writeonly image2D output_image; +layout(set = 0, binding = 2, rgba8) uniform readonly image2D accumulation_image; vec3 at(ray r, float t) { return r.origin + r.direction * t; @@ -226,6 +229,6 @@ void main() { out_color += ray_color(r, sample_index); float spp_scale = (1.0 / samples_per_pixel); - vec4 acc_color = imageLoad(output_image, ivec2(x, y)); - imageStore(output_image, ivec2(x, y), acc_color + (out_color * spp_scale)); + vec4 acc_color = imageLoad(accumulation_image, ivec2(x, y)); + imageStore(output_image, ivec2(x, y), mix(out_color, acc_color, spp_scale)); } -- cgit v1.3