Particle system rendering method, device, electronic device and readable storage medium

By classifying particle attributes and calculating function parameters, particle rendering is performed using image processing algorithms and shaders, the problem of bottleneck in rendering performance of large-scale particle systems is solved and the rendering efficiency is improved.

CN114432695BActive Publication Date: 2025-09-02BEIJING PIXEL SOFTWARE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111648569.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-09-02
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When the existing particle system rendering scheme deals with large-scale particles, the computing speed cannot meet the needs of real-time rendering, resulting in performance bottlenecks.

Method used

The method of classifying the storing of particle attributes is used to store the properties that change dynamically over time in a preset container, and the corresponding function parameters are calculated through different update strategies. The image processing algorithm is used to batch process the attribute data, and the shader is used to calculate the attribute value of the particle to reduce the burden on the central processor.

Benefits of technology

It improves the efficiency of particle attribute rendering, reduces the memory usage of the central processor, improves computing performance, and realizes real-time rendering of large-scale particles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114432695B_ABST
    Figure CN114432695B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention disclose a particle system rendering method, device, electronic device, and readable storage medium. The particle system rendering method includes: classifying and storing the attributes of each particle in a preset particle cluster, storing the attributes that change dynamically over time in a preset container; performing function calculations for a first update strategy without a time series and a second update strategy with a time series, respectively, to obtain first and second parameters for calculating the values ​​of the attributes that change dynamically over time; batch processing all attributes in the preset container using a preset image processing algorithm, selecting particles in a live and visible state and writing them to a vertex buffer, thereby enabling the particles in the vertex buffer to be read through a shader, and calculating the attribute values ​​of each particle using other constant parameters in the shader. Through the flexible use of shaders and the classified processing of update strategies, the efficiency of particle attribute rendering is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a particle system rendering method, device, electronic device and readable storage medium. Background Art

[0002] In reality, many phenomena involve large numbers of tiny particles with similar behaviors, such as fireworks, falling leaves, flowing water, and mist. Particle systems are used in 3D games to simulate these phenomena. Because particles have simple geometric characteristics, they can be rendered using quadrilaterals. The desired effect is achieved by updating the particle system's position, posture, size, and texture in real time. However, as the particle size increases, updating the particles places stringent demands on computer performance. If the computing speed cannot keep up, real-time rendering will be impossible.

[0003] It can be seen that the existing rendering solutions are unable to adapt to the rendering needs of large-scale particles. Summary of the Invention

[0004] To solve the above technical problems, the present invention provides a particle system rendering method, device, electronic device, and readable storage medium. The specific solutions are as follows:

[0005] In a first aspect, an embodiment of the present application provides a particle system rendering method, the particle system rendering method comprising:

[0006] Classify and store the attributes of each particle in a preset particle cluster, wherein the attributes that change dynamically over time are stored in a preset container, the preset particle cluster including particles of the same type and an update strategy for each particle, the update strategy including a first update strategy without a time sequence and a second update strategy with a time sequence;

[0007] Calculating a first parameter corresponding to a first preset function based on an execution start point and an execution end point of the first update strategy;

[0008] Calculate a second parameter corresponding to a second preset function based on the time series of the second update strategy and the numerical value corresponding to each time node in the time series;

[0009] Batch process all attributes in the preset container based on a preset image processing algorithm, and write particles that are alive and visible at the current time into the vertex buffer;

[0010] In the shader, all attribute values ​​of each particle in the vertex buffer are calculated according to the first parameter, the first preset function, the second parameter, the second preset function, and the current time;

[0011] Attribute rendering is performed on all particles in the preset particle cluster according to all attribute values ​​of each particle.

[0012] According to a specific implementation of the embodiment of the present application, the preset container is a SOA_VECTOR container, and the step of classifying and storing the attributes of each particle in the preset particle cluster includes:

[0013] Dividing the attributes of each particle in the preset particle cluster into attributes that vary with time and constant attributes;

[0014] Integrate the constant attributes of all particles in the preset particle cluster into a structure, and store a pointer to the structure in each particle object in the preset particle cluster;

[0015] All time-varying properties are stored in the SOA_VECTOR container.

[0016] According to a specific implementation of the embodiment of the present application, the first preset function is a unary linear function, wherein the dependent variable is the attribute value and the independent variable is time, and the step of calculating the first parameter corresponding to the first preset function based on the execution start point and execution end point of the first update strategy includes:

[0017] If the execution start point and the execution end point of the current first update strategy are the same, obtaining a first coefficient group according to a first rule, and using the first coefficient group as a first parameter when adopting the current first update strategy;

[0018] If the execution start point and the execution end point of the current first update strategy are different, a second coefficient group is obtained according to a second rule, and the second coefficient group is used as a first parameter when adopting the current first update strategy.

[0019] According to a specific implementation of the embodiment of the present application, the second preset function is a univariate multi-order polynomial corresponding to the number of time nodes of the second update strategy, wherein the dependent variable is the attribute value and the independent variable is time;

[0020] The step of calculating a second parameter corresponding to a second preset function based on the time series of the second update strategy and the numerical value corresponding to each time node in the time series includes:

[0021] Fitting the univariate multi-order polynomial using the least squares method to obtain a time matrix and an attribute value vector corresponding to the time series;

[0022] According to the preset calculation formula A T Ax=A T B calculates the second parameter, where A is the time matrix, B is the attribute value vector, and x is the second parameter.

[0023] According to a specific implementation of the embodiment of the present application, before the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method further includes:

[0024] Calculating an observation transformation matrix and a projection transformation matrix based on actual scene parameters, wherein the actual scene parameters include camera parameters, observation point parameters, and screen parameters;

[0025] The observation transformation matrix and the projection transformation matrix are written into the shader, so that the shader performs particle rendering according to the observation transformation matrix and the projection transformation matrix.

[0026] According to a specific implementation of the embodiment of the present application, after the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method includes:

[0027] Replacing the current time with the next update time of the current time;

[0028] Jump to the step of batch processing the attribute data in the preset container based on the preset image processing algorithm, and perform subsequent update rendering steps until a preset time is reached.

[0029] According to a specific implementation of an embodiment of the present application, the preset image processing algorithm is a SIMD algorithm, the attribute data in the preset container includes particle viability, visibility, and particle structure transformation, and the step of batch processing the attribute data in the preset container based on the preset image processing algorithm includes:

[0030] Determining the state of the particle at the current time based on the particle's viability, visibility, and particle structure transformation;

[0031] Write particles that are alive and visible at the current time into the vertex buffer;

[0032] Initialize the particles that are in the dead state at the current time and store them in the preset container.

[0033] In a second aspect, an embodiment of the present application provides a particle system rendering device, the particle system rendering device comprising:

[0034] a classification storage module for classifying and storing the attributes of each particle in a preset particle cluster, wherein attributes that change dynamically over time are stored in a preset container, the preset particle cluster including particles of the same type and an update strategy for each particle, the update strategy including a first update strategy without a time sequence and a second update strategy with a time sequence;

[0035] a first calculation module, configured to calculate a first parameter corresponding to a first preset function based on an execution start point and an execution end point of the first update strategy, wherein the first update strategy is an update strategy without a time series;

[0036] A second calculation module is configured to calculate a second parameter corresponding to a second preset function based on a time series of the second update strategy and a numerical value corresponding to each time node in the time series, wherein the second update strategy is an update strategy with a time series;

[0037] A processing module, configured to batch process all attributes in the preset container based on a preset image processing algorithm, and write particles that are alive and visible at the current time into a vertex buffer;

[0038] a third calculation module, configured to calculate, in a shader, all attribute values ​​of each particle in the vertex buffer according to the first parameter, the first preset function, the second parameter, the second preset function, and the current time;

[0039] The rendering module is used to perform attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle.

[0040] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, the particle system rendering method described in the first aspect is executed.

[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the particle system rendering method described in the first aspect is executed.

[0042] The embodiments of the present application provide a particle system rendering method, device, electronic device, and readable storage medium. The particle system rendering method includes: classifying and storing the attributes of each particle in a preset particle cluster, and storing the attributes that change dynamically over time in a preset container; performing function calculations on a first update strategy without a time series and a second update strategy with a time series, respectively, to obtain a first parameter and a second parameter for calculating the value of the attribute that changes dynamically over time; batch processing all attributes in the preset container through a preset image processing algorithm, selecting particles in a live and visible state and writing them to a vertex buffer, so that the particles in the vertex buffer can be read through a shader, and the attribute value of each particle can be calculated using other constant parameters in the shader. Through the flexible use of shaders and the classified processing of update strategies, the efficiency of particle attribute rendering is effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.

[0044] Figure 1 A schematic diagram of a particle system rendering method provided by an embodiment of the present application is shown;

[0045] Figure 2 A schematic diagram showing the effect of storing data types in a SOA_VECTOR container in a particle system rendering method provided by an embodiment of the present application is shown;

[0046] Figure 3 A schematic diagram of a device module of a particle rendering system rendering device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0047] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0048] The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the figures is not intended to limit the scope of the claimed invention, but rather merely represents selected embodiments of the present invention. All other embodiments derived by those skilled in the art based on the embodiments of the present invention without inventive effort are intended to be within the scope of protection of the present invention.

[0049] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or the possibility of adding one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0050] Furthermore, the terms “first,” “second,” “third,” etc., are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0051] Unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by those skilled in the art to which the various embodiments of the present invention pertain. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meaning as in the context of the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning unless clearly defined in the various embodiments of the present invention.

[0052] refer to Figure 1 , is a flow chart of a particle system rendering method provided in an embodiment of the present application. The particle system rendering method provided in an embodiment of the present application is as follows: Figure 1 As shown, the particle system rendering method includes:

[0053] Step S101, classifying and storing the attributes of each particle in a preset particle cluster, wherein attributes that change dynamically over time are stored in a preset container, the preset particle cluster including particles of the same type and an update strategy for each particle, the update strategy including a first update strategy without a time sequence and a second update strategy with a time sequence;

[0054] In a specific embodiment, a particle object typically includes two types of attribute data. The first type of attribute data is fixed attribute data that a user has set for the particle object before the particle is executed. This first type of attribute data does not change during the particle's execution. Particle objects with this first type of attribute data are often associated with a first update strategy that does not have a time sequence.

[0055] The second type of attribute data is attribute data that changes over time during the particle object's operation, such as the current position, scale factor, texture coordinates, force range, and speed. The value of this second type of attribute data is determined by the update strategy and time sequence. Particle objects with this second type of attribute data are often associated with a second update strategy with a time sequence.

[0056] During actual operation, each particle object is cloned multiple times at different points in time. The cloned new particle objects have exactly the same properties and update strategies as the original particle objects. However, because the new particle objects and the original particle objects appear at different times, their property values ​​will also be different during subsequent simulation calculations.

[0057] In this embodiment, each particle object and its cloned new particle object set are grouped into a particle cluster, and the attribute data of the particle objects in the particle cluster are classified and divided, and stored accordingly according to the type of the attribute data of the particle objects.

[0058] According to a specific implementation of the embodiment of the present application, the preset container is a SOA_VECTOR container, and the step of classifying and storing the attributes of each particle in the preset particle cluster includes:

[0059] Dividing the attributes of each particle in the preset particle cluster into attributes that vary with time and constant attributes;

[0060] Integrate the constant attributes of all particles in the preset particle cluster into a structure, and store a pointer to the structure in each particle object in the preset particle cluster;

[0061] All time-varying properties are stored in the SOA_VECTOR container.

[0062] In a specific embodiment, the preset container adopts a SOA_VECTOR container. The implementation method of the SOA_VECTOR container can be implemented by adopting an existing method, which is not described in detail in this embodiment.

[0063] The SOA_VECTOR container is a storage container that stores the attributes of a particle object separately as an attribute array, which is different from the VECTOR container that stores the particle object as a whole.

[0064] like Figure 2 As shown in the figure, when the attributes of a particle object include a, b, c, and d, VECTOR stores the attribute data of the particle object according to the complete particle object. When the user calls the attribute data from VECTOR, only a complete particle object can be called.

[0065] When storing the particle objects, the SOA_VECTOR container will store the attributes of each particle object separately as an attribute array, such as Figure 2 The SOA_VECTOR container includes an a attribute array, a b attribute array, a c attribute array, and a d attribute array.

[0066] In this embodiment, time-varying attribute data is stored in a SOA_VECTOR. Specifically, when creating a SOA_VECTOR container, users can set the memory alignment for individual attributes and attribute arrays, as well as the number of objects to be calculated. When adding objects, SOA_VECTOR stores the object's attributes in the corresponding memory area, ensuring that the content addresses of all data meet the requirements. When accessing data, users can read individual attributes of all objects using the pointers provided by the SOA_VECTOR.

[0067] For example, if Figure 2The SOA_VECTOR container described in sets the storage address of 4 types of attributes. When the processor calls the attribute from the SOA_VECTOR container, the a attribute array of all objects can be read separately.

[0068] For constant properties, the particle cluster in this embodiment stores particles of the same type and their update strategies. Within the same particle cluster, all particle objects store the same constant properties. For a given particle cluster, all constant properties are combined into a structure, and a pointer to this structure is stored in each particle object.

[0069] Specifically, the structure is structured data composed of a group of data. Constant data is integrated into a structure, and a storage method of storing a pointer in a particle object can save the storage space of the particle object to the greatest extent.

[0070] Step S102: calculating a first parameter corresponding to a first preset function based on the execution start point and execution end point of the first update strategy;

[0071] In a specific embodiment, for the first update strategy without a time series, this embodiment uses a first preset function to replace the first update strategy, and calculates the coefficient corresponding to the first preset function based on the execution start point and execution end point of the first update strategy.

[0072] The first update strategy includes update strategies that do not have a time sequence, such as particle rotation, texture rotation, and texture mirror.

[0073] The selection of the execution starting point and the execution end point can be adaptively set by the user according to the actual application scenario. For example, the user can select the function interval for execution of the first update strategy, and the execution starting point and the execution end point are the left and right endpoints of the function interval.

[0074] For example, if a particle object starts rotating from 0 seconds, from 90 degrees to 180 degrees, at a speed of 30 degrees per second, then the execution start point can be set to (0, 90) and the execution end point can be set to (3, 180).

[0075] According to a specific implementation of the embodiment of the present application, the first preset function is a unary linear function, wherein the dependent variable is the attribute value and the independent variable is time, and the step of calculating the first parameter corresponding to the first preset function based on the execution start point and execution end point of the first update strategy includes:

[0076] If the execution start point and the execution end point of the current first update strategy are the same, obtaining a first coefficient group according to a first rule, and using the first coefficient group as a first parameter when adopting the current first update strategy;

[0077] If the execution start point and the execution end point of the current first update strategy are different, a second coefficient group is obtained according to a second rule, and the second coefficient group is used as a first parameter when adopting the current first update strategy.

[0078] In a specific embodiment, a linear function aX+b=Y ​​is used to replace the first update strategy, where X is time, Y is the attribute value, and a and b are first parameters.

[0079] When the execution start time and execution end time of the first update strategy are the same, the preset calculation formula is used. b=Y1-aX1; (X1≠X2) calculate the first parameter.

[0080] When the execution start point and execution end point of the first update strategy are different, the first parameter is calculated according to the preset calculation formula a=0; b=Y1; (X1=X2).

[0081] Specifically, the execution start point and the execution end point are a user-selected function interval, and the update strategy portion of the particle outside the function interval can be calculated by mapping the modulus of the time outside the interval into the interval.

[0082] Step S103, calculating a second parameter corresponding to a second preset function based on the time series of the second update strategy and a value corresponding to each time node in the time series;

[0083] In a specific embodiment, the second update strategy includes update strategies with time series, such as position, color, rotation, and scaling. Specifically, the update strategies with time series have different numbers of time nodes. The function of the second update strategy is a piecewise function with a corresponding number of time nodes.

[0084] For the second update strategy, a univariate multi-time polynomial is used to replace the piecewise function composed of the time series. For example, for the second update strategy with three time nodes, this embodiment uses a cubic polynomial cX 3 +dX 2 +eX+f=Y replaces the second update strategy, where X is time, Y is the attribute value, and c, d, e, and f are second parameters.

[0085] After the multi-order polynomial corresponding to the second updating strategy is obtained, the second parameter of the multi-order polynomial can be calculated according to the attribute value corresponding to each time node.

[0086] According to a specific implementation of the embodiment of the present application, the second preset function is a univariate multi-order polynomial corresponding to the number of time nodes of the second update strategy, wherein the dependent variable is the attribute value and the independent variable is time;

[0087] The step of calculating a second parameter corresponding to a second preset function based on the time series of the second update strategy and the numerical value corresponding to each time node in the time series includes:

[0088] Fitting the univariate multi-order polynomial using the least squares method to obtain a time matrix and an attribute value vector corresponding to the time series;

[0089] According to the preset calculation formula A T Ax=A T B calculates the second parameter, where A is the time matrix, B is the attribute value vector, and x is the second parameter.

[0090] In a specific embodiment, the selection of the univariate multi-time polynomial can refer to the above-mentioned implementation manner, which will not be repeated here.

[0091] After obtaining the time value and attribute value of each time node in the corresponding time series, the univariate multi-order polynomial can be fitted based on the least squares method to obtain the matrix and vector form of the corresponding time series. By fitting the cubic polynomial based on the least squares method, the sorted time series can be written in the form of matrix A and vector B, where: B=(Y1, Y2, . . . , Yn), where A matrix is ​​the time matrix corresponding to the time series, and B vector is the attribute value vector corresponding to the time series.

[0092] After obtaining the time matrix and attribute value vector, according to formula A T Ax=A T B. Calculate the second parameter x of the second update strategy, where the second parameter x is a multidimensional vector corresponding to the number of the second parameters, for example, corresponding to the coefficients (c, d, e, f) of a cubic polynomial.

[0093] For the first parameter corresponding to the above-mentioned first update strategy and the second parameter corresponding to the second update strategy, the parameter values ​​will no longer change during the particle update process. The particle rendering device of this embodiment calls the API interface to write the first parameter and the second parameter into the constants of the shader of the graphics processing unit (GPU).

[0094] Specifically, both the central processing unit (CPU) and the graphics processing unit (GPU) can perform computing tasks, but their application scenarios are different. The CPU is designed for general-purpose tasks, needs to handle a variety of data types, and supports the large number of branch jumps and interrupt processing required by logical judgments, resulting in a complex internal structure.

[0095] GPUs, on the other hand, are designed solely for graphics computing tasks. The data types they process are highly uniform and independent of each other, and they don't need to worry about interruptions in computation. Their internal structure is simple. Therefore, GPUs are far more efficient than CPUs for specific computing tasks. A shader is a program that runs on a GPU.

[0096] Step S104, batch processing all attributes in the preset container based on a preset image processing algorithm, and writing particles that are alive and visible at the current time into the vertex buffer;

[0097] In a specific embodiment, the preset image processing algorithm may adopt a Single Instruction Multiple Data (SIMD) image processing algorithm.

[0098] Specifically, the SIMD image processing algorithm can calculate multiple times of data in the same amount of time, thereby increasing the computational efficiency of the central processing unit in processing the attributes in the preset container.

[0099] Specifically, the attributes processed by the preset image processing method include particle viability, visibility, particle structure transformation and other attributes that cannot be calculated in a shader.

[0100] The preset image processing algorithm can call the corresponding attribute value from the SOA_VECTOR container and set the number of attributes that can be processed simultaneously in one operation, thereby obtaining the transformation attribute values ​​such as particle viability and visibility.

[0101] According to a specific implementation of an embodiment of the present application, the preset image processing algorithm is a SIMD algorithm, the attribute data in the preset container includes particle viability, visibility, and particle structure transformation, and the step of batch processing the attribute data in the preset container based on the preset image processing algorithm includes:

[0102] Determining the state of the particle at the current time based on the particle's viability, visibility, and particle structure transformation;

[0103] Write particles that are alive and visible at the current time into the vertex buffer;

[0104] Initialize the particles that are in the dead state at the current time and store them in the preset container.

[0105] In a specific embodiment, after processing all attributes in the SOA_VECTOR container that cannot be placed in the shader, the central processing unit writes particles that are alive and visible at the current time into the vertex buffer for the graphics processor to call from the vertex buffer.

[0106] For particles that are currently in a dead state, the attribute values ​​of the particle object are set to initial values ​​and stored in the SOA_VECTOR container again for the central processing unit to call during the next update.

[0107] Step S105, in the shader, calculating all attribute values ​​of each particle in the vertex buffer according to the first parameter, the first preset function, the second parameter, the second preset function and the current time;

[0108] In a specific embodiment, the first preset function is aX+b=Y, and the second preset function is cX 3 +dX 2 +eX+f=Y, in the processing process of the above embodiment, the first parameter (a, b) and the second parameter (c, d, e, f) have been stored in the shader.

[0109] In the processing process of the above embodiment, the central processing unit processes the changed attribute values ​​of each particle according to the preset image processing algorithm, and stores the particles in the alive state and the particles in the visible state in the vertex buffer area.

[0110] In the shader of the GPU, all relevant attribute values ​​of all particles stored in the vertex buffer area, such as position, color, rotation, scale, texture coordinates and other attribute values, can be calculated based on the first parameter, the first preset function, the second parameter and the second preset function.

[0111] According to a specific implementation of the embodiment of the present application, before the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method further includes:

[0112] Calculating an observation transformation matrix and a projection transformation matrix based on actual scene parameters, wherein the actual scene parameters include camera parameters, observation point parameters, and screen parameters;

[0113] The observation transformation matrix and the projection transformation matrix are written into the shader, so that the shader performs particle rendering according to the observation transformation matrix and the projection transformation matrix.

[0114] In a specific embodiment, before rendering each particle object, it is necessary to calculate an observation transformation matrix and a projection transformation matrix based on the actual scene being rendered. Specifically, the calculation method of the observation transformation matrix and the projection transformation matrix can adopt the calculation method of the prior art, which will not be detailed here.

[0115] Specifically, the actual scene parameters include camera parameters, observation point parameters, and screen width and height parameters.

[0116] The observation transformation matrix and the projection transformation matrix are input into the shader as constants, so that the shader can render each particle in real time according to the rendering requirements of the actual scene.

[0117] Step S106 : performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle.

[0118] In a specific embodiment, after all attribute values ​​of each particle in the vertex buffer are calculated by the shader, all particles in the particle cluster can be rendered according to the observation transformation matrix, projection transformation matrix and all attribute values ​​of each particle calculated in the above embodiment.

[0119] Specifically, after the above attribute calculation steps are completed using the shader, the rendering step can adopt the conventional particle rendering step, which will not be described in detail here.

[0120] According to a specific implementation of the embodiment of the present application, after the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method includes:

[0121] Replacing the current time with the next update time of the current time;

[0122] Jump to the step of batch processing the attribute data in the preset container based on the preset image processing algorithm, and perform subsequent update rendering steps until a preset time is reached.

[0123] In a specific embodiment, the rendering time point is continuously updated. When the rendering steps for all particles at the current time point are completed, the current time is replaced with the time of the next update. Specifically, the time of the next update can be set according to the actual application scenario and is not specifically limited in this embodiment.

[0124] After replacing the current time, jump to the step of calculating the attribute data in the preset container in the above embodiment to detect the survival and visibility of the particles at the next update time point, and perform the next rendering calculation based on the survival and visibility of the particles.

[0125] In the above embodiment, steps S101 to S104 are all performed in the central processing unit, and steps S105 and S106 are performed in the graphics processing unit of the graphics processing unit.

[0126] The particle system rendering method provided in this embodiment categorizes and replaces the calculation of particle properties, converting them into functions and corresponding parameters that can be calculated in the shader. This reduces CPU memory usage, reduces frequent address changes and the simultaneous execution of multiple instructions in the CPU, and improves CPU utilization. By using the graphics processor to calculate and update some particle properties, the rendering efficiency of particle effects is improved.

[0127] refer to Figure 3 , is a schematic diagram of a device module of a particle system rendering device 300 provided in an embodiment of the present application. The particle system rendering device 300 provided in an embodiment of the present application, such as Figure 1 As shown, the particle system rendering device 300 includes:

[0128] A classification storage module 301 is used to classify and store the attributes of each particle in a preset particle cluster, wherein attributes that change dynamically over time are stored in a preset container. The preset particle cluster includes particles of the same type and an update strategy for each particle, wherein the update strategy includes a first update strategy without a time sequence and a second update strategy with a time sequence;

[0129] A first calculation module 302 is configured to calculate a first parameter corresponding to a first preset function based on an execution start point and an execution end point of the first update strategy, wherein the first update strategy is an update strategy without a time series;

[0130] A second calculation module 303 is configured to calculate a second parameter corresponding to a second preset function based on a time series of the second update strategy and a value corresponding to each time node in the time series, wherein the second update strategy is an update strategy with a time series;

[0131] The processing module 304 is configured to batch process all attributes in the preset container based on a preset image processing algorithm, and write particles that are alive and visible at the current time into the vertex buffer;

[0132] A third calculation module 305 is configured to calculate, in a shader, all attribute values ​​of each particle in the vertex buffer according to the first parameter, the first preset function, the second parameter, the second preset function, and the current time;

[0133] The rendering module 306 is used to perform attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle.

[0134] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, it executes the particle system rendering method in the above embodiment.

[0135] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the particle system rendering method in the above embodiment is executed.

[0136] In summary, the embodiments of the present application provide a particle system rendering method, device, electronic device and storage medium. The particle system rendering method provided by the embodiments of the present application converts some attributes of particles and update strategies into functions and parameters through the CPU, and stores them in the shader, so as to calculate the attribute values ​​of some attributes through the shader, thereby continuing to complete the rendering in the GPU, reducing frequent address changes in the CPU and executing multiple instructions at the same time, improving the utilization of the CPU, and reducing the memory space occupied. By using the GPU to calculate some particle updates, the rendering efficiency of the particle effect is improved. In addition, the specific implementation process of the particle system rendering device, electronic device and computer-readable storage medium mentioned in the above embodiments can refer to the specific implementation process of the above method embodiments, and will not be repeated here.

[0137] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or flowchart, and the combination of boxes in the structure diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.

[0138] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0139] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0140] The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be covered by the scope of protection of the present invention.

Claims

1. A particle system rendering method, characterized in that: The particle system rendering method includes: Classify and store the attributes of each particle in a preset particle cluster, wherein the attributes that change dynamically over time are stored in a preset container, the preset particle cluster including particles of the same type and an update strategy for each particle, the update strategy including a first update strategy without a time sequence and a second update strategy with a time sequence; Calculating a first parameter corresponding to a first preset function based on an execution start point and an execution end point of the first update strategy; Calculate a second parameter corresponding to a second preset function based on the time series of the second update strategy and the value corresponding to each time node in the time series; Batch process all attributes in the preset container based on a preset image processing algorithm, and write particles that are alive and visible at the current time into the vertex buffer; In the shader, all attribute values ​​of each particle in the vertex buffer are calculated according to the first parameter, the first preset function, the second parameter, the second preset function, and the current time; Performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle; The first preset function is a linear function of one variable, wherein the dependent variable is the attribute value and the independent variable is time. The step of calculating the first parameter corresponding to the first preset function based on the execution start point and the execution end point of the first update strategy includes: If the execution start point and the execution end point of the current first update strategy are the same, obtaining a first coefficient group according to a first rule, and using the first coefficient group as a first parameter when adopting the current first update strategy; If the execution start point and the execution end point of the current first update strategy are different, obtaining a second coefficient group according to a second rule, and using the second coefficient group as a first parameter when adopting the current first update strategy; The second preset function is a univariate multi-order polynomial corresponding to the number of time nodes of the second update strategy, wherein the dependent variable is the attribute value and the independent variable is time; The step of calculating a second parameter corresponding to a second preset function based on the time series of the second update strategy and the numerical value corresponding to each time node in the time series includes: Fitting the univariate multi-order polynomial using the least squares method to obtain a time matrix and an attribute value vector corresponding to the time series; According to the preset calculation formula The second parameter is calculated, where A is a time matrix, B is an attribute value vector, and x is the second parameter.

2. The particle system rendering method according to claim 1, characterized in that: The preset container is a SOA_VECTOR container, and the step of classifying and storing the attributes of each particle in the preset particle cluster includes: Dividing the attributes of each particle in the preset particle cluster into attributes that vary with time and constant attributes; Integrate the constant attributes of all particles in the preset particle cluster into a structure, and store a pointer to the structure in each particle object in the preset particle cluster; All time-varying properties are stored in the SOA_VECTOR container.

3. The particle system rendering method according to claim 1, characterized in that: Before the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method further includes: Calculating an observation transformation matrix and a projection transformation matrix based on actual scene parameters, wherein the actual scene parameters include camera parameters, observation point parameters, and screen parameters; The observation transformation matrix and the projection transformation matrix are written into the shader, so that the shader performs particle rendering according to the observation transformation matrix and the projection transformation matrix.

4. The particle system rendering method according to claim 1, characterized in that: After the step of performing attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle, the method includes: Replacing the current time with the next update time of the current time; Jump to the step of batch processing the attribute data in the preset container based on the preset image processing algorithm, and perform subsequent update rendering steps until a preset time is reached.

5. The particle system rendering method according to claim 1, characterized in that: The preset image processing algorithm is a SIMD algorithm, the attribute data in the preset container includes particle viability, visibility, and particle structure transformation, and the step of batch processing the attribute data in the preset container based on the preset image processing algorithm includes: Determining the state of the particle at the current time based on the particle's viability, visibility, and particle structure transformation; Write particles that are alive and visible at the current time into the vertex buffer; Initialize the particles that are in the dead state at the current time and store them in the preset container.

6. A particle system rendering device, characterized in that: The particle system rendering device includes: a classification storage module for classifying and storing the attributes of each particle in a preset particle cluster, wherein attributes that change dynamically over time are stored in a preset container, the preset particle cluster including particles of the same type and an update strategy for each particle, the update strategy including a first update strategy without a time sequence and a second update strategy with a time sequence; a first calculation module, configured to calculate a first parameter corresponding to a first preset function based on an execution start point and an execution end point of the first update strategy, wherein the first update strategy is an update strategy without a time series; A second calculation module is configured to calculate a second parameter corresponding to a second preset function based on a time series of the second update strategy and a numerical value corresponding to each time node in the time series, wherein the second update strategy is an update strategy with a time series; A processing module, configured to batch process all attributes in the preset container based on a preset image processing algorithm, and write particles that are alive and visible at the current time into a vertex buffer; a third calculation module, configured to calculate, in a shader, all attribute values ​​of each particle in the vertex buffer according to the first parameter, the first preset function, the second parameter, the second preset function, and the current time; A rendering module, configured to perform attribute rendering on all particles in the preset particle cluster according to all attribute values ​​of each particle; The first preset function is a linear function of one variable, wherein the dependent variable is the attribute value and the independent variable is time. The step of calculating the first parameter corresponding to the first preset function based on the execution start point and the execution end point of the first update strategy includes: If the execution start point and the execution end point of the current first update strategy are the same, obtaining a first coefficient group according to a first rule, and using the first coefficient group as a first parameter when adopting the current first update strategy; If the execution start point and the execution end point of the current first update strategy are different, obtaining a second coefficient group according to a second rule, and using the second coefficient group as a first parameter when adopting the current first update strategy; The second preset function is a univariate multi-order polynomial corresponding to the number of time nodes of the second update strategy, wherein the dependent variable is the attribute value and the independent variable is time; The step of calculating a second parameter corresponding to a second preset function based on the time series of the second update strategy and the numerical value corresponding to each time node in the time series includes: Fitting the univariate multi-order polynomial using the least squares method to obtain a time matrix and an attribute value vector corresponding to the time series; According to the preset calculation formula The second parameter is calculated, where A is a time matrix, B is an attribute value vector, and x is the second parameter.

7. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is run on the processor, the particle system rendering method according to any one of claims 1 to 5 is executed.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed on a processor, executes the particle system rendering method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Point cloud data three-dimensional visual rendering method and calculation method

    CN111127610A

  • Particle special effect rendering method, device and equipment and storage medium

    CN112652044A