Rendering method and device for smoke in virtual scene, electronic equipment and medium

By constructing the curl field of curl noise on a two-dimensional screen and updating the smoke properties in real-time, the problems of large amount of calculation and low interaction efficiency in the existing smoke simulation methods are solved, and real-time rendering and three-dimensional effects of large-scale smoke in the game are achieved.

CN120346514APending Publication Date: 2025-07-22NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410080651.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-19
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

The existing smoke simulation methods are too large in computing and memory consumption, making it difficult to achieve large-scale smoke rendering in real-time application scenarios, and the interaction efficiency between smoke and scene objects is low, which cannot meet the real-time rendering needs of complex systems such as games.

Method used

The dimensionality reduction smoke simulation method is adopted to solve it on a two-dimensional screen. By constructing the curl field of curl noise as smoke velocity information, and the smoke attributes are updated in real time in combination with the influence of scene objects, simplifying the calculation amount and achieving three-dimensional scene effects.

Benefits of technology

It realizes efficient rendering of large-scale smoke in real-time applications such as games, reduces computing volume and memory consumption, improves the interaction efficiency between smoke and scene objects, and meets the needs of real-time rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120346514A_ABST
    Figure CN120346514A_ABST
Patent Text Reader

Abstract

The invention provides a rendering method and device for smoke in a virtual scene, electronic equipment and a medium, and the method comprises the steps: obtaining first attribute information of a smoke emitter in response to a triggering operation for the smoke emitter associated with a specific object; the first attribute information comprises color information, depth information and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered; constructing a curl noise wave meeting a non-scattering condition, and calculating a curl field of the curl noise wave as first speed information of the smoke; updating the first speed information to obtain second speed information according to the influence of a scene object in a virtual scene on the screen on the smoke and the motion condition of the smoke; and updating the first attribute information according to the second speed information, and rendering smoke based on the updated second attribute information. According to the method, the calculated amount is simplified, meanwhile, the effect of a three-dimensional scene can be achieved, and the requirement of real-time rendering of smoke in a virtual scene is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of game processing, and more particularly, to a method, apparatus, electronic device, and medium for rendering smoke in a virtual scene. Background Art

[0002] Fluid simulation technology is an important technology in computer graphics, which can be used to simulate the movement, form, and interaction of fluids. It has a wide range of application fields, such as animation, games, engineering, medicine, etc. In animation and games, fluid simulation technology can be used to simulate special effects such as water, fire, and smoke, making the scene more realistic. In the medical field, fluid simulation technology can be used to simulate physiological processes such as blood flow and sweating, assisting in diagnosis and treatment. In the engineering field, fluid simulation technology can be used to simulate problems such as gas flow and hydraulics, assisting in design and optimization.

[0003] The basic principle of fluid simulation technology is to describe the motion law of fluids through differential equations such as the Navier-Stokes (N-S) equation, and use numerical methods to solve these equations to obtain the motion state of the fluids. The program implementation of the N-S equation is mainly divided into the Eulerian Method based on grids and the Lagrangian Method based on particles, and there is also a Mixed Method that combines the two. The Eulerian Method describes the motion state of fluids by numerically simulating the motion trajectories of fluid particles; the Lagrangian Method describes the motion state of fluids by discretizing space into grids and calculating the physical quantities of fluids at each grid.

[0004] Among them, taking smoke simulation as an example, smoke simulation is a subdivision field of fluid simulation. Smoke is composed of many tiny particles, and its motion law is similar to that of fluids, so the method of fluid simulation can be used to simulate the motion of smoke. Smoke is usually simulated using the Eulerian Method and is very suitable for parallel solution by the Graphics Processing Unit (GPU); the Lagrangian Method is also used for smoke simulation.

[0005] In the existing smoke simulation methods, whether using the Eulerian Method or the Lagrangian Method, due to the need to allocate a large number of grids or particles, a large amount of memory in units of GB (Gigabyte, one of the units of computer storage capacity) is often consumed, the calculation amount is extremely large, it is difficult to solve in real time in application scenarios that emphasize real-time performance, and it cannot meet other requirements in the application scenarios; in addition, both the Eulerian Method and the Lagrangian Method smoke simulations are only suitable for small-scale smoke simulations and also cannot meet the requirements of real-time rendering in the application scenarios. Summary of the Invention

[0006] In view of this, the present application provides a method, an apparatus, an electronic device, and a medium for rendering smoke in a virtual scene. By performing calculations on a two-dimensional screen, considering scene interactions, and realizing smoke rendering, the amount of calculation is simplified while the effect of a three-dimensional scene can be achieved, meeting the requirement for real-time rendering of smoke in a virtual scene; moreover, it can be applied to large-scale smoke simulation.

[0007] In a first aspect, an embodiment of the present application provides a method for rendering smoke in a virtual scene, the method including:

[0008] In response to the virtual scene satisfying the smoke trigger condition, obtaining first attribute information of a smoke emitter in the virtual scene; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered;

[0009] Constructing a curl noise that satisfies the divergence-free condition, and calculating the curl field of the curl noise as the first velocity information of the smoke;

[0010] Updating the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke and the self-movement of the smoke;

[0011] Updating the first attribute information according to the second velocity information, and rendering the smoke based on the updated second attribute information.

[0012] In a second aspect, an embodiment of the present application further provides a device for rendering smoke in a virtual scene, the device including:

[0013] A first acquisition module, configured to obtain first attribute information of a smoke emitter in the virtual scene in response to the virtual scene satisfying the smoke trigger condition; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered;

[0014] A first calculation module, configured to construct a curl noise that satisfies the divergence-free condition, and calculate the curl field of the curl noise as the first velocity information of the smoke;

[0015] A first update module, configured to update the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke and the self-movement of the smoke;

[0016] A rendering module, configured to update the first attribute information according to the second velocity information, and render the smoke based on the updated second attribute information.

[0017] In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the storage medium through the bus. The processor executes the machine-readable instructions to perform the method for rendering smoke in a virtual scene according to any one of the first aspects.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, it executes the method for rendering smoke in a virtual scene according to any one of the first aspects.

[0019] For the method, device, electronic device, and medium for rendering smoke in a virtual scene provided by the embodiments of the present application, by responding to the virtual scene satisfying the smoke trigger condition, first attribute information of a smoke emitter in the virtual scene is obtained; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered; a curly noise that satisfies the non-diffusion condition is constructed, and the curl field of the curly noise is calculated as the first velocity information of the smoke; according to the influence of scene objects in the virtual scene on the smoke and the self-movement of the smoke, the first velocity information is updated to obtain second velocity information; the first attribute information is updated according to the second velocity information; the smoke is rendered based on the updated second attribute information; by performing calculations on a two-dimensional screen and interacting with scene objects in the virtual scene by real-time recording of the attribute information of the smoke and rendering the smoke, the calculation amount is simplified while the effect of a three-dimensional scene can be achieved, meeting the requirement for real-time rendering of smoke in a virtual scene. Description of the Drawings

[0020] To more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0021] Figure 1 Shows a flowchart of the first method for rendering smoke in a virtual scene provided by an embodiment of the present application;

[0022] Figure 2a Shows a schematic diagram of a smoke emitter; Figures 2b - 2d The smoke emitter successively shows schematic diagrams of the color field, depth field, and thickness field of the smoke;

[0023] Figure 3Shows the flowchart of the second method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0024] Figure 4a Shows the flowchart of the third method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0025] Figure 4b Shows a schematic diagram of the constraint result of constraining smoke based on scene objects on the screen;

[0026] Figures 4c - 4f Shows an example of the interaction between scene objects in the screen and smoke, Figures 4c - 4f in which the square moves to the lower right corner and blows away the smoke;

[0027] Figure 4g Shows the specific definitions of the depth and thickness of smoke;

[0028] Figure 5a Shows the flowchart of the fourth method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0029] Figure 5b(1) is a schematic diagram showing that a shadow is generated when the camera lens rotates rapidly; Figure 5b(2) is a schematic diagram for eliminating the shadow generated in Figure 5b(1);

[0030] Figure 6a Shows the flowchart of the fifth method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0031] Figure 6b Shows a schematic diagram of calculating the smoke thickness on the path from the light source to the camera based on the real-time updated two-dimensional attribute information;

[0032] Figure 7a Shows the flowchart of the sixth method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0033] Figure 7b Shows a schematic diagram of the obtained smoke shadow map;

[0034] Figures 7c(1) - 7c(3) Respectively show schematic diagrams of the shadow effects corresponding to the Poisson disk sampling radius r = 0, sampling radius r = 0.01, and sampling radius r = 0.05;

[0035] Figure 8 Shows the flowchart of the seventh method for rendering smoke in the virtual scenario provided by the embodiments of the present application;

[0036] Figure 9a Shows the flowchart of the core steps of the method for rendering smoke provided by the embodiments of the present application;

[0037] Figures 9b - 9e The sequence frames shown are the rendering effects of the smoke in the scene in this application;

[0038] Figures 10a - 10b It shows a schematic diagram of the smoke trailing simulation with collision interaction for the smoke rendering method in this application and the existing smoke rendering method;

[0039] Figure 11 It shows a schematic structural diagram of a smoke rendering device in a virtual scene provided by an embodiment of this application;

[0040] Figure 12 It shows a schematic structural diagram of an electronic device provided by an embodiment of this application. Detailed implementation manners

[0041] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. It should be understood that the accompanying drawings in this application are only for the purposes of illustration and description, and are not used to limit the protection scope of this application. Additionally, it should be understood that the schematic drawings are not drawn to actual scale. The flowcharts used in this application show the operations implemented according to some embodiments of this application. It should be understood that the operations in the flowchart may not be implemented in sequence, and steps without logical context relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of this application.

[0042] In addition, the described embodiments are only a part of the embodiments of this application, rather than all of the embodiments. The components of the embodiments of this application usually described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of this application that is required to be protected, but only represents the selected embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of this application.

[0043] It should be noted that the term "including" will be used in the embodiments of this application to indicate the existence of the features stated thereafter, but does not exclude adding other features.

[0044] In the scenario of fluid simulation, specifically smoke simulation (also known as smoke rendering), smoke is usually simulated using the Eulerian method, which is very suitable for parallel solution by the Graphics Processing Unit (GPU). The Lagrangian method may also be used for smoke simulation. In practice, in smoke simulation, the ultimate goal of different solution methods (Lagrangian method, Eulerian method) is to solve differential equations such as the Navier-Stokes (N-S) equation and obtain the smoke velocity field at each time step, so as to obtain the smoke state of the next frame.

[0045] When solving smoke simulation based on the N-S equation, usually four other equations need to be satisfied simultaneously. Among these four other equations, satisfying one of them can ensure that the solution result is an incompressible fluid; satisfying two of them is responsible for solving the temperature, density, initial concentration, and diffusion coefficient of the smoke; satisfying the remaining one equation is responsible for maintaining the buoyancy of the smoke. That is to say, all five equations including the N-S equation and the other four equations need to be solved to iterate the dynamics of the smoke for one frame. Therefore, the computational cost of smoke simulation is extremely high, and it is difficult to solve in real time in application scenarios that emphasize real-time performance such as games and engineering.

[0046] Different from the Eulerian method, the Lagrangian method regards the fluid as composed of individual particles. The particles convert the velocity field around them into their own forces and then move. However, smoke simulation usually does not use the Lagrangian method for simulation. Although smoke itself is also composed of many tiny particles, due to the extremely small size of the particles, the movement trajectories of a large number of small particles will interfere with each other, resulting in a very large amount of calculation, and the cost of modeling each particle is too high. For example, the Lagrangian Vortex method proposed in the 2005 paper "Vortexfluid for gaseous phenomena" can simulate fluids such as turbulent smoke in great detail. However, this method has two fatal problems: low efficiency in constructing the velocity field from the vorticity field and difficulty in handling boundary conditions.

[0047] However, if we want to achieve the interaction between smoke and scene objects (Mesh data in computer graphics), when using the Euler method to simulate smoke, it is necessary to convert the Mesh data into grid data every frame, that is, to detect which grids used for simulating smoke are occupied by the Mesh every frame, then mark them, and finally exclude the smoke in the fluid solution; when using the Lagrangian method to simulate smoke, the intersection relationship between particles and triangular faces can be calculated. Although the collision detection can be accelerated by pre-establishing acceleration data structures such as octree (OC-Tree) or BVH for the Mesh in advance, when the number of scene objects increases, it is still an unbearable overhead. Among them, the above BVH (Bounding Volume Hierarchy) is a data structure used to accelerate computer graphics algorithms such as raytracing.

[0048] Based on this, the existing smoke simulation methods (i.e., smoke rendering methods) have the following problems:

[0049] (1) In the existing smoke simulation methods, whether using the Euler method or the Lagrangian method, due to the need to allocate a large number of grids or particles, a large amount of memory in the unit of GB is often consumed;

[0050] (2) The solution efficiency of the existing smoke simulation methods is very low. With the improvement of GPU computing power today, although real-time smoke simulation can be achieved by means of GPU parallel solution and vector basis dimensionality reduction projection acceleration, the overhead of only the smoke solution part is already running at full load. And real-time applications such as games are a large and complex system, which needs to take into account multiple modules such as scene rendering, GUI rendering, animation control, audio processing, and network communication at the same time. The overhead of the physical system allocation cannot support the real-time solution of fluid simulations such as smoke and liquid;

[0051] (3) Both the Euler method and the Lagrangian method for smoke simulation are only suitable for small-scale smoke simulation. Since the Euler method needs to allocate grids as containers, and the grids usually cannot extend infinitely to the entire virtual scene, it can only be simulated in the area covered by the grids; NVIDIA's pure Lagrangian method cannot spread widely because the smoke particles can only exist within the first layer of pre-simulated liquid particles, which is directly mentioned in the original Paper;

[0052] (4) If the smoke simulation is directly reduced to two-dimensional plane simulation, although the solution efficiency can be greatly improved, it will cause the disconnection between smoke rendering and the three-dimensional scene. The smoke rendering looks very flat without the correct lighting effect, and it cannot generate the correct shadow in the scene, so it cannot be integrated with the scene; the camera lens must be fixed. Once the viewing angle is changed, the smoke must be re-simulated, or the smoke is pasted on the billboard that always faces the camera. Whichever method will result in a very poor visual experience;

[0053] (5) If you want to realize the interaction between smoke and scene objects, you must convert the Mesh data into Cell data or establish a collision detection acceleration structure (OC-Tree, BVH, etc.) in advance before it can enter the solution system to participate in the calculation. The conversion process of this data structure must be performed once per frame, which is extremely inefficient.

[0054] In view of the above-mentioned deficiencies in the prior art, the present application solves the following problems:

[0055] (1) This application proposes a new dimensionality reduction smoke simulation solver. Unlike the vector-based solution, it directly solves the smoke in screen space, completely solving the problems of low solving efficiency, large memory consumption and inability to directly solve large-scale smoke in existing methods, making it possible to run smoke simulation in real-time applications such as games.

[0056] (2) This application intends to solve the problem that two-dimensional smoke is rendered without a sense of volume in a three-dimensional scene and cannot be integrated with the scene, and does not support changes in camera observation angles.

[0057] (3) This application intends to solve the problem of frequent data structure conversion required in the interaction between smoke and scene objects.

[0058] The method for rendering smoke in a virtual scene provided in an embodiment of the present application is applicable to game scenes or other scenes that have no accuracy requirements for smoke rendering but only visual requirements; when applicable to game scenes, the game can be run on a local terminal device or on a server. Specifically, when the game is run on a server, it can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0059] In an optional implementation, various cloud applications, such as cloud games, can be run under the cloud interaction system. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the game loading method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud is used for information processing. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.

[0060] In an optional embodiment, taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through the screen, that is, conventionally, the game program is downloaded and installed on an electronic device and run. The ways for the local terminal device to provide the screen to the player can include various types. For example, it can be rendered and displayed on the display screen of the terminal, or provided to the player through holographic projection. For example, the local terminal device can include a display screen and a processor. The display screen is used to present the screen, and the screen includes a game screen. The processor is used to run the game, generate the screen, and control the display of the screen on the display screen.

[0061] As Figure 1 shown, a method for rendering smoke in a virtual scene provided by the first embodiment of the present application includes:

[0062] S101. In response to the virtual scene satisfying the smoke trigger condition, obtain first attribute information of a smoke emitter in the virtual scene; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered.

[0063] S102. Construct a curl noise that satisfies the non-diffusion condition, and calculate the curl field of the curl noise as the first velocity information of the smoke.

[0064] S103. Update the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke and the self-movement situation of the smoke.

[0065] S104. Update the first attribute information according to the second velocity information, and render the smoke based on the updated second attribute information.

[0066] The embodiments of the present application provide the above method for rendering smoke in a virtual scene. By performing calculations on a two-dimensional screen, considering scene interaction, and realizing smoke rendering, the amount of calculation is simplified while the effect of a three-dimensional scene can be achieved, meeting the requirement for real-time rendering of smoke in a virtual scene; moreover, it can be applied to large-scale smoke simulation.

[0067] In the embodiments of the present application, the above rendering method can be applied to a terminal device or a server. In practice, although the method of the present application has greatly reduced the amount of calculation for smoke calculation, the amount of calculation required for the above rendering method is still relatively large. Therefore, the above rendering method is usually applied to a server (of course, it can also be applied to a terminal device with high computing performance, such as a mobile terminal or a PC). Taking the application of the above method for rendering smoke in a virtual scene to a game scene as an example, the above exemplary steps of the embodiments of the present application will be described respectively below:

[0068] S101. In response to the virtual scene meeting the smoke trigger condition, obtain the first attribute information of the smoke emitter in the virtual scene; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered.

[0069] In a game scene, a graphical user interface is provided through the screen of a terminal device, and at least part of the game scene of the game is displayed on the graphical user interface, and the at least part of the game scene includes a smoke emitter associated with a specific object. Specifically, in the game, the smoke emitter is to be modeled as a specific object, such as Figure 2a the specific object 201 shown, where Figure 2a includes multiple specific objects 201, specifically including specific object 201(a), specific object 201(b), and specific object 201(c). The purpose is to be able to give the smoke emitter a trigger condition. Therefore, this specific object is the smoke emitter. As long as this smoke emitter is triggered, smoke rendering is triggered, that is, smoke diffusion simulation. Here, the above-mentioned smoke emitter diffuses into corresponding smoke after being triggered. In response to the virtual scene meeting the smoke trigger condition, that is, detecting that the smoke emitter in the virtual scene meets the smoke trigger condition, and this smoke trigger condition can be that the player uses a smoke bomb.

[0070] After the above virtual scene meets the smoke trigger condition, that is, obtain the first attribute information of the smoke emitter, specifically including color information, depth information, and thickness information; because the smoke emitter is three-dimensional, so the above-mentioned first attribute information obtained is the first attribute information of the three-dimensional smoke emitter under the initial conditions.

[0071] In practice, the color information, depth information, and thickness information in the first attribute information are represented by the color field, depth field, and thickness field of the smoke. As Figures 2b - 2d shown, they are respectively schematic diagrams of the color field, depth field, and thickness field of the smoke. The color of the smoke emitter forms the initial smoke Color Field (color field), and the smoke emitter is drawn to the Smoke Buffer (smoke buffer), and the depth and thickness of the emitter are respectively recorded in the Depth Field (depth field) and Thickness Field (thickness field).

[0072] S102. Construct a curl noise that satisfies the divergence-free condition, and calculate the curl field of the curl noise as the first velocity information of the smoke.

[0073] In the embodiments of the present application, in order to reduce the computational complexity of the calculation during the smoke diffusion process, the velocity field of the smoke is calculated in a two-dimensional space (i.e., the screen). The specific implementation method is to construct a curl noise (i.e., Curl Noise) and calculate the curl field of the curl noise as the initial velocity field of the smoke (i.e., the first velocity information). Here, in order to ensure the incompressibility of the smoke, a specific Perlin Noise condition is added to the curl noise to ensure that the curl field of the curl noise is divergence-free.

[0074] When using the Euler method or the Lagrange method to simulate the smoke diffusion by dissolving the smoke, it is necessary to solve the Navier-Stokes equations (N-S equations). The above N-S equations describe the motion equations of the momentum conservation of viscous incompressible fluids, and the computational complexity is very high, which cannot meet the real-time requirements of smoke simulation in games. The above method of constructing curl noise can obtain the first velocity information (i.e., the initial velocity field) of the smoke by calculating the curl field of the curl noise. The entire process does not need to solve the N-S equations, greatly reducing the computational complexity in the smoke diffusion simulation process, improving the computational efficiency, and being able to meet the real-time requirements of smoke simulation in games. Among them, the constructed curl noise is as follows: for any given three-dimensional space field (field) Among them, the three-dimensional space field refers to a set of three-dimensional vectors in a three-dimensional Cartesian coordinate system; ψ1, ψ2, and ψ3 are the component vectors on the X, Y, and Z axes respectively;

[0075] We calculate its curl field (the curl field is an important concept in vector fields, which describes the rotation properties of the vector field at each point):

[0076] As the initial velocity field of the smoke, this step can be pre-calculated for acceleration. Among them, represents the curl field of the calculated vector field ψ; are the partial derivatives of the component vectors of the vector field in the X, Y, and Z axis directions, and subtraction is used to obtain the rotation intensity and direction of the vector field at each point; is the curl value at any position in the vector field, and its value can be positive, negative, or zero. A positive value indicates clockwise rotation, a negative value indicates counterclockwise rotation, and a zero value indicates no rotation.

[0077] In order to ensure the incompressibility of the smoke, that is, to ensure is the initial velocity field of the smoke. Because in the embodiments of the present application, the curl field of the curl noise is calculated as the initial velocity field of the smoke, therefore,

[0078] Among them, regarding incompressibility: The incompressibility of a fluid refers to an assumption in fluid mechanics that the volume of the fluid remains constant during motion, that is, there is no change in volume. Under the incompressibility assumption, the density of the fluid remains unchanged at any position and any time in space. This means that no matter how much external force the fluid is subjected to or how much pressure is applied, its density will not change. According to the incompressibility assumption, the mass conservation equation of the fluid can be simplified to the continuity equation, also known as the mass conservation equation. The continuity equation indicates that in an incompressible fluid, the mass flow rates at the inlet and outlet of the fluid must be equal to ensure a constant volume. In terms of visual effects, a compressible fluid would look like elastic jelly, and the visual effect is not realistic.

[0079] In the embodiment of the present application, ψ = N is taken, where N is Perlin Noise. In computer graphics, Perlin Noise is an algorithm used to generate natural, organic, and random textures. Perlin Noise can be used to simulate various visual effects in nature, such as clouds, flames, marble textures, etc. It creates a continuous noise function in two-dimensional or three-dimensional space to generate a smooth, irregular but structured noise pattern. The algorithm is based on sampling a grid, and each grid point has a random gradient vector; then, by performing interpolation calculations on the grid where the sampling point is located, a smooth value is obtained. By sampling and interpolating different grids, a continuous noise pattern can be generated.

[0080] One of the advantages of Perlin Noise is its smoothness. The values between adjacent sampling points change smoothly and continuously, and it can always ensure that the curl field is divergence-free. At this time, we directly use the curl field as the velocity field of the smoke, so it can also ensure that the velocity field is divergence-free, which can avoid solving the Poisson equation and greatly improve the calculation speed.

[0081] S103. Update the first velocity information to obtain second velocity information according to the influence of the scene objects on the smoke in the virtual scene and the self-motion of the smoke.

[0082] In the embodiment of the present application, the scene objects in the game scene will affect the first velocity information of the smoke, and moreover, the self-density of the smoke will also affect the first velocity information of the smoke. In practice, the smoke will diffuse outward under the action of its own density. Specifically, when the self-density of the smoke is greater than a preset threshold, it will diffuse outward; therefore, considering the above two factors, the first velocity information of the smoke (i.e., the initial velocity field of the smoke) is updated in real time to obtain the second velocity information of the smoke.

[0083] Among them, the specific object associated with the smoke emitter is not a scene object. The above specific object does not exist in the actual game, and its existence here is to add a smoke trigger condition. Scene objects specifically include static scene objects and dynamic scene objects; static scene objects are objects with a speed of 0 in the game scene, and dynamic scene objects are objects with a non-zero speed in the game scene. In the embodiments of the present application, in order to meet the game requirements and reduce the computational complexity of smoke calculation, only the scene objects displayed on the screen are calculated, rather than all the scene objects in the game scene.

[0084] S104. Update the first attribute information according to the second speed information, and render the smoke based on the updated second attribute information.

[0085] Specifically, use the self-movement situation of the smoke and the second speed information after the interaction between the smoke and the scene objects on the screen to update the first attribute information to obtain the updated second attribute information. Then, use the updated second attribute information to render the smoke, which realizes the diffusion simulation of the smoke. Here, the second speed information is real-time updated data. Correspondingly, the second attribute information is also real-time updated data. Using the real-time updated second attribute information to render the smoke realizes the real-time diffusion simulation of the smoke.

[0086] In the embodiments of the present application, when rendering the smoke with the real-time updated second attribute information, it is considered the interaction between the smoke and the scene objects on the screen. Specifically, that is, the transmittance of the smoke and the smoke shadow are considered. Specifically, the method of rendering the smoke with the real-time updated second attribute information: determine the transmittance of the smoke based on the thickness information in the second attribute information, and then use the color information to render the color of the smoke; based on the depth information in the second attribute information, judge the shadow of the smoke and render the smoke shadow. Finally, the color and shadow of the smoke are rendered through the second attribute information to realize the rendering of the smoke. In this way, the three-dimensional simulation effect of the smoke is realized, and since we perform the smoke calculation in the two-dimensional space of the screen, under the condition of greatly reducing the smoke calculation amount, the requirement of real-time rendering of the smoke in the game is met.

[0087] Further, as Figure 3 shown, when obtaining the first attribute information of the smoke emitter, obtaining the color information of the smoke emitter includes:

[0088] S301. Obtain the color information of the smoke emitter on the screen.

[0089] S302. Sample the color information in the three-dimensional smoke emitter according to the color information on the screen and the corresponding relationship between the preset two-dimensional coordinate points and three-dimensional vertices; the corresponding relationship is realized through the UV mapping of two-dimensional parametric coordinate mapping.

[0090] Combined with S301 - S302, the artists in the game pre - color the smoke emitter on a two - dimensional picture and record the color information of the smoke emitter in the two - dimensional space. Then, the color at each position on the two - dimensional picture is applied to each position of the smoke emitter on the three - dimensional model (for example, the spherical specific object 201(a) as shown in Figure 2a . Here, there is a preset correspondence between the two - dimensional coordinate points and the three - dimensional vertices from the two - dimensional picture to the three - dimensional model. Based on this correspondence, the color on the two - dimensional picture can be drawn onto the smoke emitter of the three - dimensional model. This process is sampling the color information of the smoke emitter.

[0091] The above - mentioned preset correspondence between the two - dimensional coordinate points and the three - dimensional vertices is usually achieved through UV mapping (i.e., UV Mapping). UV mapping is a process of mapping two - dimensional texture coordinates (UV coordinates) to the surface of a three - dimensional model. During the texture mapping process of the model, a two - dimensional UV coordinate is defined for each vertex of the model, also known as UV coordinate mapping. These UV coordinates correspond to the vertices of the model mesh and specify the positions on the texture image. The UV coordinates are represented in a two - dimensional coordinate system of (U, V) and are mapped to the specific texture image. During rendering, the UV coordinates are used to map the color samples of the texture image to the corresponding vertices on the model surface, so that the corresponding texture is displayed on the model surface. Through UV mapping, the colors or details on the two - dimensional texture image can be associated with the vertices on the surface of the three - dimensional model. In this way, during the rendering process, the texture image can be sampled according to the UV coordinates, and the corresponding color samples can be applied to the model surface to achieve the texture mapping and texturing effects.

[0092] When considering the interaction between the smoke and the scene objects in the screen, whether it is a static scene object or a dynamic scene object in the scene, as long as it has an impact on the smoke, a constraint on the first - order velocity information of the smoke is constructed, and the first - order velocity information of the smoke is updated based on this constraint. Further, as shown in Figure 4a , in the method for rendering smoke in a virtual scene provided by the embodiments of the present application, updating the first - order velocity information to obtain the second - order velocity information according to the influence of the scene objects in the virtual scene on the smoke includes:

[0093] S401. Construct a constraint on the influence of the scene object on the smoke according to the normal of the scene object in the virtual scene.

[0094] S402. Update the first - order velocity information based on the constraint on the influence of the scene object on the smoke to obtain the second - order velocity information.

[0095] Combined with S401 to S402, in the embodiments of the present application, in order to reduce the computational amount of smoke solving during the smoke rendering (or smoke diffusion simulation) process, only the scene objects in the virtual scene displayed on the screen are calculated; among them, the scene objects in the screen include static scene objects and dynamic scene objects. The above-mentioned static scene objects are objects with a speed of 0 in the game scene (for example, buildings), and the dynamic scene objects are objects with a non-zero speed in the game scene (for example, other game characters or moving vehicles).

[0096] Regardless of whether it is a static scene object or a dynamic scene object, the impact of it on the smoke generation needs to be considered. Therefore, through the normal line of the scene objects in the screen, the constraint of the above-mentioned scene objects on the first velocity information of the smoke is constructed, and the constraint is solved, that is, the first velocity information of the smoke is updated based on the above-mentioned constraint.

[0097] The specific implementation method of constructing and solving the above constraint is as follows:

[0098] Obtain the Normal Buffer (normal buffer) of the scene objects in the current screen (because they are not all scene objects in the game, so they are called target scene objects), and construct a Repel Field (repulsion field) based on the normal lines of the target scene objects to constrain the first velocity information (i.e., Velocity Field) of the smoke:

[0099]

[0100] α = |R(D(p) / d m )|;

[0101] R(x) = K 2 (x)·(3 - 2·K(x));

[0102] K(x) = max(0, min(1, |x|)), x ∈ [0, 1];

[0103] Among them, represents the vector field (i.e., velocity field) after being constrained by the repulsion field of the scene object; α represents the mixing factor calculated according to the distance from any point in the screen space to the object surface, and the purpose is to mix between two vector fields to obtain a new vector field. Among them, one of the two vector fields is the initial velocity field, and the other vector field is the repulsion field calculated according to the normal line of the scene object surface; among them, represents the initial velocity field, represents the repulsion field calculated according to the normal line of the scene object surface;

[0104] Let \(\vec{n}\) be the surface normal vector of the scene object. It is a three-dimensional vector in a three-dimensional Cartesian coordinate system. Here, we transform it to the screen space and reduce its dimension to a two-dimensional vector in a two-dimensional Cartesian coordinate system. Its two length components extend along the X and Y axes of the screen respectively;

[0105] Regarding the normal vector: The normal of the surface of a 3D model refers to the vector perpendicular to the model surface. In computer graphics, the surface of each 3D model is composed of many small patches or polygons, such as triangles or quadrilaterals. On each patch, a normal vector can be defined, which is perpendicular to the patch, and the direction of the normal points outside the model.

[0106] The normal has various uses in computer graphics. The most important one is for lighting calculation. According to the lighting model, when light hits a surface, the direction of the normal determines the direction of light reflection or refraction from the surface. In lighting calculation, the direction of the normal is very important for calculating the intensity of light and surface shading. In addition, the normal is also used for rendering and shading of surface details. By changing the direction of the normal, effects such as surface smoothing, bumpiness, and texture mapping can be achieved. Normal Map is a commonly used technique. By storing normal information in the texture, more realistic surface details can be simulated without increasing geometric details.

[0107] Among them, \(D(p)\) is the shortest distance from any position \(p=(x,y)\) in the screen space to the surface of the scene object. The calculation method used is to use the Signed Distance Field technology. Mark the boundary points of the polygon (scene object) as 0, and then calculate the distance from other internal points of the polygon to the target point \(p\) according to the Euclidean distance, and find the shortest path; \(d\) m is the maximum mixing distance that can be defined by the user and is a constant; the mixing function \(R(x)\) makes the first velocity information gradually transition from \(\psi\) to \(\psi\) starting from the distance to the surface of the scene object (distance 0) to the position (the position farthest from the surface of the object), that is, gradually transition from the velocity information constructed by the curl noise to the velocity information constructed by the repulsive field. At this time, the smoke inside the object is discharged outside the object along the surface normal direction of the object; among them, \(K(x)\) represents a piecewise function, and \(R(x)\) also represents a piecewise function. \(R(x)\) is used to smoothly simulate the intensity of the smoke being pushed away by the scene object; among them, the closer the smoke is to the surface of the scene object, the slower it is pushed away, the faster it is pushed away within the preset distance range from the scene object, and the slower it is pushed away when it is greater than a certain distance from the scene object (that is, far enough from the scene object); specifically, the constraint results are as c shown. Figure 4b shown.

[0108] In addition, for dynamic objects, the influence of the speed of dynamic objects on the smoke speed field needs to be further considered. Based on this, in the method for rendering smoke in a virtual scene provided by an embodiment of the present application, the first speed information is updated to obtain second speed information according to the influence of scene objects in the virtual scene on the smoke, and the method further includes:

[0109] Step 11: Obtain the reference speed of scene objects in the virtual scene.

[0110] Step 12: Update the first speed information based on the constraint of the influence of the scene objects on the smoke and the reference speed to obtain the second speed information.

[0111] In an embodiment of the present application, the first speed information is updated based on the constraint of the influence of the scene objects on the smoke to obtain a third speed field. Then, when interacting with dynamic scene objects: obtain the Velocity Buffer of the objects within the current screen. Since the object speeds in the Velocity Buffer have been converted to screen space, the reference speed field of the scene objects (i.e., the dynamic objects) can be obtained from the velocity buffer. Then, directly subtract the velocity (i.e., the reference speed) of the dynamic scene objects from the Velocity Field of the smoke (here is the updated third speed field above) to achieve the interaction between the smoke and the scene objects.

[0112] The specific implementation method is as follows:

[0113] Among them, in the above formula, is the smoke speed field after being constrained by the repulsion field as described above. Under the action of this speed field, the smoke will be pushed away by static scene objects (i.e., the smoke will not enter the interior of the objects) and maintain the original motion state to the greatest extent; is the speed field formed by the set of all dynamic objects in the current scene; subtracting the above two speed fields gives That is, the smoke speed field under the constraints of both the repulsion field and the speed field of dynamic scene objects. Under the action of this speed field, the smoke will be pushed away by static scene objects and maintain the original motion state to the greatest extent. At the same time, when a dynamic object passes through the position where the smoke is located, the speed of the dynamic object will affect the smoke and drive the smoke to move forward a certain distance in its speed direction.

[0114] In the above speed field calculation method for the interaction based on scene objects, since all the calculations are implemented on the screen, when implementing the interaction between scene objects and smoke, the conversion of scene object mesh data into cells (Cells) or particles causes the problem of low efficiency.

[0115] Figures 4c - 4fThe sequence of frames is an example of the interaction between the scene objects and the smoke. Figures 4c - 4f In the example, the cube moves towards the lower right corner and disperses the smoke.

[0116] In the prior art, in the method of using the Euler method or the Lagrange method to simulate and solve the first velocity information of the smoke, in each grid (corresponding to the Euler method) filled with smoke or each particle (corresponding to the Lagrange method) being a smoke particle, the distance of these grids or particles from the camera is the smoke depth, and the thickness of the smoke can also be directly obtained. In the embodiments of the present application, after reducing the smoke solution to two dimensions, the two data of the depth information and the thickness information of the smoke do not exist, which is one of the main problems to be solved in the present application. Although we solve the smoke on the screen, we estimate the depth and thickness of the smoke. The specific estimation method is as follows: Since the smoke in the present application is planar, the depth information and the thickness information of the smoke cannot be estimated using the smoke itself. Therefore, we start from the source. When drawing the smoke emitter, record the depth information and the thickness information of the smoke emitter. Although the smoke is planar, the initial smoke emitter is three-dimensional (i.e., a three-dimensional model, such as Figure 2a 201(a) in it), the distance of each frame (many pixel points) from the camera is the depth of the surface position, which is written into a picture, and the picture is the depth field of this frame (such as Figure 2c the depth field shown); the thickness recorded from the viewing direction in each frame is written into a picture, which is the thickness field (such as Figure 2d the thickness field shown). When solving the smoke, the initial first frame is three pictures: the color field, the depth field, and the thickness field ( Figures 2b - 2d ). By the second frame, the smoke is solved. The three-dimensional smoke emitter will dissipate, the pixels of the smoke will move, and the smoke emitter will slowly disperse and turn into other shapes. Correspondingly, the pixels of the smoke at the current position will jump to other positions. Therefore, in the process of continuously solving the second velocity information, we need to update the first attribute information according to the real-time solved second velocity information (i.e., the real-time updated second velocity field) to obtain the updated second attribute information. On the above three pictures, there is a one-to-one correspondence between the pixel positions of the smoke. Therefore, in the solving process, although the smoke we have is planar, the depth and thickness of the smoke emitter are always recorded. Therefore, the depth and thickness of the smoke emitter can be used to interact with the game scene objects under two-dimensional solving and render the three-dimensional effect of the smoke. In this way, not only can we ensure that the solving consumption is very small, but also the three-dimensional effect can be achieved.

[0117] The specific update method is as follows:

[0118] Step 21: Construct the motion component simulating the influence characteristics of the objects in the simulated scene on the smoke and the diffusion component simulating the self-motion characteristics of the simulated smoke, and construct a reduced-dimension smoke solver based on the motion component and the diffusion component.

[0119] Step 22: Solve the motion component and the diffusion component in the reduced-dimension smoke solver in sequence to obtain the second attribute information.

[0120] Combining the above Step 21 and Step 22, perform the first smoke-solving iteration (Advection): Update the first attribute information of the smoke based on the Velocity Field obtained in the previous step (the velocity field, which is also the representation of the second velocity information), specifically including the Color Field (the color field, that is, the recording form of the color information), the Depth Field (the depth field, that is, the recording form of the depth information), and the Thickness Field (the thickness field, that is, the recording form of the thickness information), to obtain the updated second attribute information. Based on this, in this application, first construct the motion component simulating the influence characteristics of the objects in the simulated scene on the smoke and the diffusion component simulating the self-motion characteristics of the simulated smoke, and then, based on the sum of the above motion component and the diffusion component, construct a reduced-dimension smoke solver, and perform iterative solution on the first attribute information of the smoke based on the above reduced-dimension smoke solver. Among them, the constructed reduced-dimension smoke solver is as follows:

[0121]

[0122] W p =(C p ,D p ,T p );

[0123] Among them, t is the time step, and the time step size is specified by the user. In physical solution, the time step is to decompose the evolution of the physical system into a series of discrete time intervals, and simulate the time evolution process of the system by updating the system state at each time step. The time step is an important concept in numerical simulation, especially often used when solving partial differential equations or ordinary differential equations.

[0124] Common time-step solution methods include explicit and implicit Euler methods, Runge-Kutta methods, etc. In these methods, usually the time interval is divided into several equal time step sizes, and the dynamic behavior of the system is approximately simulated by updating the state at each time step. The state update in the time step can be calculated according to the physical equations, considering the changes of physical quantities such as force, mass, velocity, and acceleration.

[0125] is the set of data components of all smokes, where \(t\) represents the time step of each solution; \(p\) is an arbitrary pixel position in screen space; \(C\) p , \(D\) p , \(T\) p are the smoke color component, depth component and thickness component at position \(p\) respectively. \(p\) refers to any two-dimensional coordinate on the screen, and \(C\) p represents the smoke color at position \(p\), which is a four-dimensional vector, and its four components represent the color values \(r\), \(g\), \(b\), \(a\) respectively. \(D\) p , \(T\) p represent the smoke depth and thickness at position \(p\) respectively. Both of them are one-dimensional vectors. The specific definitions of depth and thickness are as shown in Figure 4g . A ray is emitted from the camera in the viewing direction. The distance from the camera to the intersection point with the closest distance to the smoke surface along the ray is the depth \(D\) p , and the distance that the ray passes through inside the smoke is the thickness \(T\) p .

[0126] Among them, we perform two iterative solutions on the above-mentioned dimensionality-reduced smoke solver. In the first iteration, we only need to solve the in the formula, that is, the Semi-Lagrangian Advection part, which updates the fluid position based on the constrained velocity field \(\psi\) d , where is the velocity sampled at position \(q\), is the new fluid position at the next time step under the action of the velocity , and is the set of various data components of the fluid sampled at the new position , that is, the smoke color component, depth component and thickness component at the new position;

[0127] Regarding semi-Lagrangian stepping: Semi-Lagrangian stepping is a numerical method commonly used in computational fluid dynamics to simulate the evolution of substances or flow fields over time. During the stepping process, the evolution of substances or flow fields is carried out by following the trajectories of the velocity field. The semi-Lagrangian stepping method adopts the idea of a hybrid Eulerian method and Lagrangian method, combining the advantages of both.

[0128] Specifically, the calculation process of the semi-Lagrangian stepping method is as follows:

[0129] 1. First, based on the information of the velocity field, determine the position of the substance or flow field at the next time step. This can be achieved by tracing the trajectories of fluid elements (or points) in the opposite direction of the velocity field. In actual calculations, interpolation techniques can be used to obtain the velocity information on the trajectories.

[0130] 2. Next, according to the determined positions, calculate the values of substances or flow fields through interpolation techniques. Common interpolation methods include linear interpolation and cubic spline interpolation, etc.

[0131] 3. Finally, update the states of substances or flow fields according to the calculated values.

[0132] An important feature of the semi-Lagrangian stepping method is its good numerical stability. Since it calculates the evolution by tracking the trajectories of the velocity field, compared with the Eulerian method, it has less numerical dissipation and diffusion, and can better retain the details and structures of the flow field. In addition, the semi-Lagrangian stepping method is also applicable to handling complex scenarios such as high-speed flows and non-linear flows.

[0133] In addition, even without external force influence, smoke will diffuse outward under its own density. The second iterative solution here is to solve the diffusion component in the above formula, that is, the convolution part to simulate this diffusion phenomenon. Here, G is the Gaussian kernel, and q is any position within the neighborhood S of pixel p. Gaussian convolution is used here. Gaussian convolution is also known as Gaussian Blur, which is a commonly used image smoothing and noise reduction technique.

[0134] The basic principle of Gaussian convolution is based on the convolution operation of the Gaussian kernel (function). The Gaussian kernel is a bell-shaped curve with symmetry and smoothness, which represents the pixel intensity distribution around a point. In Gaussian convolution, for each pixel in the image, its surrounding pixels are weighted and averaged, and the weights are determined by the values of the Gaussian function. Through this way of weighted averaging, the diffusion phenomena of fluids and smoke can be well and quickly approximated.

[0135] The operation steps of Gaussian convolution are as follows:

[0136] 1. Define a Gaussian kernel, which is a two-dimensional bell-shaped function based on the central pixel;

[0137] 2. Calculate the weights of each pixel within the spatial range of the filter, that is, the values of the Gaussian kernel at that position.

[0138] 3. Perform a convolution operation between the filter and the image, that is, perform a weighted average on the pixels around each pixel, and the average weights are determined by the values of the Gaussian function in the filter.

[0139] 4. Repeat the above operations, perform a weighted average operation on each pixel in the image, and obtain the result image.

[0140] As described above, our calculation is performed in a two-dimensional space. However, we have been recording the real-time updates of the depth and thickness of the smoke. With these two data, we can make the smoke interact with the scene in the game.

[0141] Among them, Scene Interaction 1: Since the smoke calculation in the embodiments of the present application actually only occurs in the screen space, when the camera lens rotates rapidly, shadows (which can also be called phantoms or shadows) will be generated. The above-mentioned shadows and alternative words can be used to describe images or existences that look blurred, dim, or seemingly incorporeal. This phenomenon is particularly obvious when using slender emitters. Therefore, we perform camera motion correction (CMC) based on the new Depth Field, Thickness Field, and Color Field (updated second attribute information) output in the smoke calculation to weaken this phenomenon.

[0142] Specifically, as Figure 5a shown, the method for rendering smoke in the virtual scene provided by the embodiments of the present application further includes:

[0143] S501. In response to the movement of the camera lens, obtain the current two-dimensional coordinates of the smoke on the screen and the current depth information of the smoke emitter.

[0144] Specifically, when the camera lens moves, we obtain the current two-dimensional coordinates of the smoke on the screen at the current moment. At the same time, we obtain the current depth information of the smoke emitter from the real-time updated second attribute information.

[0145] S502. Calculate the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the movement of the camera.

[0146] In the embodiments of the present application, the method for calculating the offset is as follows: Calculate the world space coordinates of the smoke according to the current two-dimensional coordinates, the current depth information, and the first view matrix of the camera at present; then, calculate the offset of the smoke on the screen according to the above world space coordinates and the second view matrix before the movement of the camera.

[0147] Specifically, the above calculation of the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the movement of the camera includes: Determine the current first world space coordinates of the smoke according to the three-dimensional coordinates and the first view matrix of the camera at present; Calculate the second world space coordinates of the smoke before the movement of the camera according to the first world space coordinates and the second view matrix of the camera when the camera moves; Calculate the offset of the smoke on the screen according to the first world space coordinates and the second world space coordinates.

[0148] In the embodiments of the present application, first, calculate the world space coordinates of each smoke pixel in the depth field:

[0149] p WS =(PV) -1 ·(x, y, 2*D p -1, 1.0) T ;

[0150] Wherein, p WS represents the world space coordinates of the smoke pixel, that is, the position of the screen coordinate pixel at any position in the world space coordinates; P and V are the projection matrix (Projection Matrix) of the camera and the first view matrix (View Matrix) of the camera at present, respectively. Then, based on the historical view matrix V H (i.e., the second view matrix before the camera moves) of the previous frame, calculate the lens displacement error (Biased View Offset, BVO) accumulated due to the rotation of the camera lens:

[0151]

[0152] Wherein, p ws is the smoke coordinate in the world space of the current frame (current time step), p is the smoke coordinate in the view space of the previous frame (previous time step), and PV H ·p ws converts the world space smoke coordinate of the current time step to the view space, and subtracts it from the coordinate of the previous frame to obtain the smoke coordinate offset caused by the movement of the camera. In computer graphics, the view matrix (View Matrix) and the projection matrix (Projection Matrix) are matrices used to transform objects in a three-dimensional scene from the world space (World Space) to the view space (View Space) and the normalized device coordinate space (Normalized Device Coordinate Space).

[0153] The view matrix defines the position and orientation of a virtual camera. It transforms the objects in the world space to the perspective relative to the camera, so that the camera is located at the origin of coordinates and faces the negative direction of the z-axis. The inverse matrix of the view matrix can also be used to transform the objects in the view space back to the world space, for example, for lighting calculations.

[0154] The projection matrix is used to project objects in view space onto the normalized device coordinate space, that is, to convert three-dimensional coordinates into coordinates on the screen. There are usually two common forms of the projection matrix: orthographic projection and perspective projection. The projection effect produced by orthographic projection is parallel and is suitable for scenarios of parallel projection, while perspective projection simulates the perspective effect of the human eye, making distant objects appear smaller and nearby objects appear larger.

[0155] The process of coordinate space transformation from world space to view space is as follows:

[0156] 1. First, apply the view matrix to transform the vertex coordinates of the object to the perspective relative to the virtual camera, obtaining the coordinates in view space.

[0157] 2. Then, apply the projection matrix to transform the coordinates in view space to project them onto the normalized device coordinate space, obtaining the coordinates on the screen.

[0158] 3. Finally, map the coordinates in the normalized device coordinate space to the pixel coordinates on the actual screen through viewport transformation.

[0159] This coordinate space transformation process is a basic operation commonly used in computer graphics. It transforms the objects in the scene from three-dimensional space to a two-dimensional image on the screen, providing a basis for subsequent rendering and display.

[0160] S503. Update the current two-dimensional coordinates of the smoke on the screen according to the offset.

[0161] Here, subtracting the offset from the current two-dimensional coordinates of the smoke on the screen can calculate the actual two-dimensional coordinates of the smoke. Specifically, finally, the lens displacement error accumulated due to the rotation of the camera lens is superimposed on the second velocity information updated in real time to offset the lens displacement of the camera, so as to update the smoke on the screen.

[0162] The corresponding formula is as follows:

[0163] Wherein, is the smoke velocity field constrained by the repulsive field of static scene objects as described above, are respectively the velocity field of the dynamic object as described above and the lens displacement error (Biased View Offset, BVO) accumulated by the rotation of the camera lens calculated in the previous step, Subtracting can obtain the smoke velocity field after correcting the BVO error

[0164] In an actual game, when the camera lens turns, correspondingly, the smoke may not be visible. If the smoke is still visible, it will affect the game and bring a bad experience to the player. Therefore, in the embodiments of the present application, the following method is used to correct the above error: First, calculate the offset of the smoke on the screen, and then subtract this offset from the two-dimensional coordinates of the current smoke on the screen to correct the above problem. In the actual effect, when the camera lens turns behind the smoke and the above correction method is used, the smoke leaves the screen and the player cannot see the smoke, achieving the same effect as the three-dimensional scene.

[0165] As described above, when the camera lens rotates rapidly, shadows will be generated, as shown in Figure 5b(1); Figure 5b(2) shows the smoke calculation result under the rapid rotation of the camera lens after applying CMC.

[0166] In the embodiments of the present application, Scene Interaction II:

[0167] When rendering the smoke, the corresponding effect in the three-dimensional scene is that the thicker the smoke, the smaller the transmittance; conversely, the thinner the smoke, the larger the transmittance. To simulate this effect, in the embodiments of the present application, only the first transmittance of the smoke in the two-dimensional space is calculated. Because the thickness information (i.e., the thickness field has been updated in real time) is already included in the second attribute information updated in real time in the embodiments of the present application, and it is the thickness information of the third dimension. Therefore, multiplying the first transmittance in the previous two-dimensional space by the thickness information of this third dimension gives the second transmittance in the three-dimensional space. With this second transmittance and the color of the smoke in the second attribute information updated in real time (i.e., the color data recorded in the color field), the smoke can be rendered.

[0168] As Figure 6a shown, the method for rendering smoke in the virtual scene provided by the embodiments of the present application, rendering the smoke based on the updated second attribute information, includes:

[0169] S601. Obtain the smoke thickness on the path from the light source to the camera, and calculate the first transmittance of the smoke in the two-dimensional space based on the smoke thickness.

[0170] S602. Calculate the second transmittance of the smoke in the world space according to the first transmittance and the thickness information in the second attribute information.

[0171] S603. Render the smoke according to the color information in the second attribute information and the second transmittance.

[0172] Combined with steps S601 - S603, perform Smoke Rendering: Convert the light coordinates to screen space, and in screen space, perform 2D Ray Marching based on the Thickness Field to render the smoke color in the scene; during Ray Marching, emit rays from the light source along the camera direction for Ray Marching, and calculate the smoke thickness on the path from the light source to the camera based on the real - time updated 2D attribute information, that is, the smoke thickness d on the path can be obtained (as shown in Figure 6b ), then according to the Beer - Lambert Law, the transmittance of the smoke at the current pixel p can be obtained, and further the first transmittance of all pixels of the smoke in the 2D space can be obtained. Here, we make some changes to the Beer - Lambert Law. On the basis of the first transmittance obtained, superimpose the smoke transmittance in the Z direction of the plane depth axis as the final transmittance of the smoke. The smoke thickness in the Z direction is recorded in the Thickness Field (that is, according to the first transmittance and the thickness information in the second attribute information, calculate the second transmittance of the smoke in the world space):

[0173] I(p)=I z (p)*I uv (p)=e -εT(p) *e -εd ;

[0174] In the above formula, I(p) is the transmittance; T(p) is the smoke thickness in the Z - axis; ε is the Molar Absorption Coefficient. The I(p)=e -εT(p) in the formula is the Beer's Law formula, also known as the Beer - Lambert Law, which is a law describing the propagation and absorption of light in a transparent medium. It is used in methods for measuring the concentration of substances in a transparent medium, including fields such as chemical analysis, spectroscopy, and optical imaging. According to Beer's Law, when light passes through a transparent medium, the higher the concentration of the substance in the medium, the stronger the absorption of light, and the intensity of the light will decrease accordingly. The degree of absorption is proportional to the substance concentration and the medium thickness, and inversely proportional to the initial intensity of the light.

[0175] Among them, I uv (p) represents the first transmittance mentioned above, that is, the transmittance of the smoke in the screen space; I z (p) represents the transmittance of the screen Z - axis, that is, the transmittance from the camera viewing perspective; T(p) is the smoke thickness in the Z - axis; d represents the smoke thickness calculated under the path starting from the light source.

[0176] Ray Marching-based smoke rendering is a rendering technique in computer graphics used to simulate volumetric effects such as smoke and fog. It uses ray tracing methods to sample and integrate light in the volume, simulating the scattering and absorption effects of smoke, thus generating realistic smoke effects. In this method, the Molar Absorption Coefficient is an important parameter that describes the absorption ability of particles in the smoke to light of different wavelengths. The molar extinction coefficient is determined based on the physical properties of the smoke particles and can be obtained through experimental measurement or through simulation and estimation. In the present invention, the molar extinction coefficient is usually customized by the user according to the type of smoke required and is a constant. The larger the molar extinction coefficient, the stronger the absorption of light by the particles, and the smoke will appear denser and darker.

[0177] During the Ray Marching process, the smoke volume is sampled along the path of the light, and the light is attenuated according to the molar extinction coefficient. Specifically, each time the smoke volume is sampled, the transmittance at that point is calculated based on the density and molar extinction coefficient at the sampling point. The transmittance represents the proportion of the intensity attenuation of the light when passing through the smoke. By accumulating the transmittance of the sampling points, the absorption and scattering effects of the light in the smoke can be simulated.

[0178] Reducing the Ray Marching step to the screen space (i.e., two-dimensional space) can greatly improve the rendering efficiency of the smoke, but it will cause the smoke to appear flat and lose its sense of volume. Therefore, in the embodiments of the present application, the visual effect is improved by multiplying the smoke thickness by the transmittance to fit the Ray Marching result in the world space.

[0179] In the embodiments of the present application, Scene Interaction Three:

[0180] Since the screen is two-dimensional, when we render smoke on the screen, there is no shadow. However, in three-dimensional effects, smoke has a shadow. Therefore, in order to achieve a three-dimensional effect, the embodiments of the present application also need to render the shadow.

[0181] In the embodiments of the present application, the rendering method is as follows: Starting from the light source direction, regarding the light source as a camera, the depth values (i.e., depth information) of all pixels of the smoke are generated; during normal rendering, starting from the perspective of the real camera, the depth values (i.e., depth information) of all pixels of the smoke are also obtained. The depth values of all pixels starting from the real camera need to be converted to the light space of the light source to obtain the SSM (i.e., smoke shadow map). Then, the depth values of all pixels starting from the light source are compared with the depth values of all pixels in the SSM. If the former is larger, it means it is blocked, and based on this, the shadow of the smoke is rendered.

[0182] Further, as Figure 7a shown, for the method for rendering smoke in a virtual scene provided by an embodiment of the present application, rendering the smoke based on the updated second attribute information further includes:

[0183] S701. Obtain the depth information of each pixel in the second attribute information, and convert the depth information to the light space to obtain a smoke shadow map;

[0184] S702. Render the smoke shadow according to the smoke shadow map and the depth information of each pixel in the smoke starting from the light source direction.

[0185] Combined with S701 - S702, first, convert each pixel of the depth field on the front and back sides of the smoke to the light space (that is, based on the depth information of each pixel on the front and back sides of the smoke, convert each pixel on the front and back sides of the smoke to the light space to obtain a smoke shadow map), and obtain a smoke shadow map (Smoke Shadow Map, SSM), as Figure 7b shown; among them, the real - time updated second attribute information includes the depth information of each pixel on the front side of the smoke, and the depth information of each pixel on the back side of the smoke includes: subtracting the thickness information of each pixel in the above - mentioned second attribute information from the depth information of each pixel on the front side of the smoke to obtain the depth of the back side (that is, the reverse side) of the smoke.

[0186] Among them, the front and back sides of the smoke generally refer to two different aspects or perspectives of the smoke. In computer graphics, smoke is usually modeled as a special effect, which usually consists of two parts: the front side of the smoke and the back side of the smoke. The front side of the smoke refers to the surface of the smoke seen from the observer's perspective, which can show the density, shape, color, etc. of the smoke. The front side is usually the interaction interface between the observer and the smoke, and is the part that the observer pays attention to and perceives. The back side of the smoke refers to the surface of the smoke seen when observing the smoke from the back or side. The back side usually does not involve direct interaction with the observer, but shows the rendering information of the smoke from another angle. In some cases, the back side may show more details, textures or other visual effects. Generally speaking, the specific differences between the front and back sides depend on the modeling and rendering algorithms of the smoke and the personal choices of the designer. The front side is usually the most important part because it can directly affect the observer's perception and interaction experience. The back side is usually added to increase the texture and realism of the smoke effect, but the observer may not often directly see it.

[0187] Second, project smoke shadows onto the scene (Smoke Shadow Rendering): When rendering the scene, transform the scene fragments into the light space. That is, during the rendering process, transform the positions and attributes of the pixels (fragments) in the smoke into the light space used for lighting calculations to obtain the depth information of each pixel in the smoke from the direction of the light source. Then, compare the depth information of each pixel in the smoke from the direction of the light source with the depth information of the smoke in the light space recorded in the SSM, and draw the smoke shadows.

[0188] Among them, the shadow map is a commonly used technique in computer graphics for rendering shadows. It first renders the depth information of the scene into a special texture and then uses this texture in subsequent rendering processes to calculate shadows, thereby achieving a realistic shadow effect.

[0189] The specific process is as follows:

[0190] 1. Create a shadow map: First, a shadow map needs to be generated. It is a special depth texture that is consistent with the viewing perspective of the scene. Render the depth information of the lights (light sources) in the scene from the perspective of the observer (i.e., the distance from the light source to each pixel) into the shadow map texture.

[0191] 2. Render shadows: For each pixel, compare its position with the position of the light source. By sampling the depth value in the shadow map and comparing it with the distance between the current pixel and the light source. If the sampled depth value is less than the current distance, it means that the current pixel is under the shadow of the light source; otherwise, it means that the current pixel is in the visible area of the light source. According to this comparison result, the pixel can be shaded for shadows, such as darkening its color or adding transparency.

[0192] 3. Solve shadow distortion (hard shadows or jagged edges of shadows): Due to the resolution limitations of the shadow map and the inaccuracy of sampling, it may cause jagged distortion of the shadows (poor shadow quality). To solve this problem, some techniques can be used, such as using a shadow map with a higher resolution, increasing the number of samples, using PCF (Percentage-Closer Filtering), using Poisson Disk multiple sampling, etc., to smooth the shadow edges and improve the quality of the shadows.

[0193] Here, in computer graphics, the light space is a specific coordinate space, usually relative to the coordinate system of the light source.

[0194] Converting scene fragments to light space means converting the attributes of pixel points in the scene, such as position and normal, from world space or camera space to light space for calculation. The purpose is to more accurately consider the influence of light when calculating the lighting effect to produce a more realistic rendering result. During the conversion process, a projection matrix and a view matrix are usually used to convert the pixel points in the scene from camera space to world space, and then, through the position and direction information of the light source, they are converted to light space.

[0195] In the embodiments of the present application, a Poisson filter is applied to obtain soft shadows.

[0196] Among them, Fig. 7c shows the shadow effects obtained under different Poisson disk sampling radii r; among them, the sampling radius r corresponding to Fig. 7c(1) is 0; the sampling radius r corresponding to Fig. 7c(2) is 0.01; the sampling radius r corresponding to Fig. 7c(3) is 0.05.

[0197] The final smoke color is:

[0198] C(p) = A(p) * I(p) * S self (p);

[0199] Among them, A(p) is the solid color of the smoke, sampled from the position p in the color field, and is a four-dimensional variable. The four components respectively represent the color values r, g, b, and a; S self (p) is the self-shadow intensity of the smoke. If it is located in the shadow, the function value is 0, the value in the non-shadow area is 1, and the value in the transition area is 0-1. These values are calculated based on the rendering process of the shadow map described above and soft shadows are obtained based on the Poisson disk. In addition, I(p) is the smoke transmittance calculated above. The higher the transmittance, the lower the smoke concentration, and the smaller the value of I(p). Multiplying the three terms in the above formula can obtain the final smoke color with diffuse reflection color, smoke self-shadow, and smoke concentration information; C(p) represents the color of the smoke after rendering.

[0200] Further, as Figure 8 shown, the method for rendering smoke in the virtual scene provided by the embodiments of the present application further includes:

[0201] S801. Configure the first color channel required for the first attribute information according to the first channel configuration information of each piece of information in the first attribute information.

[0202] S802. Configure the second color channel required for the first speed information according to the second channel configuration information of the first speed information.

[0203] S803. Configure a texture map for storing the first color channel and the second color channel according to the first color channel and the second color channel.

[0204] Combined with S801 - S803, all the data required for smoke simulation in the embodiments of this application is stored in the texture map. The first attribute information includes "color information" (recorded in the Color Field), "depth information" (recorded in the Depth Field), and "thickness information" (recorded in the Thickness Field). Among them, the Color Field requires 4 color channels (namely, the red (R), green (G), blue (B), and alpha (A) channels); the Depth Field and the Thickness Field each require one channel; the first velocity information (recorded in the Velocity Field) requires two channels. All the data can just be compressed into two texture maps. Among them, the four color channels corresponding to the Color Field are called the Smoke Color Buffer (i.e., the smoke color buffer), and the four color channels corresponding to the Depth Field, the Thickness Field, and the Velocity Field are called the Smoke Data Buffer (i.e., the smoke data buffer). To ensure the simulation quality, the Smoke Color Buffer is stored in the ARGB Half format, and the Smoke Data Buffer is stored in the ARGB Float format.

[0205] Among them, in computer graphics, a buffer is a memory area used for temporarily storing and processing data. It can be used to store information such as images, colors, depths, and normals to support various calculations and operations in the image rendering and processing process.

[0206] In the embodiments of this application, the size of the two texture maps used for simulation does not exceed 10MB. Compared with the existing methods that require memory in the unit of GB to store and simulate Cell or particle data, the memory consumption is extremely small.

[0207] Based on the above - mentioned method for rendering smoke in a virtual scene, as Figure 9a shown, we summarize the method for rendering smoke in a virtual scene provided by the embodiments of this application as an example:

[0208] 1. The user picks any scene object as the smoke emitter.

[0209] 2. Draw the smoke emitter to the Smoke Buffer, and record the depth and thickness of the emitter in the Depth Field and the Thickness Field respectively.

[0210] 3. Construct the Curl Noise as the initial velocity field of the smoke, avoiding the solution of the Poisson equation and significantly improving the calculation speed.

[0211] 4. Implement the interaction with static scene objects: Obtain the Normal Buffer of the objects within the current screen, and construct a Repel Field to constrain the Velocity Field.

[0212] 5. Implement the interaction with dynamic scene objects: Convert the velocities of the scene objects to screen space, and subtract the velocities of other objects from the Velocity Field of the smoke to achieve the interaction between the smoke and the scene objects.

[0213] 6. Use the dimensionality-reduced smoke solver proposed in this application to perform the first smoke calculation iteration (Advection): Update the Color Field, Depth Field, and Thickness Field of the smoke based on the Semi-Lagrangian Advection and the Velocity Field obtained in the previous step.

[0214] 7. Perform the second smoke calculation iteration (Diffusion): Even without external forces, the smoke will diffuse outward under its own density. This step simulates this diffusion phenomenon.

[0215] 8. Since the smoke calculation actually occurs only in the screen space, when the camera lens rotates rapidly, ghosting will occur, especially obvious when using a slender emitter. Therefore, we perform camera motion correction (CMC) on the new Depth Field, Thickness Field, and Color Field output during the smoke calculation to weaken this phenomenon.

[0216] 9. Convert each pixel of the front and back Depth Fields (the back depth can be obtained by subtracting the smoke thickness from the front depth of the smoke) to the light space (Light Space) to obtain the Smoke Shadow Map (SSM).

[0217] 10. Project the smoke shadow onto the scene (Smoke Shadow Rendering): When rendering the scene, convert the scene fragments to the light space and compare them with the smoke light space depths recorded in the SSM to draw the smoke shadow. Here, we apply the Poisson Filter to obtain soft shadows.

[0218] 11. Smoke Rendering: Convert the light coordinates to screen space, and perform Ray Marching based on the Thickness Field in screen space to render the smoke color in the scene. At the same time, the self-shadow of the smoke can be drawn by converting the depth value in the DepthField to light space and comparing it with the depth values recorded in the scene Shadow Map and SSM.

[0219] 12. Repeat steps 1 - 11 iteratively and stop rendering the smoke when the preset termination condition is reached. The preset termination condition can be, for example, that the rendering time reaches a preset threshold or the pixel density of the smoke (the number of smoke particles in each pixel) is less than a set threshold.

[0220] Among them, using the method for rendering smoke in a virtual scene provided by the embodiments of the present application to Figure 2a render a specific object 201(a) in Figures 9b - 9e as shown in Figures 9b - 9e The sequence of frames shows the rendering effect of the smoke in the scene in the present application. The smoke itself has light and dark changes and can project shadows onto the surface of scene objects.

[0221] Comparison of solution efficiency: Table 1 shows the comparison of the time consumption of the method of the embodiments of the present application and the existing method for simulating smoke trails with collision interaction (as Figures 10a - 10b shown). The experimental environment is C++11 and OpenGL 4.5. The implementation environment of Unifiedparticle physics

[16] is CUDA 11.7. The test hardware is an Intel i7 - 10700 2.9GHz CPU, an NVIDIA RTX 3060 GPU, and 32G VRAM. The screen resolution is uniformly 1920 * 1080.

[0222] Table 1 Comparison of time consumption of the present application and the existing method for simulating smoke trails with collision interaction

[0223]

[0224] * Experimental environment: Intel i7 - 10700 2.9GHz CPU, NVIDIA RTX 3060 GPU, 32G VRAM

[0225] * The solution time consumption of the embodiments of the present application includes the time consumption for generating the collision body normal map and velocity map.

[0226] In the embodiments of the present application, a rigid collision body is used in the experiment, and its position is updated frame by frame; in the present application, the collision body is rendered as a velocity map and updated frame by frame; in the Euler method, the collision body is converted into a Cell and updated frame by frame; in the Lagrangian method, the collision body is converted into a rigid body particle during the initialization of the CUDA Device, and only pre-calculated once. The pre-calculation time is not included in the solution time.

[0227] The method for rendering smoke in the virtual scene provided by the present application realizes smoke rendering by performing calculations on the screen, considering scene interactions, which simplifies the calculation amount while achieving the effect of a three-dimensional scene, meeting the requirement for real-time rendering of smoke in the virtual scene; moreover, it can be applied to large-scale smoke simulation.

[0228] Based on the same inventive concept, in the second embodiment of the present application, there is also provided a device for rendering smoke in a virtual scene corresponding to the method for rendering smoke in the virtual scene in the first embodiment. Since the principle of solving problems by the device in the embodiments of the present application is similar to that of the method for rendering smoke in the virtual scene in the above embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be elaborated.

[0229] Refer to Figure 11 As shown in the figure, there is provided a device for rendering smoke in a virtual scene according to the second embodiment of the present application. The device includes:

[0230] A first acquisition module 1101, configured to obtain first attribute information of a smoke emitter in the virtual scene in response to the virtual scene satisfying a smoke trigger condition; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered;

[0231] A first calculation module 1102, configured to construct a curl noise that satisfies a divergence-free condition, and calculate a curl field of the curl noise as first velocity information of the smoke;

[0232] A first update module 1103, configured to update the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke and the self-motion of the smoke;

[0233] A rendering module 1104, configured to update the first attribute information according to the second velocity information, and render the smoke based on the updated second attribute information.

[0234] In a possible implementation manner, the acquisition module 1101 obtaining the color information of the smoke emitter includes:

[0235] Obtaining the color information of the smoke emitter on the screen;

[0236] Sample the color information in the three-dimensional smoke emitter according to the color information on the screen and the corresponding relationship between the preset two-dimensional coordinate points and three-dimensional vertices; the corresponding relationship is implemented through a two-dimensional parametric coordinate mapping UV mapping.

[0237] In a possible implementation manner, the first update module 1103 updates the first velocity information to obtain second velocity information according to the influence of the scene objects on the smoke in the virtual scene, including:

[0238] Construct a constraint on the influence of the scene object on the smoke according to the normal of the scene object in the virtual scene;

[0239] Update the first velocity information based on the constraint on the influence of the scene object on the smoke to obtain the second velocity information.

[0240] In a possible implementation manner, the first update module 1103 updates the first velocity information based on the constraint on the influence of the scene object on the smoke to obtain second velocity information, including:

[0241] Obtain the reference velocity of the scene object in the virtual scene;

[0242] Update the first velocity information based on the constraint on the influence of the scene object on the smoke and the reference velocity to obtain the second velocity information.

[0243] In a possible implementation manner, the rendering module 1104 updates the first attribute information according to the second velocity information, including:

[0244] Construct a motion component simulating the influence characteristics of the scene object on the smoke and a diffusion component simulating the self-motion characteristics of the smoke, and construct a reduced-dimensional smoke solver based on the motion component and the diffusion component;

[0245] Solve the motion component and the diffusion component in the reduced-dimensional smoke solver in sequence to obtain the second attribute information.

[0246] In a possible implementation manner, the device further includes:

[0247] A second acquisition module, configured to acquire the current two-dimensional coordinates of the smoke on the screen and the current depth information of the smoke emitter in response to the movement of the camera lens;

[0248] A second calculation module, configured to calculate the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrix before and after the movement of the camera;

[0249] A second update module, configured to update the current two-dimensional coordinates of the smoke on the screen according to the offset.

[0250] In a possible implementation, the second calculation module calculates the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the movement of the camera, including:

[0251] Calculate the world space coordinates of the smoke according to the current two-dimensional coordinates, the current depth information, and the current first view matrix of the camera;

[0252] Calculate the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the movement of the camera.

[0253] In a possible implementation, the second calculation module calculates the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the movement of the camera, including:

[0254] Determine the current first world space coordinates of the smoke according to the three-dimensional coordinates and the current first view matrix of the camera;

[0255] Calculate the second world space coordinates of the smoke before the movement of the camera according to the first world space coordinates and the second view matrix of the moving camera;

[0256] Calculate the offset of the smoke on the screen according to the first world space coordinates and the second world space coordinates.

[0257] In a possible implementation, the rendering module 1104 renders the smoke based on the updated second attribute information, including:

[0258] Obtain the thickness of the smoke on the path from the light source to the camera, and calculate the first transmittance of the smoke in the two-dimensional space based on the smoke thickness;

[0259] Calculate the second transmittance of the smoke in the world space according to the first transmittance and the thickness information in the second attribute information;

[0260] Render the smoke according to the color information in the second attribute information and the second transmittance.

[0261] In a possible implementation, the rendering module 1104 further renders the smoke based on the updated second attribute information, including:

[0262] Obtain the depth information of each pixel in the second attribute information, and convert the depth information to the light space to obtain a smoke shadow map;

[0263] Render the smoke shadow according to the smoke shadow map and the depth information of each pixel in the smoke starting from the light source direction.

[0264] In a possible implementation manner, the device further includes:

[0265] A first configuration module, configured to configure a first color channel required for the first attribute information according to the first channel configuration information of each piece of information in the first attribute information;

[0266] A second configuration module, configured to configure a second color channel required for the first speed information according to the second channel configuration information of the first speed information;

[0267] A third configuration module, configured to configure a texture map for storing the first color channel and storing the second color channel according to the first color channel and the second color channel.

[0268] The smoke rendering device in the virtual scene provided by this application simplifies the calculation amount while being able to achieve the effect of a three-dimensional scene by performing calculations on the screen, considering scene interaction, and realizing smoke rendering, meeting the requirement of real-time rendering of smoke in the virtual scene; and, it can be applied to large-range smoke simulation.

[0269] As Figure 12 shown, an electronic device 1200 provided in the third embodiment of this application includes: a processor 1201, a memory 1202, and a bus. The memory 1202 stores machine-readable instructions executable by the processor 1201. When the electronic device 1200 runs, the processor 1201 communicates with the memory 1202 through the bus. When the processor 1201 executes the machine-readable instructions, it performs the following steps:

[0270] In response to a trigger operation for the smoke emitter associated with a specific object, obtain first attribute information of the smoke emitter; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered;

[0271] Construct a curl noise that satisfies the divergence-free condition, and calculate the curl field of the curl noise as the first speed information of the smoke;

[0272] Update the first speed information to obtain second speed information according to the influence of scene objects in the virtual scene on the smoke and the self-movement situation of the smoke;

[0273] Update the first attribute information according to the second speed information, and render the smoke based on the updated second attribute information.

[0274] In a feasible implementation manner, obtaining the color information of the smoke emitter includes:

[0275] Obtaining the color information of the smoke emitter on the screen;

[0276] According to the color information on the screen and the corresponding relationship between the preset two-dimensional coordinate points and three-dimensional vertices, sampling the color information in the three-dimensional smoke emitter; the corresponding relationship is implemented through a two-dimensional parametric coordinate mapping UV mapping.

[0277] In a feasible implementation manner, updating the first speed information to obtain the second speed information according to the influence of the scene objects on the smoke in the virtual scene includes:

[0278] Constructing a constraint on the influence of the scene object on the smoke according to the normal of the scene object in the virtual scene;

[0279] Updating the first speed information based on the constraint on the influence of the scene object on the smoke to obtain the second speed information.

[0280] In a feasible implementation manner, the updating the first speed information based on the constraint on the influence of the scene object on the smoke to obtain the second speed information includes:

[0281] Obtaining the reference speed of the scene object in the virtual scene;

[0282] Updating the first speed information based on the constraint on the influence of the scene object on the smoke and the reference speed to obtain the second speed information.

[0283] In a feasible implementation manner, the updating the first attribute information according to the second speed information includes:

[0284] Constructing a motion component for simulating the influence characteristics of the scene object on the smoke and a diffusion component for simulating the self-motion characteristics of the smoke, and constructing a reduced-dimensional smoke solver based on the motion component and the diffusion component;

[0285] Successively solving the motion component and the diffusion component in the reduced-dimensional smoke solver to obtain the second attribute information.

[0286] In a feasible implementation manner, the processor 1201 further executes the following steps:

[0287] In response to the movement of the camera lens, obtaining the current two-dimensional coordinates of the smoke on the screen and the current depth information of the smoke emitter;

[0288] Calculate the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement;

[0289] Update the current two-dimensional coordinates of the smoke on the screen according to the offset.

[0290] In an alternative embodiment, the calculating the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement includes:

[0291] Calculate the world space coordinates of the smoke according to the current two-dimensional coordinates, the current depth information, and the current first view matrix of the camera;

[0292] Calculate the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement.

[0293] In an alternative embodiment, the calculating the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement includes:

[0294] Determine the current first world space coordinates of the smoke according to the three-dimensional coordinates and the current first view matrix of the camera;

[0295] Calculate the second world space coordinates of the smoke before the camera movement according to the first world space coordinates and the second view matrix of the moving camera;

[0296] Calculate the offset of the smoke on the screen according to the first world space coordinates and the second world space coordinates.

[0297] In an alternative embodiment, the rendering the smoke based on the updated second attribute information includes:

[0298] Obtain the smoke thickness on the path from the light source to the camera, and calculate the first transmittance of the smoke in the two-dimensional space based on the smoke thickness;

[0299] Calculate the second transmittance of the smoke in the world space according to the first transmittance and the thickness information in the second attribute information;

[0300] Render the smoke according to the color information in the second attribute information and the second transmittance.

[0301] In an alternative embodiment, the rendering the smoke based on the updated second attribute information further includes:

[0302] Obtain each pixel depth information in the second attribute information, and convert the depth information into the light space to obtain a smoke shadow map;

[0303] Render the smoke shadow according to the smoke shadow map and the depth information of each pixel in the smoke starting from the light source direction.

[0304] In an alternative embodiment, the processor 1201 further performs the following steps:

[0305] Configure the first color channel required for the first attribute information according to the first channel configuration information of each piece of information in the first attribute information;

[0306] Configure the second color channel required for the first speed information according to the second channel configuration information of the first speed information;

[0307] Configure the texture maps storing the first color channel and the second color channel according to the first color channel and the second color channel.

[0308] Specifically, the above-mentioned memory 1202 and processor 1201 can be general-purpose memory and processor, which are not specifically limited here. When the processor 1201 runs the computer program stored in the memory 1202, it can execute the above-mentioned method for rendering smoke in a virtual scene.

[0309] The above-mentioned device for rendering smoke in a virtual scene provided by this application simplifies the calculation amount while being able to achieve the effect of a three-dimensional scene by performing calculations on the screen, considering scene interactions, and realizing smoke rendering, meeting the requirements for real-time rendering of smoke in a virtual scene; moreover, it can be applied to large-scale smoke simulation.

[0310] The fourth embodiment of this application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it performs the following steps:

[0311] In response to a trigger operation for the smoke emitter associated with a specific object, obtain the first attribute information of the smoke emitter; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered;

[0312] Construct a curl noise that satisfies the divergence-free condition, and calculate the curl field of the curl noise as the first speed information of the smoke;

[0313] Update the first speed information to obtain the second speed information according to the influence of the scene objects in the virtual scene on the smoke and the self-movement situation of the smoke;

[0314] Update the first attribute information according to the second speed information, and render the smoke based on the updated second attribute information.

[0315] In a feasible implementation, obtaining the color information of the smoke emitter includes:

[0316] Obtain the color information of the smoke emitter on the screen;

[0317] According to the color information on the screen and the corresponding relationship between the preset two-dimensional coordinate points and three-dimensional vertices, sample the color information in the three-dimensional smoke emitter; the corresponding relationship is implemented by a two-dimensional parametric coordinate mapping UV mapping.

[0318] In a feasible implementation, updating the first speed information to obtain the second speed information according to the influence of the scene objects on the smoke in the virtual scene includes:

[0319] Construct a constraint on the influence of the scene object on the smoke according to the normal of the scene object in the virtual scene;

[0320] Update the first speed information based on the constraint on the influence of the scene object on the smoke to obtain the second speed information.

[0321] In a feasible implementation, the updating the first speed information based on the constraint on the influence of the scene object on the smoke to obtain the second speed information includes:

[0322] Obtain the reference speed of the scene object in the virtual scene;

[0323] Update the first speed information based on the constraint on the influence of the scene object on the smoke and the reference speed to obtain the second speed information.

[0324] In a feasible implementation, the updating the first attribute information according to the second speed information includes:

[0325] Construct a motion component simulating the influence characteristics of the scene object on the smoke and a diffusion component simulating the self-motion characteristics of the smoke, and construct a reduced-dimensional smoke solver based on the motion component and the diffusion component;

[0326] Solve the motion component and the diffusion component in the reduced-dimensional smoke solver in sequence to obtain the second attribute information.

[0327] In a feasible implementation, when the computer program is run by a processor, the following steps are also executed:

[0328] In response to the movement of the camera lens, obtain the current two-dimensional coordinates of the smoke on the screen and the current depth information of the smoke emitter;

[0329] Calculate the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement;

[0330] Update the current two-dimensional coordinates of the smoke on the screen according to the offset.

[0331] In an alternative embodiment, the calculating the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement includes:

[0332] Calculate the world space coordinates of the smoke according to the current two-dimensional coordinates, the current depth information, and the first view matrix of the current camera;

[0333] Calculate the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement.

[0334] In an alternative embodiment, the calculating the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement includes:

[0335] Determine the first world space coordinates of the smoke according to the three-dimensional coordinates and the first view matrix of the current camera;

[0336] Calculate the second world space coordinates of the smoke before the camera movement according to the first world space coordinates and the second view matrix of the moving camera;

[0337] Calculate the offset of the smoke on the screen according to the first world space coordinates and the second world space coordinates.

[0338] In an alternative embodiment, the rendering the smoke based on the updated second attribute information includes:

[0339] Obtain the smoke thickness on the path from the light source to the camera, and calculate the first transmittance of the smoke in the two-dimensional space based on the smoke thickness;

[0340] Calculate the second transmittance of the smoke in the world space according to the first transmittance and the thickness information in the second attribute information;

[0341] Render the smoke according to the color information in the second attribute information and the second transmittance.

[0342] In an alternative embodiment, rendering the smoke based on the updated second attribute information further includes:

[0343] Obtain the pixel depth information of each in the second attribute information, and convert the depth information to the light space to obtain a smoke shadow map;

[0344] Render the smoke shadow according to the smoke shadow map and the depth information of each pixel in the smoke starting from the light source direction.

[0345] In an alternative embodiment, when the computer program is run by a processor, the following steps are further executed:

[0346] Configure the first color channel required for the first attribute information according to the first channel configuration information of each piece of information in the first attribute information;

[0347] Configure the second color channel required for the first speed information according to the second channel configuration information of the first speed information;

[0348] Configure a texture map for storing the first color channel and storing the second color channel according to the first color channel and the second color channel.

[0349] In the embodiments of the present application, when the computer program is run by a processor, other machine-readable instructions may also be executed to perform other methods described in the embodiments. For the specific method steps and principles of execution, refer to the description of the embodiments, which will not be elaborated in detail here.

[0350] During the running of the above computer-readable storage medium, by performing calculations on the screen, considering scene interaction, and implementing smoke rendering, the amount of calculation is simplified while the effect of a three-dimensional scene can be achieved, meeting the requirements for real-time rendering of smoke in a virtual scene; and it can be applied to large-scale smoke simulation.

[0351] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the method embodiments, which will not be elaborated in this application. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings, direct couplings, or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or modules can be in electrical, mechanical, or other forms.

[0352] The module described as a separation component may or may not be physically separated. The component shown as a module may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0353] In addition, in each embodiment of the present application, each functional unit may be integrated in a processing unit, may exist physically separately for each unit, or two or more units may be integrated in one unit.

[0354] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the flight control method described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0355] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A rendering method for smoke in a virtual scene, characterized in that, The method includes: In response to the virtual scene satisfying the smoke trigger condition, obtaining first attribute information of a smoke emitter in the virtual scene; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered; Constructing a curly noise that satisfies the non-diffusion condition, and calculating the curl field of the curly noise as the first velocity information of the smoke; Updating the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke and the self-movement condition of the smoke; Updating the first attribute information according to the second velocity information, and rendering the smoke based on the updated second attribute information.

2. The method for rendering smoke in a virtual scene according to claim 1, wherein Obtaining the color information of the smoke emitter includes: Obtaining the color information of the smoke emitter on the screen; Sampling the color information in the three-dimensional smoke emitter according to the color information on the screen and the corresponding relationship between the preset two-dimensional coordinate points and the three-dimensional vertices; the corresponding relationship is implemented through a two-dimensional parametric coordinate mapping UV mapping.

3. The method for rendering smoke in a virtual scene according to claim 1, wherein Updating the first velocity information to obtain second velocity information according to the influence of scene objects in the virtual scene on the smoke, includes: Constructing a constraint on the influence of the scene object on the smoke according to the normal of the scene object in the virtual scene; Updating the first velocity information based on the constraint on the influence of the scene object on the smoke to obtain second velocity information.

4. The method for rendering smoke in a virtual scene according to claim 3, characterized in that, The updating the first velocity information based on the constraint on the influence of the scene object on the smoke to obtain second velocity information includes: Obtaining the reference velocity of the scene object in the virtual scene; Updating the first velocity field based on the constraint on the influence of the scene object on the smoke and the reference velocity to obtain the second velocity information.

5. The method for rendering smoke in a virtual scene according to claim 1, wherein The updating the first attribute information according to the second velocity information includes: Constructing a motion component that simulates the influence characteristics of the scene object on the smoke and a diffusion component that simulates the self-movement characteristics of the smoke, and constructing a reduced-dimensional smoke solver based on the motion component and the diffusion component; Successively solving the motion component and the diffusion component in the reduced-dimensional smoke solver to obtain the second attribute information.

6. The method for rendering smoke in a virtual scene according to claim 1, wherein The method further includes: In response to the movement of the camera lens, obtaining the current two-dimensional coordinates of the smoke on the screen and the current depth information of the smoke emitter; Calculating the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement; Updating the current two-dimensional coordinates of the smoke on the screen according to the offset.

7. The method for rendering smoke in a virtual scene according to claim 6, characterized in that, The calculating the offset of the smoke on the screen according to the current two-dimensional coordinates, the current depth information, and the view matrices before and after the camera movement includes: Calculating the world space coordinates of the smoke according to the current two-dimensional coordinates, the current depth information, and the current first view matrix of the camera; Calculating the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement.

8. The method for rendering smoke in a virtual scene according to claim 7, wherein Calculating the offset of the smoke on the screen according to the world space coordinates and the second view matrix before the camera movement includes: Determining the first world space coordinates of the smoke currently according to the three-dimensional coordinates and the first view matrix of the current camera; Calculating the second world space coordinates of the smoke before the camera movement according to the first world space coordinates and the second view matrix of the camera when the camera moves; Calculating the offset of the smoke on the screen according to the first world space coordinates and the second world space coordinates.

9. The method for rendering smoke in a virtual scene according to claim 1, wherein Rendering the smoke based on the updated second attribute information includes: Obtaining the smoke thickness on the path from the light source to the camera, and calculating the first transmittance of the smoke in the two-dimensional space based on the smoke thickness; Calculating the second transmittance of the smoke in the world space according to the first transmittance and the thickness information in the second attribute information; Rendering the smoke according to the color information in the second attribute information and the second transmittance.

10. The method for rendering smoke in a virtual scene according to claim 1 or 9, characterized in that, Rendering the smoke based on the updated second attribute information further includes: Obtaining each pixel depth information in the second attribute information, and converting the depth information to the light space to obtain a smoke shadow map; Rendering the smoke shadow according to the smoke shadow map and the depth information of each pixel in the smoke starting from the light source direction.

11. The method for rendering smoke in a virtual scene according to claim 1, wherein The method further includes: Configuring the first color channel required by the first attribute information according to the first channel configuration information of each piece of information in the first attribute information; Configuring the second color channel required by the first speed information according to the second channel configuration information of the first speed information; Configuring a texture map for storing the first color channel and storing the second color channel according to the first color channel and the second color channel.

12. A rendering device for smoke in a virtual scene, characterized in that The device includes: A first acquisition module, configured to acquire the first attribute information of a smoke emitter in the virtual scene in response to the virtual scene satisfying the smoke trigger condition; the first attribute information includes color information, depth information, and thickness information; the smoke emitter diffuses into corresponding smoke after being triggered; A first calculation module, configured to construct a curl noise that satisfies the non-diffusion condition, and calculate the curl field of the curl noise as the first speed information of the smoke; A first update module, configured to update the first speed information to obtain second speed information according to the influence of scene objects in the virtual scene on the smoke and the self-movement condition of the smoke; A rendering module, configured to update the first attribute information according to the second speed information, and render the smoke based on the updated second attribute information.

13. An electronic device, characterized in that, Includes: A processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to execute the method for rendering smoke in a virtual scene according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the method for rendering smoke in a virtual scene according to any one of claims 1 to 11.