A Study on Numerical Integration Methods for Rendering Atmospheric
Total Page:16
File Type:pdf, Size:1020Kb
Open Phys. 2019; 17:241–249 Research Article Tomasz Gałaj and Adam Wojciechowski A study on numerical integration methods for rendering atmospheric scattering phenomenon https://doi.org/10.1515/phys-2019-0025 In this paper, a qualitative comparison of three, pop- Received Jan 29, 2019; accepted Mar 07, 2019 ular numerical integration methods to compute the sin- gle scattering integral is presented. In provided research, Abstract: A qualitative comparison of three, popular and three methods have been chosen, namely Midpoint, Trape- most widely known numerical integration methods in zoidal and Simpson’s Rules. These three methods are fairly terms of atmospheric single scattering calculations is pre- popular in Computer Graphics field. Atmospheric scatter- sented. A comparison of Midpoint, Trapezoidal and Simp- ing is calculated using backward ray tracing algorithm tak- son’s Rules taking into account quality of a clear sky gener- ing into account variable light conditions [5]. Then, these ated images is performed. Methods that compute the atmo- methods are compared with each other taking into account spheric scattering integrals use Trapezoidal Rule. Authors quality of the generated images of the sky. As a subproduct try to determine which numerical integration method is of this research, the fidelity of the framework presented the best for determining the colors of the sky and check by Bruneton in [3] is being checked. Authors try to deter- if Trapezoidal Rule is in fact the best choice. The research mine which numerical integration method is the best for does not only conduct experiments with Bruneton’s frame- calculating the colors of the sky and check if Trapezoidal work but also checks which of the selected numerical inte- Rule is in fact the best choice. This research does not only gration methods is the most appropriate and gives the low- conduct experiments with Bruneton’s framework but also est error in terms of atmospheric scattering phenomenon. checks which of the selected numerical integration meth- Keywords: atmospheric single scattering, numerical inte- ods is the most appropriate and gives the lowest error in gration, integrals, nonlinear light scattering, gpu render- terms of atmospheric scattering phenomenon. ing PACS: 02.30.Rz, 42.68.-w 2 Atmospheric scattering background 1 Introduction In this section, the physical background of atmospheric Atmospheric scattering effects are very important for many light scattering as well as mathematical model of this phe- applications that require high realism of the outdoor nomenon is described. scenes. It becomes a crucial aspect affecting perception quality [1] of the contemporary games and virtual environ- ments [2]. The sky color is a natural indicator of the time 2.1 Physical background of a day. Recent methods such as [4, 6] calculate colors of the sky in real time (16ms). These methods use Trape- In computer graphics one can distinguish two types of zoidal Rule for integration the single scattering equation light scattering – Rayleigh and Mie scattering. Rayleigh and then save this data into a precomputed look up table scattering occurs for particles much smaller than the wave- (LUT) as to retrieve it in a real time for image synthesis. length of light and it can be described by Condition 1 [4]. λ r ≪ (1) 4π Tomasz Gałaj: Institute of Information Technology, Lodz University Here r is a radius of particle (e.g. oxygen, carbon diox- of Technology, Łódź, Poland; Email: [email protected] ide molecules), and λ is wavelength of light. On the other Adam Wojciechowski: Institute of Information Technol- λ ogy, Lodz University of Technology, Łódź, Poland; Email: hand, when particles are bigger than , Rayleigh scattering [email protected] smoothly transitions to Mie scattering. This type of scatter- Open Access. © 2019 T. Gałaj and A. Wojciechowski, published by De Gruyter. This work is licensed under the Creative Commons Attribution 4.0 License 242 Ë T. Gałaj and A. Wojciechowski ing considers aerosols as well as small steam, ice, dust par- and Mie scattering respectively. Proposed solution uses ticles. HR = 8000m and HM = 1200m as Bruneton et al. sug- The major difference between these two types of scat- gested in [6]. tering is that intensity of Rayleigh scattering depends on the wavelength of scattered light, whereas Mie scattering does not. This implies that the blue sky color is the effect II(λ) of Rayleigh scattering combined with a lack of violet pho- ton receptors in people’s retinas [7]. On the other hand, the L grey tones of halos around the sun, clouds, fog are caused Pc by Mie scattering. P ′ b θ I SR,M(λ,θ,P) What is more, one has to define single and multiple P Pa V P scattering terms. Single scattering means that only one h O light scattering event [8] is taken into account – event af- ter which some part of light traveling towards the eye is de- flected away from the viewing direction (out-scattering) or Figure 1: Schematic of how the single scattering is being calculated. is deflected back on the viewing direction (in-scattering). The amount of light that enters the viewer’s eye along viewing ~ On the other hand, with multiple scattering a number of direction V (from Pa to Pb) is integrated. When viewer is inside ~ light scattering events are taken into account. In this re- the atmosphere then Pa = PO. Next, incoming light L enters the search only the single scattering term is taken into account atmosphere at point PC. Then the amount of light from the sun as it is less complex than multiple scattering and it is suffi- (from P to PC) that reaches point P (at altitude h) along viewing direction V~ is integrated cient in terms of verification of the stated hypothesis. 2.2 Mathematical model 2.2.2 Scattering coeflcients In this section equations of physically based mathematical model are presented that were used to calculate single at- Rayleigh’s scattering equation provides scattering coeffi- mospheric scattering. The equations are based on the ones cients for a volume for which we know its molecular den- that were proposed by Nishita [4, 9]. sity. These coefficients are given by Equation 4. 3 2 2 s 8π (n − 1) βR(λ) = (4) 2.2.1 Scattering intensity 3Nλ4 Here superscript S indicates that it is a scattering co- Scattering intensity for Rayleigh/Mie scattering is de- efficient, subscript R means that it is a coefficient for scribed by Equation 2. It expresses the amount of light that Rayleigh scattering, λ is the given light’s wavelength, n is has been scattered exactly at a point P (see Figure 1) to- index of refraction of air and N is molecular density at sea ~ ~ wards direction V and with incident light direction L. level. As one can see, this equation depends on the wave- s s length. If the wavelength is short, the value of βR will be ISR M (λ, θ, P) = II(λ)ρR,M(h)FR,M(θ)βR M(λ) (2) , , s higher and if the wavelength is long, the value of βR will In the above equation, λ is the spectral wavelength of be lower. the light, II(λ) stands for the spectral intensity of the in- This explains why the sky is blue during the day and coming light [10], ρR,M(h) is the Rayleigh/Mie density func- ~ red-orange at the dawn or dusk. During the day, when the tion, FR M(θ) is phase function for the angle θ between V , sun is in the zenith, light has relatively short distance to and ~L, and βs (λ) is scattering coefficient. R,M travel before reaching observer’s eye and therefore blue The density function ρR M(h) expresses how density of , light is being scattered towards the eye and sky appears air particles decreases in dependence of altitude h. This blue (green and red light need to travel bigger distance to function is defined by Equation 3. be scattered). On the other hand, at sunrise or sunset, light h ρ h has to travel much longer distance than in the previous R,M( ) = exp(− H ) (3) R,M scenario. Before light reaches the observer’s eye, most of In the above equation, h is the altitude of the point P the blue light has been scattered away, and only red-green above the ground and HR,M are scale heights for Rayleigh light will have a chance to reach observers eye. Numerical integration methods for rendering atmospheric scattering Ë 243 Mie scattering is similar to Rayleigh, but it applies to 2.2.5 Single scattering particles that are much greater than the scattered wave- length. These particles (aerosols) may be found on low In previous sections all the components that are required altitudes of the Earth’s atmosphere. Therefore, equation to compute the single scattering have been introduced. To for Mie scattering coefficients needs to be slightly different compute single scattering, Equation 9 that takes into ac- (Equation 5). count Rayleigh and Mie scattering is used. This equation 3 2 2 s 8π (n − 1) defines the single scattering intensity of the light beam βM() = (5) 3N that reaches the observer’s eye, after exactly one scatter- Here subscript M stands for Mie scattering and the rest ing event. of the parameters are the same as in the Rayleigh scatter- 0 I λ θ P I λ βs λ F θ ing coefficient equation. SR,M ( , , ) = I( ) R,M( ) R,M( ) (9) P Z b −t(P,Pc ,λ)−t(P,Pa ,λ) (ρR,M(h(P)) · e )dP 2.2.3 Phase functions Pa In the Equation 9, the term PO is location of the ob- The phase function is describing angular dependency of server’s eye, ~L is the direction from the light source to sam- scattered light in respect to the direction of incoming light ple point P on V~ , λ is the wavelength of the scattered light.