Skip to content
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

Fix NAN bug when MLT propose a path with 0 radiance #477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

w3ntao
Copy link
Contributor

@w3ntao w3ntao commented Jan 9, 2025

In MLTIntegrator::Render(), when computing radiance for current path and proposed path, there is a non zero probabilty that their radiance (cCurrent, cProposed) evaluated to 0.

In such case, both accept and splat value will be affected:

  • accept will be assigned 1 when cCurrent == 0
  • LProposed * accept / cProposed and LCurrent * (1 - accept) / cCurrent will be evaluated to NAN, thus pollute the final image
Float cProposed = c(LProposed, lambdaProposed);
Float cCurrent = c(LCurrent, lambdaCurrent);
Float accept = std::min<Float>(1, cProposed / cCurrent);

// Splat both current and proposed samples to _film_
if (accept > 0)
    film.AddSplat(pProposed, LProposed * accept / cProposed, lambdaProposed);
film.AddSplat(pCurrent, LCurrent * (1 - accept) / cCurrent, lambdaCurrent);

My proposed fix is simple: just avoid film.AddSplat() when cCurrent == 0 || cProposed == 0, and then compute accept accordingly.

@mmp
Copy link
Owner

mmp commented Jan 30, 2025

It's not clear to me how this could end up happening: after the bootstrapping step, then by design, every initial path should have a non-zero contribution. As mutations happen, a path with zero contribution should never be accepted. So I'm not sure how we ever end up with cCurrent == 0. Do you have any insight about this? If that is happening, then that suggests there is a bug elsewhere that should probably be found and fixed.

@w3ntao
Copy link
Contributor Author

w3ntao commented Feb 8, 2025

after the bootstrapping step, then by design, every initial path should have a non-zero contribution

This is what I disagree: during bootstrapping, when all initial paths carry zero radiance (not so common but I think it's possible), then the importance-sampling-selected path makes zero contribution. That's when you have cCurrent == 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants