Skip to content

Commit

Permalink
merian-nodes: Accumulate: Respect sample count again
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Sep 20, 2024
1 parent f8ea38b commit 73cee50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/merian-nodes/nodes/accumulate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Inputs:
| VkImageIn | prev_accum | feedback last `accum` | 1 |
| VkImageIn | prev_moments | feedback last `moments` | 1 |
| | | | |
| VkImageIn | irr | irradiance input (irradiance in `rgb`, sample count in `a`) | no |
| VkImageIn | irr | irradiance input (irradiance in `rgb`, sample count in `a`!) | no |
| | | | |
| VkImageIn | mv | motion vectors in `r` and `g` channel | no |
| VkImageIn | moments_in | moments in `r` and `g` channel | no |
Expand Down
5 changes: 3 additions & 2 deletions src/merian-nodes/nodes/accumulate/accumulate.comp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void main() {
if (any(greaterThanEqual(ipos, imageSize(img_accum)))) return;

vec3 irr = texelFetch(img_irr, ipos, 0).rgb;
float samples = texelFetch(img_irr, ipos, 0).a;
vec2 moments = texelFetch(img_moments, ipos, 0).rg;
vec4 percentiles;

Expand Down Expand Up @@ -246,8 +247,8 @@ void main() {
prev_irr_histlen.a = min(1.0 / (1.0 - adaptive_alpha) - 1, prev_irr_histlen.a);
}

prev_irr_histlen.a = min(prev_irr_histlen.a + 1, max_history);
float alpha = min(pc.accum_alpha, 1. - 1. / prev_irr_histlen.a);
float alpha = min(pc.accum_alpha, prev_irr_histlen.a / (prev_irr_histlen.a + samples));
prev_irr_histlen.a = min(prev_irr_histlen.a + samples, max_history);

irr = mix(irr, prev_irr_histlen.rgb, alpha);
moments = mix(moments, prev_moments, alpha);
Expand Down

0 comments on commit 73cee50

Please sign in to comment.