=Paper= {{Paper |id=Vol-2763/CPT2020_paper_s6-7 |storemode=property |title=Synthesis methods for realistic images of three-dimensional scenes containing media with a refractive index gradient |pdfUrl=https://ceur-ws.org/Vol-2763/CPT2020_paper_s6-7.pdf |volume=Vol-2763 |authors=Dmitry Zhdanov,Igor Potemin,Andrey Zhdanov,Vladimir Galaktionov,Alexey Garbul }} ==Synthesis methods for realistic images of three-dimensional scenes containing media with a refractive index gradient== https://ceur-ws.org/Vol-2763/CPT2020_paper_s6-7.pdf
    Synthesis methods for realistic images of three-dimensional scenes
             containing media with a refractive index gradient
               D.D. Zhdanov1, I.S. Potemin1, A.D. Zhdanov1, V.A. Galaktionov2 , A.A. Garbu12
    ddzhdanov@mail.ru | ipotemin@yandex.ru | adzhdanov@itmo.ru | vlgal@gin.keldysh.ru | tnmik@gin.keldysh.ru
                                    1
                                      ITMO University, Saint Petersburg, Russia;
                         2
                           Keldysh Institute of Applied Mathematics RAS, Moscow, Russia

    The paper presents the results of a study of the possibility of implementing an effective and physically correct stochastic ray
tracing in gradient media based on the Runge-Kutta method. For implementation in the photorealistic rendering system, the specifics
of the ray tracing method in complex three-dimensional scenes were considered. One of the main features of ray tracing in
geometrically complex scenes is the large volume of geometric primitives that need to be tested for the intersection of the ray segment
with the primitives. A method of ray propagation in voxel space of the scene is proposed. The method allows significant speeding up
the process of searching for ray intersections with geometry primitives. To implement these ray tracing features the special program
interface for gradient media was proposed, which can become the basic interface for a media of all types. Methods for calculating the
luminance of all lighting components in gradient media were considered. The results of modeling the propagation of rays and image
synthesis in a fiber with a refractive index gradient are presented.
    Keywords: ray tracing, gradient medium, Runge-Kutta method, rendering, photon maps.

                                                                          If the optical properties of the medium (refractive
1. Introduction                                                       index) change continuously, then, following the Fermat
    The solution to the problem of realistic visualization            principle, the ray path takes the form of a curved line
of optically complex scenes and virtual prototyping of                having a minimum optical path from the start to
optical devices in a real environment is based on the                 endpoints of the path. The ray path is determined by the
construction of models of physically correct propagation              eikonal equation [1], for which, in general, there are
of light radiation in an optically complex environment.               numerical solutions [2, 3]. In computing optics, solutions
Within the framework of constructing models for the                   are used to calculate the ray path in a gradient lens
interaction of light radiation with scene objects and                 environment. However, the solutions used in
optical devices included in this scene, two main models               computational optics are used for simple geometric
are distinguished: - firstly, the conversion of light                 shapes that bound the gradient lens and, in most cases,
radiation at the boundaries of objects and, secondly, the             the laws of change in the refractive index are analytical
propagation of light radiation in the space between the               functions that have simple solutions.
boundaries of scene objects.                                              The ray tracing methods used in computer graphics
    Models of the conversion of light radiation at the                are fundamentally different from the methods of
boundaries of objects, for example, reflection and                    computational optics. The main difference is the number
refraction of light at the boundary of dielectrics,                   of geometric objects in the scene. If in computing optics
scattering of light on the surface, described by a                    the number of geometric primitives that limit the gradient
bidirectional scattering function, a change in polarization           medium is generally measured by units, then in computer
at the boundary of dielectrics, birefringence, etc., have             graphics systems this number can reach tens of millions.
gained a lot of attention in computer graphics and                    Besides, in computer graphics systems, the gradient of
computational optics. Models of light propagation in a                the refractive index may not be an analytical function, but
medium, as a rule, are limited by attenuation of light                rather be an analog of a three-dimensional texture that
radiation and, in some cases, by modeling such effects as             varies the refractive index of the medium. These
volume scattering and fluorescence. However, all these                differences lead to significant changes in software
models are based on the assumption that the propagation               interfaces and ray tracing algorithms. Also, computer
of light is rectilinear or straightforward. Even modeling             graphics systems are not limited to ray tracing. Their task
of such effects as volume scattering and fluorescence are             is to calculate the apparent luminance of the scene, and
also based on the assumption that the propagation of light            gradient media make it impossible to use standard
is straightforward. The specificity of these models is that           algorithms for calculating the luminance components of
the straightness of light radiation is limited by extinction          direct, secondary and caustic illumination.
events that occur when a beam “hits” a scattering                         In this paper, we consider methods of ray tracing in
particle. In this case, the particles are not defined                 gradient media inside a complex geometric environment,
explicitly but are reduced to such parameters as the                  methods for calculating the luminance components of
extinction cross-section, which determines the probability            direct, secondary, and caustic illumination and solutions
of the beam “being captured” by the scattering particle,              for the unification of ray tracing methods in gradient
and the phase function, which determines the character of             media for computer graphics systems and computational
the light scattering by the particle and plays the role of a          optics.
bidirectional scattering function of the surface. As a
                                                                      2. Materials and method
result, the ray path in a scattering or fluorescent medium
is a broken line, consisting of rectilinear segments.                     In the approximation of geometric optics the law of
                                                                      light propagation in a gradient medium is derived from


Copyright © 2020 for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY
4.0)
the Maxwell equations:
                                                                                               𝑟𝑟
                                                                                           𝑖𝑖�∫𝑟𝑟 𝑘𝑘(𝑟𝑟⃗′)∙𝑑𝑑𝑟𝑟⃗ ′ −𝜔𝜔𝜔𝜔�
                                           𝐸𝐸(𝑟𝑟⃗, 𝑡𝑡) = 𝐸𝐸(𝑟𝑟⃗)𝑒𝑒 −𝑖𝑖𝑖𝑖𝑖𝑖 = 𝐸𝐸0 (𝑟𝑟⃗)𝑒𝑒        0                           = 𝐸𝐸0 (𝑟𝑟⃗)𝑒𝑒 𝑖𝑖𝑖𝑖(𝑟𝑟⃗)
                                    �                                                           𝑟𝑟                                                                                                         (1)
                                                                                           𝑖𝑖�∫𝑟𝑟 𝑘𝑘(𝑟𝑟⃗′)∙𝑑𝑑𝑟𝑟⃗ ′ −𝜔𝜔𝜔𝜔�
                                           𝐻𝐻(𝑟𝑟⃗, 𝑡𝑡) = 𝐻𝐻(𝑟𝑟⃗)𝑒𝑒 −𝑖𝑖𝑖𝑖𝑖𝑖 = 𝐻𝐻0 (𝑟𝑟⃗)𝑒𝑒         0                          = 𝐻𝐻0 (𝑟𝑟⃗)𝑒𝑒 𝑖𝑖𝑖𝑖(𝑟𝑟⃗)
                   𝑟𝑟
where 𝜓𝜓(𝑟𝑟⃗) = ∫𝑟𝑟 𝑘𝑘(𝑟𝑟⃗′) ∙ 𝑑𝑑𝑟𝑟⃗ ′ represents the optical path                                   where 𝑡𝑡 is the reduced parameter of the ray path, 𝑇𝑇                                           �⃗(𝑟𝑟⃗) is
                   0
or eikonal.                                                                                          the optical ray vector, 𝐷𝐷                   �⃗(𝑟𝑟⃗) is the parameter of variation
    Passing to the geometric approximation, the eikonal                                              of the refractive index.
equation in vector form can be expressed as the                                                             As a result, after substituting expressions (3) into
following:                                                                                           equation (2), the eikonal equation is transformed to a
                   𝑑𝑑          𝑑𝑑𝑟𝑟⃗                                                                 first-order differential equation, which can be solved
                       �𝑛𝑛(𝑟𝑟⃗) � = ∇𝑛𝑛(𝑟𝑟⃗)        (2)                                              numerically by the Runge-Kutta method.
                  𝑑𝑑𝑑𝑑         𝑑𝑑𝑑𝑑
                                                                                                                                               𝑑𝑑𝑑𝑑(𝑟𝑟⃗)
where 𝑛𝑛(𝑟𝑟⃗) is the refraction index of the medium at the                                                                                                  = 𝐷𝐷(𝑟𝑟⃗)                                       (4)
                                                                                                                                                   𝑑𝑑𝑑𝑑
                        𝑑𝑑𝑟𝑟⃗
point 𝑟𝑟⃗, and 𝑠𝑠⃗(𝑟𝑟⃗) = is the direction (unit vector) of the                                             To solve this equation, discretization is performed
                         𝑑𝑑𝑑𝑑
                                                                                                     along with the curved segments 𝑡𝑡𝑖𝑖 of the ray path, where i
propagation of light energy. Fig. 1 shows the curved
                                                                                                     varies from 0 to N.
trajectory of the light ray and the vector of its direction at
                                                                                                            The initial parameters of the ray are known:
the point 𝑟𝑟⃗.
                                                                                                     (𝑟𝑟⃗0 , 𝑠𝑠⃗0 (𝑟𝑟⃗0 ), 𝜓𝜓(𝑟𝑟⃗0 )) and as a result of successive iterations,
    Obviously, in a homogeneous medium, the refraction
                                                                                                     the parameters of the ray at the endpoint N can be
index of the medium 𝑛𝑛(𝑟𝑟⃗) does not depend on the space
                                𝑑𝑑 2 𝑟𝑟⃗
                                                                                                     calculated: (𝑟𝑟⃗𝑁𝑁 , 𝑠𝑠⃗𝑁𝑁 (𝑟𝑟⃗𝑁𝑁 ), 𝜓𝜓(𝑟𝑟⃗𝑁𝑁 )).
coordinate 𝑟𝑟⃗ and thus 2 = 0. As a result, the ray path                                                    An algorithm for constructing a ray path can be
                          𝑑𝑑𝑠𝑠
turns into a straight line.                                                                          represented as follows:
                                                                                                     (1) We specify a certain increment Δ𝑡𝑡 of the ray path,
                                                                                                                which can be selected based on considerations of
                                                                                                                variation of the refraction index in the region of the
                                                                                                                point 𝑟𝑟⃗0 or proximity to the boundaries of the
                                                                                                                medium.
                                                                                                     (2) Following the Runge-Kutta method, the following
                                                                                                                parameters are calculated recursively, starting from
                                                                                                                point 𝑖𝑖 = 0:
             Fig. 1. A path of ray in a gradient medium
                                                                                                                        ⎧                        𝐴𝐴⃗ = Δ𝑡𝑡𝐷𝐷    �⃗(𝑟𝑟⃗𝑖𝑖 )
    To implement ray tracing in a medium with a gradient                                                                ⎪ 𝐵𝐵                               Δ𝑡𝑡                   Δ𝑡𝑡
                                                                                                                        ⎪ �⃗ = Δ𝑡𝑡𝐷𝐷       �⃗ �𝑟𝑟⃗𝑖𝑖 + 𝑇𝑇        �⃗(𝑟𝑟⃗𝑖𝑖 ) + 𝐴𝐴⃗�
of the refractive index, you can use the simplest solution,                                                                                                 2                      8
namely, imagine a gradient medium in the form of a set                                                                                                                            Δ𝑡𝑡                       (5)
of layers with constant refractive indices inside each                                                                  ⎨ 𝐶𝐶⃗ = Δ𝑡𝑡𝐷𝐷       �⃗ �𝑟𝑟⃗𝑖𝑖 + Δ𝑡𝑡𝑇𝑇     �⃗(𝑟𝑟⃗𝑖𝑖 ) + 𝐵𝐵       �⃗�
                                                                                                                        ⎪                                                          2
layer. In this case, the beam path will be a set of straight                                                            ⎪ �⃗                                     1
                                                                                                                                (𝑟𝑟 ) �⃗(𝑟𝑟 )                           ⃗          �⃗ ⃗
sections and a change in the direction of the beam path                                                                 ⎩ 𝑇𝑇 ⃗𝑖𝑖+1 = 𝑇𝑇 ⃗𝑖𝑖 + 6 �𝐴𝐴 + 4𝐵𝐵 + 𝐶𝐶 �
will occur at the boundaries of the layers. Fig. 2 (a)                                               (3) Following the calculated parameters, the ray is
illustrates this approach. The main advantage of this                                                           transferred to the point i + 1 and at this point, its
approach is the simplicity of ray tracing. However, this                                                        parameters are calculated: coordinates, energy
approach has several drawbacks, firstly, with a rough                                                           propagation direction and eikonal:
splitting, an error in the formation of the ray path is                                                                                                                1
possible, and with frequent splitting, it may slow down                                                  ⎧                𝑟𝑟⃗𝑖𝑖+1 = 𝑟𝑟⃗𝑖𝑖 + Δ𝑡𝑡 �𝑇𝑇    �⃗(𝑟𝑟⃗𝑖𝑖 ) + �𝐴𝐴⃗ + 2𝐵𝐵           �⃗��
                                                                                                         ⎪                                                             6
the tracing process, since the number of the ray path                                                                                                      �⃗(𝑟𝑟⃗𝑖𝑖+1 )
                                                                                                         ⎪                                                 𝑇𝑇
segments increases. Secondly, the process of constructing                                                ⎪                                  𝑠𝑠⃗𝑖𝑖+1 =
the boundaries of the medium for a given refractive index                                                                                                  𝑛𝑛(𝑟𝑟⃗𝑖𝑖+1 )
                                                                                                                                                                                                            (6)
is not an easy task and can be quite easily solved only for                                                                                           𝑘𝑘
                                                                                                         ⎨𝜓𝜓(𝑟𝑟⃗ ) = 𝜓𝜓(𝑟𝑟⃗ ) + Δ𝑡𝑡 [𝑥𝑥 2 (𝑟𝑟⃗ ) + 𝑥𝑥 2 (𝑟𝑟⃗ )] −
                                                                                                                                                         0
“simple” media in which there are some symmetry and                                                      ⎪
                                                                                                                     𝑖𝑖+1               𝑖𝑖+1
                                                                                                                                                         2                  𝑖𝑖+1                  𝑖𝑖

an analytical law of variation of the refractive index, for                                              ⎪               𝑘𝑘0 Δ𝑥𝑥 2
example, for gradient media with axial symmetry.                                                         ⎪                            �⃗(𝑟𝑟⃗𝑖𝑖+1 )𝑇𝑇
                                                                                                                                    �𝐷𝐷               �⃗(𝑟𝑟⃗𝑖𝑖+1 ) − 𝐷𝐷     �⃗(𝑟𝑟⃗𝑖𝑖 )𝑇𝑇
                                                                                                                                                                                      �⃗(𝑟𝑟⃗𝑖𝑖 )�
                                                                                                         ⎩                     6
Therefore, in most cases, another approach is used to
form the ray path.                                                                                   (4) The process is repeated until the ray reaches a given
    To solve the differential equation (2), an approach                                                         point.
based on the Runge-Kutta method is used. We introduce
the following notation:                                                                                  This algorithm provides high accuracy of ray transfer
                                      𝑑𝑑𝑑𝑑                                                           in a gradient medium, ensuring the continuity of its
           ⎧                    𝑡𝑡 =                                                                 trajectory. Fig. 2 (b) illustrates the specifics of the ray
           ⎪                           𝑛𝑛
                                                                                                     tracing algorithm in a gradient medium.
                        𝑑𝑑𝑟𝑟⃗                             𝑑𝑑𝑟𝑟⃗ (3)
             �⃗(𝑟𝑟⃗) =
           ⎨𝑇𝑇                = 𝑛𝑛(𝑟𝑟⃗)𝑠𝑠⃗(𝑟𝑟⃗) = 𝑛𝑛(𝑟𝑟⃗)
           ⎪            𝑑𝑑𝑑𝑑                              𝑑𝑑𝑑𝑑
           ⎩           �⃗(𝑟𝑟⃗) = 𝑛𝑛(𝑟𝑟⃗)∇𝑛𝑛(𝑟𝑟⃗)
                       𝐷𝐷
              Fig. 2. Ray tracing methods in a gradient environment. (a) piecewise linear trajectory, (b) continuous trajectory

                                                                       searching for the intersection of a ray with geometry
3. Ray tracing algorithms                                              (which does not fundamentally differ from the algorithm
        The above approaches allow ray tracing in media with           considered in the first case), it is necessary to implement
a refractive index gradient. However, these methods are                an algorithm for ray tracing in voxel space. Fig. 3
suitable for unlimited environments. In reality, all media             illustrates the problem of ray tracing in a spatially
are limited and it is necessary to take into account the               partitioned gradient media. Geometric objects in the
shape of the geometric objects that bound this medium.                 scene are tied to spatial voxels and, to accelerate the ray
Two main types of constraints of the gradient medium                   tracing process, the search for the point where the ray
can be distinguished. Firstly, these are simple optical                meets these objects is carried out only when the ray
elements, for example, gradient lenses [4-7]. The                      enters the corresponding voxel. The algorithm proposed
peculiarity of these objects is a small number of                      for finding the point of intersection of the ray with the
geometric shapes that limit this environment. As a rule,               surface is not applicable for searching for the entry point
these are simple analytical objects, such as planes,                   to the voxel, since the voxel found after transferring the
cylinders, and spheres. Secondly, these are complex                    ray to the point 𝑟𝑟⃗𝑖𝑖+1 may not be the next one. It may
three-dimensional scenes that can form the limitation of a             ultimately lead to the omission of a geometric object. The
gradient medium consisting of millions of independent                  use of a chord or tangent segment of a ray can also lead
triangles. Naturally, the search algorithms for the                    to the problem of skipping a geometric object. Fig. 3
intersection of the curved path of the beam with the                   illustrates this possibility. Therefore, to search for the
boundary of the gradient medium will be specific for                   next voxel and its entry point, it is necessary to find the
these two cases.                                                       point of intersection of the ray with the boundary of the
        In the first case, it is enough to implement an                current voxel. Since the voxel, as a rule, has the shape of
additional method for a geometric object, which will                   a parallelepiped with planes parallel to the coordinate
inform you on which side of the surface there is a point               planes, the algorithm for finding the intersection point
offset from the current position by a distance Δ𝑡𝑡. If the             with its boundaries is greatly simplified:
point remains in the gradient medium, then the ray                     (1) We specify the starting point (𝑟𝑟⃗0 , 𝑠𝑠⃗0 (𝑟𝑟⃗0 )) and (based
tracing process (formulas (5) and (6)) continues. If the                    on the parameters of the gradient medium) the ray
point leaves the gradient medium, then the iterative                        transfer parameter Δ𝑡𝑡.
process of refinement of the search for the point of                   (2) Parameters 𝐴𝐴⃗, 𝐵𝐵  �⃗, 𝐶𝐶⃗ , 𝑇𝑇
                                                                                                         �⃗(𝑟𝑟⃗𝑖𝑖+1 ) are calculated by the
intersection of the ray with the boundary surface begins.                   formula (5), and then 𝑟𝑟⃗𝑖𝑖+1 by formula (6).
Наиболее The simplest process is to search for the                     (3) If the point 𝑟𝑟⃗𝑖𝑖+1 lies inside the voxel, then the ray
intersection of the straight segment of the ray formed                      transfer parameter Δ𝑡𝑡 is taken as the initial parameter
either by the chord (𝑟𝑟⃗𝑖𝑖+1 − 𝑟𝑟⃗𝑖𝑖 ), or tangent to the ray path          to search for the point where the beam meets the
(𝑠𝑠⃗𝑖𝑖 ). The obtained distance is converted into the                       geometric objects inside the voxel.
parameter Δ𝑡𝑡 and the calculation of the new position of               (4) If the point 𝑟𝑟⃗𝑖𝑖+1 is outside the voxel boundary, then
the point i+1 starts from point i. This process is repeated                 an iterative approaching is made to the voxel
until the point i+1 approaches the surface so close that                    boundary, the task of which is to find a point on the
the last approximation can be replaced by a simple                          boundary and determine the beam transfer parameter
rectilinear segment of the ray path. As a rule, two or three                to this point Δ𝑡𝑡. In this case, the point 𝑟𝑟⃗𝑖𝑖+1 and the
iterations are enough to find the point of intersection of                  transfer parameter Δ𝑡𝑡 are chosen in such a way that
the beam with optical accuracy.                                             the point turned out to be a small distance beyond
        In the second case, when ray tracing in a three-                    the voxel border. However, if no intersection with
dimensional scene containing millions of triangles, the                     the geometry inside the voxel was found, then to
situation is completely different. The main reason is the                   search for a new border inside the next voxel, the
spatial partitioning of the scene. The ray is not traced                    point and the transfer parameter return to a short
directly from the surface to the surface. The beam                          distance inside the current voxel.
propagates in a voxel space, which divides the medium                  (5) If an intersection with a geometric object inside the
into some volumes, usually in the form of a                                 voxel was found, then the beam is converted at the
parallelepiped. These volumes may or may not contain                        boundary of the geometric object. And, if the beam
elements of the boundary of the scattering medium.                          remains in the gradient medium, the procedure for
Before reaching the boundary of the medium, the ray                         searching for the intersection of the beam with the
must sequentially cross and process all the voxels located                  boundary of the current voxel is repeated.
on its path. Therefore, in addition to the algorithm for
   To implement the ray tracing method in three-                         provided the basic functionality necessary for ray tracing.
dimensional scenes containing gradient media, a gradient                 The main methods of the environment interface should:
media program interface was implemented, which




                                     Fig. 3. Ray tracing methods in a spatially split stage gradient medium

(1) Determine the optimal beam transfer parameter from                   (7) Calculate the absorption of the ray when it is
    the point 𝑟𝑟⃗𝑖𝑖 in the direction 𝑠𝑠⃗𝑖𝑖 (𝑟𝑟⃗𝑖𝑖 ). If the medium           transferred from the point 𝑟𝑟⃗𝑖𝑖 to the point 𝑟𝑟⃗𝑖𝑖+1 .
    does not have gradient properties, then the transport
    parameter is set to infinity and a direct ray tracing is                These interfaces are enough to implement ray tracing
    realized. The beam transfer parameter can take into                  in gradient media of optical devices and three-
    account the spatial partitioning properties of the                   dimensional scenes. Besides, the implementation of these
    scene and, if necessary, be calculated up to the                     programming interfaces at a basic level will allow the
    border of the nearest voxel.                                         implementation of ray tracing methods that will not
(2) For the set 𝜆𝜆0 , 𝜆𝜆1 , 𝜆𝜆2 , … 𝜆𝜆𝑀𝑀 of wavelengths determine        depend on the properties of the environment in which
    the subset of wavelengths for which ray tracing                      they are distributed. This solution will greatly simplify
    along one path is possible, i.e. no dispersion.                      the implementation of image synthesis methods and, in
(3) Calculate the refraction index of the medium at the                  some cases, will avoid the need to impose additional
    point 𝑟𝑟⃗𝑖𝑖 .                                                        conditions on the scene parameters in the rendering
(4) Calculate the gradient of the refraction index of the                process.
    medium at the point 𝑟𝑟⃗𝑖𝑖 .
(5) Осуществлять перенос луча из точки 𝑟𝑟⃗𝑖𝑖 в току                      4. Luminance calculation algorithms
    𝑟𝑟⃗𝑖𝑖+1 и вычислять новое направление в конце                                      The methods for calculating the luminance of the
    трассы луча 𝑠𝑠⃗𝑖𝑖+1 (𝑟𝑟⃗𝑖𝑖+1 ).                                             scene's scattering surfaces located in gradient media have
(6) Calculate the optical path and geometric path of the                        their specifics. The visible luminance of the scene object
    ray from the point 𝑟𝑟⃗𝑖𝑖 to the point 𝑟𝑟⃗𝑖𝑖+1 .                             is determined by the well-known formula [8]:
                                                                                   𝐿𝐿0 (𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗) +
                                                       𝑛𝑛(𝜆𝜆, 𝑟𝑟⃗)     4𝜋𝜋
                         𝐿𝐿(𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗) = 𝜏𝜏(𝜆𝜆, 𝑡𝑡)             �1                                                              �   (7)
                                                                                                                    �⃗ ∙ 𝑣𝑣⃗′�𝑑𝑑𝑑𝑑
                                                       𝑛𝑛′(𝜆𝜆, 𝑟𝑟⃗) � 𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵(𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗, 𝑣𝑣⃗′)𝐿𝐿(𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗′)�𝑁𝑁
                                                                    𝜋𝜋
where: 𝐿𝐿0 (𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗) is the own luminance of the observed           (1) The luminance of direct vision is the intrinsic
object at a wavelength 𝜆𝜆, at a point 𝑟𝑟⃗ and in the direction               luminance of the surface that the observer sees
𝑣𝑣⃗, 𝜏𝜏(𝜆𝜆, 𝑡𝑡) – medium transmission at wavelength 𝜆𝜆 and on                directly or through a series of "mirror" surfaces. For
the path t from the luminance source to the observer,                        surfaces in gradient media, this luminance
𝑛𝑛(𝜆𝜆, 𝑟𝑟⃗) – index of refraction at the observer point,                     component can be calculated directly, for example,
𝑛𝑛′(𝜆𝜆, 𝑟𝑟⃗) – index of refraction at the point of formation of              by the ray tracing method.
luminance, 𝐿𝐿(𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗′) - the luminance of the light source         (2) The luminance of caustic illumination is the
illuminating the surface at a wavelength 𝜆𝜆, at a point 𝑟𝑟⃗ in               brightness of the surface that the observer sees
the direction 𝑣𝑣⃗′, 𝑁𝑁      �⃗ – the direction of the local normal to        directly or through a series of “mirror” surfaces
the surface at the point of illumination 𝑟𝑟⃗,                                illuminated through the “mirror” surfaces. To
𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵(𝜆𝜆, 𝑟𝑟⃗, 𝑣𝑣⃗, 𝑣𝑣⃗′) - The bidirectional scattering                  calculate this luminance component, the most
distribution function of the surface (that is how many                       suitable method would be a method based on the use
times the brightness of a surface under given lighting and                   of photon maps [9]. Caustic lighting maps are
observation conditions differs from the brightness of an                     created by stochastic rays emitted from light sources,
ideal diffuser) at wavelength 𝜆𝜆, at a point 𝑟𝑟⃗, in direction               stored, and then “read” in accordance with equation
of illumination 𝑣𝑣⃗′ and in the direction of observation 𝑣𝑣⃗.                (7) as the intrinsic luminance of the observed object.
The integration of luminance is carried out over the entire                  This approach is technically applicable for surfaces
hemisphere of the illumination of the observation surface.                   in gradient media, and requires only additional
      For the computing method, the luminance can be                         analysis of the ray hit the caustic map.
represented as the sum of the four components visually
presented in Fig. 4:
                                          Fig. 4. Four components of visible luminance

(3) The luminance of direct illumination is the                       methods). The classical methods of bi-directional ray
    luminance of the surface that the observer sees                   tracing can also be inefficient since they allow the
    directly or through a series of “mirror” surfaces                 possibility of connecting the paths of forward and
    directly illuminated by light sources. To calculate               backward rays through gradient media, which cannot
    this brightness component, as a rule, the method of               be effectively implemented in the physically correct
    multiple importance sampling is used, weighting the               approximation of ray tracing. Therefore, the most
    brightness learned from the choice of points on the               suitable solution to the problem of calculating the
    light source (light sampling - which allows you to                brightness of secondary illumination is the method of
    calculate the luminance of direct illumination using              bi-directional ray tracing using photon maps. From a
    radiometric ratios) and the choice of direction in the            practical point of view, this method is implemented
    bidirectional scattering function (BDF sampling -                 similarly to the method for calculating the brightness
    allowing the method of calculating shadow rays to                 of caustic illumination. The only difference is that
    find the brightness of visible light sources) [10]. In            photonic maps are formed at the second and further
    most cases, the main contribution is made by the                  distant diffuse scattering events.
    method of choosing points on the light source,
    however, this method cannot be applied to the case              The above solutions allow you to implement
    of surface illumination through gradient media               physically correct rendering of scenes containing gradient
    (radiometric ratios do not allow calculating                 media.
    luminance efficiently and correctly). The method of
    choosing directions for the bidirectional scattering         5. Results
    function has several serious limitations, for example,           The ray tracing method and photorealistic rendering,
    it cannot be applied to scenes containing small-sized        based on the forward stochastic ray tracing method in
    light sources. Therefore, to calculate the brightness        scenes containing gradient media, was implemented as
    when illuminating a surface through a gradient               part of the Lumicept computer-based photorealistic
    medium, it is necessary to use the photon map                image synthesis system [13]. Besides, a method for
    method, which is technically implemented as a                visualizing ray paths propagating in a medium with a
    method for calculating the luminance of caustic              refractive index gradient was implemented.
    illumination. If there are extended light sources of             As an example, a scene was constructed consisting of
    large size, weigh it with the method of selecting            a cylindrical fiber with a refractive index varying from
    directions according to the bidirectional scattering         axis to edge (as shown in Fig. 5), a small-sized LED
    function.                                                    source illuminating the end of the fiber, and a radiation
(4) The luminance of the secondary illumination is the           receiver which detects the component of caustic
    brightness of the surface that the observer sees             illumination on the opposite end of the fiber. As an
    directly or through a series of “mirror” surfaces            alternative, a scene was built consisting of a series of
    illuminated by light scattered on the diffuse surfaces       cylinders in optical contact. The radius of the cylinder
    of the scene. To calculate this luminance component,         was determined from the condition that the refraction
    forward ray tracing method, backward ray tracing             index changes by 0.005. Modeling was carried out at
    methods, path tracing methods [11], or various               various parameters of the beam displacement. The
    options based on bi-directional ray tracing methods          number of steps varied from 20 to 100. The ray path
    [12] are used. If the scene contains gradient media,         remained practically unchanged and the synthesized
    then the use of ray tracing methods and methods of           image remained unchanged. The simulation results
    path tracing in most cases becomes ineffective. The          showed a match with the simulation results for the
    main reason is the low probability that the rays hit         alternative scene. Images of several ray paths and the
    the observer’s receiver (in forward ray tracing              distribution of illumination behind the end of the fiber are
    methods) or the light source (in backward ray tracing        shown in Fig. 5.
    Fig. 5. Variation of the refractive index from the center to the edge of the fiber, the beam path inside the fiber and the distribution
                                      of illumination behind the end of the fiber (from left to right)

   The coincidence of the simulation results obtained in                [8] Kajiya, James T. (1986), "The rendering equation"
various ways indirectly confirms the correctness of the                      (PDF),       Siggraph     1986:     143–150,     doi:
chosen implementation of the ray tracing method.                             10.1145/15922.15902
                                                                        [9] Jensen H.W. (1996) Global Illumination using
6. Conclusion                                                                Photon Maps. In: Rendering Techniques ’96.
    In the framework of this study, an effective and                         Eurographics, pp. 21–30. Springer, Vienna.
physically correct method of ray tracing in gradient                         https://doi.org/10.1007/978-3-7091-7484-5_3
media was proposed. For implementation in the                           [10] Vincent Pegoraro, [Handbook of Digital Image
photorealistic rendering system, a gradient software                         Synthesis: Scientific Foundations of Rendering],
interface was proposed, which can become the basic                           CRC Press, 2017
interface for all types of media. Methods were proposed                 [11] Kang, C., Wang, L., Xu, Y. et al. A survey of photon
for calculating the luminance of all lighting components                     mapping state-of-the-art research and future
in gradient media.                                                           challenges. Frontiers Inf Technol Electronic Eng 17,
    The main tasks that are planned as part of the                           185-199                                       (2016).
expansion of the proposed approach are, firstly, to                          https://doi.org/10.1631/FITEE.1500251
determine the optimal parameter for beam movement in                    [12] Georgiev, I., Krivanek, J., Slusallek, P.:
free space, which should provide a given accuracy of the                     Bidirectional light transport with vertex merging. In:
position of the new point in space and the new direction                     SIGGRAPH Asia 2011, pp. 27:1-27:2, ACM, New
of beam propagation, and, secondly, to develop an                            York, NY, USA (2011).
effective method for determining the parameter of ray                   [13] Hybrid Light Simulation Software Lumicept //
tracing to the boundary of the spatial cell of the scene                     Integra.jp.                                     URL:
(voxel).                                                                     https://integra.jp/en/products/lumicept (date of call
                                                                             10.03.2020)
Asknowledges
                                                                        About the authors
   The work was supported by RFBR, Grants № 18-08-
                                                                            Zhdanov Dmitry D., PhD, Head of the Visualization
01484, 19-01-00435, 20-01-00547.
                                                                        Technology     Chair    of    ITMO       University. E-mail:
References                                                              ddzhdanov@mail.ru.
                                                                            Potemin Igor S., PhD, Assistant of the Visualization
[1] Max Born and Emil Wolf, Principles of Optics.                       Technology     Chair    of    ITMO       University. E-mail:
    Pergamon Press, Fourth edition, 1970.                               ipotemin@yandex.ru.
[2] Handbook of optics / sponsored by the Optical                           Zhdanov Andrey D., Ph.D student at ITMO University,
                                                                        Visualization Technology chair. E-mail: adzhdanov@itmo.ru
    Society of America; Michael Bass, editor in chief. -
                                                                            Galaktionov Vladimir A., Professor, Doctor of Science in
    2nd ed., McGraw-Hill , Inc., 1995, ch.9.                            physics and mathematics, head of the Department of computer
[3] R. K. Luneburg, Mathematical Theory of Optics,                      graphics and computational optics at Keldysh Institute of
    University of California Press, 1966, pp.182-195.                   Applied Mathematics RAS. E-mail: vlgal@gin.keldysh.ru
[4] D. T Moore, "Gradient-Index Optics: A Review,"                          Garbul Alexey A., researcher of Department of computer
    Appl. Opt. 19, 1038-1035 (1980)                                     graphics and computational optics at Keldysh Institute of
[5] E. W. Marchand, [Gradient Index Optics], Academic                   Applied Mathematics RAS. E-mail: tnmik@gin.keldysh.ru
    Press, New York, NY, (1978).
[6] Applied Digital Optics: From Micro-optics to
    Nanophotonics Bernard C. Kress and Patrick
    Meyrueis 2009 John Wiley & Sons, Ltd
[7] Sawyer D. Campbell, Jogender Nagar, Donovan E.
    Brocker, John A. Easum, Jeremiah P. Turpin,
    Douglas H. Werner, "Advanced gradient-index lens
    design tools to maximize system performance and
    reduce SWaP," Proc. SPIE 9822, 98220P (17 May
    2016); doi: 10.1117/12.2223040