aboutsummaryrefslogtreecommitdiffstats
path: root/shaders/compute.comp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-02-10 22:21:34 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-02-10 22:21:34 +0100
commiteaf294dd2eed3423f7f27967fd5441059fd5b809 (patch)
treef199d9ad6331c16558ca816e0c7f25ec57e6d008 /shaders/compute.comp
parent5e39b7485d08345a4eb3686b344840791888d1f9 (diff)
Use two images for accumulation (TAA style)
Diffstat (limited to 'shaders/compute.comp')
-rw-r--r--shaders/compute.comp9
1 files changed, 6 insertions, 3 deletions
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));
}