CN113160413B - Real-time dynamic cloud layer drawing method based on cellular automaton - Google Patents
Real-time dynamic cloud layer drawing method based on cellular automaton Download PDFInfo
- Publication number
- CN113160413B CN113160413B CN202110214214.9A CN202110214214A CN113160413B CN 113160413 B CN113160413 B CN 113160413B CN 202110214214 A CN202110214214 A CN 202110214214A CN 113160413 B CN113160413 B CN 113160413B
- Authority
- CN
- China
- Prior art keywords
- state
- cloud
- texture
- cloud layer
- cell
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 59
- 230000001413 cellular effect Effects 0.000 title claims abstract description 48
- 238000009877 rendering Methods 0.000 claims abstract description 31
- 238000005070 sampling Methods 0.000 claims abstract description 29
- 230000000694 effects Effects 0.000 claims abstract description 20
- 230000007704 transition Effects 0.000 claims description 46
- 235000013405 beer Nutrition 0.000 claims description 9
- 238000012546 transfer Methods 0.000 claims description 9
- 238000009499 grossing Methods 0.000 claims description 8
- 230000008859 change Effects 0.000 claims description 7
- 238000012545 processing Methods 0.000 claims description 6
- 238000010899 nucleation Methods 0.000 claims description 5
- 230000003321 amplification Effects 0.000 claims description 2
- 230000002238 attenuated effect Effects 0.000 claims description 2
- 238000003199 nucleic acid amplification method Methods 0.000 claims description 2
- 230000005540 biological transmission Effects 0.000 claims 1
- 239000000203 mixture Substances 0.000 claims 1
- 230000010354 integration Effects 0.000 description 23
- 230000006870 function Effects 0.000 description 19
- 238000004364 calculation method Methods 0.000 description 18
- 238000002834 transmittance Methods 0.000 description 11
- 238000002156 mixing Methods 0.000 description 10
- 238000004422 calculation algorithm Methods 0.000 description 7
- 239000012634 fragment Substances 0.000 description 7
- 230000008569 process Effects 0.000 description 6
- 230000002452 interceptive effect Effects 0.000 description 5
- 238000012805 post-processing Methods 0.000 description 5
- 230000006399 behavior Effects 0.000 description 4
- 230000000007 visual effect Effects 0.000 description 4
- 238000010276 construction Methods 0.000 description 3
- 230000004927 fusion Effects 0.000 description 3
- 238000005286 illumination Methods 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000011160 research Methods 0.000 description 3
- BQCADISMDOOEFD-UHFFFAOYSA-N Silver Chemical compound [Ag] BQCADISMDOOEFD-UHFFFAOYSA-N 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 239000013078 crystal Substances 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000004907 flux Effects 0.000 description 2
- 230000000877 morphologic effect Effects 0.000 description 2
- 229910052709 silver Inorganic materials 0.000 description 2
- 239000004332 silver Substances 0.000 description 2
- 238000004088 simulation Methods 0.000 description 2
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 2
- 230000005653 Brownian motion process Effects 0.000 description 1
- 241000549343 Myadestes Species 0.000 description 1
- 238000002835 absorbance Methods 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000005537 brownian motion Methods 0.000 description 1
- 230000010307 cell transformation Effects 0.000 description 1
- 230000000739 chaotic effect Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 150000001875 compounds Chemical class 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000008034 disappearance Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000013178 mathematical model Methods 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000000704 physical effect Effects 0.000 description 1
- 230000008092 positive effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
- 238000005303 weighing Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
- G06T17/20—Finite element generation, e.g. wire-frame surface description, tesselation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/04—Texture mapping
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/08—Volume rendering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/10—Geometric effects
- G06T15/20—Perspective computation
- G06T15/205—Image-based rendering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Image Generation (AREA)
Abstract
本发明公开了一种基于细胞自动机的实时动态云层绘制方法,其步骤包括:1)生成动态云层的细胞自动机,该细胞自动机采用Moore邻域作为细胞邻域与生命游戏的死‑活判定规则;2)细胞自动机根据输入的初始低分辨率图像的全局纹理建立细胞自动机的数据结构,作为随时序变化的每一帧的细胞演化纹理;数据结构包括全局数组cellMap与各个生命系统;3)对每一帧的细胞演化纹理进行平滑并插值放大,得到对应帧的大尺寸纹理;4)每一帧对应的大尺寸纹理与分形噪声叠加产生云层细节,以及计算密度场在每一个纹理元素所对应点的值;5)采样由多个云团形成的体积云;6)计算点光源对云层产生的散射效果,最终渲染出云层的真实感效果图。
The invention discloses a real-time dynamic cloud layer drawing method based on cellular automata. Judgment rule; 2) The cellular automaton establishes the data structure of the cellular automaton according to the global texture of the input initial low-resolution image, as the cell evolution texture of each frame changing with time sequence; the data structure includes the global array cellMap and each living system. 3) Smooth and interpolate the cell evolution texture of each frame to obtain the large-scale texture of the corresponding frame; 4) The large-scale texture corresponding to each frame is superimposed with fractal noise to generate cloud layer details, and the density field is calculated in each frame. The value of the point corresponding to the texture element; 5) Sampling the volume cloud formed by multiple cloud clusters; 6) Calculate the scattering effect of the point light source on the cloud layer, and finally render the realistic rendering of the cloud layer.
Description
技术领域technical field
本发明属于计算机图形图像、虚拟现实技术、软件技术领域,涉及一种基于细胞自动机的实时动态云层绘制方法与系统。The invention belongs to the technical fields of computer graphics, virtual reality technology and software, and relates to a real-time dynamic cloud layer rendering method and system based on cellular automata.
背景技术Background technique
自然环境中的云层具有各异的形态与光照明细节,如何针对其特征进行合理的建模与绘制(渲染)一直都是有意义的研究主题。Clouds in the natural environment have different shapes and lighting details. How to reasonably model and draw (render) their characteristics has always been a meaningful research topic.
细胞自动机(又译元胞自动机)是一种描述复杂模式与行为的数学模型,在该模型中,分布于演化网格上的每一细胞都处于有限的离散状态集中的某个状态。在每一次时间步进中,每一细胞都遵循同样的转移规则、根据其邻域细胞的状态分布转移至下一时刻的状态。1966年,冯诺伊曼提出早期的细胞自动机以研究具有生物体一般的、自体复制特性的自动机系统。随着研究的深入,细胞自动机理论与生命游戏在物理模拟、社会学仿真、生物学研究与人工生命等领域得到广泛的研究与应用。“生命游戏”是由约翰·康威于1970年提出的、著名的二维细胞自动机(Gardner,M.(1970).Mathematical games:The fantasticcombinations of John Conway's new solitaire game“life”.Scientific American(Vol.223,pp.120-123).)。该工作意图寻找能产生复杂行为的简单规则,他的规则使用Moore邻域(8-邻域)和二元细胞状态(生-死),状态转移。本方法的动态云的构建即基于细胞自动机随时间进行形态演化的思想。Cellular automata (also translated as cellular automata) is a mathematical model that describes complex patterns and behaviors, in which each cell distributed on an evolving grid is in a certain state in a finite set of discrete states. In each time step, each cell follows the same transition rules and transitions to the next state according to the state distribution of its neighbors. In 1966, von Neumann proposed early cellular automata to study automata systems with organism-general, self-replicating properties. With the deepening of research, cellular automata theory and life games have been widely studied and applied in the fields of physical simulation, sociological simulation, biological research and artificial life. "The Game of Life" is a famous two-dimensional cellular automaton proposed by John Conway in 1970 (Gardner, M. (1970). Mathematical games: The fantastic combinations of John Conway's new solitaire game "life". Scientific American ( Vol.223, pp.120-123).).). This work aims to find simple rules that can generate complex behaviors, his rules use Moore neighborhoods (8-neighborhoods) and binary cell states (life-death), state transitions. The construction of the dynamic cloud of this method is based on the idea that cellular automata carry out morphological evolution over time.
传统的体积云绘制方法多使用分形噪声构建云层密度场,该方法生成的云团分布可控性不强、难以呈现特定形状与变化规律。The traditional volume cloud rendering method mostly uses fractal noise to construct the cloud density field.
发明内容SUMMARY OF THE INVENTION
针对现有技术中存在的技术问题,本发明的目的在于提供一种基于细胞自动机的实时动态云层绘制方法与系统。本发明引入了可由用户预定义与交互操作的云层分布纹理,通过细胞自动机演化该纹理实现云层分布的动态变化。本方法通过分布纹理与分形噪声构建体积云的云层密度场,并从密度场包络出发进行动态步长光线积分实现体绘制。In view of the technical problems existing in the prior art, the purpose of the present invention is to provide a real-time dynamic cloud layer rendering method and system based on cellular automata. The present invention introduces a cloud layer distribution texture that can be predefined and interactively operated by a user, and realizes the dynamic change of cloud layer distribution by evolving the texture through cellular automata. The method constructs the cloud density field of the volume cloud by distributing texture and fractal noise, and performs dynamic step ray integration based on the density field envelope to realize volume rendering.
本发明提出的云层绘制方法整体分为两部分:细胞自动机驱动的云层分布纹理演化和体绘制驱动的云层绘制。对于云层分布纹理部分,本系统着重体现了分布纹理演化的平凡性、使用不需物理特征的一般细胞自动机即实现了云层的动态变化,在与后处理(即下文中的“图像后处理”)结合后可生成各种特殊效果。同时,该系统也有着良好的可拓展性,其对不同种类细胞的离散维护与塌陷处理使得使用多种不同规律的云层系统同时演化成为可能。在云层的体绘制部分,本方法使用分形布朗噪声获得云层细节,并着重优化了体绘制积分的效率,使算法在性能和效果上取得了一定平衡。The cloud layer rendering method proposed by the present invention is divided into two parts as a whole: cloud layer distribution and texture evolution driven by cellular automata and cloud layer rendering driven by volume rendering. For the part of cloud layer distribution texture, this system embodies the triviality of distribution texture evolution, and realizes the dynamic change of cloud layer by using general cellular automata without physical features. ) can be combined to generate various special effects. At the same time, the system also has good scalability, and its discrete maintenance and collapse processing of different types of cells makes it possible to use a variety of cloud systems with different laws to evolve simultaneously. In the volume rendering part of the cloud layer, the method uses fractal Brownian noise to obtain the details of the cloud layer, and focuses on optimizing the efficiency of the volume rendering integral, so that the algorithm achieves a certain balance in performance and effect.
本发明的技术方案为:The technical scheme of the present invention is:
一种基于细胞自动机的实时动态云层绘制方法,其步骤包括:A real-time dynamic cloud layer rendering method based on cellular automata, the steps of which include:
1)生成动态云层的细胞自动机,该细胞自动机采用Moore邻域作为细胞邻域与生命游戏的死-活判定规则,即对一目标细胞,根据其当前的不同状态使用不同的状态转移方式,其中状态转移规则Rule={B0,B1,…,B8,S0,S1,…,S8},B0-B8为一个死细胞在邻域活细胞数为0-8时的状态转移规则,S0-S8为活细胞对应的状态转移规则;1) A cellular automaton that generates dynamic clouds. The cellular automaton uses Moore's neighborhood as a dead-alive decision rule for cell neighborhoods and the game of life, that is, for a target cell, different state transition methods are used according to its current state. , where the state transition rule Rule={B0,B1,...,B8,S0,S1,...,S8}, B0-B8 is the state transition rule of a dead cell when the number of live cells in the neighborhood is 0-8, S0- S8 is the state transition rule corresponding to living cells;
2)所述细胞自动机根据输入的初始低分辨率图像的全局纹理建立细胞自动机的数据结构,作为随时序变化的每一帧的细胞演化纹理;所述数据结构包括全局数组cellMap与各个生命系统,不同生命系统对应于该全局纹理中的不同区域;根据所述状态转移规则和像素值确定各区域对应的一组细胞坐标与生命力信息,并存储到各区域对应的生命系统中;其中图像中每一像素对应一个细胞,像素值对应细胞的生命力;全局数组cellMap存储当前帧中每一像素对应的细胞状态信息;其中所述细胞自动机根据每一生命系统对应的所述状态转移规则Rule计算对应生命系统下一帧细胞变化;当所有生命系统计算完毕后,根据当前所得下一帧细胞信息更新全局数组cellMap,然后遍历所有生命系统,获得每个生命系统所拥有的活细胞并记录存储到cellList中;2) The cellular automaton establishes the data structure of the cellular automaton according to the global texture of the input initial low-resolution image, as the cell evolution texture of each frame changing with time sequence; the data structure includes the global array cellMap and each life system, different life systems correspond to different regions in the global texture; a set of cell coordinates and vitality information corresponding to each region are determined according to the state transition rules and pixel values, and stored in the life system corresponding to each region; Each pixel corresponds to a cell, and the pixel value corresponds to the vitality of the cell; the global array cellMap stores the cell state information corresponding to each pixel in the current frame; wherein the cellular automaton is based on the state transition rule Rule corresponding to each living system Calculate the cell changes in the next frame of the corresponding life system; when all the life systems are calculated, update the global array cellMap according to the current cell information of the next frame, and then traverse all the life systems to obtain the living cells owned by each life system and record and store them into cellList;
3)对步骤2)得到的每一帧的细胞演化纹理进行平滑并插值放大处理,得到对应帧的大尺寸纹理;3) smooth and interpolate the cell evolution texture of each frame obtained in step 2) to obtain a large-size texture of the corresponding frame;
4)将每一帧对应的大尺寸纹理与分形噪声叠加产生云层细节,以及计算密度场在每一个纹理元素所对应点的值;4) superimposing the large-size texture corresponding to each frame and fractal noise to generate cloud layer details, and calculating the value of the density field at the corresponding point of each texture element;
5)通过可变长度积分状态机的步进状态转移方法采样由多个云团形成的体积云;5) Sampling a volume cloud formed by a plurality of cloud clusters through a step-by-step state transition method of a variable-length integral state machine;
6)通过比尔定律和Henyey-Greenstein像函数计算点光源对云层产生的散射效果,最终渲染出云层的真实感效果图。6) Calculate the scattering effect of the point light source on the cloud layer through Beer's law and the Henyey-Greenstein image function, and finally render the realistic rendering of the cloud layer.
进一步的,所述状态转移规则是指根据细胞i当前状态及其邻域中细胞j的状态决定下一时刻该细胞i状态的状态转移函数;状态转移函数为f为任意形式的转移函数。Further, the state transition rule refers to determining the state transition function of the state of cell i at the next moment according to the current state of cell i and the state of cell j in its neighborhood; the state transition function is: f is a transfer function of any form.
进一步的,为所述生命系统设置边界约束,所述边界约束为:依据生命系统中的细胞距该生命系统中心距离,对细胞进行隔断或线性衰减。Further, a boundary constraint is set for the living system, and the boundary constraint is: according to the distance between the cells in the living system and the center of the living system, the cells are isolated or linearly attenuated.
进一步的,所述生命系统支持在一定半径内随机“播种”,即在生命系统随机位置处直接生成具有一定生命力的新细胞。Further, the living system supports random "seeding" within a certain radius, that is, new cells with a certain vitality are directly generated at random positions of the living system.
进一步的,步骤3)中,将步骤2)得到的每一帧的细胞演化纹理进行平滑并插值放大处理得到的图像与预制的一高分辨率图像进行插值平滑所获得的图像进行融合,得到对应帧的大尺寸纹理。Further, in step 3), the image obtained by smoothing the cell evolution texture of each frame obtained in step 2) and the image obtained by interpolation and amplification processing are fused with the image obtained by interpolating and smoothing a prefabricated high-resolution image to obtain a corresponding image. Large size texture for frames.
进一步的,所述分形噪声为其中,Dg为噪声全局卷动,Wi为第i层噪声的振幅,Fi为第i层噪声的频率,m为层数,Noise()为用噪声纹理形式表示的噪声函数,x为位置作为噪声函数的变量。Further, the fractal noise is Among them, D g is the noise global scroll, Wi is the amplitude of the noise of the i -th layer, F i is the frequency of the noise of the i-th layer, m is the number of layers, Noise() is the noise function expressed in the form of noise texture, and x is the position as a variable of the noise function.
进一步的,步骤4)中,计算密度场在每一个纹理元素所对应点的值的方法为:Further, in step 4), the method for calculating the value of the density field at the point corresponding to each texture element is:
1-1)将为体绘制构建的云层建模为底端平坦、顶端膨大的半球形,设云层基准平面高度为0,根据云层分布纹理上点P的实际厚度值p计算该点P的云层密度场的顶端PUpper和底端PLower;1-1) The cloud layer constructed by volume rendering is modeled as a hemisphere with a flat bottom and an enlarged top. Set the cloud layer base plane height to 0, and calculate the cloud layer at this point P according to the actual thickness value p of the point P on the cloud layer distribution texture. The top P Upper and the bottom P Lower of the density field;
1-2)对于位于点P位置、高度为h的点,首先计算它的相对高度比例t;再根据比例t计算该点的云层密度Pden;1-2) For the point at the position of point P and the height is h, first calculate its relative height ratio t; then calculate the cloud layer density P den of this point according to the ratio t;
1-3)将密度Pden与整体透光率常量transmittance相乘获得该点实际的散射率α。1-3) Multiply the density P den by the overall transmittance constant transmittance to obtain the actual scattering rate α of the point.
进一步的,绘制体积云的方法为:首先根据云层分布纹理生成云层包络网格,然后从云层包络网格出发,基于可变长度积分状态机的步进状态转移方法绘制体积云;其中,基于可变长度积分状态机的步进状态转移方法为:Further, the method for drawing a volume cloud is: firstly, a cloud layer envelope grid is generated according to the cloud layer distribution texture, and then starting from the cloud layer envelope grid, the volume cloud is drawn based on a step-by-step state transition method of a variable-length integral state machine; wherein, The step-by-step state transition method based on the variable-length integral state machine is:
2-1)将积分位置的步进分为大步长FAST_STEP与小步长SLOW_STEP;设置状态0为未遇到云,此时进行大步长的FAST_STEP;设置状态1为上一步FAST_STEP遇到云,此时进行小步长SLOW_STEP;设置状态2为已经在云中,此时进行小步长SLOW_STEP;设置状态3为已达到小步长数量上限,此时只进行FAST_STEP至所有步数耗尽;2-1) Divide the step of the integral position into a large step FAST_STEP and a small step SLOW_STEP; set state 0 to mean that no cloud is encountered, and perform FAST_STEP with a large step at this time; set state 1 to the previous step FAST_STEP encounters a cloud , then perform small step SLOW_STEP; set state 2 to be already in the cloud, then perform small step SLOW_STEP; set state 3 to reach the upper limit of the number of small steps, then only perform FAST_STEP until all steps are exhausted;
2-2)当FAST_STEP后的当前新位置云层密度场不为0时,状态机从状态0转移至状态1;当位于状态1,且上一次SLOW_STEP后的当前新位置密度场不为0时,从状态1转移至状态2;当位于状态2,且上一次SLOW_STEP后的当前新位置密度场为0时,认为已经离开了云层,从状态2转移至状态0;当SLOW_STEP次数达到上限后,无条件转移至状态3。2-2) When the current new position cloud density field after FAST_STEP is not 0, the state machine transfers from state 0 to state 1; when it is in state 1 and the current new position density field after the last SLOW_STEP is not 0, Transfer from state 1 to state 2; when it is in state 2, and the current new position density field after the last SLOW_STEP is 0, it is considered that it has left the cloud layer, and it transfers from state 2 to state 0; when the number of SLOW_STEP reaches the upper limit, unconditional Transition to state 3.
进一步的,对于积分路径上的每个采样点P,计算得到该点P的散射率α作为该点P的不透明度;然后将点P的颜色预乘点P的不透明度,然后使用预乘不透明度的混合模式进行混合,作为RGB颜色值。Further, for each sampling point P on the integration path, the scattering rate α of the point P is calculated as the opacity of the point P; then the color of the point P is premultiplied by the opacity of the point P, and then the The transparency blending mode is blended as RGB color values.
与现有技术相比,本发明的积极效果为:Compared with the prior art, the positive effects of the present invention are:
与传统方法不同,本方法引入可由用户定义并进行交互操作的云层分布纹理,在该纹理的基础上融合分形噪声生成云层密度场。为实现云层种类各异的变化效果,本方法使用细胞自动机对上述云层分布纹理进行动态演化。因此本发明的方法具有可控性强的优点,能够实现各种类型的云层的变化效果,实时绘制的效果具有丰富性和多样性。Different from the traditional method, this method introduces a cloud layer distribution texture that can be defined and interactively operated by the user, and fuses fractal noise on the basis of the texture to generate a cloud layer density field. In order to realize the changing effects of different types of clouds, this method uses cellular automata to dynamically evolve the above-mentioned cloud distribution textures. Therefore, the method of the present invention has the advantages of strong controllability, and can realize the changing effects of various types of cloud layers, and the effects of real-time rendering are rich and diverse.
与传统静态的天空云层表示和绘制方法相比,本发明具有云层体绘制方式的优点,即具备动态演化的能力:通过细胞自动机的演化与云层分布纹理的多级平移两种方式,本方法及系统可自如地演化云层分布、实现较好的动态效果。在这个过程中,调整细胞自动机的规则可得到丰富的演化规律效果。此外,本发明所提出的体绘制方法对中、低空云层的体积感表现力更强、可动态变化光照,动态调整光源颜色与基色还可实现连续无缝的天候时间变换。Compared with the traditional static sky cloud layer representation and rendering method, the present invention has the advantages of the cloud layer volume rendering method, that is, it has the ability of dynamic evolution: through the evolution of the cellular automaton and the multi-level translation of the cloud layer distribution texture, the method And the system can freely evolve cloud distribution and achieve better dynamic effects. In this process, adjusting the rules of cellular automata can obtain rich evolutionary law effects. In addition, the volume rendering method proposed in the present invention has stronger expressiveness for the volume sense of mid- and low-altitude cloud layers, can dynamically change illumination, and can realize continuous and seamless weather and time change by dynamically adjusting the color of the light source and the base color.
与传统体绘制方法相比,本发明的云层分布具有更高的可控性,灵活结合细胞自动机和预绘制纹理与后处理可实现单纯噪声无法体现的特殊动态与不同种类的云层效果。Compared with the traditional volume rendering method, the cloud layer distribution of the present invention has higher controllability, and the flexible combination of cellular automata, pre-rendered texture and post-processing can realize special dynamics and different types of cloud layer effects that cannot be reflected by simple noise.
附图说明Description of drawings
图1是本发明的方法流程图。FIG. 1 is a flow chart of the method of the present invention.
图2为细胞自动机系统结构图。Figure 2 is a structural diagram of the cellular automata system.
图3为固定步长射线步进(Ray Marching)采样示例。Figure 3 is an example of fixed-step ray marching (Ray Marching) sampling.
图4为云层包络网格图。Figure 4 is a grid diagram of the cloud envelope.
图5为可变长度积分状态机。Figure 5 is a variable-length integration state machine.
具体实施方式Detailed ways
下面通过具体实施例和附图,对本发明做进一步详细说明。The present invention will be described in further detail below through specific embodiments and accompanying drawings.
本方法的基本流程如图1所示:The basic flow of this method is shown in Figure 1:
1.动态云层的细胞自动机生成1. Cellular automata generation of dynamic clouds
对于云层分布纹理的演化,本发明提出了一个可同时演化不同规则系统并保持其相互作用的复合式细胞自动机(对应流程图中“生命系统”和“随时间演化”模块)。值得注意的是,该细胞自动机的架构并不局限于某种特定的演化规则,在同一规则空间演化的多个系统可具有截然不同的特性。For the evolution of cloud layer distribution texture, the present invention proposes a compound cellular automaton that can simultaneously evolve different rule systems and maintain their interactions (corresponding to the "life system" and "time evolution" modules in the flowchart). It is worth noting that the architecture of the cellular automaton is not limited to a specific evolutionary rule, and multiple systems evolving in the same rule space can have completely different characteristics.
1.1规则定义1.1 Rule Definition
虽然“生命游戏”的演化过程具有良好的混沌特征,但其“非死即活”的细胞变换使整体图像的局部特征变化剧烈、稳定性差,不适合直接作为云层分布纹理使用。本发明提出的基础规则是“生命游戏”基础规则的改进。规则延续使用经典的Moore邻域(8-邻域)作为细胞邻域与生命游戏的死-活判定规则,即对某一特定细胞,根据其当前的死/活状态使用不同的状态转移方式。本发明的一个状态转移规则可由如下的一组值表示:Although the evolution process of "Game of Life" has good chaotic characteristics, its "dead or alive" cell transformation makes the local features of the overall image change drastically and has poor stability, which is not suitable for direct use as a cloud layer distribution texture. The basic rule proposed by the present invention is an improvement of the basic rule of "Game of Life". The rule continues to use the classic Moore neighborhood (8-neighborhood) as the cell neighborhood and the dead-alive decision rule of the game of life, that is, for a specific cell, different state transition methods are used according to its current dead/alive state. A state transition rule of the present invention can be represented by the following set of values:
Rule={B0,B1,…,B8,S0,S1,…,S8},其中B0-B8为一个死细胞在邻域活细胞数为0-8时的状态转移规则,S0-S8为活细胞的对应的状态转移规则。状态转移规则是指根据细胞当前状态及其邻域中细胞的状态决定下一时刻该细胞状态的状态转移函数;状态转移规则可以写为即一个细胞在t+1时刻的状态为t时刻的邻域状态组合,称为细胞自动机的局部映射或局部规则。在本发明中,状态转移规则可以为任意定义的规则,即f可以为任意形式的转移函数。Rule={B0,B1,…,B8,S0,S1,…,S8}, where B0-B8 is the state transition rule of a dead cell when the number of live cells in the neighborhood is 0-8, and S0-S8 is a live cell corresponding state transition rules. The state transition rule refers to the state transition function that determines the state of the cell at the next moment according to the current state of the cell and the state of the cells in its neighborhood; the state transition rule can be written as That is, the state of a cell at time t+1 is the neighborhood state combination at time t, which is called the local map or local rule of cellular automata. In the present invention, the state transition rule can be an arbitrarily defined rule, that is, f can be a transition function in any form.
在本发明方法中,将每个细胞的二元死/活(0/1)替换为由0-255表示的“生命力”,该数值恰好对应8bit图像中一个通道的亮度值范围。本发明将所有“生命力”(即云层分布纹理中亮度值)大于零的细胞均视作“活”,上述细胞状态转移规则中的“死/活”也对应变换为-255至255范围内的整数。如此设计的细胞自动机可通过调节更广范围的参数获得层次更为细腻、可控性更好的演化。针对图像处理,这里的细胞对应于图像中的像素,即每一像素是一个细胞,像素值对应细胞的生命力。In the method of the present invention, the binary dead/live (0/1) of each cell is replaced by "vitality" represented by 0-255, which corresponds to the luminance value range of one channel in the 8-bit image. In the present invention, all cells with "vitality" (that is, the brightness value in the cloud layer distribution texture) greater than zero are regarded as "live", and the "dead/live" in the above cell state transition rules are also transformed into cells within the range of -255 to 255. Integer. The cellular automata designed in this way can obtain more detailed and controllable evolution by adjusting a wider range of parameters. For image processing, the cells here correspond to the pixels in the image, that is, each pixel is a cell, and the pixel value corresponds to the vitality of the cell.
1.2细胞与生命系统组织1.2 Organization of cells and living systems
传统细胞自动机实现为多将细胞状态直接存储在全局网格数组中,这种实现简洁朴素但难以处理具有不同规则的细胞同时演化的情形。本发明提出的方法将具有上述状态转移规则的一组细胞的坐标与生命力信息储存于一个特定的“生命系统”中,全局纹理(全局数组cellMap)表示的整个细胞自动机系统则由若干“生命系统”同时演化叠加得到。该系统的整体逻辑如图2所示。Traditional cellular automata are implemented by directly storing the cell state in the global grid array. This implementation is simple and simple, but it is difficult to deal with the simultaneous evolution of cells with different rules. The method proposed in the present invention stores the coordinates and vitality information of a group of cells with the above state transition rules in a specific "life system", and the entire cellular automata system represented by the global texture (global array cellMap) is composed of several "life systems". The system” simultaneously evolves and superimposes. The overall logic of the system is shown in Figure 2.
本系统的输入数据为一张低分辨率的灰度图(全局纹理),该纹理图的分辨率常采用128*128,根据此灰度图建立的细胞自动机的数据结构包括全局数组cellMap与各个生命系统,各个生命系统可将整张灰度图划分成不同的区域,区域之间可以重叠,所有区域也可以不完全覆盖整张图。每一个区域即可以作为一个lifesystem演化的原始的细胞数据。可能拥有不同规则的每个生命系统在其变长数组cellList中存储该系统拥有的活细胞。每一生命系统的步进循环包括如下两个步骤:The input data of this system is a low-resolution grayscale image (global texture). The resolution of the texture image is usually 128*128. The data structure of the cellular automaton established based on this grayscale image includes the global array cellMap and Each life system, each life system can divide the entire grayscale image into different areas, the areas can overlap, and all areas can not completely cover the entire image. Each region can be used as the original cell data for the evolution of a lifesystem. Each living system that may have different rules stores the living cells owned by that system in its variable-length array cellList. The stepping cycle of each living system consists of the following two steps:
1)在每帧起始时,全局cellMap中存储着此帧全局规则网格上每点的细胞死/活信息。首先为每个生命系统根据该状态转移规则计算下一帧细胞变化。这一计算将遍历该生命系统此刻所有活细胞的8-邻域,并从全局cellMap中获得邻域中活细胞的数目。1) At the beginning of each frame, the global cellMap stores the cell dead/live information of each point on the global regular grid of this frame. First, for each living system, the next frame of cell changes is calculated according to the state transition rule. This calculation will traverse the 8-neighborhood of all living cells in the living system at this moment and obtain the number of living cells in the neighborhood from the global cellMap.
2)当所有生命系统计算完毕后,根据刚刚计算的下一帧细胞信息刷新写入全局cellMap,再次遍历所有生命系统,获得每个生命系统所拥有的活细胞并记录存储到cellList中。此过程开可以得到下一帧全局规则网格上的细胞死/活信息。2) When all the living systems are calculated, refresh and write the global cellMap according to the cell information of the next frame just calculated, traverse all the living systems again, obtain the living cells owned by each living system, and store the records in the cellList. This process can get the cell dead/live information on the global regular grid in the next frame.
如此进行的计算保持了不同规则细胞间的相互影响,在细胞数较少时也无需遍历全部规则网格。此外,封装不同演化规则细胞群落的“生命系统”能为我们提供更加具体的细胞控制手段;每个生命系统所使用的演化规则(状态转移函数、规则)是不一样的。本发明首先引入了依据细胞距生命系统中心距离进行隔断或线性衰减的系统边界约束,使用边界约束的系统可动态模拟一定半径内的“一块云团”,对这样的生命系统中心进行平移即可手动控制该云团的移动趋势。生命系统还支持在一定半径内随机“播种”,即在生命系统随机位置直接生成具有一定生命力的新细胞,对于一些扩张特征较弱的规则,该设计可保持整个系统的活力;向一个空系统中播种细胞亦可实现在指定位置产生新的云团源。本部分的设计具有可拓展性,用户可根据实际需求编写对应的播种、衰减规则以实现特定的需求效果。This calculation preserves the interaction between different regular cells, and does not need to traverse the entire regular grid when the number of cells is small. In addition, "living systems" that encapsulate cell communities with different evolution rules can provide us with more specific means of cell control; the evolution rules (state transfer functions, rules) used by each living system are different. The present invention firstly introduces a system boundary constraint that cuts off or linearly decays according to the distance between cells and the center of the living system. The system using the boundary constraint can dynamically simulate a "piece of cloud" within a certain radius, and the center of such a living system can be translated. Manually control the movement trend of this cloud. The living system also supports random "seeding" within a certain radius, that is, new cells with a certain vitality are directly generated at random positions in the living system. For some rules with weak expansion characteristics, this design can maintain the vitality of the entire system; to an empty system Seeding cells in the medium can also achieve the generation of new cloud sources at specified locations. The design of this part is scalable, and users can write corresponding seeding and attenuation rules according to actual needs to achieve specific needs.
2.图像后处理与交互演化2. Image post-processing and interactive evolution
本发明是针对动态变化的云层的动态变化过程和渲染而提出的方法与系统(对应流程图中“高分辨率插值平滑”、“交互图像叠加融合”模块)。细胞自动机演化得到的128*128细胞演化纹理的分辨率较低,本系统首先进行一次图像模糊、将其平滑并插值放大至512*512的大尺寸纹理,并在此时刻与上一时刻(帧)的演化纹理中进行插值得到真正被体绘制使用的云层分布纹理。值得注意的是,修改该模糊的迭代次数与采样半径可对云层边界的锐度与弧度进行调整,在体绘制部分内容将进一步详述。The present invention is a method and system proposed for the dynamic change process and rendering of dynamically changing cloud layers (corresponding to the "high-resolution interpolation smoothing" and "interactive image overlay and fusion" modules in the flowchart). The resolution of the 128*128 cell evolution texture obtained by the cellular automaton evolution is low. The system first blurs the image, smoothes it, and interpolates it to a large-scale texture of 512*512. At this moment and the previous moment ( frame) to obtain the actual cloud distribution texture used by volume rendering. It is worth noting that modifying the number of iterations and sampling radius of the blur can adjust the sharpness and radian of the cloud boundary, which will be further detailed in the volume rendering section.
动态插值的平滑512*512纹理已可作为云层分布纹理在体绘制中使用,但本发明考虑对云层构型的更高可控性,额外引入了以下两种后处理与交互演化步骤:The smooth 512*512 texture of dynamic interpolation can be used in volume rendering as cloud layer distribution texture, but the present invention considers higher controllability of cloud layer configuration, and additionally introduces the following two post-processing and interactive evolution steps:
1)从形状预制的分布纹理开始演化:用户可以预制一张128*128的细胞自动机初态,完全自定义演化起始时的云层形状。此方法在演化起始时遍历128*128预制纹理的所有像素,将所有亮度非零的像素添加至一个特殊的起始生命系统中。该系统可使用某种细胞自动机规则,也可使用完全不同的特殊规则将每个细胞仅仅视作“像素”进行点处理等数字图像处理过程。这些“像素”仍会被其它生命系统视为活细胞并正常地进行混合演化,灵活应用上述各种方案可实现若干不同的效果。128*128的低分辨率图像经过细胞自动机演化之后,通过高分辨率插值平滑操作,得到512*512的高分辨率图像。1) Start the evolution from the prefabricated distribution texture of the shape: the user can prefabricate a 128*128 initial state of the cellular automaton, and completely customize the shape of the cloud layer at the beginning of the evolution. This method traverses all the pixels of the 128*128 prefab texture at the beginning of evolution, adding all pixels with non-zero brightness to a special starting life system. The system can use certain cellular automata rules, or it can use completely different special rules to treat each cell as just a "pixel" for digital image processing such as point processing. These "pixels" will still be regarded as living cells by other living systems and normally undergo mixed evolution, and the flexible application of the various schemes described above can achieve several different effects. After the low-resolution image of 128*128 is evolved by cellular automata, the high-resolution image of 512*512 is obtained by high-resolution interpolation smoothing operation.
2)直接对最终纹理进行处理:用户可直接对平滑后的512*512纹理上进行交互绘图叠加,采用交互图像叠加融合操作实现与经过高分辨率插值平滑所获得的512*512图像的融合。这些处理不影响细胞自动机的实际行为,在实现如飞机尾迹云、云层中生成“空洞”等与云层演化相对“独立”的效果时非常有效。2) Directly process the final texture: the user can directly perform interactive drawing overlay on the smoothed 512*512 texture, and use the interactive image overlay fusion operation to achieve the fusion with the 512*512 image obtained by high-resolution interpolation and smoothing. These processes do not affect the actual behavior of cellular automata, and are very effective in realizing effects that are relatively "independent" from cloud evolution, such as aircraft wake clouds and the generation of "holes" in clouds.
以上的这些交互、后处理步骤近一步说明了本发明“平凡”的细胞自动机实现——演化更看重可控性较强的云层与可自定义的演化规则,而非依赖特定的物理特性或细胞行为。The above interaction and post-processing steps further illustrate the realization of the “ordinary” cellular automaton of the present invention—evolution pays more attention to cloud layers with strong controllability and customizable evolution rules, rather than relying on specific physical properties or cell behavior.
3云层体密度场构建3. Construction of cloud volume density field
本部分对应流程图中的“叠加分形噪声”和“云层密度场构造”模块。为了得到进行体绘制所需的路径积分之前,首先需要描述积分空间中任意坐标的云层密度。这一计算从上步骤得到的512*512云层分布纹理开始,首先将512*512纹理与分形噪声叠加产生云层细节,再对应计算密度场在每一个纹理元素所对应点的值。This part corresponds to the "Superimposed Fractal Noise" and "Cloud Density Field Construction" modules in the flowchart. Before obtaining the path integral required for volume rendering, the cloud density at any coordinate in the integral space needs to be described first. This calculation starts from the 512*512 cloud layer distribution texture obtained in the previous step. First, the 512*512 texture and fractal noise are superimposed to generate cloud layer details, and then the value of the density field at the corresponding point of each texture element is calculated accordingly.
3.1分形噪声计算3.1 Fractal noise calculation
云层的边缘细节通过将噪声纹理通过分形布朗运动叠加得到,即通过叠加多层频率倍增、振幅递减的基础噪声纹理获得愈加丰富的分形细节:The edge details of the cloud layer are obtained by superimposing the noise texture through fractal Brownian motion, that is, more and more fractal details are obtained by superimposing multiple layers of basic noise textures with frequency multiplication and decreasing amplitude:
其中,Dg为噪声全局卷动,Wi为第i层噪声的振幅,Fi为第i层噪声的频率,Noise()为噪声函数,x为位置作为函数变量。Among them, D g is the noise global scroll, Wi is the amplitude of the i -th layer of noise, F i is the frequency of the i-th layer of noise, Noise() is the noise function, and x is the position as a function variable.
本发明实现中共叠加了四层分形噪声:The present invention realizes that four layers of fractal noise are superimposed in total:
Fi依次取1,3,9,27。F i takes 1, 3, 9, and 27 in turn.
Wi依次取0.5、0.25、0.125、0.0625。Wi takes 0.5, 0.25, 0.125, and 0.0625 in turn.
对于空间中的每个位置,其三维坐标拆分、求和后得到在二维纹理上进行采样的UV坐标。在云层演化中,本系统沿三个维度卷动噪声以实现细胞自动机演化之外的云层细节的变化。在得到分形噪声强度N后,便可计算云层分布纹理上任一点P的云层实际厚度值p:For each position in space, its 3D coordinates are split and summed to get the UV coordinates sampled on the 2D texture. In cloud evolution, the present system scrolls noise along three dimensions to achieve changes in cloud detail beyond cellular automata evolution. After obtaining the fractal noise intensity N, the actual thickness p of the cloud layer at any point P on the cloud layer distribution texture can be calculated:
p=plum·Np= plum ·N
其中plum为上一步骤计算得到的云层分布纹理的任意像素点P的亮度。where p lum is the brightness of any pixel point P of the cloud layer distribution texture calculated in the previous step.
3.2密度场计算3.2 Density field calculation
根据自然中云层的形态特征,本发明将为体绘制构建的云层建模为底端平坦、顶端膨大的半球形。不妨规定云层基准平面高度为0,根据云层分布纹理上点P的实际厚度值p计算该点P的云层密度场的顶端PUpper和底端PLower:According to the morphological characteristics of clouds in nature, the present invention will model the clouds constructed by volume rendering as a hemisphere with a flat bottom and an enlarged top. It is advisable to specify that the height of the cloud layer reference plane is 0, and calculate the top P Upper and bottom P Lower of the cloud layer density field at this point P according to the actual thickness value p of the point P on the cloud layer distribution texture:
PUpper=C·pP Upper =C·p
PLower=-0.3C·pP Lower =-0.3C·p
其中,C为云层厚度参数,-0.3为底面较之顶面的收缩系数。修改这些常量可控制云层整体的顶、底厚度。Among them, C is the cloud layer thickness parameter, and -0.3 is the shrinkage coefficient of the bottom surface compared with the top surface. Modifying these constants controls the overall top and bottom thickness of the cloud layer.
PUpper与PLower描述了云层密度场在点P位置的上界和下界。一般认为云层边缘处的密度较低、中心密度较高。对于位于点P位置、高度为h的某点,首先计算它的相对高度比例t:P Upper and P Lower describe the upper and lower bounds of the cloud density field at the point P. It is generally believed that the density at the edge of the cloud layer is lower and the density at the center is higher. For a point located at the position of point P and the height is h, first calculate its relative height ratio t:
再根据比例t计算该点的云层密度:Then calculate the cloud density of the point according to the ratio t:
其中smoothstep为三次插值函数:where smoothstep is a cubic interpolation function:
smoothstep(min,max,p)=-2t3+3t2,smoothstep(min, max, p)=-2t 3 +3t 2 ,
对于PUpper和PLower差值较小、整体偏薄的云层,再进行一次插值以平滑薄云的渲染效果:For the cloud layer with small difference between P Upper and P Lower , and the overall thin cloud layer, perform another interpolation to smooth the rendering effect of thin cloud:
Pden=Pden·smoothstep(0,1.8,PUpper-PLower),if(PUpper-PLower)≤18P den =P den ·smoothstep(0, 1.8, P Upper -P Lower ), if(P Upper -P Lower )≤18
式中的1.8即为云层过薄的阈值。The 1.8 in the formula is the threshold for the thin cloud layer.
最后,将密度Pden与整体透光率常量相乘获得该点实际的散射率α:Finally, multiply the density P den by the overall transmittance constant to obtain the actual scattering rate α at that point:
α=Pden·transmittanceα=P den ·transmittance
通过调节整体透光率常量transmittance即可调整云层整体的不透明度。下一步骤的路径积分策略中将进一步讨论该参数transmittance的选取。The overall opacity of the cloud layer can be adjusted by adjusting the overall transmittance constant transmittance. The selection of this parameter transmittance will be discussed further in the path integration strategy in the next step.
4云层体绘制积分4 Cloud Volume Rendering Credits
本部分对应流程图中的“构建包络网格”、“采用步进状态转移的可变长度积分”和“透明度计算与混合”模块。体积云效果使用射线步进(Ray Marching)算法绘制体积感较强的云,如层云、积云和积雨云等。这些云高度较低、多成团块状,具有边界分明、明暗对比显著的特征。This section corresponds to the Building Envelope Mesh, Variable Length Integral with Step State Transition, and Transparency Calculation and Blending modules in the flowchart. The volume cloud effect uses the Ray Marching algorithm to draw clouds with a strong sense of volume, such as stratus, cumulus, and cumulonimbus. These clouds are relatively low in height and mostly in the form of clumps, with well-defined boundaries and striking contrast between light and dark.
4.1基本的路径积分方法概述4.1 Overview of Basic Path Integral Methods
用于体绘制的Ray Marching算法的基础是从视点出发,沿视线逐步采样、积累计算结果。图3描述了一个典型的简单Ray Marching算法,该方法自视点前的一个平面出发,每个片元的颜色计算都由次数固定的路径积分得到,积分路径即是自视点出发、穿过该片元的光路。The basis of the Ray Marching algorithm for volume rendering is to start from the viewpoint and gradually sample and accumulate the calculation results along the line of sight. Figure 3 depicts a typical simple Ray Marching algorithm. This method starts from a plane in front of the viewpoint. The color calculation of each fragment is obtained by the path integration with a fixed number of times. Yuan's light path.
次数固定的简单Ray Marching算法很容易实现,但却具有一系列问题:The simple Ray Marching algorithm of fixed degree is easy to implement, but has a series of problems:
1)效率低下。沿屏幕中云层不覆盖的光路进行的全部采样都是无效的,在两朵云层之间进行的大量采样也是无效的。1) Inefficiency. All sampling along the light path not covered by clouds in the screen is invalid, as is the bulk sampling between two clouds.
2)走样明显。浪费大量采样的潜在后果便是实际有效的采样数目不足以生成平滑的高质量图像,产生条带和走样,对于稀薄的云层还可能产生云层断开、消失等视觉错误。2) The aliasing is obvious. The potential consequence of wasting a large number of samples is that the actual effective number of samples is not enough to generate a smooth high-quality image, resulting in banding and aliasing, and for thin clouds, visual errors such as cloud disconnection and disappearance may occur.
使用固定步数的全屏Ray Marching算法,在云层区域较大时,即使对整条光路进行每片元256次的采样,仍可观察到明显的采样不均导致的条带和走样现象。Using the full-screen Ray Marching algorithm with a fixed number of steps, when the cloud layer area is large, even if the entire optical path is sampled 256 times per fragment, banding and aliasing caused by obvious uneven sampling can still be observed.
4.2本发明的积分策略4.2 Integral strategy of the present invention
为解决固定步数全屏路径积分的诸多问题,本发明主要提出了两种方法:首先构建云层包络网格,之后从包络出发、使用变长策略进行积分。In order to solve many problems of full-screen path integration with a fixed number of steps, the present invention mainly proposes two methods: firstly, a cloud layer envelope grid is constructed, and then a variable-length strategy is used to carry out the integration from the envelope.
4.2.1构建包络网格4.2.1 Building an envelope mesh
从视点出发的路径积分在抵达云层区域之前可能浪费大量采样点,对于不存在云层的区域进行的采样更是完全无效。构建云层包络网格后,从网格上片元出发的路径积分起点便只会落在云层附近。本系统通过之前步骤生成的512*512的云层分布纹理构建包络网格。由于叠加的分形噪声与分布纹理相乘后亮度永远小于等于分布纹理本身,该纹理实际上描述了云层可能出现的包络区域。The path integration from the viewpoint may waste a large number of sampling points before reaching the cloud area, and it is completely ineffective for the sampling in the area without cloud layer. After the cloud envelope mesh is constructed, the starting point of the path integration from the fragments on the mesh will only fall near the cloud layer. The system constructs the envelope mesh through the 512*512 cloud layer distribution texture generated in the previous steps. Since the brightness of the superimposed fractal noise and the distribution texture is always less than or equal to the distribution texture itself, the texture actually describes the possible envelope area of the cloud layer.
包络使用129*129的正方形网格以搭配缩小到128*128的云层分布纹理。首先遍历后处理结束后的该纹理、找到所有亮度大于零的像素,记录这些像素对应的生成顶点,再生成对应的顶点索引和三角形索引。对于每个方形区域,其对边总连接高度插值最大的两个顶点。The envelope uses a 129*129 square grid with a cloud distribution texture downscaled to 128*128. First traverse the texture after post-processing, find all pixels with brightness greater than zero, record the generated vertices corresponding to these pixels, and then generate the corresponding vertex index and triangle index. For each square area, its opposite sides always connect the two vertices with the largest height interpolation.
根据云层分布纹理生成的云层包络网格如图4所示。The cloud envelope mesh generated according to the cloud layer distribution texture is shown in Figure 4.
4.2.2可变长度积分与步进状态转移4.2.2 Variable length integral and step state transition
在进行路径积分时,我们期望尽可能减少不必要的采样。由于体积云多聚集成一片片云团、云带,可变长度积分的思想便是在积分路径位于云外时加大步长前进、抵达云内时则缩小步长、精确积累结果(云由包络网格表示,通过判断在包络网格的内/外来确定位于云内/外)。本发明提出一种基于可变长度积分状态机的步进状态转移方法,该方法为图5所示的状态机和状态转移。When doing path integration, we want to reduce unnecessary sampling as much as possible. Since volume clouds are mostly aggregated into cloud clusters and cloud bands, the idea of variable-length integration is to increase the step size when the integration path is outside the cloud, and reduce the step size and accurately accumulate the results when the integration path is outside the cloud. Envelope grid representation, determined to be inside/outside the cloud by judging inside/outside the envelope grid). The present invention proposes a step-by-step state transition method based on a variable-length integral state machine, which is the state machine and state transition shown in FIG. 5 .
将积分位置的步进分为大步长(FAST_STEP)与小步长(SLOW_STEP)。The step of the integral position is divided into a large step (FAST_STEP) and a small step (SLOW_STEP).
状态0:未遇到云。此时进行大步长的FAST_STEP。Status 0: Cloud not encountered. At this point, a FAST_STEP with a large step size is performed.
状态1:上一步FAST_STEP遇到云。此时进行小步长的SLOW_STEP。State 1: The previous step FAST_STEP encountered a cloud. At this time, a small step SLOW_STEP is performed.
状态2:已经在云中。此时进行小步长的SLOW_STEP。Status 2: Already in the cloud. At this time, a small step SLOW_STEP is performed.
状态3:已达到小步长数量上限。此时不再考虑路线上的云层状况,只进行FAST_STEP至所有步数耗尽。Status 3: The maximum number of small steps has been reached. At this time, the cloud conditions on the route are no longer considered, and only FAST_STEP is performed until all steps are exhausted.
关键的状态转移时机为:The key state transition timings are:
A:当FAST_STEP后的当前新位置云层密度场不为0时,状态机从状态0转移至状态1。由于之前的FAST_STEP步长较大,为确保接下来的SLOW_STEP捕捉到全部云层细节,此时在积分路径上后退一步FAST_STEP。A: When the cloud density field at the current new position after FAST_STEP is not 0, the state machine transitions from state 0 to state 1. Since the previous FAST_STEP step size is large, in order to ensure that the next SLOW_STEP captures all the details of the cloud layer, at this time, take a step back FAST_STEP on the integration path.
B:当位于状态1,且上一次SLOW_STEP后的当前新位置密度场不为0时,从状态1转移至状态2。B: When in state 1 and the current new position density field after the last SLOW_STEP is not 0, transition from state 1 to state 2.
C:当位于状态2,且上一次SLOW_STEP后的当前新位置密度场为0时,认为已经离开了云层,从状态2转移至状态0。C: When it is in state 2, and the current new position density field after the last SLOW_STEP is 0, it is considered that it has left the cloud layer, and it is transferred from state 2 to state 0.
D:当SLOW_STEP次数达到上限后,无条件转移至状态3。D: When the number of SLOW_STEP reaches the upper limit, unconditionally transfer to state 3.
如此设计的可变步长路径积分能较好地捕捉到各种云层的细节。即使是非常稀薄的云层,只要有一步FAST_STEP命中密度场不为0的任何区域,算法就会切换至SLOW_STEP以高精度采样所有区域。The variable-step path integral designed in this way can better capture the details of various cloud layers. Even with very thin clouds, as soon as one step of FAST_STEP hits any area where the density field is not 0, the algorithm switches to SLOW_STEP to sample all areas with high precision.
4.2.3透明度计算与混合4.2.3 Transparency calculation and blending
在介绍光照模型之前,首先介绍如何在云层密度场中积累透明度。对于一个片元,其颜色和透明度是通过对积分路径上的所有采样点的计算并进行混合实现的。对于积分路径上的每个采样点,计算该点的散射率α(如3.2所述)作为该点的不透明度、按照光照模型计算的结果作为RGB颜色值。采样点之间的混合包括颜色值混合与透明度混合两部分。对于采样点P,将该点的颜色计算与透明度计算值记为:Before introducing the lighting model, we first describe how to accumulate transparency in the cloud density field. For a fragment, its color and transparency are achieved by computing and blending all sample points along the integration path. For each sampling point on the integration path, calculate the scattering rate α of the point (as described in 3.2) as the opacity of the point, and the result calculated according to the lighting model as the RGB color value. The blending between sampling points includes two parts: color value blending and transparency blending. For the sampling point P, the color calculation and transparency calculation value of this point are recorded as:
Psample=(Prgb,Pa)P sample =(P rgb ,P a )
其中,Prgb为该点的颜色,Pa为该点不透明度。Among them, P rgb is the color of the point, and Pa is the opacity of the point.
对于每个片元,颜色和透明度积累从初始值(0,0,0,0)开始。For each fragment, color and opacity accumulation starts from the initial value (0,0,0,0).
对于已经积累的颜色S和新的采样点Psample,使用Alpha预乘(pre-multipliedalpha)进行混合:For the accumulated color S and the new sample point P sample , use alpha pre-multiplied (pre-multipliedalpha) for mixing:
S′rgb=Srgb+(1.0-Sa)·Prgb·Pa S' rgb =S rgb +(1.0-S a )·P rgb ·P a
S′a=Sa+(1.0-Sa)·Pa S' a =S a +(1.0-S a )·P a
上式亦可写作一个统一的形式:The above formula can also be written in a unified form:
S′=S+(1.0-Sa)·Ppre-mult;plied S'=S+(1.0-S a )·P pre-mult; plied
即先将P的颜色预乘P的不透明度,而后使用预乘不透明度的混合模式进行混合。这样的混合在每次采样时进行,最终得到的结果是预乘了Alpha的片元颜色,以同样的方式(Add,One OneMinusSrcAlpha)与天空背景混合。同时,一旦某个片元的不透明度Sa达到了1(即完全不透明),路径积分便可提前终止,完成云层体绘制积分。That is, the color of P is first multiplied by the opacity of P, and then mixed using the premultiplied opacity blending mode. This blending is done on every sample, and the final result is a premultiplied alpha fragment color that is blended with the sky background in the same way (Add, One OneMinusSrcAlpha). At the same time, once the opacity Sa of a certain fragment reaches 1 (that is, it is completely opaque), the path integration can be terminated in advance, and the cloud volume rendering integration is completed.
4.2.4参数选取与优化4.2.4 Parameter selection and optimization
对于上述提到的若干参数,其数值选取有如下的特征:For several parameters mentioned above, the value selection has the following characteristics:
整体透光率transmittance:在不影响视觉效果的情况下取值越大越可能使积分提前结束,但取值过大会使云层过于僵硬。Overall transmittance transmittance: The larger the value is without affecting the visual effect, the more likely the integration will end earlier, but if the value is too large, the cloud layer will be too stiff.
大步长FAST_STEP:次数过少可能使稀薄的云层断开,若步长过大,在SLOW_STEP用尽后视觉效果下降明显。 Large step size FAST_STEP: If the number of times is too small, the thin clouds may be disconnected. If the step size is too large, the visual effect will drop significantly after the SLOW_STEP is exhausted.
小步长SLOW_STEP:次数过少、提前切换至大步长对视觉效果影响较大。 Small step size SLOW_STEP: Too few times and switching to a large step size in advance will have a greater impact on the visual effect.
光照采样次数LSTEP:该采样将在下一步骤中详细介绍。由于该采样位于内层循环中,次数稍多便会显著影响性能。 Lighting Sampling LSTEP: This sampling will be detailed in the next step. Since this sampling is in an inner loop, a little more can significantly impact performance.
期望路径积分尽可能提前结束以减少循环量。经过调试与权衡,本发明的效果使用0.22的整体透光率、最多64次FAST_STEP、最多64次SLOW_STEP和每采样点4次光照采样。The path integral is expected to end as early as possible to reduce the amount of loops. After debugging and weighing, the effect of the present invention uses an overall light transmittance of 0.22, a maximum of 64 FAST_STEP, a maximum of 64 SLOW_STEP, and 4 lighting samples per sampling point.
5.光照模型和光照计算5. Lighting model and lighting calculation
本部分介绍如何在每次采样时(积分路径上每个采样点)计算光照颜色值,对应流程图中的“光照计算”模块。当一条特定的光线进入云团后(云包络网格所表示的云),经过水滴、冰晶的多次散射,部分光线被云团吸收、部分光线散射至其它方向,亦有部分其它方向光线的散射部分加入其光路。在影视特效等非实时领域会采用一些方法精确计算云团内发生的多次散射,但随着散射次数指数级别增长的计算量难以满足实时性要求。本发明使用的光照模型通过比尔定律和Henyey-Greenstein像函数计算点光源对云层产生的单次散射效果。This section describes how to calculate the light color value at each sampling time (each sampling point on the integration path), corresponding to the "light calculation" module in the flowchart. When a specific light enters the cloud (the cloud represented by the cloud envelope grid), after multiple scattering by water droplets and ice crystals, some of the light is absorbed by the cloud, some of the light is scattered to other directions, and some of the light is scattered in other directions. The scattering part of the added to its light path. In non-real-time fields such as film and television special effects, some methods are used to accurately calculate the multiple scattering that occurs in the cloud, but the calculation amount that increases exponentially with the number of scattering is difficult to meet the real-time requirements. The illumination model used in the present invention uses Beer's law and the Henyey-Greenstein image function to calculate the single scattering effect of the point light source on the cloud layer.
5.1比尔定律5.1 Beer's Law
比尔定律描述了光线通过吸收介质时吸光度与介质厚度、浓度的关系。其表述为:Beer's law describes the relationship between the absorbance and the thickness and concentration of the medium when light passes through an absorbing medium. It is expressed as:
其中,T为透光率,为透过介质的光通量,为抵达介质的光通量,τ为光深度(optical depth)。本方法中,通过在每个采样点额外做一组朝向光源的路径积分,并将该路径积分上的散射率α求和作为该采样点的光深度τ:where T is the transmittance, is the luminous flux through the medium, is the luminous flux reaching the medium, τ is the optical depth. In this method, an additional set of path integrals toward the light source is performed at each sampling point, and the scattering rate α on the path integral is summed as the optical depth τ of the sampling point:
比尔定律阐述了:随着光深度的增加,透过采样点的光强呈指数下降。上述积分中y描述朝向光源的积分距离。将该积分得到的结果带入亮度计算,路径积分方程可表示为:Beer's Law states that as the depth of light increases, the intensity of light transmitted through the sampling point decreases exponentially. In the above integral, y describes the integral distance towards the light source. Bringing the result obtained by this integration into the luminance calculation, the path integral equation can be expressed as:
将这组的额外路径积分称作光照采样(LSTEP)。该积分用于判断光源在到达采样点之前经过了何种厚度的云层,并根据比尔定律对应衰减光强。由于位于路径积分循环内层,该采样只进行很少的次数(本发明进行4次),且一旦离开云层(采样得到的散射率α为零)便立刻中止。This set of additional path integrals is called Lighting Samples (LSTEP). The integral is used to determine what thickness of cloud layer the light source passes through before reaching the sampling point, and correspondingly attenuate the light intensity according to Beer's law. Due to being in the inner layer of the path integration loop, this sampling is performed only a few times (4 times in the present invention), and is terminated as soon as it leaves the cloud layer (the sampled scattering rate α is zero).
5.2 Henyey-Greenstein相函数5.2 Henyey-Greenstein phase function
比尔定律能较好地计算不同厚度云层接受的光照影响,但其散射计算是各向同性的,而云层中的水滴和冰晶主要发生的米氏散射(Mie Scattering)有着显著的各向异性特征,许多气象现象,如雾虹、日环都和米氏散射的各向异性特征有关。一个更常见的现象是逆光云层边缘的银白色光带(silver lining)。Beer's law can better calculate the influence of light received by clouds of different thicknesses, but its scattering calculation is isotropic, and the Mie Scattering mainly occurs in water droplets and ice crystals in clouds has significant anisotropic characteristics, Many meteorological phenomena, such as fog bows and solar rings, are related to the anisotropic characteristics of Mie scattering. A more common phenomenon is silver lining around the edges of backlit clouds.
这种现象是由米氏散射中占主导地位的强烈前向散射(forward scatteringpeak)导致的:在云层边缘云层较薄,强烈的前向散射使光路方向几乎不变且强度衰减很小。由于米氏散射的相函数较为复杂,在应用中通常使用Henyey-Greenstein相函数近似其散射分布,其表述为:This phenomenon is caused by the dominant forward scattering peak in Mie scattering: the cloud layer is thinner at the edge of the cloud layer, and the strong forward scattering makes the light path direction almost unchanged and the intensity attenuation is small. Since the phase function of Mie scattering is relatively complex, the Henyey-Greenstein phase function is usually used in applications to approximate its scattering distribution, which is expressed as:
其中g为各项异性系数,θ为入射光线和出射光线的夹角,g的值越大相函数的分布越集中于夹角θ为0的前向散射部分。Where g is the anisotropy coefficient, θ is the angle between the incident light and the outgoing light, the larger the value of g, the more concentrated the distribution of the phase function is in the forward scattering part where the angle θ is 0.
在每个采样点计算光照颜色时,根据该点的视线向量(即积分方向)和光源向量的夹角计算Henyey-Greenstein相函数的影响,并与比尔定律的颜色值相乘,路径积分方程变化为:When calculating the light color at each sampling point, the influence of the Henyey-Greenstein phase function is calculated according to the angle between the line of sight vector (that is, the integration direction) of the point and the light source vector, and multiplied with the color value of Beer's law, the path integral equation changes for:
应用了Henyey-Greenstein相函数的光照计算,可注意到在光源附近的云层边缘出现了显著的silver lining现象。Illumination calculations using the Henyey-Greenstein phase function, notice a significant silver lining phenomenon at the edge of the cloud near the light source.
5.3光照参数调整5.3 Lighting parameter adjustment
本系统外部输入的云层颜色包括进行光照计算之前,云层的环境颜色BaseColor和光源颜色LightColor两部分。每个采样点的最终颜色由基础颜色和光源颜色加和得到,不受光源影响的部分(例如厚云的背面)即为环境颜色。通过调整环境颜色和光源颜色,本系统可实现在一天不同时段中颜色不同的各种天候效果。The cloud layer color input from the outside of the system includes two parts, the environment color BaseColor of the cloud layer and the light source color LightColor before the lighting calculation is performed. The final color of each sampling point is obtained by adding the base color and the light source color, and the part not affected by the light source (such as the back of a thick cloud) is the ambient color. By adjusting the color of the environment and the color of the light source, the system can realize various weather effects with different colors in different periods of the day.
以上实施例仅用以说明本发明的技术方案而非对其进行限制,本领域的普通技术人员可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明的精神和范围,本发明的保护范围应以权利要求所述为准。The above embodiments are only used to illustrate the technical solutions of the present invention rather than limit them. Those of ordinary skill in the art can modify or equivalently replace the technical solutions of the present invention without departing from the spirit and scope of the present invention. The scope of protection shall be subject to what is stated in the claims.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110214214.9A CN113160413B (en) | 2021-02-25 | 2021-02-25 | Real-time dynamic cloud layer drawing method based on cellular automaton |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110214214.9A CN113160413B (en) | 2021-02-25 | 2021-02-25 | Real-time dynamic cloud layer drawing method based on cellular automaton |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113160413A CN113160413A (en) | 2021-07-23 |
CN113160413B true CN113160413B (en) | 2022-07-12 |
Family
ID=76883492
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110214214.9A Active CN113160413B (en) | 2021-02-25 | 2021-02-25 | Real-time dynamic cloud layer drawing method based on cellular automaton |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113160413B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117523026B (en) * | 2024-01-08 | 2024-03-29 | 北京理工大学 | Cloud and fog image simulation methods, systems, media and terminals for infrared remote sensing imaging |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103177461A (en) * | 2013-01-31 | 2013-06-26 | 华北电力大学(保定) | Fractal cloud model cellular automation based art pattern generation method |
CN103793894A (en) * | 2013-12-04 | 2014-05-14 | 国家电网公司 | Cloud model cellular automata corner detection-based substation remote viewing image splicing method |
CN106570929A (en) * | 2016-11-07 | 2017-04-19 | 北京大学(天津滨海)新代信息技术研究院 | Dynamic volume cloud construction and drawing method |
CN110298909A (en) * | 2019-06-28 | 2019-10-01 | 北京工业大学 | A kind of weathering phenomena simulation method based on three-dimensional cellular automaton |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7724258B2 (en) * | 2004-06-30 | 2010-05-25 | Purdue Research Foundation | Computer modeling and animation of natural phenomena |
US20120313942A1 (en) * | 2011-06-09 | 2012-12-13 | Carestream Health, Inc. | System and method for digital volume processing with gpu accelerations |
-
2021
- 2021-02-25 CN CN202110214214.9A patent/CN113160413B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103177461A (en) * | 2013-01-31 | 2013-06-26 | 华北电力大学(保定) | Fractal cloud model cellular automation based art pattern generation method |
CN103793894A (en) * | 2013-12-04 | 2014-05-14 | 国家电网公司 | Cloud model cellular automata corner detection-based substation remote viewing image splicing method |
CN106570929A (en) * | 2016-11-07 | 2017-04-19 | 北京大学(天津滨海)新代信息技术研究院 | Dynamic volume cloud construction and drawing method |
CN110298909A (en) * | 2019-06-28 | 2019-10-01 | 北京工业大学 | A kind of weathering phenomena simulation method based on three-dimensional cellular automaton |
Non-Patent Citations (1)
Title |
---|
"基于元胞自动机的云层实时模拟";姚海 等;《系统仿真学报》;20080630;第20卷(第11期);第2946-2950页 * |
Also Published As
Publication number | Publication date |
---|---|
CN113160413A (en) | 2021-07-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105574827B (en) | A kind of method, apparatus of image defogging | |
CN102903146B (en) | For the graphic processing method of scene drawing | |
CN105912234B (en) | The exchange method and device of virtual scene | |
US20100164974A1 (en) | Systems and methods for the real-time and realistic simulation of natural atmospheric lighting phenomenon | |
US9684997B2 (en) | Efficient rendering of volumetric elements | |
CN106204735B (en) | Application method of the Unity3D terrain datas in 11 environment of Direct3D | |
CN102915559A (en) | Real-time transparent object GPU (graphic processing unit) parallel generating method based on three-dimensional point cloud | |
CN104091363A (en) | Real-time size cloud computing method based on screen space | |
CN111080505B (en) | Method and device for improving graphic element assembly efficiency and computer storage medium | |
CN108805971A (en) | A kind of ambient light masking methods | |
CN110443759A (en) | A kind of image defogging method based on deep learning | |
CN113160413B (en) | Real-time dynamic cloud layer drawing method based on cellular automaton | |
CN115713584A (en) | Method, system, device and storage medium for rendering volume cloud based on directed distance field | |
CN114820990A (en) | A digital twin-based visualization method and system for flood control in river basins | |
CN112017254B (en) | A hybrid ray tracing rendering method and system | |
Zhang et al. | Stylizedgs: Controllable stylization for 3d gaussian splatting | |
CN110400366B (en) | Real-time flood disaster visualization simulation method based on OpenGL | |
CN112233214A (en) | A snow scene rendering method, device, device and storage medium for a large scene | |
CN111784817A (en) | Shadow display method and device, storage medium and electronic device | |
CN115906703A (en) | A GPU fluid simulation method for real-time interactive applications | |
Klehm et al. | Property and lighting manipulations for static volume stylization using a painting metaphor | |
CN104299262B (en) | A kind of three-dimensional cloud analogy method based on velocity field streamline | |
Dachsbacher | Interactive terrain rendering: towards realism with procedural models and graphics hardware | |
CN114373058A (en) | Sea surface mesh dynamic division and height field generation method based on illusion engine | |
CN110502305B (en) | Method and device for realizing dynamic interface and related equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |