An Efficient Approach to Real-Time Sky Simulation Kun Yang2,Qicheng Li25,Zhangjin Huang2,Jia Wang,Guoping Wang2 大e流aarg 心 wangjial@dpu.edu.cn Abstract 2.Related work 1.Introduction is one of the major idered the i whic eans the the feclimg of the ky en ncrs the app ed off the nes,volu d on h ds are d Ebent The of the real-timenqrmt g78-1-4244-1579-3/0725.00020071EEE
An Efficient Approach to Real-Time Sky Simulation Kun Yang1,2, Qicheng Li1,2,3, Zhangjin Huang1,2, Jia Wang4 , Guoping Wang1,2 1 Dep. of Computer Science & Technology, Peking University, Beijing, China 2 Key Laboratory of High Confidence Software Technologies (Peking University), Ministry of Education, China 3 IBM China Research Lab, Beijing, China {yangk, lqc, hzj, wgp }@graphics.pku.edu.cn 4 Network Center, DaLian Polytechnic University, Dalian, China wangjia@dlpu.edu.cn Abstract Real-Time sky rendering plays a great role on visualization in many 3D applications. It is difficult to simulate a realistic sky without considering the effect of clouds and the scattering effect of the atmosphere. In this paper, we use a physical scattering model to simulate the sky, and a Perlin Noise texture to create highly realistic clouds. Different effects of the sky are also generated by combining the lighting model with various atmospheric constituents. 1. Introduction Rendering realistic sky is one of the major challenges in the simulation of outdoor scenes. Although many of the simulation methods have considered the light effects, they usually neglect the influence of the environment itself, which means the atmosphere, clouds, fog, smoke and other gaseous constituents. Two approaches to sky rendering have traditionally been used in games and similar applications. In the static approach, one or more photographs are textured onto a 3D model of the sky. For example, a cloud texture can be overlaid on top of a blue sky texture. The cloud texture can then be rendered offset over time to produce an animation. While the resulting sky can be very convincing given a high quality photograph, the lack of dynamics is a significant drawback. The second approach involves creating clouds procedurally. Procedural cloud generation can be divided into two categories, volumetric and planar, based on how the clouds are represented. In this paper, we propose an efficient approach which combines the light scattering model with the simulation of clouds. In the end of this paper we give some examples generated by our algorithm. 2. Related work The realistic sky simulation has been an active area of research for many years. Numerous approaches have been proposed for realistic sky simulation. Nishita [1] brought out a rough experience-based sun light model which separated the sky area into strap light sources and using different CIE models in different environments. Inakge [2] and Irwin [3] considered the physical model which is based on the Rayleigh and Mie scattering. Preetham [4] presented a day light analysis model which has considered the atmosphere effect on the light. With the rapid development of GPU, Dobashi [5] and Hoffman [6] started to render the sky model using GPU. One of the most important sky scene simulations is the cloud. The appropriate clouds can increase the realistic feeling of the sky scene dramatically. The usual approaches of cloud simulation include the following two models: 1) The physical model, which uses the true physical and mathematical methods to simulate the cloud. The typical approach is proposed by Nishita [7]. Also Nelson Max [8] adopted volumetric rendering to enhance the effect of simulation. Their methods can produce highly realistic clouds, but the calculation is too complex to be real-time. 2) The texture model, which employs one or more textures to combine and rotate to simulate the flow of cloud. The typical methods include Gardner [9], Perlin [10] and Ebert [11]. The texture model is widely used in the real application of virtual environment because of the real-time rendering requirement. 978 -1-4244-1579-3/07/$25.00 © 2007 IEEE
realistic feeling.However,too many sampling points 3.Sky model cost much more spending in the computer resource and the improvement of eftects is not so obvious.We This section descnbes a high realisti sky dome choa%the sampling distances as△8=△p=l5, model.To ncrease the realistic feeling of the sky which means only 144 verkex points will be used to scene.the flowing clouds effect is considered.A describe our sky dome model rendering method based on the texture map combined with a light scattering model is proposed to create a 3.2.The simulation of clouds highly realistic sky seene. After building the geometry skeleton,we use sphere 3.1.Sky deme model texture mapping to mask the cloud texture on the sky dome.which will increase the realistic fecling of sky. The sky dome model [14.15]is the skekton of this I's diffcult to simulate clouds in 3D enviroements sky model,which will create a hemi-sphere to cover because the light will be retlected,rettacted and the whole seene (see Figure 1h scamtered when it go through the clouds.We use texture distnbution method [12]to realize the flow of clouds.The core idea of this mcthod is to scroll sky 起xr减a random speed in both u and v directions (see Figure 3).To make it more realistic,we build multi-layer cload textures and different layer mowves at a different speed,then we mix these layer into one 起xure. Figure 1.The sky dome model We define the sky domse model by the polar system with the center of sphere as the origin and r as the adius (see Figur2宝 r=r0osin属仍 '■r属 =r cos(o)cos) Here,is the latitude and is the longitude: 05os/205052.Then we ca get every poimt's coordinales (x y.z)according to its latitude Figure 3.The sketch map for the simulation of and longitude. clouds Now we use the Perlin Noise [10]to generate the cloud texture.Abo Pallister [13]proposed a idea of comhining four noise textures to creale clouds.To build a Pertin Noise,we need a noise fuction and an imerpolation function.The noise fuction i a random namber generator which will gemerate a random namber according to an integer number.The Figure 2.The polar system inerpoltion fiction is alays seleeled from the linear interpolation,cosine interpolation and cubic After construction of the mathemanical model of the ncpo山tic. sky dome,we will sample points on the hemi-sphere, using the discrete sampling on the latitude and longitude coordinates The distance of latitude sampling is Ap and the loegitade one is A6.Then the toeal number of the sample points is 石 “11+1石 (360/A890/△9·Sampling more points will Figure 4.The distribution of noise produce a higher rendering precision and higher 157
3. Sky model This section describes a high realistic sky dome model. To increase the realistic feeling of the sky scene, the flowing clouds effect is considered. A rendering method based on the texture map combined with a light scattering model is proposed to create a highly realistic sky scene. 3.1. Sky dome model The sky dome model [14, 15] is the skeleton of this sky model, which will create a hemi-sphere to cover the whole scene (see Figure 1). Figure 1. The sky dome model We define the sky dome model by the polar system with the center of sphere as the origin and r as the radius (see Figure 2): cos( )sin( ) sin( ) cos( )cos( ) x r y r z r I T I I T Here, I is the latitude and T is the longitude: 0 / 2, 0 2 dd dd I S TS . Then we can get every point’s coordinates (x, y, z) according to its latitude and longitude. Figure 2. The polar system After construction of the mathematical model of the sky dome, we will sample points on the hemi-sphere, using the discrete sampling on the latitude and longitude coordinates. The distance of latitude sampling is 'I and the longitude one is 'T . Then the total number of the sample points is (360 / )(90 / ) ' ' T I . Sampling more points will produce a higher rendering precision and higher realistic feeling. However, too many sampling points cost much more spending in the computer resource, and the improvement of effects is not so obvious. We choose the sampling distances as ' ' T M 15 , which means only 144 vertex points will be used to describe our sky dome model. 3.2. The simulation of clouds After building the geometry skeleton, we use sphere texture mapping to mask the cloud texture on the sky dome, which will increase the realistic feeling of sky. It’s difficult to simulate clouds in 3D environments because the light will be reflected, refracted and scattered when it go through the clouds. We use texture distribution method [12] to realize the flow of clouds. The core idea of this method is to scroll sky texture at a random speed in both u and v directions (see Figure 3). To make it more realistic, we build multi-layer cloud textures and different layer moves at a different speed, then we mix these layer into one texture. Figure 3. The sketch map for the simulation of clouds Now we use the Perlin Noise [10] to generate the cloud texture. Also Pallister [13] proposed an idea of combining four noise textures to create clouds. To build a Perlin Noise, we need a noise function and an interpolation function. The noise function is a random number generator which will generate a random number according to an integer number. The interpolation function is always selected from the linear interpolation, cosine interpolation and cubic interpolation. Figure 4. The distribution of noise
To ereate a smooth noise fuanction.we will directions.We import the model provided by Homlian construct some new noise functions by changing the [6]which is more physically accurate to this work. ampliade and froquecy as follws: ymy■Y ynk=ersistence◆e Here,persistemce is a factor which means the amplitude will change with the froquency.The fimal fanction is gencrated by summing up all of these noise fimctions. The final 2D result of Perlin Noise is illustrated in Figure 7.Sketch map of the scattering model Figure 5. Based on the physical model,we can get the c可tion as follows: L=L。+L (2) where is the term of attenation.L is the incidence ray from the sky.As shown in Figure 7,one cam see that,which is the reflex ray with an intrinsic color.is absorbed by the atmosphere partly Figure 5.The generation of texture using the and deviates from primary direction as a result of Perin Noise outscatering.These two parts compose the attenuation of ray.However,the ray from sky and other directions 3.3.The seattering model cam radiate along the direction of the reflex ray.and this is the inscattenng ray. Now the cloud eftect is omly the gray etfect (see The equationn of absorptiomn and outscattering is Figure 6).Some simaltions use the cokr table map to )=1eee"=LA加 (3) simulate the sky scene.but the effect is some kind of where is the factor of abeorption.is the factor robotistic and not so realistic.We will use a precise scattering model to enhance the realistic focling of the of scatering.B and are based on the sky scene. wavelength ot rary.and can expressed as a triple vector in RGB system In practice.is set to the value suggested im【小.nd B.is the sum of the R与eh coefficient and Mie coefficient. However,there is also a phenomenon which can add light to a ray.Such case is iscattering,where the lig恤,4lch4 as origmally headed in a ditferent direction,is scattered into the path of a light ray and Figure 6.Comparison of not using and using adds to the ray's radiance.To compute the inseamering seattering models[】 y.we define a scattering ph现function岗仍,hich The tradrtional outdoor rendering method always gives the probability of scattered light going in the uses the following tog model in hardware to simulate direction and 6 is the angle between the incidence the effect: ray and the scattering ray.Since)is a probability L=41-f0+c,J 4) function.when integrated over the entire sphere of diroctions the result is I.Hence we have the following where is the intrinsic color which is alays a light equabion: blue color.C is the color of fog and f is the fog Cactoe.This model has an obvious shorteul:the simple .-民L+E0月 (40 Ar formula ean't expeess the real complex physical model where B.=B。+B。,and E is a scalar factor and the inteasiry does't change in different view which represents the emergy of sun.From(4线,we have 15
To create a smooth noise function, we will construct some new noise functions by changing the amplitude and frequency as follows: 2 * i i frequency amplitude persistence e ® ¯ Here, persistence is a factor which means the amplitude will change with the frequency. The final function is generated by summing up all of these noise functions. The final 2D result of Perlin Noise is illustrated in Figure 5. Figure 5. The generation of texture using the Perlin Noise 3.3. The scattering model Now the cloud effect is only the gray effect (see Figure 6). Some simulations use the color table map to simulate the sky scene, but the effect is some kind of robotistic and not so realistic. We will use a precise scattering model to enhance the realistic feeling of the sky scene. Figure 6. Comparison of not using and using scattering models [4] The traditional outdoor rendering method always uses the following fog model in hardware to simulate the effect: 0 (1 ) fog L L f Cf (1) where 0 L is the intrinsic color which is always a light blue color, Cfog is the color of fog, and f is the fog factor. This model has an obvious shortcut: the simple formula can’t express the real complex physical model and the intensity does’t change in different view directions. We import the model provided by Hoffman [6] which is more physically accurate to this work. Figure 7. Sketch map of the scattering model Based on the physical model, we can get the equation as follows: 0 Ex In L Lf L (2) where Ex f is the term of attenuation, LIn is the incidence ray from the sky. As shown in Figure 7, one can see that L0 , which is the reflex ray with an intrinsic color, is absorbed by the atmosphere partly and deviates from primary direction as a result of outscattering. These two parts compose the attenuation of ray. However, the ray from sky and other directions can radiate along the direction of the reflex ray, and this is the inscattering ray. The equation of absorption and outscattering is x x x Ab Sc Ab Sc L x L e e L e ( ) 0 0 ( ) E E E E (3) where E Ab is the factor of absorption, E Sc is the factor of scattering. E Ab and E Sc are based on the wavelength of ray, and can expressed as a triple vector in RGB system. In practice, E Ab is set to the value suggested in [4], and E Sc is the sum of the Rayleigh coefficient and Mie coefficient. However, there is also a phenomenon which can add light to a ray. Such case is in-scattering, where the light, which was originally headed in a different direction, is scattered into the path of a light ray and adds to the ray’s radiance. To compute the inscattering ray, we define a scattering phase function I( ) T , which gives the probability of scattered light going in the direction T , and T is the angle between the incidence ray and the scattering ray. Since I( ) T is a probability function, when integrated over the entire sphere of directions the result is 1. Hence we have the following equation: ( ) Ex Sun Sc L L E x E IT E ' ' (4) where Ex Ab Sc E E E , and Sun E is a scalar factor which represents the energy of sun. From (4), we have
4)-B化+B-》固 Hesearch[12]which was using the texture perturtation. The color of sky is simply gemerated by the specified color so it's not so real.Figure sd is the result of the Since B is the sum of the Raykigh coefficient and scamering model in [4.which mainly focused on the Mie coefficient,the function)depends on the simalation of scattering itself without considering the partickes doing the scattering.For particles much true environment.And Figure &e is the result of our smaller than the wavelength of light algonthm which illsstrates the realistic effoct. (rcQ0s以k到-A(is based on the Rayleigh cofficient.For larger particles.)c()is hased on the Henyey /Greenstein function which is an approximation to the Mie coefficient 3 鸟(=-(0+cw20 46 0-g ◆仍= ) 4r1+g'-2 g cos网 Here,g is the eceemtricity of the Mie coefficient.We use am appeoximation to express it,which scales with 1/4.Heace. 具的-ae子的+u…产-万 -2 where B and p ae the Rayleigh coeficieat and Mie coefficient,respectively.Substinuting ()(5). we can work out the scamering ray. 3.4.Implementation and results The algorithm is mainly composed by the following two steps: (1)Pre-Process step will use Perlin Noise to e件OriA雨 generale the clods texture.We don't need to consider Figure 8.Comparison of different approaches lo0 uch on the1ie-Gc0 suming of pre-wce线,since we can export a litle larger texture.The final texture The thickness of cloudk,the intersity of light and resolution is 512x 512.and it spends ws about one ohers paramcters are alo provided in our algorith to minute. penerate different cmvironment effects as shown in (2)Real-time Render step includes the modeling Figure 9. of sky dome,texture mapping and distbances and scattering calculation.The texture turbulences and 4.Conelusion and future work scattering resal calculation will take advantage of GPU because GPU has powerfual computing ability in We present an approach to the high realistic sky vector and matrx calcultion. simalation.The models of Perlin Noise cloud texture Using a compuer with AMD SempronT 2500+ and physeal seantering are imported into our algorithm 512M RAM memory and ATI 9600 Series (with 128M and good effects are generated. RAM),the frame refresh rate is more than 200 at the There is still much room foe improwement.Firstly. resolution640°480. the impact of the clouds on the light can be modeled We use several pictures to compare the effect of different approoches.Figure Sa is the sky box model moee accurately.Secondly,the reflection effect can be introduced in the physical model to make the which can't generale the fow of elouds easily.Figure environmemt moee realitie especially considering 8b is a simple sky dome model which has clumy and different time and ditferent emionment of'a day robotistie flow effect.Figure Sc is genemted by ATI 130
(1 )) ( ) ( ) ( 0 x Ex x Sc Sun Ex Ex L x E L e e E E E E I T (5) Since Sc E is the sum of the Rayleigh coefficient and Mie coefficient, the function ( ) I T depends on the particles doing the scattering. For particles much smaller than the wavelength of light ( r 0.05O ), () () R I T IT is based on the Rayleigh coefficient. For larger particles, () () HG I TIT is based on the Henyey / Greenstein function which is an approximation to the Mie coefficient. 3 2 ( ) (1 cos ) R I T T S (6) 2 2 3/2 (1 ) ( ) 4 (1 2 cos ) HG g g g I T S T (7) Here, g is the eccentricity of the Mie coefficient. We use an approximation to express it, which scales with 2 1/ O . Hence, 2 3 (1 ) 2 ( ) (1 cos ) 2 3/2 4 (1 2 cos ) g Sc R M g g E IT E T E S S T (8) where R E and M E are the Rayleigh coefficient and Mie coefficient, respectively. Substituting (8) into (5), we can work out the scattering ray. 3.4. Implementation and results The algorithm is mainly composed by the following two steps: (1) Pre-Process step will use Perlin Noise to generate the clouds texture. We don’t need to consider too much on the time-consuming of pre-process, since we can export a little larger texture. The final texture resolution is 512h512, and it spends us about one minute. (2) Real-time Render step includes the modeling of sky dome, texture mapping and disturbances and scattering calculation. The texture turbulences and scattering result calculation will take advantage of GPU because GPU has powerful computing ability in vector and matrix calculation. Using a computer with AMD Sempron™ 2500+, 512M RAM memory and ATI 9600 Series (with 128M RAM), the frame refresh rate is more than 200 at the resolution 640*480. We use several pictures to compare the effect of different approaches. Figure 8a is the sky box model which can’t generate the flow of clouds easily. Figure 8b is a simple sky dome model which has clumsy and robotistic flow effect. Figure 8c is generated by ATI Research[12] which was using the texture perturbation. The color of sky is simply generated by the specified color so it’s not so real. Figure 8d is the result of the scattering model in [4], which mainly focused on the simulation of scattering itself without considering the true environment. And Figure 8e is the result of our algorithm which illustrates the realistic effect. Figure 8. Comparison of different approaches The thickness of clouds, the intensity of light and others parameters are also provided in our algorithm to generate different environment effects as shown in Figure 9. 4. Conclusion and future work We present an approach to the high realistic sky simulation. The models of Perlin Noise cloud texture and physical scattering are imported into our algorithm, and good effects are generated. There is still much room for improvement. Firstly, the impact of the clouds on the light can be modeled more accurately. Secondly, the reflection effect can be introduced in the physical model to make the environment more realistic especially considering different time and different environment of a day. (a) Sky box (b) Sky dome (c) Texture perturbation [12] (d) Scatterring model [4] (e) Our algorithm
(2006AAll17334),NSF of China (60573151),amd Chinn Postdocsoml Science Foudation(20060390359) References 1]Nichita T,Nakarmse E.Curtinuous tone rpreestation of free-dimessional objects ilumismed by sky light.In Couper Giraphirs (Pmeredingr f ACM SKGiGRAPH5 1956,203125.132. 2]Inkape M.Volume tracing of stmngpherie envinemenx The 1amal Comrurer,1991.7(1:10H-113. (a)A cloudy sky (3]Irwin J.,Fullspeetral rerderig of the earth's atmoophere using a pho sicall moddl of Kaykigh scamerng In Proceedng of 1996 Eun5n4 phie LK Can6wr%,【ondan.19%、p 100-115 4]A.Preetham.P.Shirey,B.E.Smit,A Practicol Arabtic Model frr Daylight m Prereediver of ACW 8GGP指99.1999,e.9110. 5]Dobeshi Y.Yamoo T.Nishit T..lmerctive rendering of atosphenc scatterig etlect s using graphics wue.In Prucenltgs of me ACM SIGGRIPH Ba2eu,Spai,2002,p.99107. [6]Naty HodTman,Nathiniel,Areot J.Preethim,Rendering (h)A elear sky with lighl clauds Outdoor Liaht Scattering in Real Time Ia Prucevlogs of G Drlaper CanGrence 2002,Califomia,USA.2002 印.8生89. 【7]Nishita T,aeiY,Knea山K.cdal,Displry method of the sky oolnr taking ink的crnt multip在at:nagm Preceediys of Parifc Cirmubes W,Pchang.Souh Kurea, 19m,m117-32 Opliesl Models for Direet Volurte Redkering /FF3 toartinue on Vama上nw时 Coupwer Grapics.1995.112:99-108 9]Gooffney Gmniner Y Viceoll Simulatim of Ckuds I Compwer Graphics (Proceedings of ACAf SKGGRAPI 83). 195,19%}9?-03. fe)A night sky with light clouds [10]Perlin.K.An Imape Symthesizer.In Cowpwer Groi (Proceeutnys ofC'.M SKKiR.PH 85)1985,1913 287-296 1111 Dovid E S.Volunetrk Modeling with Implict Punctions:A Clond is Bom.h Proceediver af AC.M 8GG4H97,199T,e.147-155. 12]Joln Isidore,Gueanadi Riguer,Textr:Perturbation Exb.山akXi以l Piuei Sia:kwce I女cWe:Publishing.Mi出nesa,2002,pp川]-]C%. 13 Pallister.K.Gezeratina Prooedural Cous Using 3D Hardwire.In Gcnve Prevremvuimn:Grver 2.Matk Deloara ed. Charkes River Media,2001.pp 453-473. [14]Timoty Roden,lan Picberry,Clouds ind starx (d)An avereast sky with heavy cloiks effien real-eime pmectral sky mndering ucing D Figure 9.The different environment effects atnare.In Procee-Gimgs u Me 2005 ACM SIGCil generated by our algorithm fnvaraatioval Caefreare.Valerea,Spain,Jin.2005,mp 44-437. (15]Geor Zoli A Sky Drmnc Visisbstan fur Acknowledgements Idertficatiun of Asronomical Orienations.Mfoae eiinn200652y152-l66 The retech was supported by the 973 Progrtm of China(200NCB7194031,B63 Program of C上▣ 100
(a) A cloudy sky (b) A clear sky with light clouds (c) A night sky with light clouds (d) An overcast sky with heavy clouds Figure 9. The different environment effects generated by our algorithm Acknowledgements The research was supported by the 973 Program of China (2004CB719403), 863 Program of China (2006AA01Z334), NSF of China (60573151), and China Postdoctoral Science Foundation(20060390359). References [1] Nishita T, Nakamae E., Continuous tone representation of three-dimensional objects illuminated by sky light. In Computer Graphics (Proceedings of ACM SIGGRAPH 86), 1986, 20(3): 125-132. [2] Inakage M., Volume tracing of atmospheric environments. The Visual Computer, 1991, 7(2): 104-113. [3] Irwin J., Full-spectral rendering of the earth’s atmosphere using a physical model of Rayleigh scattering. In Proceeding of 1996 Eurographics UK Conference, London, 1996, pp. 103-115. [4] A.J. Preetham, P. Shirley, B.E. Smit., A Practical Analytic Model for Daylight. In Proceedings of ACM SIGGRAPH 99, 1999, pp. 91-100. [5] Dobashi Y, Yamamoto T, Nishita T., Interactive rendering of atmospheric scattering effect s using graphics hardware. In Proceedings of the ACM SIGGRAPH / EUROGRAPHICS Conference on Graphics Hardware, Barcelona, Spain, 2002, pp. 99-107. [6] Naty Hoffman, Nathaniel, Arcot J. Preetham., Rendering Outdoor Light Scattering in Real Time. In Proceedings of Game Developer Conference 2002, California, USA, 2002, pp. 85-89. [7] Nishita T, Dobashi Y, Kaneda K. et al., Display method of the sky color taking into account multiple scattering. In Proceedings of Pacific Graphics’96, Pohang, South Korea, 1996, pp. 117-132. [8] Max Nelson, Optical Models for Direct Volume Rendering. IEEE Transactions on Visualization and Computer Graphics, 1995, 1(2): 99-108. [9] Geoffrey Gardner Y., Visual Simulation of Clouds. In Computer Graphics (Proceedings of ACM SIGGRAPH 85), 1985, 19(3): 297-303. [10] Perlin, K., An Image Synthesizer. In Computer Graphics (Proceedings of ACM SIGGRAPH 85), 1985, 19(3): 287-296. [11] David E S., Volumetric Modeling with Implicit Functions: A Cloud is Born. In Proceedings of ACM SIGGRAPH 97, 1997, pp. 147-153. [12] John Isidoro, Guennadi Riguer, Texture Perturbation Effects. In ShaderX: Vertex and Pixel Shader Tips and Tricks, WordWare Publishing, Minnesota, 2002, pp. 91-108. [13] Pallister, K., Generating Procedural Clouds Using 3D Hardware. In Game Programming Gems 2, Mark Deloura ed., Charles River Media, 2001, pp. 463-473. [14] Timothy Roden, Ian Parberry, Clouds and stars: efficient real-time procedural sky rendering using 3D hardware. In Proceedings of the 2005 ACM SIGCHI International Conference, Valencia, Spain, Jun. 2005, pp. 434-437. [15] Georg Zotti, A Sky Dome Visualisation for Identification of Astronomical Orientations. Information Visualization, 2006, 5(2): 152-166.