mitsuba-renderer / mitsuba2

Mitsuba 2: A Retargetable Forward and Inverse Renderer
Other
2.05k stars 267 forks source link

- [🐛 bug report] issue of rotate_mueller_basis in polarized material #287

Open jxo opened 3 years ago

jxo commented 3 years ago

Summary

No frame is attached with stokes in mitsuba2. problem 1: In every polarized material code, contains following statements: weight = mueller::rotate_mueller_basis(weight, -wi_hat, p_axis_in, mueller::stokes_basis(-wi_hat), wo_hat, p_axis_out, mueller::stokes_basis(wo_hat)); Why use p_axis_in, and p_axis_out as in and out basis ? We should choose s_axis_in, s_axis_out here as basis_current, or you will get s1 and s2 in stokes vector rotated by 90 degree.

problem2: stokes vector in world frame, should be converted respect to sensor's frame.

System configuration

every system configuration

Description

  1. use s_axis_in, s_axis_out instead of p_axis_in and p_axis_out for all polarized material.
  2. we should use another rotate mueller matrix to convert stokes vector to sensor's frame.
tizian commented 3 years ago

Hi jxo,

A few weeks ago we've actually conducted some polarized measurements of metal and dielectric surfaces in the lab and this also raised some questions about potential 90˚ flips etc. So I'm currently in the process of double checking all polarization specific implementations again very carefully, and at the same time writing much more thorough documentation about it. You're comments are very helpful in this process, thanks!

Regarding the specific points:

1) This is actually also my suspicion and I have already changed this on a local branch of mine. The "problem" is that I couldn't find a reference that was super clear about which of these s/p vectors is now actually the reference vector to use here. Can you maybe point me to some document about this? This will also be super useful for the documentation to avoid such 90˚ flips and possible confusion in the future.

2) Ah yes, this is a feature that is currently indeed missing, but would be quite important. I guess it would make sense to align the output Stokes vector s.t. it is measured w.r.t. the camera's x-axis? Each pixel would still have to use a slightly different x-axis though as it needs to be orthogonal to the ray direction.

Best, Tizian

jxo commented 3 years ago

@tizian Yeah,I think you got it. stokes_basis() function is quite important in the implementation of mitsuba2, it simplifies interfaces of bsdf and structure of stokes. Frame is generated by coordinate_system() function implicitly according to light direction. I have added the rotation mueller, and converted Stokes vector w.r.t camera's x-axis. Each sample of pixel uses slightly different x-axis which is orthogonal to the light direction for perspective camera, and I got following result. Scene configuration: Light is coming from (0, 0, 1) to (0, 0, 0), camera sits at (0, 0, 5) and looks into (0, 0, 0), up is (0, 1, 0), right hand frame. We can get the same result if camera is rotated around z-axis. sphere_test

Something more, light should attach to some kind of frame, so that we can use partially polarized or polarized light.

I can help to find the documentation of problem 1, maybe in some optics or electromagnetic book.

tizian commented 3 years ago

Thanks for the update. Yes, I would greatly appreciate some book or other source about using s vs. p for the basis. I've looked at quite a few references already and somehow this is never stated so explicitly.

tizian commented 3 years ago

Hi jxo, Please have a look at the branch camera_stokes_rotation that I just pushed to the repository. It should address the missing rotation to align with the camera's x-axis. Here is also a small test scene where a 45˚ camera rotation illustrates the difference: rotation_test.zip

Please let me know if this is how you expected the feature to work.

Best, Tizian