Skip to content

Conversation

@Speierers
Copy link
Member

This PR provides an implementation of adpative sampling similar to the one implemented in Blender's Cycles. The adaptive_sampling is intended to be used as a wrapper to another integrator, and will render the image using the
wrapped integrator, allocating more samples in regions of higher variance. The implementation is based on "Global adaptive sampling hierarchies in production ray tracing".

image

A callback can be set on the integrator to track progress and access intermediate renderings for progressing rendering (e.g. in a viewport). It is also very helpful for debugging.

    adaptive_integrator = mi.load_dict({
        'type': 'adaptive_sampling',
        'threshold': 0.05,
        'pass_spp': 16,
        'nested': scene.integrator()
    })

    def callback(pass_i: int,
                 accum_spp: int,
                 pass_spp: int,
                 img: mi.TensorXf,
                 odd_img: mi.TensorXf,
                 error: mi.TensorXf,
                 active: mi.TensorXf):
        print(f'Adaptive sampling pass {pass_i}, rendering {dr.count(active)} pixels with {pass_spp} spp.')
        return True

    adaptive_integrator.set_callback(callback)

Remaining TODOs

  • Proper testing, open to suggestions!
  • Efficient implementation using dr.freeze to avoid JIT tracing at every pass.

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