1 Introduction

Opal exhibits a captivating “play of color,” an optical phenomenon characterized by shimmering iridescence patterns (see the supplementary video). This is primarily due to its composition of multiple colloidal layers on the scale of the visible light wavelength, forming what is known as colloidal polycrystalline. Concerning the optical property that diffracts visible light, research and development has been conducted for practical applications, such as quantum information processing [30] and electrophoretic color displays [2]. Opal also has been used in jewelry since ancient times and is thus invaluable, not only as a raw material from an industrial perspective but also as a cultural treasure from the historical and artistic perspectives.

Due to the complexity of its internal structure, no method exists at present to represent to represent opal realistically in computer graphics (CG). Considering that each colloid in opal is only about a few hundred nanometers in diameter and that opal stones are usually tens of millimeters in size, it is currently impractical to model the internal structure of opal directly using today’s computers due to their memory limitations. Therefore, it is imperative to develop a model that retains the visual characteristics of opal’s play of color while also simplifying the internal structure for efficient optical computations.

In this study, the complex internal structure of opal is plausibly modeled using the three-dimensional (3D) additively weighted Voronoi tessellation and percolation model of the graph formed by its sites. In addition, the diffraction patterns of visible light within opal are computed via path tracing by applying the Ewald construction, a technique commonly utilized in X-ray diffraction (XRD) theory. The final output image is obtained through spectral rendering, which is responsible for the diffraction, scattering, and absorption occurring inside opal. An overview of the proposed approach is given in Fig. 1, while the results of the visual simulation are shown in Figs. 11, 12 and 13.

The remainder of this paper is organized as follows. The next section summarizes existing studies related to the visual simulation of opal. Section 3 introduces the internal structure of real opal and elucidates the principles behind its play of color. Section 4 explains how to model the internal structure of opal, while Sect. 5 describes a rendering method to reflect this play of color in the model. Section 6 shows and discusses the results of our simulation, and Sect. 7 concludes the paper with brief remarks on future research directions.

Fig. 1
figure 1

Overview of the proposed approach. We generate a solid texture for the internal structure of opal by computing three-dimensional (3D) additively weighted Voronoi tessellation, weighted by Perlin noise, and a percolation model of the graph formed by sites in the Voronoi diagram. We also define the external shape of opal using a mesh or Bézier patches (Sect. 4). For this model, we render output images by computing scattering and absorption due to impurities inside opal, as well as diffraction due to colloidal grains using the Ewald construction (Sects. 5 and 6)

2 Related work

In this section, we review related works from the perspective of three of opal’s characteristics: as a gemstone, as an aggregate material, and as having structural color. Further, we place the proposed method within the context of prior studies.

2.1 Visual simulation of gemstones

Due to opals’ distinct play of color, they are often incorporated as gemstones. Yet, the visual simulation of gemstones has long been a research problem in CG.

When rendering single-crystal gemstones, dispersion [52] and polarization [58] play crucial roles due to their visual impact. For instance, Guy and Soler [19] interactively simulated single-crystal gemstones in consideration of these phenomena, as well as of absorption and birefringence. Though this method was applied to relatively simple facet-cut shapes, Hui et al. [23] extended the approach to incorporate more complex geometries. Even further, some studies have been able to reproduce the optical phenomena observed in specific minerals, including asterism or chatoyancy [61], birefringence in uniaxial crystals like calcite [55], aventurescence [54] found in sunstone and aventurine, and labradorescence [56] in labradorite. As well, Imura et al.  [25] present an attempt to render opals; however, despite successfully reproducing play of color, the physical basis for modeling and rendering remains ambiguous in the paper.

2.2 Rendering aggregate materials

Opal is formed by the aggregation of numerous colloidal grains of a visible size. For example, Soulié et al. [49] attempted to reproduce granite using the 3D Voronoi diagram, and Meng et al. [34] modeled tens of millions of particles at three different scales and rendered them using explicit path tracing and approximate computations depending on visibility. Müller et al. [37] expanded this method to a model capable of rendering different particle distributions in different spaces.

2.3 Structural color in computer graphics

Play of color is classified as a kind of structural color. As such, this section presents studies on the visual simulation of structural color, categorized according to the optical phenomenon responsible.

Diffraction due to microscopic irregularities on the object surface. He et al. [20] and Stam [50] computed diffracted light using the Beckmann–Kirchhoff equation. Thereafter, Cuypers et al. [6] extended Stam’s theory to proposed a wave-based bidirectional reflectance distribution function (BRDF) utilizing the Wigner distribution function. Meanwhile, Wu and Zheng [59] integrated the Wigner distribution function into microfacet theory, resulting in a BRDF capable of computing light diffraction, absorption, and attenuation simultaneously. Further, Dhillon et al. [7] developed a method of interactively reproducing the diffraction of organisms using a measured model, and Toisoul and Ghosh [53] proposed an efficient data-driven method for rendering diffraction. Finally, Holzschush and Pacanowski [21] presented a method to compute diffraction due to microstructures on microfacets.

Thin-film interference. Smits and Meyer [48] introduced an optical model for thin-film interference in CG. Subsequently, Gondek et al. [16] proposed a BRDF to represent thin-film interference for spectral rendering. Icart and Arqués [24] attempted to integrate thin-film interference theory into a diffraction model, whereas Belcour and Barla [3] proposed a method the computational RGB rendering of multiple reflections in a thin film on microfacets. However, the accuracy of this model degrades with coarser microfacets. Kneiphof et al. [32] initiated successful improvements.

Other structural colors. Nagata et al. [38] proposed a method for multilayer thin-film interference in pearl, while Sun [51] introduced a model that considers both diffraction by microstructures and interference by multilayer thin films to reproduce the structural colors found on insects. Guillen et al. [17] presented a generic model to reproduce pearlescent materials, and Benamira and Sumanta [4] focused on diffraction-aware hair rendering. Further, Huang et al.[22] developed a model to compute the structural color of the feathers on pigeon necks, and Guo et al. [18] proposed a light-scattering model that pre-computes and considers diffraction and interference by nearby particles in participating media. Finally, **a et al. [60] reproduced Quetelet scattering, which is the interference between light scattered by particles and light reflected on a water surface.

2.4 Contributions of the proposed method

We propose a method focusing on opal, diverging from a comprehensive gemstone representation approach as in Guy et al. [19]. Similar to Weidlich and Wilkie [54], our approach explicitly models the internal structure of a gem. However, while aventurescence occurs near the surface of gemstones, play of color occurs deep inside opal, so it is necessary to define the internal structure in three dimensions. Because opal has fewer clusters than granular materials, we explicitly render each cluster individually instead of computing statistical volume rendering. The microscopic structure of opal resembles that of Guo et al. [18] in that neighboring particles diffract. However, the distinct microscopic regularity of opal results in sharp diffraction peaks like specular reflection. Consequently, diffraction intensities are computed online rather than look-up of pre-computed results as in Guo et al. [18].

3 Preliminaries

The objective of this section is to cover the physical properties of real opals comprehensibly. Section 3.1 describes the internal structure of real opals, and Sect. 3.2 explains the principle of play of color in opals. Subsequently, we report the results of observing an opal using a digital microscope in Sect. 3.3.

3.1 Internal structure of real opals

Macroscopically, opal is an amorphous quasi-mineral primarily composed of silicon dioxide. Figure 2 presents images of real opals, the smallest unit of which is a silica sphere (Fig. 2a) with a particle diameter of 400 nm or less [29]. Due to their size, silica spheres in opal are classified as colloids, amorphous spheres that lack a regular atomic arrangement. Opals also contain impurities [14] within the silica spheres and in the gaps between them, so the scattering and absorption of light due to these impurities determine the opal’s base color, which is primarily white, with black [33] and red [46] being the next most well known. Opals with a black base color are referred to as black opals (Fig. 2b), and those with a reddish base color are called fire opals (Fig. 2c).

Fig. 2
figure 2

Photographs of real opals, which show play of color. Base color is typically white (a), while color variations include black (b) and red (c)

Fig. 3
figure 3

Internal structure of opal. The smallest unit of an opal is a silica sphere (a) with a diameter of several hundred nanometers, and impurities are contained within the silica spheres and in the gaps between them. Many silica spheres stack to form a colloidal crystal (b). These colloidal crystals randomly organize into colloidal polycrystalline structures (c), collectively constituting an opal (d)

Silica spheres are aligned inside an opal, forming a face-centered cubic (fcc) lattice or hexagonal close-packed (hcp) structure. The term “crystal" traditionally refers to the arrangement of atoms and molecules, and the arrangement of colloids similar to a crystal structure is called a colloidal crystal (Fig. 3b). The tone of the play of color arises from the 3D diffraction of light due to the colloidal crystal structure.

Colloidal crystals, aggregates of silica spheres, form a polycrystalline structure over extended distances (Fig. 3c), known as a colloidal polycrystalline structure. The individual colloidal crystal structures forming colloidal polycrystalline structures are termed colloidal crystal grains. As such, the play of color observed in opals is not simply a shift in structural color; rather, it is characterized by a complex varying pattern dependent on the direction of light sources and the viewpoint. Meanwhile, the pattern of the play of color is attributed to the colloidal polycrystalline structure.

Fig. 4
figure 4

Diffraction via the periodic structure within an opal. A colloidal crystal with a face-centered cubic (fcc) structure (a) diffracts visible light due to its periodic structure (b). The diffraction mechanism is similar to that of multilayer reflection, but opal is characterized by the presence of many diffraction planes in 3D directions (c)

3.2 Principle of play of color among opals

The short-range regular structure of an opal is responsible for the coloring in its play of color, while the long-range random structure contributes to the overall pattern. When we focus on a particular grain, it has a colloidal crystal structure, where colloids of the same size are aligned. Although colloidal crystals in opals have been known to mimic an fcc or an hcp structure, we assume for simplicity that all silica spheres exhibit an fcc structure. A schematic diagram of fcc is shown in Fig. 4a, where the colloids constituting the opal are approximately the size of visible light and the regular arrangement in the colloidal crystal structure causes the diffraction of visible light, resulting in the appearance of structural color. When light enters the colloidal crystal from the air, the condition for the wavelength \(\lambda \) of diffraction is known as the Bragg–Snell condition:

$$\begin{aligned} m\lambda = 2D\left( n^2 - \sin ^2\theta \right) ^{\frac{1}{2}}, \end{aligned}$$

where m denotes the diffraction order, D the lattice spacing, n the average refractive index of the colloidal crystal, and \(\theta \) the incidence angle. In the case of an fcc structure, the relationship between D and the diameter of a silica sphere d, illustrated in Fig. 4b, is given by:

$$\begin{aligned} D = \sqrt{\frac{2}{3}}d. \end{aligned}$$

Because colloidal crystals are 3D microstructures, there are multiple ways of forming a lattice plane in a single colloidal crystal (Fig. 4c).

Opal exhibits a colloidal polycrystalline structure, with each grain having a distinct crystal lattice tilt. Consequently, the normal of the diffraction plane varies from region to region, resulting in complex patterns within a single opal.

3.3 Observation of opals using a digital microscope

When modeling the internal structure of opals, it is necessary to determine the sizes of colloidal grains. However, to the best of our knowledge, no reports exist with measurements of colloidal crystal grain sizes in natural opals. Therefore, we observed colloidal grain sizes in real opals using a digital microscope Leica DVM6. The results are presented in Fig. 5, where the sizes were found to be around 1–1.5 mm.

Fig. 5
figure 5

Observation of opals using a digital microscope

Fig. 6
figure 6

Process of modeling the internal structure of an opal using the proposed method. For simplicity, the figure is presented on a two-dimensional plane. Initially, the concentration field of the silica spheres is represented using Perlin noise (a). Subsequently, the colloidal polycrystalline structure formed through nucleation is represented by an additively weighted Voronoi diagram, weighted by Perlin noise (b). Finally, the bonding of adjacent grains through sintering is represented by bond percolation within the network formed by the sites of the Voronoi diagram (c)

4 Modeling

In this section, we describe a method for modeling opals. As described in the previous section, the hue of the play of color is determined by the inclination of the lattice planes within the colloidal grains. Therefore, it is sufficient to model opals in units of colloidal grains to simulate the play of color visually. In this study, an opal’s external shape is defined by meshes or Bézier patches, while the internal structure is represented by the solid texture of the colloidal polycrystalline structure. Section 4.1 proposes a method for representing the colloidal polycrystalline structure, and Sect. 4.2 discusses modeling the base color.

4.1 Representation of internal structure

In the field of materials engineering, studies have been conducted to simulate colloidal self-organization [8] accurately. However, these methods often face limitations in terms of scale or computational time. In this study, we propose a method for the fast generation of plausible solid textures from a visual simulation perspective, based on the process of real opal formation. The proposed approximation is based on a 3D additively weighted Voronoi diagram and percolation of the network formed by its sites. The process of modeling the internal structure is illustrated in Fig. 6.

4.1.1 Formation process of opal

Based on a paper [12] delineating a method for synthesizing artificial opals, we consider the process of opal formation. First, silica spheres of a uniform size are generated (Fig. 6a top), and at this stage, neighboring silica spheres remain unaggregated. Next, colloidal crystals are formed by sedimentation (Fig. 6b top), a process referred to as nucleation, and the particles adopt a crystalline structure at the initial state. Finally, the precursor opal is solidified through sintering, a process of exposing the sample to elevated temperatures for strong enhancement. Generally, grain growth is observed during sintering (Fig. 6c top), and it is characterized by the enlargement of adjacent grains through the incorporation of others.

4.1.2 Additively weighted Voronoi diagram

In this study, the nucleation process of colloidal polycrystalline is represented by a 3D additively weighted Voronoi diagram (Fig. 6b), the rationale for which is as follows.

According to Aurenhammer [1] , an additively weighted Voronoi tessellation is defined as follows. Consider a set of points S in n-dimensional real space \(\textbf{R}^n\), where each element of S is called a site. For \(s, q\in S\) , let the dominant domain dom(sq) of s with respect to q be the set of points in space that is closer to s or equidistant between s and q:

$$\begin{aligned} dom(s, q)= & {} \{x \in \textbf{R}^n \mid \delta _{a}(x, s) \le \delta _{a}(x, q) \}, \\ \delta _{a}(x, s)= & {} \delta (x, s) - w(s), \end{aligned}$$

where \(\mathrm {\delta }\) is a function that returns the Euclidean distance and \(w(s)\in \textbf{R}\) is the weight of the site s. The domain reg(s) of the site \(s \in S\) is given by:

$$\begin{aligned} reg(s)=\bigcap _{q \in S - \{s\}}{dom(s, q)}. \end{aligned}$$

This spatial partitioning by regions is referred to as additively weighted Voronoi tessellation.

Intuitively, the generation of a Voronoi diagram can be regarded as a process in which each site searches for its neighbors and, in turn, includes them in its own domain (Fig. 6b bottom). In contrast, polycrystalline nuclei grow by assimilating neighboring particles during nucleation, akin to the process of forming Voronoi diagrams. Consequently, we depict the internal structure of precursor opal after nucleation using a 3D additively weighted Voronoi diagram. Note that Voronoi diagrams are indeed prevalent in materials engineering for illustrating the polycrystalline architecture [41]. The weight of each site in these diagrams serves as a parameter that controls the initiation of growth in each Voronoi region, analogous to the nucleation timing of crystal nuclei. In this study, the weights of the sites are determined by utilizing Perlin noise [40], an approach that adds a layer of complexity and realism to the model.

4.1.3 Percolation model

Broadbent and Hammersley [5] first proposed a model called Bernoulli percolation, and since then, percolation theory has been studied primarily in the fields of mathematics and physics. Concerning the history of the development of percolation models, see a thorough survey by Duminil-Copin [9]. Percolation is a model that explores the properties of a graph by removing edges or nodes probabilistically, where the model for removing edges is known as bond percolation, and the model for removing nodes is referred to as site percolation. This concept can be applied to problems concerning material conductivity and information propagation.

In this study, we employed the Bernoulli percolation model, a type of bond percolation, to approximate colloidal grain growth, and this model randomly determines edge existence probabilities following a Bernoulli distribution. Implementation involves assigning a uniformly random value in [0, 1] to each graph edge, removing edges when their values exceed the threshold \(p\in [0, 1]\), and retaining edges when they are below the threshold. An example of Bernoulli percolation on an orthogonal grid is illustrated in Fig. 7, computed on the graph comprising the sites of a Voronoi diagram to represent the merging of adjacent grains according to grain growth (Fig. 6c bottom). The graph formed by the sites can be easily obtained by considering a Delaunay triangulation, which is the dual of the Voronoi diagram. In the graph obtained after the percolation computation, the adjacent nodes are considered a single grain bounded by grain growth.

Fig. 7
figure 7

Examples of Bernoulli percolation on a \(4\times 4\) grid. First, the edges of the graph are assigned values [0, 1] using uniformly random numbers (a). Then, edges with a value greater than the threshold p are removed. The results for p, set to 0.25 and 0.5, are shown in (b) and (c), respectively

4.1.4 Generation of internal structural data

Specific steps for modeling the internal structure are outlined below. First, a 3D additively weighted Voronoi diagram is created, with sites positioned in the 3D space using Poisson disk sampling. These sites are then weighted using Perlin noise.

Next, to compute percolation, a Delaunay triangulation is constructed based on the Voronoi diagram, and each edge is assigned a value in [0, 1] using a uniformly generated random number. Thereafter, the threshold is set appropriately, and the percolation process is applied to the network of sites.

Lastly, a solid texture stores the internal structure model (Fig. 8). Initially, each cluster is assigned an index and stored in voxels. Next, a codebook is generated that stores the orientations of crystals corresponding to the total number of indices. The resulting data structure corresponds to the vector quantization of the internal structure, which avoids the redundant representation of the internal structure and improves memory efficiency. The orientation of uniformly random grains is generated by Shoemake’s algorithm [45] and stored as quaternions.

Fig. 8
figure 8

Data structure representing the internal structure. A solid texture depicting the colloidal polycrystalline structure is represented by code string and codebook

4.2 Modeling base color

To reproduce the base color, it is essential to consider the light absorption and scattering within opals. In opals, a part of \(\textrm{Si}^{4+}\), which constitutes a silica sphere, is replaced with impurities [14], such as \(\textrm{Al}^{3+}\) and \(\textrm{Fe}^{3+}\). Absorption and scattering are also caused by impurities entering the gaps between the colloidal crystals.

In this study, the absorption and scattering of light of the wavelength \(\lambda \) occurring within opals are expressed by two kinds of coefficients: the absorption coefficient \(\sigma _\mathrm {a,\lambda }\) and the scattering coefficient \(\sigma _\mathrm {s,\lambda }\), where the former represents the absorption of light by ions substituting \(\textrm{Si}^{4+}\) or impurities entering the gaps of the colloidal crystal and the latter denotes Rayleigh scattering due to impurities in the gaps between colloidal crystals. Rayleigh scattering [43] is a wavelength-dependent phenomenon that occurs when the diameter of the particles is sufficiently small compared to the wavelength.

5 Rendering

Resulting images are synthesized through spectral rendering using Monte Carlo path tracing on the model proposed in the previous section. In recent years, there has been an attempt at RGB rendering of structural colors, including rendering of thin-film interferences [3, 32]. However, opals, the target of this study, exhibit complex and repetitive internal reflections, and there is a known problem with RGB rendering where errors occur in the computation results as the number of ray bounces increases [11]. As such, we adopted spectral rendering to avoid this problem.

In this study, we perform ray marching within the solid texture obtained in the previous section. When a ray enters different crystal grains, we compute the diffraction as in Sect. 5.1 using the tilt information of the crystal grains in the region. In addition, to reproduce the base color, we compute the multiple scattering in the participating media, as explained in Sect. 5.2.

5.1 Rendering play of color

As demonstrated in Sect. 3.2, when light enters a colloidal crystal, it diffracts in a specific direction due to its periodic structure. In this study, we adapt the XRD theory, typically used for the structural analysis of crystals, to suit colloidal crystals. This adaptation allows us to incorporate the theory into our path tracing framework.

5.1.1 Ewald construction

When a ray penetrates a colloidal crystal, multiple diffraction directions are considered, as depicted in Fig. 4c. To identify these directions efficiently, we employed the Ewald construction, a technique rooted in XRD theory.

A point in the crystal with identical surroundings is referred to as a lattice point \(\varvec{R}\), whose expression can be represented by:

$$\begin{aligned} \varvec{R} = l\varvec{a} + m\varvec{b} + n\varvec{c}, \end{aligned}$$

where \(\varvec{a}\), \(\varvec{b}\), and \(\varvec{c}\) denote the basis vectors, and l, m, and \(n \in {\textbf {Z}}\).

The basis vectors in fcc can be expressed by:

$$\begin{aligned} \varvec{a} = \frac{d}{\sqrt{2}}(1, 1, 0), \; \varvec{b} = \frac{d}{\sqrt{2}}(0, 1, 1), \; \varvec{c} = \frac{d}{\sqrt{2}}(1, 0, 1), \end{aligned}$$

where d denotes the diameter of the particles (Fig. 9a). For the basis vectors, we define the reciprocal lattice fundamental vectors \(\varvec{a}^{*}\), \(\varvec{b}^{*}\), and \(\varvec{c}^{*}\) as follows:

$$\begin{aligned} \varvec{a}^{*}=\frac{\varvec{b}\times \varvec{c}}{\varvec{a}\cdot \varvec{b}\times \varvec{c}}, \; \varvec{b}^{*}=\frac{\varvec{c}\times \varvec{a}}{\varvec{b}\cdot \varvec{c}\times \varvec{a}}, \; \varvec{c}^{*}=\frac{\varvec{a}\times \varvec{b}}{\varvec{c}\cdot \varvec{a}\times \varvec{b}}. \end{aligned}$$

Using the reciprocal basis vectors and hk,  and \(l \in {\textbf {Z}}\), we express the reciprocal lattice vector G as:

$$\begin{aligned} \varvec{G}_{hkl}=h\varvec{a}^{*} + k\varvec{b}^{*} + l\varvec{c}^{*}. \end{aligned}$$

The absolute value of the reciprocal lattice vector is related to the lattice spacing \(D_{hkl}\) of the lattice plane passing through \(\varvec{a} / h\), \(\varvec{b} / k\), and \(\varvec{c} / l\), as follows:

$$\begin{aligned} \left| \varvec{G}_{hkl}\right| = \frac{1}{D_{hkl}}. \end{aligned}$$

Next, we define the scattering vector \(\varvec{q}\), which is the vector that directs the wave vector of the incident wave \(\varvec{k}_0\) to the wave vector of the scattered wave \(\varvec{k}\) (Fig. 9b):

$$\begin{aligned} \varvec{q} = \varvec{k} - \varvec{k}_0. \end{aligned}$$
(1)

Note that the magnitude of the wave vector is \(1/\lambda \). In XRD, it is known that crystal diffraction reaches its maximum [31] when:

$$\begin{aligned} \varvec{q} = \varvec{G}_{hkl}. \end{aligned}$$
(2)
Fig. 9
figure 9

Vectors used in X-ray diffraction (XRD) theory. The basis vectors define the structure of a lattice and are used to describe the crystal structure (a). The scattering vector is defined as the vector that directs the wave vector \(\varvec{k}_0\) of the incident wave to the wave vector \(\varvec{k}\) of the scattered wave (b). The angle between \(\varvec{k}_0\) and \(\varvec{k}\) is referred to as the scattering angle, denoted by \(2\theta \)

The Ewald construction [10] is an efficient method for identifying reciprocal lattice points that satisfy the conditions of Eq. (2) (Fig. 10a). Initially, the starting point of \(\varvec{q}\) is placed at the origin of the reciprocal lattice. Subsequently, in accordance with the definition of scattering vectors, \(\varvec{q}\) is drawn as a vector toward the origin of the reciprocal lattice, and \(\varvec{k}\) is represented as a vector that shares its starting point with \(\varvec{k}_0\) and its end point with \(\varvec{q}\). Then, a sphere is drawn with origin \(-\varvec{k}\) and radius \(1/\lambda \), called the Ewald sphere. Because the wave vector has a magnitude \(1/\lambda \), any point on the Ewald sphere surface can be the endpoint of \(\varvec{q}\). The diffraction maximum occurs when the conditions of Eq. (2) are satisfied, i.e., when a reciprocal lattice point exists on the surface of the Ewald sphere.

A sphere of radius \(2/\lambda \) centered at the origin of the reciprocal lattice is referred to as a limiting sphere, and the geometrical properties of the Ewald sphere guarantee that the reciprocal points giving the diffraction maxima are within the limiting sphere. Therefore, the reciprocal lattice points satisfying Eq. (2) can only be found on the Ewald sphere surface among the reciprocal lattice points within the limiting sphere.

Fig. 10
figure 10

Ewald construction. If a sphere of radius \(1/\lambda \) is drawn in lattice space with the starting point of the wave vector at its center, the reciprocal lattice points with diffraction maxima always exist on the sphere surface (a). If a sphere of radius \(2/\lambda \) is drawn with the origin at its center, we have a limited range of reciprocal lattice points where the diffraction maxima can be observed (b)

5.1.2 Computation of diffraction

We use the Ewald sphere in path tracing to simulate the diffraction of light within colloidal crystals. In X-ray structure analysis, \(\varvec{k}_0\) and \(\varvec{k}\) are given, allowing analysis of the crystal’s internal structure using Eqs. (1) and (2).

In contrast, because the direction of the incident light \(\varvec{\omega }_\textrm{i}\) of a ray toward a colloidal crystal and the internal structure of a colloidal crystal is already given, we consider identifying the outgoing direction \(\varvec{\omega }_\textrm{o}\) of the ray through the conditions in Eqs. (1) and (2). The wave vector \(\varvec{k}_0\) of the incident ray is derived from the given \(\varvec{\omega }_\textrm{i}\), and whether the sum with the reciprocal lattice vector \(\varvec{G}_{hkl}\) exists on the Ewald sphere surface will determine whether the incident ray diffracts.

We derive the wave vector \(\varvec{k}_0\) based on the given \(\varvec{\omega }_\textrm{i}\) and assess whether the sum involving the reciprocal lattice vector \(\varvec{G}_{hkl}\) falls on the Ewald sphere surface, which will determine whether the incident ray diffracts. First, note that the wavelength is multiplied by \(1/n_\textrm{eff}\) because the colloidal crystal travels in a medium with an effective refractive index of \(n_{\textrm{eff}}\). Equation (1) is reformulated with \(\varvec{\omega }_\textrm{i}\) and \(\varvec{\omega }_\textrm{o}\) to produce:

$$\begin{aligned} \varvec{q} = \frac{n_{\textrm{eff}}}{\lambda }\varvec{\omega }_\textrm{o} - \frac{n_{\textrm{eff}}}{\lambda }\varvec{\omega }_\textrm{i}. \end{aligned}$$
(3)

Substituting Eq. (2) to Eq. (3), we have:

$$\begin{aligned} \varvec{G}_{hkl}= & {} \frac{n_{\textrm{eff}}}{\lambda }\varvec{\omega }_\textrm{o} - \frac{n_{\textrm{eff}}}{\lambda }\varvec{\omega }_\textrm{i},\end{aligned}$$
(4)
$$\begin{aligned} \varvec{\omega }_\textrm{o}= & {} \varvec{\omega }_\textrm{i} + \frac{\lambda }{n_{\textrm{eff}}}\varvec{G}_{hkl}. \end{aligned}$$
(5)

Incident light diffracts when \(\varvec{\omega }_\textrm{o}\), computed by Eq. (5), satisfies the following:

$$\begin{aligned} \left| \varvec{\omega }_\textrm{o} \right| = 1, \end{aligned}$$
(6)

and its direction is \(\varvec{\omega }_\textrm{o}\).

In spectral rendering, because \(\lambda \) is limited to the visible light spectrum and the diameter of colloidal particles d is fixed when searching for the diffraction direction using Eq. (5), it is practical to limit the number of \(\varvec{G}_{hkl}\) values by employing a limiting sphere. Because the range of the spectrum treated in this study is 360–830 nm, \(\varvec{G}_{hkl}\) values of 15 and 59 are considered sufficient when the opal grain size is 250 and 350 nm, respectively. In cases in which there exist multiple potential \(\varvec{\omega }_\textrm{o}\) values that satisfy Eq. (6), one of the diffraction directions is stochastically selected at random, according to the magnitude of the Fresnel reflectance computed using half of the scattering angle \(\theta \).

5.2 Rendering base color

To compute the effect of participating media using path tracing, paths are constructed by sampling the distance t to the interaction point with participating media, determining the behavior of the participating media using the scattering coefficient \(\sigma _\mathrm {s, \lambda }\) and absorption coefficient \(\sigma _\mathrm {a, \lambda }\), defined in Sect. 4.2, and determining the direction of the ray using the phase function, in the above-mentioned order, as in [28]. In the case of ray scattering, we use Frisvad’s method [13] for importance sampling of the phase function.

Table 1 Parameters and running time of the visual simulation of each image, where \(num_{\text {s}}\) denotes the number of sites of the additively weighted Voronoi diagram initially placed, p the probability of the existence of edges when computing bond percolation, \(num_{\text {c}}\) the number of clusters at the end of modeling, \(t_\text {m}\) the running time of modeling, d the diameter of the silica sphere, \(num_{\varvec{G}}\) the number of reciprocal grid points \(\varvec{G}_{hkl}\) in the limiting sphere and \(t_\text {r}\) the running time of rendering. The resolution of each image is 1440 \(\times \) 1080, and the maximum bounce of each path is 64, sampled in 4096 spp
Fig. 11
figure 11

Results of visual simulation of opal with the proposed method. The display stand was rotated by \(5^{\circ }\). The color and pattern of the opal changed as the stand was rotated

6 Results and discussions

We implemented our method using \(\text {C}++\) and CUDA and executed it on a computer with an Intel Core i9-10900X, 128GB of RAM, and an NVIDIA GeForce RTX 3070 graphics card. The resolution of the solid texture is \(512^{3}\). Refer to Table 1 for the other parameter values used in the modeling of each example. Note that \(num_s\) denotes the number of sites of the additively weighted Voronoi diagram initially placed, while \(num_{\varvec{G}}\) the number of reciprocal grid points. Spectral rendering was performed using 48 color channels sampled at 10 nm intervals from 360 to 830 nm. The maximum number of bounces was set to 64. Each example was rendered with 4096 samples per pixel and a resolution of 1440 \(\times \) 1080. We used an environment map sourced from a dancing_hall_4k.exr image available under the CC0 license on Poly Haven [42]. This map was upsampled from an RGB color space to a spectral space to serve as a light source. Note that the dot pattern observed in the rendered results stems from the regularly arranged ceiling light sources. While several methods exist for upsampling [26, 35, 39], considering the minimal amount of spatio-temporal computation required in rendering, we adopted the classic Smits’ method [47]. However, note that this technique was originally designed for texture upsampling and does not provide a spectral distribution of light sources. Ideally, images taken with a hyperspectral camera should be used for the environment map.

6.1 Results

Representation of opal. Figure 11 empirically proves the plausibility of our visual simulation with the proposed method, rotating the display stand in increments of \(5^{\circ }\). As the stand is rotated, the color and pattern inside the opal change, and it can be confirmed that the opal represents play of color. Refer to the supplementary video for a view of the rotation of the simulated opal.

Figure 12 shows the results of a visual simulation by changing the grain size of the silica spheres. According to Gao et al. [15], colloidal crystals show blue, green, and red color effects when the silica sphere is 207, 249, and 350 nm, respectively. Our visual simulation results are consistent with the report.

Fig. 12
figure 12

Color change of the emitted play of color: Blue at 210 nm, green at 250 nm, and red at 350 nm, and this agrees with the report by Gao et al. [15]

Fig. 13
figure 13

Representation of black opal and fire opal. Figure 2b and 2c is used as reference. The absorption coefficients of \(\text {Al}^{3+}\) ions for black opal and \(\text {Fe}^{3+}\) ions for fire opal were used

Figure 13 shows the results of reproducing black opal and fire opal using \(\text {Al}^{3+}\) and \(\text {Fe}^{3+}\) ions as absorption coefficients for their base color. The opal was modeled based on Fig. 2b and c, and the results indicate that the base color of opals is visually plausible.

Performance. Table 1 summarizes the runtime required to obtain the results of our visual simulation. Modeling took approximately 17–21 s, whereas rendering required about 11–43 min. The case in Fig. 13a for fire opal using \(\text {Al}^{3+}\) deserves special attention the \(num_{\text {s}}\) initially placed is 10 times greater than in the other cases, though \(t_{\text {m}}\) is not much different. Conversely, \(t_{\text {r}}\) is scaled to \(num_{\varvec{G}}\), but it is significantly reduced because \(\sigma _\mathrm {a,\lambda }\) is large. This suggests that ray iterations are more likely to be terminated in preliminary stages.

6.2 Discussions

Internal structure model. In this study, we proposed a texture generation method that provides visually plausible output results from the viewpoint of visual simulation. However, the validation is limited to changing the parameter values of the diameter of the silica spheres and the absorption and scattering coefficients due to impurities. In addition, it is essential to verify the physical accuracy and controllability of the simulation by varying other parameter values.

We employed a Bernoulli percolation model to approximate colloidal polycrystalline grain growth from the viewpoint of computational efficiency. However, real grain growth entails complex parameters, such as temperature, pressure, and grain boundary energy [44], suggesting the potential re-examination of using a Bernoulli distribution to determine edge existence probability. In the field of materials engineering, studies have been conducted to simulate the self-organization of colloidal crystals [8], although the computational scale is currently limited. Advancements in these studies will enhance the accuracy of internal structure modeling.

Each opal has an inherent complex internal structure, and identifying the internal structure of a real opal requires the microscopic observation of irreversible cut surfaces. Consequently, it is difficult to verify the validity of the internal structure against real opals. To assess quantitatively the effectiveness of the method, further detailed investigations would be imperative through collaboration with experts in the fields of crystallography and materials engineering.

Computational model of diffraction. In this study, the diffraction direction of incident light on a colloidal crystal is computed online using the Ewald construction, providing an effective approach for materials that exhibit sharp diffraction peaks, potentially due to crystal structures. However, as indicated in Table 1, the computational time required for rendering increases linearly with the number of reciprocal grid points in the limiting sphere, leading to decreased efficiency. For materials with numerous or a wide spread of diffraction peaks, it is more efficient to research pre-computed results. In this study, although all internal structures were assumed fcc for simplicity, it is known that a part of the internal structure of real opal is replaced by hcp. Accounting for this effect would enable the computation of a more accurate diffraction.

Computational efficiency of rendering. This study used Monte Carlo path tracing, which takes longer to converge while requiring less memory at runtime. We would like to reduce the runtime by incorporating photon map** [27], path guiding [36], or more efficient spectral rendering [57].

User study. Following the approach taken by Nagata et al. [38], it is imperative to conduct user studies to assess the fidelity of rendering results produced by our proposed method compared to real opal.

Applicability of the proposed method. Guy et al.’s method[19] has been applied to design the external shape of single-crystal gemstones. While this study endeavors to apply the method to texture design using CAD, enabling external shapes to be defined with Bézier patches, it is difficult to achieve this at the current frame rate. A fundamental review of the rendering method is thus necessary to apply this study to jewelry design. We expect that adopting a physically motivated approach to modeling opals will significantly enhance the applicability and impact of our research. Many pairs of internal structure models and their rendering results can be generated, and we are exploring the feasibility of using these datasets as training data to estimate the internal structure of real opals using machine learning.

7 Conclusion

In this paper, to realize a realistic visual simulation of opals, we proposed a method to represent the internal structure by computing an additively weighted Voronoi diagram and bond percolation of the graph formed by its sites. Further, we introduced a technique to compute the diffraction direction of a 3D colloidal crystal using the Ewald construction. We demonstrated that the proposed method produces visually plausible virtual opals.

We also used a percolation model to approximate grain growth and proved this model applicable to visual simulations. We believe it extends beyond polycrystalline modeling, offering potential uses in diverse types of visual simulation. Further, the computation of diffraction directions based on the Ewald construction may also be applied to visual simulations of other colors with regular structures.