Fix nearest-neighbor interpolation of cached reconstruction filter #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Benedikt!
I was implementing film and reconstruction functionality in my renderer and I learned a lot from your implementation. I think that I stumbled upon a very tiny problem in your implementation that can have a noticeable effect on the result however.
When you retrieve the cached filter value, you effectively floor the continuous array index (via int cast) rather than rounding it to the closest integer. This will pick the "wrong" value (i.e. not the nearest neighbor) about 50% of the time as shown in the illustration below.
Since we are dealing with positive values, shifting the continuous index to the left by adding 0.5 before flooring is enough to achieve rounding. Here's a comparison between direct filter evaluation as reference, floor and round (using the Lanczos filter):
I removed the normalization of
_filter
to achieve the same intended filter for these comparisons, since direct evaluation is not normalized.