<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Calculation of Noise Components for Bidirectional Path Tracing with Photon Maps?</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Keldysh Institute of Applied Mathematics RAS</institution>
          ,
          <addr-line>Miusskaya sq. 4, 125047 Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The classic Monte-Carlo ray tracing is a powerful method which allows to simulate virtually all effects in ray optics, but it may be inadmissibly slow for many cases, such as calculation of images seen by a lens or pin-hole camera. In this cases another stochastic method is more efficient such as the bi-directional ray Monte-Carlo tracing with photon maps (BDPM). The level of noise i.e. the r.m.s. (“root mean square”) of pixel luminance calculated in one iteration of the method, depends on various parameters of the method, such as the number of light and camera paths, radius of integration sphere etc. so it is desirable to be able to predict this dependence to choose optimal parameters of the method. It was shown that this r.m.s is a sum of 3 functions scaled by reverse number of camera and light rays. These functions themselves are independent of the number of rays, so knowing them one can predict the noise for any number of rays and thus find the optimal one. These functions are a sort of correlations and their calculation from ray tracing is not a trivial problem. In this paper we describe a practical method of calculation and demonstrate the usage of its results for the choice of ray number.</p>
      </abstract>
      <kwd-group>
        <kwd>Realistic Rendering</kwd>
        <kwd>Bi-directional Monte-Carlo Ray Tracing</kwd>
        <kwd>Photon Maps</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Currently simulation of light propagation is widely used not only in optical engineering
but also in design of new materials. It is intensively applied in architectural,
automotive and aircraft design tasks. If wave effects can be neglected, a kind of stochastic
ray tracing is a good choice. This realm mainly includes Metropolis Light Transport
and Monte-Carlo ray tracing (MCRT) method [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. When an image is to be calculated
the classic forward ray tracing from light source is inefficient and so is replaced with
various bi-directional modifications [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Of them we consider the so-called
bidirectional Monte-Carlo ray tracing with photon maps (BDPM) [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The weak side
of all stochastic methods is that their results are noisy, and so is this one, thus much
work had been done to decrease it [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
? Publication is supported by RFBR grant 20-01-00547
      </p>
      <p>
        The level of noise in this method mainly depends on the method of random
scattering of the forward and backward rays, on choosing the vertex to merge (or, in other
words, in which vertex of the camera path to use photon maps for estimation of the
illumination) and, at last, on the number of forward and backward rays traced during
one iteration. Most publications are devoted to the first two means, for example, [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ],
[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] or [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], while less attention had been paid to the number of rays. Meanwhile it
is an important factor and frequently it happens that e.g. the number of forward rays is
already superfluous, so increasing it further does not decrease noise but only increases
the run time. In other cases it happens that the number of forward rays is really critical
while we traced excess number of camera rays. It is usually difficult to predict which
proportion of them is optimal while its good choice may accelerate calculations several
times.
      </p>
      <p>
        In this paper we address the latter problem. In [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] the general law which determines
the noise in BDPM had been derived. It states that the variance of pixel luminance is
a sum of three components scaled by inverse number of rays. These 3 components are
independent from the number of rays and thus once calculated, at least approximately,
they can be later used to predict how the noise level depends on the number of rays
traced in one iteration and thus choose the better number of rays. In other words, had
we knew these 3 components (which usually depend on pixel) we would be able to
predict the noise level for any number of rays.
      </p>
      <p>Although their mathematical definition is trivial, these three values are not that easy
to calculate numerically by ray tracing. In this paper we describe a method of their
efficient calculation and demonstrate their usage to choose the optimal number of rays.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Noise in BDPM</title>
      <p>Usually BDPM proceeds iteration by iteration. In each iteration we trace NF light
(“forward”) paths and, for each pixel p, NB(p) camera (“backward”) paths. Then each light
path is checked against each camera path and if there are vertices they run close, they are
“merged” into a join path (which connects camera and light source). We then calculate
contribution of this join path to the luminance of pixel and increment pixel luminance
by this value. The accumulated sum, divided by NF NB(p)NI where NI is the number
of iterations, converges to the expectation. This average is independent from NF and
NB(p), but the noise (variance) is. Say, if there is already too many light paths while
few camera paths, tracing these excess light rays only takes time without gain, so it is
advantageous to reduce their number.</p>
      <p>
        The optimal number of rays (total per scene for light paths and individually for each
pixel for camera paths) is that which results in the least noise after the fixed calculation
time. To solve this minimization problem we need to know how the variance of the
value produced in one iteration depends on that number of rays. This dependence is
described by the 3-term law [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], but its terms are not that easy to calculate numerically.
      </p>
      <p>Here and below we shall always speak about the values for one given pixel p and so
drop this notation, writing NB instead of NB(p) etc.</p>
      <p>
        As shown in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], the variance of pixel luminance calculated in one iteration is
      </p>
      <p>Calculation of Noise Components for BDPM 3
where C(X(F ); X(B)) is the contribution to pixel luminance from “merging” the light
path X(F ) and camera path X(B), its average hhCii is obviously the limiting pixel
luminance L, and h iF , h iB denote the averages over the ensemble of light and camera
paths, respectively.</p>
      <p>
        Notice this law holds regardless of whether we use Multiple Importance Sampling
[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] or not which only affects the values of hhC2ii, hhCi2F iB and hhCi2BiF .
      </p>
      <p>Calculation of hhC2ii is easy: whenever we add C to the pixel luminance, we also
add C2 to the “error image”. Then at each iteration we calculate</p>
      <p>C</p>
      <p>1 XNB XNF C2(Xi(F ); Xj(B))</p>
      <p>NBNF j=1 i=1
and averaging it over iterations C just gives what we need: C ! hhC2ii. But with
hhCi2F iB and hhCi2BiF we face difficulty.</p>
      <p>For example, let us suppose there is very many light paths per iteration. Then for
each camera ray the sum over them gives a good approximation to hCiF . The average
over camera paths is bad because normally we have a few (10, max. 100) camera paths
through one pixel per iteration. But if we additionally average over iterations, we get
a good approximation to hhCi2F iB. This, however, does not work if there are not that
many light paths (to be precise, not that many intersections). In this case the average
over light paths from one iteration deviates seriously from hCiF . Meanwhile
averaging the squared value over iterations may give averaged square, not square of average
because averaging over iterations is hh ii. What to do then?</p>
      <p>Solution is very simple. Let the number of light and camera paths traced in one
iteration be the same (for all iterations). To calculate hhCi2F iB, let us subdivide the
set of light paths traced in one iteration into two halves containing NF1 and NF2 rays.
Then, let at each iteration
(1)
(2)
(3)
Its average over iterations is just hhCi2F iB. Indeed, the average over iterations is
hh iF iB = hh iBiF , because of linearity the order of averaging has no effect. For
any camera path Xj(B) the two inner sums are independent because the two halves
of light paths are statistically independent. The average of each of them is naturally
hCiF (Xj(B)). Therefore averaging it over iterations</p>
      <p>B = hhBiF iB = hhCiF hCiF iB = hhCi2F iB
(4)
gives just what we need.</p>
      <p>Similarly, to calculate hhCi2BiF we subdivide the set of camera paths (through the
pixel) into two halves, NB1 and NB2 , calculate at each iteration
F</p>
      <p>NF 00
1 X</p>
      <p>1</p>
      <p>X
and average it over iterations.</p>
      <p>Notice the two halves have not to be equal (i.e. contain a different number of rays).
Usually it is convenient to relate odd rays to the first half and even rays to the second
half.</p>
      <p>Knowing these quadratic averages and the limiting image luminance L one can
calculate the variance of pixel luminance as</p>
      <p>Notice C; B; F as well as L depend on pixel but are independent of the number of
rays. This latter property is very important because allows to predict noise level for
any number of rays. One can perform calculation for some inoptimal number of rays
and find C; B; F ; L and then find the number of rays (with NB generally depending on
pixel) which minimizes the noise.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Results</title>
      <p>
        We traced the famous Cornell Box with an isotropic point light source slightly below
the center of the floor. All scene surfaces are gray Lambert with albedo 50%. Both
direct and indirect illumination was taken from photon maps. Integration sphere radius
was 1/120 of the scene size. “Diffuse depth” i.e. the maximal allowed number of diffuse
events for camera ray [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] was BDD=1. Scene image is shown in Figure 1.
      </p>
      <p>Pixel luminance calculated in one iteration is a random value which is independent
from another iteration. Therefore the reference value of noise can be calculated directly
from the sample variance of the series of iterations. Also, the above 3 noise terms had
been calculated as described above and the total noise had been calculated from them
according to (6).</p>
      <p>The amplitude of noise calculated by these two ways are shown in Figure 2. One
can see that these latter nearly coincide.</p>
      <p>The contribution of the three noise components is shown in Figure 3.</p>
      <p>Fig. 3. Noise components q NF1NB (C L2); q 1 NNBF 1 (B L2); q 1 NNFB 1 (F L2) put into
the R, G and B color channel of the image. Left panel: NB = 100, right panel: NB = 300. In
both cases NF = 300000. The average values of the three components over the red rectangle is
(0:0293; 0:595; 0:229) in the left image and (0:0169; 0:344; 0:230) in the right one, so the first
two components decreased just p3 times. Average r.m.s. over the red rectangle is 0.639 in the
left image and 0.414 in the right one.</p>
      <p>In Figure 3, q NF1NB (C L2), q 1 NNBF 1 (B L2) and q 1 NNFB 1 (F L2) are put
into the R, G and B color channels. One can see that the image is mainly green, i.e.
the second component dominates. Since C; B; F and L are independent of the number
of rays, to reduce noise one needs to increase the number of camera rays per pixel NB
while increase of the number of light rays is nearly useless. Results for NB increased
to 300 are shown in the right panel of Figure 3.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>We proposed a method for calculation the components C; B; F of the noise in BDPM
and demonstrated how it can be used to choose the optimal number of rays traced in
one iteration of the BDPM method.</p>
      <p>The noise itself can be calculated directly from the sample variance of the series
of values accumulated in successive iterations, but this does not let one decide which
number of rays (camera or light) is critical and must be increased. Meanwhile knowing
the three noise components C; B; F one can see which of them dominates and thus
which number of rays (camera or light) must be increased. If time spent on tracing
camera and light rays is known together with time spent on their merging, one can also
calculate the optimal number of rays i.e. the one which gives the smallest noise during
the same calculation time.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Pharr</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Humphreys</surname>
          </string-name>
          , G.:
          <article-title>Physically Based Rendering, Second Edition: From Theory To Implementation</article-title>
          . Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 2nd edn. (
          <year>2010</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Dodik</surname>
          </string-name>
          , N.:
          <article-title>Implementing probabilistic connections for bidirectional path tracing in the Mitsuba Renderer (Sep</article-title>
          <year>2017</year>
          ), https://www.cg.tuwien.ac.at/research/publications/2017/dodik2017-pcbpt.
          <source>Last accessed 01 Sep</source>
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Jensen</surname>
            ,
            <given-names>H.W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Christensen</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>High quality rendering using ray tracing and photon mapping</article-title>
          .
          <source>In: ACM SIGGRAPH</source>
          <year>2007</year>
          <article-title>Courses</article-title>
          . ACM, New York, NY, USA (
          <year>2007</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Veach</surname>
          </string-name>
          , E.:
          <article-title>A dissertation: Robust Monte-Carlo methods for light transport simulation (</article-title>
          <year>1997</year>
          ), http://graphics.stanford.edu/papers/veach thesis/thesis.pdf.
          <source>Last accessed 01 Sep</source>
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Vorba</surname>
          </string-name>
          , J.:
          <article-title>Bidirectional photon mapping</article-title>
          .
          <source>In: Proceedings of CESCG 2011: The 15th Central European Seminar on Computer Graphics</source>
          . pp.
          <fpage>25</fpage>
          -
          <lpage>32</lpage>
          . Charles University, Prague (
          <year>2011</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Ershov</surname>
            ,
            <given-names>S.V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhdanov</surname>
            ,
            <given-names>D.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Voloboy</surname>
            ,
            <given-names>A.G.</given-names>
          </string-name>
          :
          <article-title>Estimation of noise in calculation of scattering medium luminance by MCRT</article-title>
          .
          <source>Mathematica Montisnigri</source>
          <volume>45</volume>
          ,
          <fpage>60</fpage>
          -
          <lpage>73</lpage>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Georgiev</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          , Krˇiva´nek, J., Davidovicˇ, T.,
          <string-name>
            <surname>Slusallek</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Light transport simulation with vertex connection and merging</article-title>
          .
          <source>ACM Trans. Graph</source>
          .
          <volume>31</volume>
          (
          <issue>6</issue>
          ),
          <volume>192</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>192</lpage>
          :
          <fpage>10</fpage>
          (Nov
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Hachisuka</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pantaleoni</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jensen</surname>
            ,
            <given-names>H.W.:</given-names>
          </string-name>
          <article-title>A path space extension for robust light transport simulation</article-title>
          .
          <source>ACM Trans. Graph</source>
          .
          <volume>31</volume>
          (
          <issue>6</issue>
          ),
          <volume>191</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>191</lpage>
          :
          <fpage>10</fpage>
          (
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Ershov</surname>
            ,
            <given-names>S.V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhdanov</surname>
            ,
            <given-names>D.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Voloboy</surname>
            ,
            <given-names>A.G.</given-names>
          </string-name>
          :
          <article-title>Calculation of MIS weights for bidirectional path tracing with photon maps</article-title>
          .
          <source>In: Proceeding of conference on Computing for Physics and Technology</source>
          . pp.
          <volume>20</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>20</lpage>
          :
          <fpage>5</fpage>
          .
          <string-name>
            <surname>Moscow</surname>
          </string-name>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Sbert</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Havran</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Szirmay-Kalos</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Multiple importance sampling revisited: breaking the bounds</article-title>
          .
          <source>EURASIP Journal on Advances in Signal Processing 15</source>
          ,
          <fpage>1</fpage>
          -
          <lpage>15</lpage>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Hachisuka</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jensen</surname>
            ,
            <given-names>H.W.</given-names>
          </string-name>
          :
          <article-title>Stochastic progressive photon mapping</article-title>
          .
          <source>In: ACM SIGGRAPH Asia 2009 Papers</source>
          . pp.
          <volume>141</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>141</lpage>
          :
          <fpage>8</fpage>
          . ACM, New York, NY, USA (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>