MASARYK UNIVERSITY FACULTY OF INFORMATICS Atmospheric effects for real-time global illumination BACHELOR'S THESIS Aron Samuel Kovacs Brno, Spring 2018 MASARYK UNIVERSITY FACULTY OF INFORMATICS Atmospheric effects for real-time global illumination BACHELOR'S THESIS Aron Samuel Kovacs Brno, Spring 2018 This is where a copy of the official signed thesis assignment and a copy of the Statement of an Author is located in the printed version of the document. Declaration Hereby I declare that this paper is m y original authorial work, which I have worked out o n m y o w n . A l l sources, references, a n d literature used or excerpted during elaboration of this work are properly cited and listed i n complete reference to the due source. Áron Samuel Kovács Advisor: M g r . Jan Čejka i Acknowledgements I thank m y advisor M g r . Jan Čejka for his great help w i t h m y thesis. I w o u l d also like to thank m y family a n d friends for their support. 111 Abstract Fast simulation of atmospheric effects is an important area of research for outdoor real-time visualisations. This thesis describes the principles of real-time rendering of atmospheric effects for the purpose of their simulation and describes a method for real-time rendering of volumetric clouds shaded w i t h light provided by the atmosphere. The described techniques are implemented as example projects using render library mallumo. iv Keywords global illumination, O p e n G L , real-time computer graphics, Rust, volumetric clouds v Contents Introduction 1 1 Mallumo 3 2 Theoretical background 5 2.1 Radiant flux 5 2.2 Irradiance 5 2.3 Radiance 5 2.4 Transmittance 5 2.5 Scattering 6 2.5.1 Forward scattering and backscattering 6 2.5.2 Elastic scattering 6 2.5.3 Dominant scattering processes i n Earth's atmosphere 7 2.5.4 Phase functions for Rayleigh and M i e scatterings 7 2.5.5 Single and multiple scattering 8 2.6 Shapes and density of clouds 9 2.7 Turbidity 10 2.8 Lighting of clouds 10 3 Related work 13 3.1 Atmosphere 13 3.1.1 Nishita93 model 13 3.1.2 Nishita96 model 14 3.1.3 Preetham model 15 3.1.4 Haber model 16 3.1.5 Bruneton model 17 3.2 Clouds 18 3.2.1 Skybox a n d skydome 18 3.2.2 Implicit volumes 18 3.2.3 Polygon clouds 19 3.2.4 Particle clouds 19 3.2.5 Procedural clouds 19 4 Implementation 21 4.1 Bruneton model 21 vii 4.1.1 Physical model 21 4.1.2 Rendering equations 22 4.1.3 M e t h o d 23 4.1.4 Precomputation 24 4.1.5 Parametrization 26 4.1.6 Rendering 26 4.1.7 Computational complexity 27 4.1.8 Limitations 27 4.1.9 Implementation details 28 4.2 Clouds 29 4.2.1 Modelling 29 4.2.2 Texture generation 30 4.2.3 Rendering 31 4.2.4 Optimizations 33 5 Results 35 5.1 Sky 35 5.2 Clouds 37 6 Conclusion 45 Bibliography 47 A List of electronic attachments 51 viii List of Tables 5.1 C l o u d rendering speed at F u l l H D resolution. List of Figures 1.1 Sponza scene without albedo texture, illuminated directly and indirectly by the Sun using anisotropic V X G I . 3 2.1 Light entering a scattering m e d i u m , producing forward scattering and backscaterring. 6 2.2 Single and multiple scattering, courtesy of [4]. 9 2.3 Different types of clouds occurring at w i d e range of altitudes, courtesy of [1]. 9 3.1 Fisheye skydome rendering of the spectral radiance of the Nishita93 model, for sun zenith angles 87°, 41°, 31°, 21°, courtesy of [6]. 13 3.2 Fisheye skydome rendering of the spectral radiance of the Nishita96 model, for sun zenith angles 87°, 41°, 31°, 21°, courtesy of [6]. 14 3.3 Fisheye skydome rendering of the spectral radiance of Preetham, for sun zenith angles 87°, 41°, 31°, 21°. Note how bright the sky is compared to the previous models, courtesy of [6]. 15 3.4 Fisheye skydome rendering of the spectral radiance of the Haber model, for sun zenith angles 87°, 41°, 31°, 21°. Note how the sky is less orange near the horizon compared to the Nishita93 and the Nishita96 models, courtesy of [6]. 16 3.5 Fisheye skydome rendering of the spectral radiance of the Bruneton model, for sun zenith angles 87°, 41°, 31°, 21°. Courtesy of [6]. 17 3.6 Implicit volume on the left and perturbed result o n the right, courtesy of [13]. 18 3.7 A n example of a polygon cloud, courtesy of [14]. 19 4.1 Simplex-Worley noise and Worley noise at increasing frequencies. 30 4.2 Worley noise at increasing frequencies. 31 4.3 C u r l noise. 31 5.1 Rendering of the sky w i t h the Sun at the zenith angle of 0°, w i t h the camera looking straight up. 35 xi 5.2 Rendering of the sky w i t h the Sun at the zenith angle of 60°. 36 5.3 Rendering of the sky w i t h the Sun at the zenith angle of 93°, meaning the Sun is below the horizon. 36 5.4 Rendering of the clouds w i t h R = 32 and rapidly moving camera. Figure 5.5 is enclosed i n the red square. 38 5.5 Detail of Figure 5.4. 38 5.6 Rendering of the clouds w i t h D equal to 1, N equal to 512, and w i t h the Sun at the zenith angle of 50°. 41 5.7 Rendering of the clouds w i t h D equal to 1, N equal to 512, and w i t h the Sun at the zenith angle of 66°. 41 5.8 Rendering of the clouds w i t h the field of view of 16°, D equal to 1, and N equal to 512. Note the artefacts caused by discretisation of the noise functions and insufficient step length. 42 5.9 Rendering of the clouds w i t h the field of view of 16°, D equal to 4, and N equal to 512. 42 5.10 Rendering of the clouds w i t h D equal to 1, and N equal to 512. 43 5.11 Rendering of the clouds w i t h D equal to 1, and N equal to 128. 43 xii Introduction Atmosphere and clouds are an important part of a landscape. To provide their realistic simulation i n real-time interactive applications, more often than not, a great effort is spent to make them look convincing. However, i n many cases, this effort falls short, and the results may not be of desired quality. Lately, advances i n hardware have made it possible to render volumetric clouds i n real-time. The method described i n this thesis is based on the work of researchers i n Guerrilla Games company, w h o presented their work i n 'The Real-time Volumetric Cloudscapes of Horizon: Zero Dawn' on the S I G G R A P H 2015 Advances i n Real-Time rendering i n Games course [1]. The purpose of this thesis is to extend the render library mallumo with real-time precomputed atmospheric effects such as the colour of the sky dependent on the position of the Sun, and transmittance of light of objects inside the atmosphere and beyond the atmospheric boundary. Implementation of these effects is based on the w o r k of Bruneton et al. [2]. Provided are also raymarched volumetric clouds illuminated by the before mentioned atmospheric model. 1 1 Mallumo M a l l u m o 1 is a global-illumination render library written i n the Rust p r o g r a m m i n g language. This library uses O p e n G L 4.5 internally to access G P U features. Mallumo provides safe abstraction over OpenGL, preventing most errors caused by incorrect usage of the A P I . Most of the errors are caught i n compile time, which is achieved by repurposing Rust type system and ownership m o d e l for O p e n G L constructs. The errors that can not be caught i n compile time, e.g. running out of G P U memory, are detected during runtime and reported to the user of this rendering library, i n a w a y that makes it possible to react to them. M a l l u m o uses, as is typical, for the basic scene rendering polygon rasterisation. To provide global illumination effects, such as diffuse or specular interreflections, dynamic shadows, ambient occlusion, the user of this library may voxelize the scene and then fed it to the mallumo rendering pipeline. This is illustrated i n Figure 1.1. M a l l u m o supports rendering of camera aligned quad, which may be used either for postprocessing or ray-based rendering methods. Basic postprocessing, w h i c h is directly supported, includes blurring, gamma correction, several tone mapping functions, and many others. Figure 1.1: Sponza scene without albedo texture, illuminated directly and indirectly by the Sun using anisotropic V X G I . 1. Available on https: //gitlab. com/mallumo/mallumo. 3 2 Theoretical background This chapter covers theoretical background necessary for the understanding of atmospheric visual effects. Firstly, it defines basic terms from radiometry: radiant flux, irradiance, radiance, and transmittance; then it defines scattering and its subterms. Afterwards, this chapter provides a brief classification of clouds, their density, and their lighting. 2.1 Radiant flux Radiant flux , is the total amount of radiant energy emitted, reflected, transmitted or received per unit time. Its unit is Watt. 2.2 Irradiance Irradiance £ is defined as radiant flux received by a surface per unit area. Its unit is Watt/m2 . 2.3 Radiance Radiance L is defined as radiant flux emitted, reflected, transmitted or received by a surface, per unit area per unit solid angle. Its unit is Watt/m2 sr. 2.4 Transmittance The transmittance of the material is its effectiveness i n transferring radiant energy. M o r e specifically, it is the ratio of incoming and outgoing light, and it refers to the energy loss caused by absorption or scattering. A s absorption and scattering are affected by the wavelength of light, transmittance too is non-uniform and depends on the light's frequency. 5 2. T H E O R E T I C A L B A C K G R O U N D 2.5 Scattering Scattering is a physical phenomenon where radiation i n the f o r m of sound, m o v i n g particles or, as relevant to the atmosphere, light deviates f r o m a straight trajectory due to local non-uniformities. These may vary, but i n the context of atmospheric scattering, they are mostly molecules or small particles such as aerosols. The implication of scattering is that i n the direction f r o m w h i c h light is coming may not be a source of light, w h i c h is the reason w e perceive the sky as having colour. 2.5.1 Forward scattering and backscattering Change of trajectory caused b y scattering is not limited to an arbitrary range. It is, therefore, useful to provide distinction based o n the change of direction, and thus to define terms forward scattering and backscattering. The distinction is simple: forward scattering occurs w h e n radiation is deflected w i t h i n 90°of the direction of propagation, and backscattering w h e n the deflection is more than 90°, this is illustrated i n Figure 2.1. Figure 2.1: Light entering a scattering m e d i u m , p r o d u c i n g forward scattering and backscaterring. 2.5.2 Elastic scattering A scattering process is called elastic if during the scattering process the energy of the light is conserved, meaning while the trajectory may change, the energy is constant. Elastic scattering is an idealisation 6 2. T H E O R E T I C A L B A C K G R O U N D as the energy i n fact changes, but, if the loss of energy is sufficiently small, it can usually be neglected. 2.5.3 Dominant scattering processes in Earth's atmosphere There are two dominant scattering processes i n Earth's atmosphere, namely Rayleigh scattering a n d M i e scattering (both described i n detail further), with Rayleigh scattering being described as elastic. The domain of particles, o n w h i c h each scattering has the most influence, is given by dimensionless parameter a, defined as DC = 71-*- (2.1) A where Dp is the diameter of the particle, and A is the wavelength of incident radiation. If a is significantly less than 1 then most prevalent is Rayleigh scattering, if alpha is approximately equal to 1 then M i e scattering. In case alpha is significantly greater than 1, a class of geometric scattering models is required, however, i n the case of the atmosphere, most particles fall within the range of either Rayleigh or Mie scattering, and thus they are sufficient for accurate representation of scattering events. 2.5.4 Phase functions for Rayleigh and Mie scatterings Phase function Phase function is a type of one-dimensional functions describing angular distribution of scattered light based on the direction of incoming light. G i v e n scattering angle ]i, phase function returns the relative amount of light under ]i. Rayleigh scattering Rayleigh scattering is an elastic scattering of light caused by particles much smaller than the wavelength of the light. Typical particles whose scattering behaviour can be approximated w i t h Rayleigh scattering are air molecules, whose size is roughly i n the range of a. Rayleigh scattering is symmetrical around the axis of incoming light, and the 7 2. T H E O R E T I C A L B A C K G R O U N D Rayleigh phase function P R for air molecules is given by Rayleigh theory [3] as: pR(e) = ^ - ( i + cos2 (e)) (2.2) ion M i e scattering M i e scattering is scattering of light b y particles similar to the wavelength of the light, e.g. aerosols. M i e phase function is complex and consists of multiple lobes, which prevalence is given by the size of the scattering particle. A s the size of the particle exceeds the wavelength, the front lobe exceeds the other side or backward lobes w h i c h can be exploited, and M i e phase function PM can be approximated w i t h Henyey-Greenstein function, which was further improved by Cornette and Shanks (also k n o w n as Cornette-Shanks phase function) [3]: PM(0) « _ L ( l - g ^ O W W ) ( 2 . 3 ) 87r(2 + £ 2 ) ( 1 + £ 2 _ 2 £ a > s 2 ( 9 ) ) i where g G ( — 1,1) is an asymmetry factor denoting the w i d t h of the forward lobe. 2.5.5 Single and multiple scattering Single scattering occurs w h e n radiation is scattered once by localised scattering centre. However, i n case there are many scattering centres grouped together, they cause radiation to scatter multiple times which is called multiple scattering. Single scattering may usually be treated as a r a n d o m phenomenon, while multiple scattering is more deterministic, due to many scattering events that tend to average out. W h e n taking into account elastic scattering processes, such as mentioned Rayleigh scattering, simulation of multiple scattering is needed, because radiation may undergo multiple scattering events due to not losing m u c h energy. Still, the number of scatterings to compute may not be necessarily high, as Rayleigh scattering is not ideally elastic, and contribution of higher order scatterings is therefore not as strong. Eventually, photons w i l l either escape atmosphere into space due to change of their trajectory or lose energy because of scattering pro- 8 2. T H E O R E T I C A L B A C K G R O U N D cesses or be absorbed by objects inside the atmosphere including the planet itself. Single and multiple scattering is illustrated i n Figure 2.2. Figure 2.2: Single and multiple scattering, courtesy of [4]. 2.6 Shapes and density of clouds Clouds are classified into many different types. The most basic classification is based on the height on w h i c h they occur, w h i c h is then further subdivided based on the cloud shapes, as can be seen i n Figure 2.3. Figure 2.3: Different types of clouds occurring at w i d e range of altitudes, courtesy of [1]. Roger Clausse and Leopold Facy i n 'The clouds' [5] note that density of the clouds increases at lower temperatures and that the tem- 9 2. T H E O R E T I C A L B A C K G R O U N D perature decreases w i t h altitude. This implies that density of clouds proportionally increases w i t h altitude. C l o u d shapes and altitude-based density provide a framework for specifying density at given point, knowing just what type of cloud the point belongs to, and at w h i c h altitude it is positioned. Turbidity is the reduction i n the transparency of an object due to particles suspended w i t h i n w h i c h cause absorption or scattering of the light. The examples of turbidity i n the atmosphere may include clouds or smog. 2.8 Lighting of clouds When a ray of light enters a cloud, it is partially absorbed or scattered. Scattering of light by aerosols is described by M i e scattering, w h i c h provides only single scattering. To fully compute ray's path, it is necessary to trace it through the cloud volume at small steps, w h i c h is computationally very expensive and not suitable for real-time performance. Schneider [1] proposes that the cloud volume behaves as a collector for light, meaning the more a point is surrounded by clouds, the higher the chance that light is refracted f r o m the cloud towards the point. The implication of this is that edges are darker than dense regions and v i e w rays sample more light w h e n going through them. This so-called Powder term is given by where d is density of a cloud at given point. To account for absorption Schneider [1] proposes to use BeerLambert law, also known as Beer's law, which relates transmittance of material to its optical depth. 2.7 Turbidity Powder(d) — 1.0 — e-2d (2.4) = e — T (2.5) 10 2. T H E O R E T I C A L B A C K G R O U N D where T is transmittance of the material sample, <$>e is the transmitted radiant flux, Og is the received radiant flux by that material sample and T is its optical depth. Together the attenuation A is given by the following formula A = PM x Powder x Beer (2.6) where PM accounts for single scattering and Powder and Beer terms account for multiple scattering. 11 3 Related work 3.1 Atmosphere Since atmospheric simulations are an important part of many outdoor and indoor visualisations, there are many models describing it. They are mostly based on the same physical basis, however, each makes different simplifying assumptions which affect both the visual results and the performance. In this section, few select models w i l l be briefly described and compared. 3.1.1 Nishita93 model Figure 3.1: Fisheye skydome rendering of the spectral radiance of the Nishita93 model, for sun zenith angles 87°, 41°, 31°, 21°, courtesy of [6]. The Nishita93 model [7], illustrated i n Figure 3.1, is one of the first physically based atmospheric models. Nishita93 computes only single scattering and is based on numerical integration along the v i e w ray. Two transmittance samples are computed, one from the viewer to the sample, and one from the sample to the Sun. The first transmittance value is computed dynamically, and the second is precomputed and stored i n a 2D texture. Precomputation is done w i t h discretising the atmosphere into n$ spherical concentric layers of constant optical depths, and w i t h nc concentric cylinders oriented towards the Sun, whose intersections w i t h the spherical layers are used as sampling points for the precomputed 2D transmittance texture. 13 3- R E L A T E D WORK Complexity and limitations The precomputation stage evaluates a single integral w i t h ns samples for a l l elements of the ns x nc texture, a n d thus has 0(ns 2 nc) time complexity a n d 0(nsnc) m e m o r y complexity. D u r i n g rendering, a single integral is evaluated for each pixel w i t h 0(ns) samples using the precomputed transmittance texture with additional 0(1) memory complexity necessary for numerical integration. This model completely ignores multiple scattering, w h i c h makes it almost always underestimate radiance values by roughly one third compared to the ground truth. 3.1.2 Nishita96 model Figure 3.2: Fisheye skydome rendering of the spectral radiance of the Nishita96 model, for sun zenith angles 87°, 41°, 31°, 21°, courtesy of [6]. The Nishita96 model [8], illustrated i n Figure 3.2, is a n extension of Nishita93 w i t h a n approximation of multiple scattering. Multiple scattering may be of any order, however, the authors compute only double scattering due to the increasing computational complexity. For double scattering, it is required to compute integral over all directions at each sampling point along the v i e w ray. The authors recommend to compute the integral only for eight directions and to precompute single scattering for each nx x ny x n z point i n the grid along those directions, and store it i n a 3 D texture for better performance. 14 3- R E L A T E D WORK Complexity and limitations During the precomputation stage, eight 3D tables are computed, each for one direction. For each vertex, a single scattering is computed incrementally from one vertex to the next along the axis determined by the currently computed table which yields 0 ( n 3 ) time and memory complexity. During rendering, similarly to Nishita93, a single integral is evaluated for each pixel w i t h additional eight lookups into the precomputed textures, w h i c h leads to 0(ns) time complexity and 0(1) memory complexity. Using this model the viewer is limited to the positions within the atmosphere and underestimates radiance, although not as m u c h as Nishita93, which is caused by only accounting up to second scattering (per the authors' implementation). 3.1.3 Preetham model Figure 3.3: Fisheye skydome rendering of the spectral radiance of Preetham, for sun zenith angles 87°, 41°, 31°, 21°. Note how bright the sky is compared to the previous models, courtesy of [6]. The Preetham m o d e l [9], illustrated i n Figure 3.3, is still one of the more used models i n computer graphics due to its simplicity and performance. This model is directly based on Nishita96 by computing radiance for many view directions, sun directions and turbidity values and then fitting them w i t h an analytical function from Perez et al.[10] using non-linear least square fitting. Preetham m o d e l is limited to only g r o u n d v i e w and is also limited to the Sun being above the horizon. W h i l e by itself the Preetham m o d e l does not have aerial perspective, it is usually paired with an independent equation derived using the flat Earth hypothesis, which simplifies it. Since the Preetham 15 3- R E L A T E D WORK model and the aerial perspective equation are separate, it can lead to inconsistencies, especially near the horizon. Complexity and limitations This model has no precomputation phase, and for each pixel, the time and memory complexity are 0(1). Because it is based on the Nishita96 model, it accounts only up to second scattering. It is also limited to the Sun being above the horizon. The viewer is limited to the ground because the analytical functions were fitted for the viewer at the ground level, and the complementary aerial perspective assumes flat Earth. Somewhat surprisingly, the Preetham m o d e l overestimates the radiance values, probably due to the analytical functions used, not being an exact fit to the data extrapolated from the base Nishita96 model. 3.1.4 Haber model Figure 3.4: Fisheye skydome rendering of the spectral radiance of the Haber model, for sun zenith angles 87°, 41°, 31°, 21°. Note h o w the sky is less orange near the horizon compared to the Nishita93 and the Nishita96 models, courtesy of [6]. The Haber m o d e l [11], illustrated i n Figure 3.4, is based on the Nishita96 model with storing atmospheric data in ns layers of constant optical depths, but stores precomputed scattering data in nr x UQ X n§ grid based on spherical coordinates centred on the viewer. Multiple scattering computations are also more precise as integration occurs over all directions at each grid cell. The m a i n approximations of the Haber model consist of replacing Rayleigh and M i e phase functions 16 3- R E L A T E D WORK w i t h their o w n for all scattering order, w h i c h causes at least for M i e scattering to lose some energy. Similarly to Nishita93 and Nishita96, rendering is done w i t h sampling along the view ray. Complexity and limitations A s s u m i n g fixed number of scattering orders, computing values for nr x tiQ x ritp grid takes Oin^-n^-n^ time due to the fact that all directions are taken into account and 0{nrnQn^) memory for the 3D texture. Due to the transmittance not being precomputed, each pixel takes 0(nrns) time w h i c h could, however, be reduced to 0(nr) w i t h O ( l ) memory. This model limits the viewer to the ground, because it is computed for a specific sun zenith angle and a specific viewer altitude. Evaluating a pixel also takes a comparably long amount of time due to having quadratic time complexity. 3.1.5 Bruneton model Figure 3.5: Fisheye skydome rendering of the spectral radiance of the Bruneton model, for sun zenith angles 87°, 41°, 31°, 21°. Courtesy of [6]. The Bruneton m o d e l [2], illustrated i n Figure 3.5, precomputes multiple scattering orders, including sun zenith angles below the horizon. This model supports all view angles and does not constrain the viewer i n any way, meaning that all positions are supported. This m o d e l was implemented as a part of this thesis, and therefore, it is described i n detail i n the following chapter. 17 3- R E L A T E D WORK 3.2 Clouds Clouds are very difficult to recreate i n computer graphics, especially when constrained to real-time performance. Over the years there have been many different techniques and methods, some of them are briefly described i n this section. 3.2.1 Skybox and skydome Skybox and skydome provide one of the simplest ways to create clouds. Either an artist creates 2 D texture or a photo of cloudy sky is taken, w h i c h is then projected onto box or dome. This box or dome is then fed into the used graphical pipeline and then rendered. This method is very performant, since it requires rendering only a couple of polygons, but is very limited i n its capabilities, and by itself, it is only capable of providing static clouds. 3.2.2 Implicit volumes Kniss et al. [12] propose using implicit volumes and a perturbation texture. The base cloud shape is defined by an analytic function, whose input is distorted w i t h an offset generated by querying the 3 D noise texture, as can be seen i n Figure 3.6. Figure 3.6: Implicit volume on the left and perturbed result on the right, courtesy of [13]. 1 8 3- R E L A T E D WORK 3.2.3 Polygon clouds Similar to the implicit volumes method, but instead of using an analytic function to describe the base shape, the bounding volume is defined by polygon model, an example can be seen i n Figure 3.7. Figure 3.7: A n example of a polygon cloud, courtesy of [14]. 3.2.4 Particle clouds The idea is to build clouds from small uniform particles. Each particle is semi-transparent, and after computation of their colour, they are blended together. 3.2.5 Procedural clouds Instead of defining the base volume which is then randomly perturbed, the shape of clouds is created by using noise w i t h certain properties. Perlin noise or Simplex noise are usually used, w h i c h are layered at increasing frequencies. This noise is then combined w i t h a height gradient to better simulate cloud density, that changes w i t h height. 1 9 4 Implementation This chapter describes the Bruneton m o d e l and its implementation, and cloud rendering method based on the work presented by Schneider [1] for the render library mallumo. 4.1 Bruneton model 4.1.1 Physical model The Bruneton model is a clear sky atmospheric model, which assumes atmosphere made out of only molecules and small particles such as aerosols. The atmosphere itself is a spherical layer of these particles around a globe contrasting the approach made b y some previously mentioned atmospheric models w h i c h assume flat Earth. The distribution of particles i n the atmosphere is not uniform, however, the density at each point is parametrised only by height, not by altitude or longitude. A t each point, light that is scattered and absorbed is given by where fie R and fie M are extinction coefficients for Rayleigh and M i e scatterings. For small particles, w h i c h are subject to Rayleigh scattering, f5e R is equal to scattering coefficient f5s R due to Rayleigh scattering being elastic. fis R is given by the Rayleigh theory[3]: where h is the altitude, A is the wavelength, n is the index of refraction of air, N is the molecular density at sea level, and HR is the thickness of the part of the atmosphere that is affected by Rayleigh scattering. For aerosols, scattering is given by M i e scattering. While Rayleigh scattering's behaviour can be accurately described as elastic, ignoring the loss of energy i n M i e scattering can lead to significant inaccuracies, as aerosols absorb a sizeable fraction of the incoming light. Therefore, it (4.1) (4.2) 21 4. I M P L E M E N T A T I O N is needed to include absorption coefficient Sa into extinction coefficient Be , w h i c h for M i e scattering becomes P M = P M + P M (4-3) Density of aerosols decreases exponentially w i t h height, and as such BS M is given by: ^ / a ) = j S s M ( 0 , A ) e i (4.4) where HM is the thickness of the part of the atmosphere that is affected by M i e scattering. 4.1.2 Rendering equations We define the following: • L(x, v, s) is the radiance of light reaching x from direction v with the Sun being i n direction s, • XQ (X, V) is the extremity of ray originating i n x w i t h direction v located either at the top of the atmospheric boundary or o n the ground, • Earth is a Lambertian surface w i t h a height field of reflectance a(x,A) and normal n(x). W i t h these we define the following equations: ry ie{R,M} T ( x , y ) = e x p ( - £ £ 6\{h)dh) (4.5) T T J I ( \ _ J J2 7r ^(X 0/ s)to.n(xo)dto if inside atmosphere, 1[L\{XQ,S) — < IU otherwise. (4.6) J[L]{y,v,s)= f £ j 6f(y)Pi (o;.z;)L(y,a;,s)da; (4.7) • / 4 7 r i e { R , M } where T is transmittance between x and y, X is radiance of light reflected at XQ, J is radiance of light at height y i n direction —v. 22 4. I M P L E M E N T A T I O N LQ(X,V,S) W i t h these we define following rendering equations: L(x,v,s) = LQ(X,V,S) + lZ[L](x,v,s) + S[L](x,v,s) (4.8) T(x, Xo)LSUN v = s and the Sun is not occluded, 0 otherwise. (4.9) K[L] (x, v, s) = T(x, x0)X[L] (x0, s) (4.10) S[L](x,v,s)= T(x,y)J[L](y,v,s)dy (4.11) Jx £[L](x,s) = / L(x,co,s)co.n(x)dco (4.12) Jin where LQ is the direct sunlight LSUN attenuated b y T, 1Z is the light reflected at XQ attenuated by T before reaching x, S is the light scattered towards x between XQ and x, £ is the irradiance of x. These equations are used directly i n the precomputation and rendering part of this method. 4.1.3 Method The method is based on precomputing L as much as possible w i t h only m i n i m a l approximations and idealisations. To compute L, zero a n d single scatterings are computed exactly, while computation of multiple scattering is approximated w i t h the assumption that the Earth is a perfect sphere of constant reflectance. W i t h perfect sphere, position and direction can be reduced to only two parameters: altitude r and v i e w zenith angle u. S u n direction is given by spherical coordinates 9 and (p, where 9 and (p can be thought of as intermediate variables for us a n d v. Thus to express functions dependent o n x, v, s only 4 parameters are needed, 2 for x and v a n d 2 for s. r = \x\ (4.13) u = ^ (4.14) = ^y- (4.15) v = v • s (4.16) 23 4. IMPLEMENTATION To take these approximations into account, w e define P ' R , P ' M , L ' , L'Q, L'SUN, a', X'Q, T', £', S', J ' , w h i c h are approximations of PR, PM, L, Lo, Lsun, a, XQ, T, S, S, J, for the case of spherical Earth and w h i c h are parametrized w i t h r, u, us, and v, as needed. The only exception is T' w h i c h is parametrized w i t h r a n d u, a n d thus corresponds to T(x, XQ(X, V)). TO compute transmittance between arbitrary points x and y, we use the following identity as i n 'Accurate atmospheric scat- tering'[15] = TO ( 4 ' 1 7 ) where rx a n d ux are given for x b y Equations (4.13) a n d (4.14), a n d where where rd=^d2 + 2duxrx + rx (4.18) to = ^ (4-19) \x-y\ (4.20) 4.1.4 Precomputation In the precomputation phase three tables are computed: transmittance table T , irradiance table E , and scattering table S. T stores transmittance T'(r, u), E stores irradiance E'(r, us) and S stores scattering S'(r, u, uS/ v). For T , transmittance T' is computed for all r and u. To precompute E and S, Algorithm 4.1 is used to compute each scattering order one after the other. To this end, it uses three intermediate tables A E , A S and A J of w h i c h two are s u m m e d w i t h their respective tables after the end of each iteration. To save space, Bruneton et al. [2] propose storing the red component of M i e scattering i n the a channel of S. The following equation is used to approximate the blue and green channels w i t h the red channel S M ~ S R — - ^ - ^ (4.21) ?>R,r PM,r PR 24 4. I M P L E M E N T A T I O N The idea behind A l g o r i t h m 4.1 is that we can define L as 1 = 10 + ^ + 12 +... (4.22) where L, denotes the contribution of light reflected and scattered i times. The reflection and scattering terms are given by ft and S. Thus for any i greater than 0, L, is given by Li = (K + S)[Li-1] (4.23) w i t h this, L can be rewritten as L = L 0 + I 4 + L 2 + . . . (4.24) = L 0 + (ft + S) [L0 ] + (ft + S) [L2 ] + . . . = L 0 + (ft + S) [L0 ] + (ft + 5) [(ft + S) [L0 ]] + . . . A l g o r i t h m 4.1 Precompute n scattering orders T ( r , f 0 <- T ' ( r ^ ) A E ( r , p s ) ^ £ ' [ L [ , ] ( r / F s ) AS(r,u,us,v) 4- S'[L'Q}{r,u,us,v) E(r,jiB) 4- 0 S(r,n,n8,v) i- lsS(r,u,us,v) for z ^— 1 to n do AJ(r, p S / v ) <- J " ' [ T ^ A E + AS] (r, u, us,v) AM(r,ji8) 4- 8'[tsS]ir,\i3) lsS(r,u,us,v) 4- $*Q T(x,y)hJ(\y\,u,us,v)dy E(r,}is) 4- E(r,}is) + AE(r,}is) S(r, u, uSl v) 4- S(r, u, us,v) + AS(r, u, us,v) end for 25 4. I M P L E M E N T A T I O N 4.1.5 Parametrization In the precomputation phase, several tables are filled with their corresponding values. While it is useful to think of these tables as simple N dimensional textures, whose values can be retrieved by keying w i t h [0,1]N coordinates, at the hardware level their storage is discretised. To effectively utilise the [0,1] range, a special m a p p i n g between the coordinates and their physical counterparts must be devised. T and E are tables for transmittance and irradiance functions dependent on r and u. For these naive m a p p i n g w o u l d be sufficient. However, S is a 4 dimensional table, therefore, it grows rapidly w i t h more precision and a special care must be taken to conserve memory. Naive mapping to [0, l ] 4 without large resolution would produce visible artefacts especially near the horizon, so to better exploit the range of possible values, Bruneton et al.[2] propose the following mapping ur (4-25) 1 + ^ i f ^ < 0 a n d A > 0 , otherwise.2 2p+2H I _ g-3^s-0.6 M * = I _ g -3 .6 (4 -2 7 ) 1 + V where (4.28) p = J r 2 - R 2 b (4.29) H=y/B*-Rl (4.30) A = r2 u2 - p2 (4.31) where Rjy is the distance from Earth's centre to the bottom atmospheric boundary, and Rf is the distance to the top atmospheric boundary. 4.1.6 Rendering D u r i n g rendering, several terms must be evaluated: SkyColor, Radiance, Irradiance. SkyColor determines the colour of the unob- 26 4. I M P L E M E N T A T I O N scured sky, Radiance must be taken into account w h e n observing an object at point y from point x, and Irradiance is light received by point x. Irradiance is stored i n a precomputed f o r m i n E . SkyColor a n d Radiance are defined as follows SkyColor\r,]i,]is,v) = L'sun{}i, }is, v)T'(r, }is) + L'sky(r, ji, jiS/v) (4.32) Radiance{x,y,}is,v) = L'(rX/jiX/jiS/v) - T(x,y)L'(rd/jid/jiSid/v) (4.33) where rx, \ix, r&, ]id are the same as i n Equation (4.17), a n d L 'sky(r 'V'Vs,v) = £ R[{v)S[{r,}i,}is,v) ie{RRM} rx}is + v\x -y\ Usd= r s ' rd 4.1.7 Computational complexity Precomputation is the most costly part of this model. It involves computing integral over all ng x n^ directions for all cells of a 4 D table yielding for fixed number of scattering orders 0{nr^n^nvnQn^) time complexity and 0(nrn^n^snv) m e m o r y complexity. Rendering itself has 0 ( 1 ) time and memory complexity. 4.1.8 Limitations Limitations for this atmospheric model stem from the approximations, which make it possible to precompute. Firstly, it assumes ideally spherical Earth w i t h homogeneous particle distribution dependent solely o n the distance from the Earth's centre. Thus are discarded any possible irregularities occurring due to local differences w h i c h surely exist for any planet, be it changes i n terrain or differences i n the atmosphere. Furthermore, as a consequence of atmospheric homogeneity, a clear sky is assumed meaning clouds are not compatible with this model i n the sense of affecting the scattering of light. (4.34) (4.35) 2 7 4. I M P L E M E N T A T I O N 4.1.9 Implementation details Tables parametrized b y r, ]i, ]is a n d v are 4 dimensional. M a l l u m o , w h i c h is based o n O p e n G L , does not support 4 D textures. D u e to this, the implementation of these tables is done i n the following way, similarly to the original implementation: internally they are regular 3D textures, but each 2 D layer stores 3 D information as sublayers positioned next to each other. Interpolation for the three coordinates that are stored regularly is done b y built-in linear interpolation, as provided b y O p e n G L . M a n u a l linear interpolation is used for the fourth coordinate. This implementation uses the same size of the textures as were used by the authors: • T is 256 x 64, has 3 channels, each of them is 4 byte float, taking 192 K B , • E , A E are 64 x 16, have 3 channels, each of them is 4 byte float, taking 12 K B , • S, A S , A J are 32 x 128 x 32 x 8, where the w i d t h is 32 x 8, the height is 128 and the depth is 32, have 4 channels, each of them is 4 byte float, taking 16 M B . This method produces H D R images, meaning they are not bound to (0,1) range i n each R G B component, but instead the upper b o u n d is positive infinity. To convert this image into (0,1) range this implementation uses filmic tone mapping. The precomputation part should be faster than the original implementation, due to better exploitation of O p e n G L capabilities. To name a few, the original implementation embeds parameters into the shader source code, which is repeatedly done for each triplet of wavelengths. This way of changing values requires recompiling shaders, for fifteen precomputed wavelengths it w o u l d compile thirty shaders when only six are needed. O n the other hand, i n this implementation the values are changed w i t h uniforms. Furthermore, the original implementation uses geometry shaders to write to the individual layers of 3 D textures, instead of this, glNamedFramebufferTextureLayer is used to attach layers of 3 D textures directly to a framebuffer, skipping the unnecessary geometry shader stage. 28 4. I M P L E M E N T A T I O N The m a i n functional difference between this implementation and the original w o r k by Bruneton et al. is not computing light shafts. The rationale behind this is computing light shafts requires shadow volumes, w h i c h mallumo does not provide. 4.2 Clouds This section describes the implementation of clouds based on the work presented by Schneider [1]. The method has small precomputation phase i n w h i c h noise textures are generated. The rendering part consists of raymarching along the view ray and accumulating light provided by the atmosphere. 4.2.1 Modelling Modelling approach of clouds is based on raymarching, as described i n [1]. V i e w direction is determined for each pixel and samples are accumulated along the view ray. Density is computed at each sample point, and the sample is illuminated by the atmosphere, the Bruneton atmospheric model is used i n this implementation, as described i n the previous chapter. The density is given by a set of parameters whose product gives the final density. The first parameter is coverage, w h i c h determines whether there is a cloud. While technically the coverage parameter is either 0 or 1, it is better to define it as a gradient, to provide smoother scale and to prevent hard edges. The second parameter is given by altitude: the higher the sample, the denser the cloud. The third parameter is given by the cloud's type. In this implementation, only three types of clouds are provided: stratus, cumulus and cumulonimbus. Again, these are implemented as gradients over altitude, and the cloud type parameter is a gradient over the types of clouds. W i t h this method it is possible to define numerous types, however, this is not sufficient for the cloud types, for w h i c h is characteristic that individual clouds overlay each other, e.g. cirrocumulus. 2 9 4. I M P L E M E N T A T I O N 4.2.2 Texture generation This method of rendering clouds uses three noise textures a n d one control texture. A t each point, the three noise textures are queried and combined, and the control texture provides information about coverage, cloud type and turbidity The textures are generated from the following noises: • Worley noise was introduced by Steven Worley [16] and is regularly used for caustics and water effects. It has r o u n d features, w h i c h make it suitable for modelling billow like shapes similar to clouds. • Simplex noise was introduced and later improved by K e n Perlin [17]. Layering 2D Simplex noise at increasing frequencies creates visually interesting and detailed hills and valleys. This extended to 3 D provides clouds w i t h a more detailed look. • C u r l noise is used for fluid, fire, a n d smoke effects, and w h e n used as a lookup table is a relatively inexpensive method to distort cloud shapes and add turbulence. Two of the three noise textures are created b y modulating a n d layering inverted Worley and Simplex noise. Curl noise is used for the third one: • The first texture is used for providing base shape for the clouds and has four channels, i n the first one is combined SimplexWorley noise and i n the other three is Worley noise at increasing frequencies. Its resolution is 1283 , has 4 channels, each of them is 4 byte float, and takes 32MB. Figure 4.1: Simplex-Worley noise and Worley noise at increasing fre- quencies. 30 4. I M P L E M E N T A T I O N The second texture provides detail to the base shape, it has three channels, each of them is Worley noise at increasing frequencies. Its resolution is 323 , has 4 channels, each of them is 4 byte float, and takes 384KB. Figure 4.2: Worley noise at increasing frequencies. The third texture has curl noise at all three channels, its resolution is 1282 , has 3 channels, each of them is 4 byte float, and takes 192KB. Figure 4.3: C u r l noise. • The control texture is a 2D texture and has three channels. The first one contains coverage of the sky, the second one is turbidity, and the third one is used for the cloud type. 4.2.3 Rendering Rendering clouds is done by raymarching. That means that given a point and a vector, a set of points is sampled along the ray. In the case of clouds, the data that are collected f r o m samples are densities at each sample point. The densities that are collected are used i n several ways. W h e n raymarching a view ray, density is used to occlude what 31 4. I M P L E M E N T A T I O N is behind the sample, and at each view ray's sample it is also required to determine its colour, w h i c h is given by the following equation Colour = Attnospherelrradiance x PM X Beer x Powder (4.36) Atmosphere irradiance is computed as described i n the previous section. The Powder term requires density at sample which is computed by Algorithm 4.2 and the Beer term requires optical depth to the light source, w h i c h is just another raymarching f r o m the position of the sample towards the light. Algorithm 4.2 Sample cloud density Input: x sample coordinates / base scale C, C s control texture, scale S, Ss Simplex-Worley texture, scale W, Ws Worley texture, scale U, Us curl texture, scale Output: Density sample density Control «— C(xxz x / x Cs ) Coverage «— ExtractCoverage(C, Control) CloudType «— ExtractCloudType(C,Control) Turbidity «— ExtractTurbidity(C, Control) CloudTypeDensity «— CloudType^ensny AltitudeDensity «— AltitudeDensity Gradient{CloudType,Xy) StableDensity «— CloudTypeDensity x AltitudeDensityx Turbidity BaseDensity S(x x / x Ss) x StableDensity CurlOffset«— U(xxz x J xUs) DetailErosion «— W(x x / x W j + CurlOffset) x StableDensity Density max(BaseDensity — DetailErosion,0) 32 4- I M P L E M E N T A T I O N 4.2.4 Optimizations Raymarching is costly w h i c h leads to poor framerate. This can be partially alleviated with the following techniques, at the loss of visual quality. Luckily, pixel level details are not necessary for clouds, so the loss is not that important. Downsampling The most basic optimisation technique is to simply render at a lower resolution and then stretch the image. Reprojection Reprojection is based o n exploiting the fact, that the camera does not move rapidly between frames. Thus the majority of pixels w o u l d have mostly correct values if they were not redrawn, albeit they may be slightly moved, which is corrected by taking into account the previous view matrix. Algorithm 4.3 is parametrised w i t h Z , w h i c h is the side of a square of which one pixel is computed each frame. Randomizing the order of the pixels slightly reduces artefacts, that are created by having old values next to each other. 33 4. I M P L E M E N T A T I O N Algorithm 4.3 Reproject previous accumulated frame Input: Q pixel's texture space coordinates N size of the square of pixels belonging to the same group V view matrix W previous view matrix P projection matrix F previous frame Fs subframe S frame size Ss subframe size Z subframe number Output: Colour colour of the pixel Cn = [Q X SJ Offset <- Cn mod N FragmentFrameNumber ^— N x Offsety + Offsetx if FragmentFrameNumber = Z mod N2 then Colour <- Fs (( LQ x SS J + 0.5)/Ss) return end if Cw 4- ToWorldSpace(Ct,P,W) Reprojected <— P x V x Cw if Inside(ReprojectedXy, Square(Point(l,l),Point(—1, —1)) then Colour <- F(ToTextureSpace(Reprojectedxy)) else Colour <- Fs(Ct) end if 3 4 5 Results In this chapter are presented results of this thesis implementation. Benchmarks were compiled w i t h Rust 1.26, and were done o n 3 PCs, all running W i n d o w s 10, w i t h the following G P U s : N V I D I A GeForce G T X 860M, N V I D I A GeForce GTX1070 and A M D Radeon R X Vega 64. These G P U s are listed as G l , G 2 , G 3 respectively i n the tables below. The results are obtained by averaging 500 runs. 5.1 Sky In this section are presented results for sky rendering. Rendering of the frame of F u l l H D resolution(1920 * 1080) takes 1.463 ms, 0.447 ms, 0.421 ms for G l , G2, G 3 respectively. Renderings of the sky w i t h the Sun being at various zenith angles are s h o w n i n Figures 5.1, 5.2, a n d 5.3. Figure 5.1: Rendering of the sky w i t h the Sun at the zenith angle of 0°, w i t h the camera looking straight up. 35 5. RESULTS Figure 5.3: Rendering of the sky w i t h the S u n at the zenith angle of 93°, meaning the Sun is below the horizon. 36 5. RESULTS 5.2 Clouds In this section, different configurations of rendering parameters for cloud renderings are compared i n terms of rendering speed and artefacts. The clouds are illuminated by the Bruneton model, while using the sky as i n the previous section. A s mentioned previously, raymarching is costly. O n G l at F u l l H D resolution without any optimisations and w i t h 256 samples per view ray, the p r o g r a m was killed by the operating system due to the rendering taking too long, w h i c h is unacceptable for any application. Because of this, several configurations for optimisation techniques are compared i n terms of speed and visual quality. To this end, we define downsampling factor D , w h i c h is the reduction i n size of one dimension, reprojection factor R, which is the same as Z i n Algorithm 4.3, and N w h i c h is the number of samples per view ray. We constrain D to 1, 2 and 4. D o w n s a m p l i n g by the factor of 8 would lead to too much loss of details. R does not have an effect w h e n not m o v i n g the camera, as it is composed f r o m the previous frames, however, if the camera is m o v i n g , there may be artefacts due to the pixel values being too old. This means that on sufficiently performant G P U s this is not a concern, even w i t h larger R. However, on slower G P U s this may quickly lead to visual errors. This is shown i n Figures 5.4 and 5.5 with overexaggerated R. Due to this, we constrain ourselves to R being either 2 or 4, meaning that the full frame is composed from 4 or 16 frames respectively. W h e n considering that 30 frames per second are needed to create the illusion of motion, at worst the oldest values are half a second old. Tested values for N were 128, 256 and 512. The m i n i m u m value chosen is 128, due to the fact that lower values would produce too many obvious visible artefacts. 37 5. RESULTS Figure 5.4: Rendering of the clouds w i t h R = 32 and rapidly m o v i n g camera. Figure 5.5 is enclosed i n the red square. Figure 5.5: Detail of Figure 5.4. 38 5. RESULTS Table 5.1 shows that: • Doubling D reduces the rendering time to half, i n some configurations to one third, this is slightly unexpected as doubling D reduces the final image to a fourth of its size. One possible explanation is the overhead of the cloud rendering method, possibly waiting too long for the texture lookups. • D o u b l i n g R reduces the rendering time by two thirds o n some configurations a n d b y third o n others. This can be explained by the overhead of reprojection, w h i c h is not w o r t h o n smaller resolutions, w h i c h downsampling imitates. • D o u b l i n g N increases the rendering time roughly twofold, the explanation is that each view ray needs twice as many computa- tions. D R N Gl(ms) G2(ms) G3(ms) 1 2 512 1258.392 132.948 88.641 1 2 256 733.992 77.371 49.814 1 2 128 464.685 48.893 29.570 1 4 512 484.961 56.288 35.162 1 4 256 285.216 32.842 19.767 1 4 128 182.437 21.083 12.060 2 2 512 598.094 55.686 34.406 2 2 256 287.245 32.250 19.339 2 2 128 182.501 20.671 11.512 2 4 512 216.141 23.176 17.586 2 4 256 126.971 13.378 9.390 2 4 128 80.595 8.484 5.405 4 2 512 235.653 23.323 17.229 4 2 256 136.876 13.254 9.250 4 2 128 87.532 8.256 5.265 4 4 512 80.553 9.456 13.209 4 4 256 46.604 5.229 6.955 4 4 128 29.207 3.193 3.736 Table 5.1: C l o u d rendering speed at F u l l H D resolution. 39 5. RESULTS Results for cloud rendering are shown i n Figures 5.6 and 5.7 w i t h the Sun being at various positions. The loss of details i n clouds for some D and N configurations is highlighted i n Figures 5.8, 5.9, 5.10 and 5.11. Configurations w i t h various R values are not compared, because for the chosen values of R, only some pixel values are old enough to produce some visibly wrong pixels and only w i t h rapidly moving camera. The effect of changing D is s h o w n i n Figures 5.8 and 5.9. W h i l e increasing D leads to higher performance, as s h o w n i n Table 5.1, it directly causes the loss of details. Note, that the image is only a small part of the resultant image, and the decrease i n details is not as obvious w i t h regularly used values for the field of view. Artefacts caused by discretisation of the noise functions into small resolution tables and insufficient step length can be seen i n Figure 5.8. Again, this is not noticeable w i t h the regularly used field of view values. The effect of changing N is s h o w n i n Figures 5.10 and 5.11. The number of samples impacts the length of the step w h e n raymarching through the c l o u d volume. W i t h a lower number of samples, less density is accumulated, especially w h e n pockets of high density are missed. 40 5. RESULTS Figure 5.6: Rendering of the clouds with D equal to 1, N equal to 512, and w i t h the Sun at the zenith angle of 50°. Figure 5.7: Rendering of the clouds with D equal to 1, N equal to 512, and w i t h the Sun at the zenith angle of 66°. 41 5. RESULTS Figure 5.8: Rendering of the clouds w i t h the field of v i e w of 16°, D equal to 1, and N equal to 512. Note the artefacts caused by discretisation of the noise functions and insufficient step length. Figure 5.9: Rendering of the clouds w i t h the field of v i e w of 16°, D equal to 4, and N equal to 512. 42 5. RESULTS Figure 5.10: Rendering of the clouds w i t h D equal to 1, and N equal to 512. Figure 5.11: Rendering of the clouds w i t h D equal to 1, and N equal to 128. 4 3 6 Conclusion This thesis extended the render library m a l l u m o w i t h an accurate low-cost atmospheric model, and w i t h a cloud m o d e l p r o v i d i n g a robust framework for specifying the weather, capable of r u n n i n g i n real-time. These extensions were tested w i t h various optimisation configurations. Results were then compared i n terms of computational speed and image quality. Future w o r k for this thesis includes voxelization of the clouds, which may then be fed into mallumo's render pipeline, and thus provide voxel-based visual effects, such as dynamic shadows, or ambient occlusion for diffusing transparent media, whose usage w i l l be therefore consistent with the already existing solution. Possible future work may also include implementing voxel shadow volumes based o n the work of K l e h m et al. [18], and extending the atmospheric model w i t h light shafts. 4 5 Bibliography 1. S C H N E I D E R , A n d r e w . The Real-time Volumetric Cloudscapes of Horizon: Zero Dawn [online]. 2015 [visited o n 2018-05-15]. Available from: http ://advances.realtimerendering.com/s2015/ The, /,20Real-time, /,20Volumetric, /,20Cloudscapes, /,20of, /,20Horizon, /0 20-y.20Zero%20Dawn%20-%20ARTR.pdf. 2. B R U N E T O N , Eric; N E Y R E T , Fabrice. Precomputed Atmospheric Scattering. In: Proceedings of the Nineteenth Eurographics Conference on Rendering. Sarajevo, Bosnia and Herzegovina: Eurographics Association, 2008, p p . 1079-1086. E G S R '08. Available from DOI: 10.1111/j .1467-8659.2008.01245.x. 3. T H O M A S , G a r y E.; S T A M N E S , Knut. Radiative Transfer in the Atmosphere and Ocean. Cambridge University Press, 1999. C a m bridge Atmospheric and Space Science Series. ISBN 0-521-89061- 6. Available from DOI: 10.1017/CB09780511613470. 4. C H U A N G , Yung-Yu. Surface Integrators [online]. 2008 [visited on 2018-02-18]. Available from: h t t p s : / /www . c s i e . n t u . edu . tw/ ~cyy / courses / rendering / 08f a l l / l e c t u r e s / handouts / c h a p l 6 _ i n t e g r a t o r . p d f . 5. R O G E R C L A U S S E , Leopold Facy. The Clouds. N e w York: Grove Press, 1961. 6. B R U N E T O N , Eric. A Qualitative and Quantitative Evaluation of 8 Clear Sky Models. CoRR. 2016, vol. abs/1612.04336. Available from arXiv: 1612.04336. 7. NISHITA, Tomoyuki; SIRAI, Takao; T A D A M U R A , Katsumi; N A K A M A E , Eihachiro. Display of the Earth Taking into Account Atmospheric Scattering. In: Proceedings of the 20th Annual Conference on Computer Graphics and Interactive Techniques. Anaheim, C A : A C M , 1993, pp. 175-182. S I G G R A P H '93. ISBN 0-89791-601-8. Available from DOI: 10.1145/166117.166140. 8. NISHITA, Tomoyuki; D O B A S H I , Yoshinori; N A K A M A E , Eihachiro. Display of Clouds Taking into Account Multiple Anisotropic Scattering and Sky Light. In: Proceedings of the 23rd Annual Conference on Computer Graphics and Interactive Techniques. N e w York, N Y , 47 B I B L I O G R A P H Y U S A : A C M , 1996, p p . 379-386. S I G G R A P H '96. I S B N 0-89791- 746-4. Available from DOI: 10.1145/237170.237277. 9. P R E E T H A M , A . J.; S H I R L E Y , Peter; SMITS, Brian. A Practical Analytic M o d e l for Daylight. In: Proceedings of the 26th Annual Conference on Computer Graphics and Interactive Techniques. N e w York, N Y , U S A : A C M Press/Addison-Wesley Publishing C o . , 1999, pp. 91-100. S I G G R A P H '99. ISBN 0-201-48560-5. Available from DOI: 10.1145/311535.311545. 10. P E R E Z , R.; S E A L S , R.; M I C H A L S K Y , J. All-weather model for sky luminance distribution—Preliminary configuration and validation. Solar Energy. 1993, vol. 50, no. 3, pp. 235-245. ISSN 0038- 092X. Available from D O I : h t t p s : / / d o i . org/10 .1016/0038- 092X(93)90017-I. 11. H A B E R , Jörg; M A G N O R , Marcus; SEIDEL, Hans-Peter. Physicallybased Simulation of Twilight Phenomena. ACM Trans. Graph. 2005, vol. 24, no. 4, p p . 1353-1373. ISSN 0730-0301. Available from DOI: 10.1145/1095878.1095884. 12. KNISS, Joe; P R E M O Z E , Simon; H A N S E N , Charles; EBERT, David. Interactive Translucent Volume Rendering and Procedural M o d eling. In: Proceedings of the Conference on Visualization '02. Boston, Massachusetts: IEEE Computer Society, 2002, p p . 109-116. VIS '02. I S B N 0-7803-7498-3. Available also from: h t t p : / / d l . acm . org/citation.cfm?id=602099.602114. 13. H A D W I G E R , Markus; KNISS, Joe M . ; R E Z K - S A L A M A , Christof; W E I S K O P F , Daniel; E N G E L , Klaus. Real-time Volume Graphics. Natick, M A , U S A : A . K . Peters, Ltd., 2006. ISBN 1568812663. 14. B O U T H O R S , Antoine; N E Y R E T , Fabrice; M A X , Nelson; B R U N E T O N , Eric; C R A S S I N , C y r i l . Interactive M u l t i p l e Anisotropic Scattering i n Clouds. In: Proceedings of the 2008 Symposium on Interactive 3D Graphics and Games. Redwood City, California: A C M , 2008, p p . 173-182. I3D '08. I S B N 978-1-59593-983-8. Available from DOI: 10.1145/1342250.1342277. 15. O ' N E I L , Sean. Accurate atmospheric scattering. In: GPU Gems 2: Programming Techniquesfor High-Perf ormance Graphics and GeneralPurpose Computation (Gpu Gems). Addison-Wesley Professional, 2005. I S B N 0-32133-559-7. 48 B I B L I O G R A P H Y 16. W O R L E Y , Steven. A Cellular Texture Basis Function. In: Proceedings of the 23rd Annual Conference on Computer Graphics and Interactive Techniques. N e w York, N Y , U S A : A C M , 1996, p p . 291- 294. S I G G R A P H '96. I S B N 0-89791-746-4. Available from D O I : 10.1145/237170.237267. 17. P E R L I N , Ken. Improving Noise. In: Proceedings of the 29th Annual Conference on Computer Graphics and Interactive Techniques. San Antonio, Texas: A C M , 2002, pp. 681-682. S I G G R A P H '02. ISBN 1-58113-521-1. Available from DOI: 10.1145/566570.566636. 18. K L E H M , Oliver; K O L , Timothy R ; SEIDEL, Hans-Peter; EISEM A N N , Elmar. Stylized Scattering via Transfer Functions and Occluder Manipulation. In: Proceedings of the 41st Graphics Interface Conference. Halifax, Nova Scotia, Canada: Canadian Information Processing Society, 2015, pp. 115-121. G I '15. ISBN 978-0-9947868- 0-7. Available also from: h t t p : / / d l . acm. o r g / c i t a t i o n . cf m? id=2788890.2788911. 49 A List of electronic attachments A l o n g w i t h the thesis, the attachments are included i n attachments. z i p file consisting of: • / b i n / folder, w h i c h contains executable files atmosphere .exe and clouds . exe, along w i t h manual. t x t , • /mallumo/ folder, w h i c h contains the entire m a l l u m o library extended with the atmospheric and cloud modules. Source code created as a part of this thesis can be found i n - /src/atmosphere/ - /assets/shaders/atmosphere/, - /src/clouds/ - /assets/shaders/clouds/, - / s r c / r e p r o j e c t i o n . r s - /assets/shaders/reprojection.frag. 51