With the gradual integration of computers into people’s work and life, it is no longer an unattainable goal to use the power of science and technology to simulate various states of matter. In the future, virtual simulation modeling technology will become more and more high-end with the improvement of the needs of the times. However, nowadays, there are many problems in generating real-time image animation. For traditional simulation methods, huge computation and realistic rendering have become technical bottlenecks. This topic takes the generation of flame animation as an example to illustrate. On the basis of the depth stripping algorithm and texture mapping method, not only particle system modeling is introduced, but also a new N-S equation is improved for research. The research results show the following. (1) The model constructed by this method has superior performance and has been greatly improved; after iteration, the error value is as low as 0.03 and the accuracy value is as high as 98%. (2) After 500 simulations, there are 399 kinds of static and 698 kinds of dynamic flames, respectively; it takes 24.01 s and 98.21 s to generate 500 incomplete animations. (3) Compared with the particle system and deep learning model for flame animation recognition and detection, the highest false alarm rate of this model is 4.6%, and the lowest is 0.9%, and the experimental effect is stable; the highest recognition of flame animation can reach 99.2%, and the lowest is 98.5%. (4) Generally speaking, experts and ordinary people have a high evaluation on the effect of this model; except for the first group, the scores are all over 80%, and the highest score can reach 85.936%. Finally, the experimental results are good, which proves the effectiveness and feasibility of this method, which has certain research contribution value. However, for the follow-up work, the algorithm and model have room for further improvement.

1. Introduction

3D animation makes use of 3D space technology and related software modeling and realizes realistic dynamic and static pictures. It can even generate applications of various scenes in real time, which is the blueprint for the future of mankind. However, it is very difficult to simulate irregular natural products such as wind, water, smoke, and fire in life scenes. They cannot be defined and constructed by general mathematical models and physical attributes. Therefore, how to generate the real texture of flowing objects has always been a very challenging subject. For some skilled professionals, the process of realizing a flame is just a basic animation exercise. But the simpler the animation, the more difficult it is to control and realize the details. A flame contains a lot of knowledge in the field of computer graphics, and every dynamic and static performance is followed by unpredictable and ever-changing states. The purpose of this paper is to build the model faster and better in real time, simplify the calculation process, and reduce the redundant calculation. In addition, the paper also strengthens the color matching of flame, increases the detail texture, and ensures the realistic effect. After many investigations and consulting, there are many real simulation data about flame at home and abroad, and the research degree and cognitive degree are different.

This paper refers to the previous research literature and methods and combines new ideas of multiple modes to create innovations, which have certain theoretical and practical significance. The following literature can give some theoretical support and data support to this paper. The specific contents are as follows. The improved double depth stripping algorithm combined with Beer’s law can be used to calculate the attenuated light intensity [1]. Use the network of depth feature fusion and reconstruction to distinguish the microfiber existence characteristics of the convolution neural network [2]. Aiming at the high detection rate, low false detection rate, and real-time requirements of the video flame detection algorithm, experiments are carried out based on target tracking and multifeature fusion [3]. Based on the trust model and dynamic and static features, a probability model of multifeature fusion is established [4]. A particle system is used to control the properties of firework particles at the moment of explosion, and texture mapping is used to draw firework particles [5]. The Gyarmathy model and Perlin noise are introduced for geometric modeling, and complex flames are drawn in virtual scenes, and the real-time and fidelity aspects are studied [6]. Deep stripping and GPU are combined to draw a real-time approximate soft shadow [7]. Based on Level-Set surface deformation, the modified MacCormack and smoke density evolution curve are introduced, and a flame blue core surface evolution model is proposed [8]. The algorithm is completely implemented in GPU, fast modeling and rendering, and the final result is obtained by alpha mixing [9]. Use C4D and AE software particle special effects to make animation in three-dimensional space [10]. For local texture mapping, the region is established by picking points, and the interactive topological structure of data is studied [11]. The computer is used to simulate fluid motion, and mathematical and physical models are constructed based on N-S equations to simulate real-time flame [12]. For the -buffer algorithm and ray tracing algorithm, a visibility detection scheme without setting deviation is formulated [13]. TLM modeling in GPU texture mapping operation is based on UML-SystemC [14]. Texture mapping of the 3D model used the ASM algorithm, RBF interpolation function, feature point constraint, and deformation [15].

2. Theoretical Basis

2.1. Flame Animation

A flame [16] is a physical and chemical phenomenon in nature. At the same time, it is an extremely complex and unpredictable state, with hot gasification parts. In essence, a flame is an exothermic reaction, which relies on the high-speed movement of surrounding air molecules in the reaction range to emit light. In the field of vision, it is a fluid phenomenon with random motion changes, so it is difficult to describe it concretely by geometry. At the same time, due to its ever-changing state in time and space, it is difficult to truly simulate the dynamic feeling of flame combustion. Making an excellent flame animation through simulation experiments is a piece of deep knowledge. Therefore, the best way to accurately describe the interaction of various molecules in a mass of gas is to model. The classical modeling materials are sorted out in order to deepen understanding, as shown in Table 1.

In this paper, we mainly pursue the “realism” of flame, which belongs to the visual research purpose. Therefore, we can abandon some normative requirements in physics. The complicated motion of heated gas is abstracted and simplified as a dynamic motion field. By changing the original monotonous motion law in the sports field, the generation of flame will be more flexible and real. Among them, we define the sports field as an -dimensional vector in the real number field. It has 1 to function attributes with time . The vortex field is defined as , a five-dimensional vector over a real number field. The specific formula is as follows:

The rotation angle characteristic value is as follows:

Position and speed are as follows:

2.2. Deep Stripping Algorithm

Depth peeling’s [21] full name is the deep stripping algorithm. This is a technology that can solve the problem of unordered rendering of opaque objects and realize sorting depth values. Using the shadow mapping proposed by Lance Williams, the depth test is simulated. Through multiple rendering methods, the color of the target will be stripped out layer by layer according to the flow. Then, according to the target requirements, the rendering results are obtained by mixing colors in a certain order.

The specific algorithm flow is as follows. (1) Firstly, render transparent objects, using the depth buffer test function to get color values. Then, copy the depth value into the depth texture. (2) Secondly, turn on the comparison function and filter the colors that can pass the test. This step mainly selects colors with large depth values. Then, the color value and the corresponding depth value of the next layer are obtained. (3) Repeat the second step continuously, separating layer after layer of color until all colors are stripped out. (4) Arrange the hierarchical colors in the order from back to front. Then, gradually render the depth and complexity of transparent objects to get the results.

Generally, API functions in the ARB extension function in OpenGL are used to realize the effect of this algorithm. OpenGL [22] is a software interface on graphics hardware and a state machine, which can write three-dimensional graphics applications. Its operation sequence is similar, and a series of processing stages are called rendering pipelines. In addition, based on the low-level mechanism of the window system, some function libraries can simplify programming.

2.3. Texture Mapping

Texture mapping [23], the Chinese whole process, is a kind of OpenGL hardware, which can save a variety of textures. It has the functions of reducing calculation amount and improving calculation speed. A texture image is attached to the surface of a three-dimensional object to improve the surface color richness. This mapping process can enhance the realism of objects. Sometimes, users can help adjust the surface shape, reflection, shadow, and other information through this method. It can be used with the deep stripping algorithm, illumination calculation, image mixing, and other technologies so as to design a more perfect and beautiful effect. The related function steps are as follows.

2.3.1. Two-Dimensional Mapping

According to the target, different intermediate mapping media are used to generate different textures. Then, paste the texture on a simple three-dimensional object. If represents a mapping, there are

2.3.2. Three-Dimensional Mapping

After the first step, the texture on the three-dimensional object that has been mapped once is mapped to the final target object surface. If stands for mapping, there are

In addition, there are some pieces of knowledge or operations related to texture mapping, which are supplemented here.

Perspective correct interpolation is as follows:

The pixel footprint [24] is as follows:

The higher-order Taylor expansion is as follows:

The three-dimensional stripe texture is as follows:

2.4. Mathematical Physics Method

In this paper, the N-S (Navier-Stokes) equation is introduced [25]. This method is approved at home and abroad and can completely describe fluid phenomena. Its kinetic energy conservation equation is as follows:

The mass conservation equation is as follows: where represents the velocity field; represents the density of the fluid; refers to the external force; denotes time; can explain the kinematic viscosity coefficient; means the advection term.

The whole process steps are as follows:

Formulas (13)–(17) are the flow steps after formula (12) is decomposed. Formula (13) is the calculation of the advection term, which is operated by the semi-Lagrange formula. Formula (14) is related to the diffusion term and can be obtained by the implicit method. Formula (15) is the answer to add the external force term. Formulas (16) and (17) represent the velocity with a divergence of 0, which is mainly obtained by the projection of the H-H theorem.

3. Research on Simulating Real-Time Flame Animation

3.1. Introducing Particle System

The simulation method of the particle system is simple and easy to realize. However, it cannot accurately describe the process of flame combustion. But it takes a large number of tiny particles as its basic elements, which can effectively represent those irregular fuzzy substances. In this experiment, each particle can have many properties, which are consistent with the various properties of the flame itself. And the particle system contains two forms: dynamic and static, and each particle experiences a different life cycle. It coincides with some concepts abstracted by us—the motion of the dynamic sports field. As for some weaknesses of the particle system, we integrate the method of the dynamic motion field to make up for the design of the flame animation model. The initialization improvement of the particle system is described as follows.

Determine the initial position of new particles with the following:

The location of new flame particles is as follows:

3.2. Improvement of the Model Method
3.2.1. Double-Layer Depth Stripping Algorithm

In this experiment, although the traditional depth stripping algorithm can ensure the correct color results, the rendering of times leads to the inefficiency of this method, which reduces the final animation effect. Therefore, we need to improve the original algorithm. On the basis of the original, considering the hardware requirements and financial constraints, this paper gives priority to the proposed double-layer deep stripping algorithm. The new algorithm can increase the running speed by nearly two times. This method uses new technology, is easy to implement, and can save the maximum or minimum depth value. At the same time, the new algorithm can store multiple color values. Thus, the target of the first layer and the last two layers can be stripped out by rendering again. It ensures the correctness of the original algorithm, improves the performance of the algorithm to the maximum extent under the consideration of the existing resource constraints, and can complete the complete real-time rendering task in complex scenes.

3.2.2. Modified N-S Equation

After the introduction of the particle system, the mathematical and physical methods in this paper need to be modified. That is to say, the advection term of the N-S equation is modified to meet the needs of experiments. This is because the introduction of the particle system affects the key to flame formation in the system. If it is not changed and corrected in time, it will directly destroy the formation of flame animation. When simulating flame, the external shape of the flame is constructed by the generation and disappearance of particles. At this time, the advection item needs to add parameters:

It should be noted that the value range of is . In this way, the shape of the whole part is controlled by the particle system. For the detailed natural state of the fluid, it is debugged by the improved N-S equation.

3.3. Analog Implementation

We use a flow chart to illustrate the formation and implementation of the whole flame animation, as shown in Figure 1.

This paper uses a variety of methods to simulate animation effects. Firstly, the concept of the dynamic motion field is put forward, and some shortcomings are compensated by combining the particle system. For GPU objects, OpenGL tools are used to accelerate the implementation of Navier-Stokes equations. It is worth noting that the N-S equation here has been improved on the advection term based on the characteristics of the particle system. At this time, the motion of particles can be completely controlled. Use the double-layer depth stripping algorithm to render real color, and then add the texture mapping method to enhance the realism of animation and improve the calculation speed.

4. Experimental Analysis

4.1. Experimental Environment

In this section, we show some of the main experimental equipment, as shown in Table 2.

4.2. Flame Effect Display

Based on the particle polygon patch, the running speed of the system can be accelerated without too many particles. We designed five kinds of flame particle textures. It is also necessary to map textures to enhance the realism of details in order to achieve the most ideal flame dynamic effect, as shown in Figure 2.

There are many modes in the formal simulation of flame effects, and we intercept some simulation states to show them. We can see that there are clearly visible flames and fireworks, as well as simulations of the surrounding tiny particles or smoke patterns, and the details are clearer than those in the traditional particle system animation. It can also simulate the random form of fire being blown when it is blown by the wind, as shown in Figure 3.

4.3. Performance Test

In order to verify whether the final performance of the model is superior to the traditional algorithm model after the application of this method, we test the error and accuracy of the model. Note that the model needs to be pretested to check the error. If the loss function is too large and does not reach the expected target value, the model generation is unstable, and further modification of the model is needed. As for the accuracy test, the accuracy of the algorithm is mainly judged when the model error is stable and the formal test is carried out. Both the pretest stage and the formal test stage are iterated 60,000 times, and the test results every 5000 times are recorded and evaluated after quantification, as shown in Figures 4 and 5.

In the pretest stage, we set the error target value to be less than 0.05. If the test results do not meet this requirement, then this experiment is invalid, and the model and algorithm need to be modified again. From the figure, we can find that after 5000 iterations, both methods can converge rapidly to varying degrees. At this time, the traditional method can only converge from 0.85 to 0.134, and the fluctuation value of subsequent iterations is large, and it is not stable to the target value of about 0.05 until 40,000 iterations. The method in this paper can quickly converge to a smaller size and directly reduce it to 0.07. Then, after 30,000 iterations, the error value can be stabilized at about 0.03. Not only the target value is reached, but also the final error value is smaller, and the effect is obvious.

In the formal test phase, we set the final accuracy target value as 0.93. That is to say, the accuracy of the model should reach more than 93% before it is qualified. For the traditional method, after 10,000 iterations, the model accuracy is above 0.93, but in 20,000 tests, the test accuracy is only 0.92. The values of subsequent iterations are also unstable, and the overall curve is in a state of twists and turns, and the average accuracy can reach 95%. For this method, we can find that after 5000 iterations, the accuracy value rapidly increased to 0.943, and the subsequent test curve gradually increased and then quickly tended to be flat. Finally, after 15,000 iterations, the ultra-high-precision value of 0.98 can be basically maintained, exceeding the target value.

4.4. Flame Modal Test

The flame animation generated by us will generate different modes due to various factors. After 500 tests, count the clear flame patterns that can be captured by ultraclear lens under static and dynamic conditions. In addition, the generation time of incomplete animation (unified as the state when the flame integrity is one-fifth) and complete animation should be counted. We can find that with the increase in test times, the flame can capture more forms. The static state can capture up to 399 forms; the dynamic state can capture up to 698 different forms. In the initial state, the first test shows that the generation time of incomplete animation is only 0.05 s, and that of complete animation is 0.18 s, so the animation generation speed is very fast. After 500 simulations, it takes 24.01 s for incomplete animation and 98.21 s for complete animation. This result takes less time than originally expected, indicating that there is a faster generation speed during the test than the initial test, as shown in Figure 6.

4.5. Detection Recognition Rate Effect

After the production of flame animation, we need to use professional tools and software to identify and detect flame animation. A total of 5 test groups were set up, and each group carried out 20 recognition tests on different flame animations, with a total of 100 recognition tests. In order to better highlight the recognition effect of this method, we add the model recognition effect comparison between the unimproved particle system method and the deep learning method, as shown in Figures 7 and 8.

Before the formal test, we pretest the nonflame animation to test the false-positive rate of the three methods. Also, set up 5 sets of tests. From Figure 7, it can be found that the particle system method has the highest false alarm rate in test group 1 and test group 3. Among test groups 2, 4, and 5, the false alarm rate of the deep learning method is the highest, and the highest false alarm degree can reach 16.5%. However, the false-positive rate of this model is the lowest among the five test groups, the highest false-positive rate is only 4.6%, and the lowest is 0.9%. The effect is stable, and the interference degree is the least.

From the formal test in Figure 8, we can find that the recognition rate of flame in the animated video in this model is the highest among the five groups of data, with the highest recognition rate reaching 99.2% and the lowest recognition rate reaching 98.5%. The highest recognition rate of the particle system is 93.6%. The highest recognition rate of the deep learning model is 96.8%, which is slightly higher than that of the particle system. This proves that the flame animation produced in this experimental test is excellent and the effect is excellent.

4.6. Satisfaction Test

Making animation needs to have a certain degree of appreciation and beauty. Therefore, the flame animation completed in our experiment is evaluated from five aspects: beauty, integrity, fidelity, clarity, and detail. Five experts and 25 volunteers were invited to score six groups of flame animations based on this model. Statistical animation effect satisfaction is shown in Figure 9.

We can find that the animation integrity of the other five groups is higher than 90%, except for the integrity of the sixth group, which is 82.2%. The group with the highest aesthetic and detailed effects is the third group, which is 90.23% and 89.34%, respectively. At the same time, the third group is also the group with the highest average evaluation, reaching 85.936%. The second group has the best realistic effect, which can reach 89.23%. Group 6 is the group with the highest clarity, but the overall score is not high. The worst animation effect is the first group, with an overall score of only 73.526%.

5. Conclusion

This paper is located in a three-dimensional space angle to generate computer graphics, using CG technology to simulate virtual reality. This is an applied subject with wide application and rapid development. It intersects with many research fields and has a bright future. In this article, we take flame animation as a demonstration research example, organically combined with a variety of technical methods. In this paper, the animation model and algorithm are analyzed and tested, and the various forms of fireworks are finally captured. In addition, the dynamic and static flame animation simulation pictures are intercepted to verify the application value of the experiment. The specific research results show that based on the deep stripping algorithm and the function of texture mapping, the flame data is visualized, and the professional simulation satisfaction evaluation is carried out. Use professional tools and software to identify and detect flame animation so as to confirm the discrimination degree of flame. It overcomes the limitation of computer performance and calculates and optimizes the error and accuracy. Improve the mathematical and physical equations to reduce the resistance that affects the real-time performance because of the complexity of calculation. The final experimental effect is close to that in nature, and the details are close to reality. Whether in the fields of games, advertisements, or special effects, it is very meaningful to study the construction of irregular real-time animation.

Although this paper simulates flame animation from a new angle and obtains ideal realistic flame effects of various forms, however, more attention should be paid to the optimization of future work. For example, OpenGL rendering efficiency is not excellent enough, and there is room for improvement in the limitation of specific hardware requirements. The generation speed of animation needs to be finely controlled. Also, the delay performance of animation may lead to poor audience perception, which needs further optimization. Improve the interface and the research on the calling effect when the parameters meet all conditions and the lack of consideration of some scenes, such as the simulation when the flame is blocked by obstructions and the firepower is weak. Texture mapping may be distorted. The above description of the shortcomings of this paper will be the focus of future work.

Data Availability

The experimental data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The authors declared that they have no conflicts of interest regarding this work.