Closed Thomaswang0822 closed 2 months ago
Sorry, I am still exploring and learning the entire Falcor project (magnificent work btw). I made mistakes in 2 details in my previous comment: 1) Just realized there are other tests in addition to unit tests, which are executed by FalcorTest.exe. In particular, those unit tests don't have direct checking on warped-area sampling differentiable PT. Image tests do have. And here are the test result. I commented out line 51 "[ForwardDerivative(fwd_computeHarmonicWeight)]" which links computeHarmonicWeight() to its custom fwd_diff function and let Falcor to auto-diff.
PS my_folder> .\tests\run_image_tests.bat --gen-refs -f .*test_WARDiffPathTracer.* --parallel 1
Reference directory: my_folder\tests\data\refs\<branch name>\windows-ninja-msvc-Release
Generating references for 4 tests on 1 processes
renderpasses/test_WARDiffPathTracerMaterialFwd_d3d12 : STARTED
renderpasses/test_WARDiffPathTracerTranslationBwd_d3d12 : STARTED
renderpasses/test_WARDiffPathTracerMaterialFwd_d3d12 : PASSED (13.9 s)
renderpasses/test_WARDiffPathTracerTranslationFwd_d3d12 : STARTED
renderpasses/test_WARDiffPathTracerTranslationBwd_d3d12 : PASSED (25.0 s)
renderscripts/test_WARDiffPathTracer_d3d12 : STARTED
renderpasses/test_WARDiffPathTracerTranslationFwd_d3d12 : PASSED (9.2 s)
renderscripts/test_WARDiffPathTracer_d3d12 : PASSED (6.8 s)
Generating references PASSED (0.0 s).
All related tests passed.
2) In my previous runs and attached screenshot, I used the wrong bunny test scene. It should be "test_scenes/bunny_war_diff_pt.pyscene" from the python configuration file. Now here is the updated comparison: First is original code with custom fwd_diff function; Second is my modified code with auto diff; And I changed max bounces and sample per pixel to 4 and 8 respectively
Now we can see there is a big difference. It's very possible my reasoning is wrong. Still, I'd like some expert confirmation. Really appreciate that!
Originally brought up in issue #426 created earlier
Here is the copied info:
This may be long and a little involved. I will try my best to explain the possible issue.
It's an issue of implementation detail of harmonic weight used by warped-area sampling (WAS) differentiable path tracer. Here is the paper
I am talking about this function: float computeHarmonicWeight() in Source\RenderPasses\WARDiffPathTracer\WarpedAreaReparam.slang This is the current implementation:
This function basically implements the computation of weight_i, a single line in Algorithm 2 in the paper. It seems like the code doesn't match the formula given in the paper. Here is some derivation & explanation. (I will use 'w' for omega, unit direction and 'weight' for w in the paper for convenience)
And here is my modified implementation:
After the change, here is the bunny_ref test scene. (First is before change, second is after change.) I did see some very subtle difference. But admittedly, I am not an expert on Falcor, differentiable rendering, or WAS, so it's very possible I am wrong. But I do want to point things out in case there is something wrong.
Thank you!
Finally, here is the launch.json entry for this test scene for your convenience.