New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 23 Figure 23-4 updateReservoir function #4
Comments
Hi @jeremyong - thanks for your message! I've pointed the authors of Chapter 23 here so they can take a look at your question / bug report. They'll either respond here directly or I'll post for them once they've had a chance to review. |
@jeremyong Yes, the code as written should work, but you're correct that moving the summation of M values into To avoid some hard-to-explain and hard-to-debug problems, I suggest leaving (The simplistic, TL;DR reason for this is reservoirs may have different representations when actively in use v.s. just loaded from memory. Intermediate reservoirs reused, say, between frames may compress some data to save space while the active, in-register variants probably store uncompressed data plus temporary additional components. Trying to |
Thanks @chris-wyman, I wonder than if it might be better to have a struct like |
@acmarrs-nvidia Hey Adam! In Chapter 23, Figure 23-4, the code as listed looks like the following:
As written, this code works but I believe
updateReservoir
has a bug in it, specifically related to the update ofresult.M
(which denotes the sample count). I believe the correct update should beresult.M += input.M;
. Note that the listing as a whole works provided the user only usesmergeReservoirs
becausemerged.M
is overwritten with the correct result afterwards. A refactored code listing might look like:Note: the only distinction between
mergeReservoirs
andupdateReservoir
as implemented above is that the former leaves its argumentsr1
andr2
unchanged, whileupdateReservoir
mutates the first argument.The text was updated successfully, but these errors were encountered: