marlam / camsim

simulation of RGB and depth cameras
https://marlam.de/camsim
MIT License
10 stars 3 forks source link

[Question] Details on computing VPL area #2

Closed VC86 closed 10 months ago

VC86 commented 10 months ago

Hello,

I was trying to reproduce the results of your work on AMCW ToF simulation with simplified indirect lighting (using RSMs) as I'm interested in evaluating how fast this technique can run (by the way, very nicely written).

Among the equations reported in the paper, with reference to image one finds that:

Thanks (and thanks for your interesting work).

marlam commented 10 months ago

Hello, thank you for your interesting question!

CamSim contains a reimplementation of the RSM idea and does not implement the paper 1:1. It uses a different derivation of the light transport approximation, described in doc/illumination.tex (see illumination.pdf). This version intentionally avoids area estimations. Furthermore, it also avoids the problematic one-over-distance-squared term from Equation (10) because that breaks down for very small distances, e.g. in corners. See also src/simulation-everything-fs.glsl line 469ff.

There are more ways in which CamSim differs from the paper. For example, in CamSim the RSM is a cube map so that it can capture the entire environment.

I am not sure how the VPL area was estimated in the original implementation for the paper, and I don't have access to the original source code; if you need that, please contact A. Kolb.

As a side node, nowadays I would suggest using path tracing to simulate multipath effects (and all other relevant effects), even if your goal is speed, since GPUs can now accelerate path tracing too (even though rasterization will still be faster). See for example WurblPT for a CPU-based path tracer that implements ToF simulation.

VC86 commented 10 months ago

Dear @marlam,

thank you for this reply and your support! I have a few questions to clear out the differences between the paper and your implementation, if you don't mind. I fully agree that it could be possible to switch to path tracing but I'd still like to have at least the original option for comparison up and running.

Related to that:

Thanks again for your attention!

marlam commented 10 months ago

Hmm, it seems I did not remember the details correctly. There is indeed still a $1/r^2$ term in CamSim, in the attenuation_factor which models the OpenGL attenuation term. With the defaults attenuationConstant=1, attenuationLinear=0, attenuationQuadratic=1, it is basically $1/(1+r^2)$. This avoids the breakdown for $r<1$, but it just sweeps the problem under the rug instead of solving it. The CornellBox example uses attenuationConstant=0 to get the original $1/r^2$ behavior, presumably to be closer to physically based renderers.

Regarding VPL areas and scaling problems: unfortunately I cannot remember the details anymore. The changes in the CamSim model were made to use radiance and avoid area estimations where possible. For details regarding the original paper implementation, please contact A. Kolb.

Yes, $|RSM|$ is the cardinality, so it's basically the mean of all VPLs.

Yes, I think your formulation for Lambertian BRDFs is correct.

VC86 commented 10 months ago

Many thanks for these details @marlam , I asked directly Prof. Kolb for details on the area computation. I also see in some papers there is such a thing as clipping the geometry term (in your case, the weight factor) to avoid overshoots that cause known artifacts for $r \rightarrow 0$; will post the reference later. I will close the issue once I have reported back the answer.