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

Radius search operation in photon mapping #2

Open
arpit15 opened this issue Mar 18, 2024 · 7 comments
Open

Radius search operation in photon mapping #2

arpit15 opened this issue Mar 18, 2024 · 7 comments

Comments

@arpit15
Copy link

arpit15 commented Mar 18, 2024

Thanks for creating this wonderful repository. I am trying to implement SPPM using your sppm.py sample. Can you provide some pointers on how to perform the photon tracing pass. I am unable to resolve following things in the photon pass

  1. how to recursively trace rays? Does mitsuba.Loop allow nested loops
  2. How to handle multiple grid contributions for neighborhood?

Any thoughts or suggestions would be helpful. I have almost working solution in mitsuba C++ .

Also, this paper is interesting if photon mapping is interesting to you.

@DoeringChristian
Copy link
Owner

DoeringChristian commented Mar 18, 2024

Hi,
I don't think I ever finished the photon mapping integrator.
In order to construct a hashgrid in Mitsuba efficiently, you need the ability to atomically scatter, without splitting kernels. This was only added in a recent version of Mitsuba and will most likely be expanded on in the upcoming nanobind rework:

  1. It is possible to nest Mitsuba loops, however it is not possible/advisable to do recursion. With path tracing algorithms you usually rely on manual tail-recursion elimination, where you expand the recursive calls to iterations of a loop.
  2. This relates to the atomic scattering problem, you would lookup the grid cell using a hash in an array and insert the photon there. The insertion part will either require atomics or a cumulative sum (which I tried in my implementation).

I hope this helps.

@arpit15
Copy link
Author

arpit15 commented Mar 19, 2024

I am not very familiar with hash maps algorithms on GPU. Can you kindly share the reference of what you implemented in sppm.py for storing visible points?

@DoeringChristian
Copy link
Owner

To be honest I don't think there is a reference for what I did there.
I oriented myself on the Mitsuba0.6 implementation and the pbrt books but I'm unsure if I used any hashmap esq implementations from them.
There is a paper from AMD on world space ReSTIR, from which I took some inspiration here.

I also don't think taht my implementation works correctly.
The idea was that to insert a set of points into a hash map I first calculate the number of points per cell. This usually requires atomic increments. I got arround this requirement by splitting kernles, which is very slow. Then I used a prefix sum over the cell sizes to calculate the starting offset of every cell in an array. Finally I added them into the cells (this again requires atomics).

@arpit15
Copy link
Author

arpit15 commented Mar 19, 2024

Thanks for sharing the reference. I have a few questions

  1. By splitting kernels, do you mean calling dr.eval?
  2. I can test atomics from your branch here. Do you know if drjit team has plans to merge it?

@DoeringChristian
Copy link
Owner

  1. Yes, calling dr.eval computes all scheduled variables. This effectively splits the computation in two kernels. This has some overhead accociated with it.
  2. The branch is only an experiment I did and will probably not work. I think the upcoming nanobind_v2 version will support this.

@arpit15
Copy link
Author

arpit15 commented Jun 12, 2024

@DoeringChristian nanobind_v2 and some atomics are added to drjit now. I will take a stab in python now.
I made an sppm impl in cpp based on PBRT and added a discussion here.

@DoeringChristian
Copy link
Owner

I saw your results. They look very nice. It would be really cool if sppm works on the GPU in Mitsuba.

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

No branches or pull requests

2 participants