mitsuba3 icon indicating copy to clipboard operation
mitsuba3 copied to clipboard

Fix normalmap

Open tomix1024 opened this issue 2 years ago • 1 comments

Description

The shading frame in the normalmap BSDF was not computed correctly. The shading frame-local normal was used in conjunction with the world-space dp_du to construct the perturbed shading frame. The shading frame in turn was interpreted as the "shading frame in world space", as well as the relative transformation between the original shading frame and the perturbed one...

Testing

resources/data/tests/scenes/git/test_normalmap_roughconductor_path.xml has been added in my fork of the mitsuba-data repository to verify the changes. (But this probably does not really count here, does it?) The improved correctness relative to the previous implementation can be seen if the normal-mapped rendering is compared to a not normal-mapped rendering.

I have added src/bsdfs/tests/test_normalmap.py, that verifies that sampling from a normal-mapped BSDF is the same as sampling from the nested BSDF with an appropriately rotated surface interaction.

Checklist

  • [x] My code follows the style guidelines of this project
  • [x] My changes generate no new warnings
  • [x] My code also compiles for cuda_* and llvm_* variants. If you can't test this, please leave below
  • [x] I have commented my code
  • [x] I have made corresponding changes to the documentation
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] I cleaned the commit history and removed any "Merge" commits
  • [x] I give permission that the Mitsuba 3 project may redistribute my contributions under the terms of its license

tomix1024 avatar Sep 15 '23 17:09 tomix1024

Please have a look if the tests are sufficient as they are now... The interesting case occurs only if an anisotropically scattering BSDF is nested inside of the normalmap, so it is difficult to have some "analytic" ground truth solution to test against.

Also the code is compiling for me with GCC 9 on Ubuntu 20.04, GCC 11 on Ubuntu 22.04 and Visual Studio 2022 on Windows 11. I am not sure why the CI build is failing.

tomix1024 avatar Sep 15 '23 22:09 tomix1024