PSIntegrator: fix biased boundary gradients when sample_border is enabled - #1954
Open
fknfilewalker wants to merge 3 commits into
Open
PSIntegrator: fix biased boundary gradients when sample_border is enabled#1954fknfilewalker wants to merge 3 commits into
PSIntegrator: fix biased boundary gradients when sample_border is enabled#1954fknfilewalker wants to merge 3 commits into
Conversation
fknfilewalker
force-pushed
the
psintegrator-boundary-fixes
branch
from
September 9, 2026 17:06
1a3a2d5 to
43d17e9
Compare
Boundary splats were scaled by ``1 / spp``, which assumes a wavefront of ``prod(crop_size) * spp``. When the film samples its border, ``prepare()`` launches ``prod(crop_size + 2 * border) * spp`` samples instead, which overestimates the derivative by 1.56x for a 16x16 film with the default Gaussian reconstruction filter. These image blocks are splatted with ``weight = 0`` and hence need an explicit sample count. Boundary samples are spread over the crop window, so the correct factor is ``prod(crop_size) / wavefront_size``. It reduces to ``1 / spp`` if the film does not sample its border.
Silhouette points projecting outside of the crop window were discarded, although the reconstruction filter reaches ``border_size`` pixels beyond it and the primal render does account for them. Widen the frustum test by that amount when the film samples its border.
``Sensor::sample_direction`` returns ``ds.uv`` relative to the crop window, while ``ImageBlock::put`` subtracts the block's own offset from the position it is handed. The boundary splats passed ``ds.uv`` straight through, so with a non-zero ``crop_offset`` the discontinuous derivatives landed ``crop_offset`` pixels away from the edge they belong to. ``sample_rays`` already adds the offset back for the primal render, and ``ptracer`` does the same for its particle splats.
fknfilewalker
force-pushed
the
psintegrator-boundary-fixes
branch
from
September 9, 2026 17:09
43d17e9 to
b9351f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
1 / spp, but when the film samples its border the wavefront isprod(crop_size + 2 * border) * spp, overestimating the derivative. Useprod(crop_size) / wavefront_sizeinstead, which reduces to1 / sppwhen no border is sampled.border_sizepixels beyond it. Widening the frustum test reduces error against finite differences.sample_directionreturnsds.uvrelative to the crop window, whileImageBlock::putsubtracts the block's own offset, so with a non-zerocrop_offsetthe derivatives landedcrop_offsetpixels away from the edge they belong to. Add the offset back, as the primal render andptraceralready do.cuda_*andllvm_*variants. If you can't test this, please leave below