Particle effect realization method, device, equipment and storage medium
By setting two particle emitters and combining constraints, the gradual change of line segments in the star line cluster is realized, which solves the problems of line segment jump and custom distance limitation in the existing technology, and improves the quality of particle effects and flexibility.
Patent Information
- Application Number
- CN202111619795.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-12-27
AI Technical Summary
In the existing UE4 official content example project, the star line clump effect will jump, resulting in poor particle effect, and the separation distance of line segments that appear or disappear cannot be customized, which has certain limitations.
By setting two particle emitters, the first emitter emits star particles, and the second emitter emits linear particles, obtaining the particle properties and emission mode of the two particle emitters, combining the constraints to generate particle effect diagrams, so that the linear segment can be gradually changed The constraints for appearing or disappearing and customize the occurrence or disappearance of line segments.
In the special effects of star line clump particles, the line segments can gradually appear or disappear, which improves the quality of the particle effect. The constraints for the appearance or disappearance of line segments can be customized, which is flexible and adapts to the dynamic movement of the particle system.
Smart Images

Figure CN114377390B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of realizing particle effects, and in particular, to a method, device, equipment and storage medium for realizing particle effects. Background Art
[0002] In game development, it is often necessary to implement a lot of particle effects. The first type of particle effect is the stacking of color patches, while the second type of particle effect requires the use of program logic to achieve the ideal effect (such as self-collision between particles, such as particles generating different pulling forces based on the distance relationship between each other, etc.).
[0003] At present, the existing technical solution is: use UE4 particle system to achieve particle effects. Taking the UE4 official content example project as an example, the connection between particle points and lines can be realized to create a star line cluster (also known as point line cluster, Plexus, an effect composed of points and lines). Among them, the star line cluster in the existing UE4 official content example project is implemented based on the 3d neighboring grid NeighborGrid3D (used for neighboring particle traversal), and its implementation method is: when the particle system is generated, a NeighborGrid3D is generated, and the particle system space is divided into several equal parts, and then during each frame of rendering the particle, all particles are traversed, and according to the area in the NeighborGrid3D where the current particle is located, all particles in this area are found as neighboring particles of the current particle, and the distance between the two particles is calculated to generate a connection line.
[0004] However, in the implementation of the star line cluster effect in the existing UE4 official content sample project, the lines between the star particles will "jump" to appear / disappear, resulting in poor particle effects. Summary of the invention
[0005] The embodiments of the present invention provide a method, device, equipment and storage medium for realizing particle effects, so as to overcome the problem that the particle effects realized in the prior art are relatively poor.
[0006] In a first aspect, an embodiment of the present invention provides a method for realizing a particle effect, comprising:
[0007] Obtaining particle properties of each star particle emitted by a first emitter and an emission mode of the first emitter;
[0008] Obtaining the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle;
[0009] A particle effect graph is generated by rendering according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
[0010] Optionally, the emission mode of the first emitter is to generate N star particles per second and each star particle has a life cycle of T; the emission mode of the second emitter is to emit all line particles at one time and each line particle has no life cycle; the method further includes:
[0011] According to the number N of star particles generated per second and the life cycle T of each star particle, the number of lines generated between every two star particles is calculated;
[0012] The number of lines is used as the number of all line particles emitted by the second emitter at one time.
[0013] Optionally, the particle attributes of the star particle include the star particle identifier, the position information of the star particle corresponding to the star particle identifier, the size of the star particle, and the color value of the star particle; the particle attributes of the line particle include the line particle identifier, the position information of the line particle corresponding to the line particle identifier, the size of the line particle, and the color value of the line particle;
[0014] The step of obtaining the particle properties of each line particle emitted by the second emitter and the constraint conditions for presenting the effect of each line particle gradually appearing or disappearing includes:
[0015] Get the identifier of the currently running line particle, and use the currently running line particle as any line particle emitted by the second emitter;
[0016] For any of the line particles, according to the identification of the line particle, the identifications of two target star particles connected to the line particle are determined, and according to the identifications of the two target star particles, the position information of the two target star particles, the sizes of the two target star particles, and the color values of the two target star particles are obtained;
[0017] Determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold;
[0018] According to the position information of the two target star particles, the sizes of the two target star particles and the color values of the two target star particles, the position information of the line particle corresponding to the line particle, the size of the line particle and the color value of the line particle are determined.
[0019] Optionally, determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold includes:
[0020] According to the distance between the two target star particles and a preset distance threshold, a distance range in which the line particles gradually appear or disappear is obtained through a spline interpolation function;
[0021] The distance range is used as the constraint condition.
[0022] Optionally, determining the position information of the line particle, the size of the line particle, and the color value of the line particle corresponding to the identifier of the line particle according to the position information of the two target star particles, the size of the two target star particles, and the color values of the two target star particles includes:
[0023] Determine the position information of the line particle according to the position information of the two target star particles, and align the line particle with the two target star particles;
[0024] Determining the color value of the line particle according to the color values of the two target star particles;
[0025] The size of the line particle is determined according to the distance between the two target star particles and the sizes of the two target star particles.
[0026] Optionally, determining the position information of the line particle according to the position information of the two target star particles includes:
[0027] According to the position information of the two target star particles, finding the midpoint position between the two target particles;
[0028] The midpoint position is used as the position information of the line particle.
[0029] Optionally, determining the color value of the line particle according to the color values of the two target star particles includes:
[0030] According to the color values of the two target star particles, the color value of the line particle is obtained by interpolation calculation; or,
[0031] The color value of the line particle is obtained by multiplying the color values of the two target star particles.
[0032] Optionally, the size of the line particle includes a length value of the line particle and a width value of the line particle; and determining the size of the line particle according to the distance between the two target star particles and the sizes of the two target star particles includes:
[0033] Taking the distance between the two target star particles as the length value of the line particle;
[0034] The average value of the sizes of the two target star particles is taken as the width value of the line particle.
[0035] Optionally, rendering and generating a particle effect graph according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and the constraint condition includes:
[0036] According to the constraint condition, determining the gradually changing weight of the line particle;
[0037] Determining change information of the color value of the line particle and change information of the width value of the line particle according to the weight, the color value of the line particle and the width value of the line particle;
[0038] According to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and according to the change information of the color value of the line particles and the change information of the width value of the line particles, each of the star particles and each of the line particles is rendered to generate a particle effect diagram.
[0039] In a second aspect, an embodiment of the present invention provides a device for realizing a particle effect, comprising:
[0040] A first acquisition module, used to acquire the particle properties of each star particle emitted by the first emitter and the emission mode of the first emitter;
[0041] A second acquisition module is used to acquire the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle;
[0042] The rendering module is used to render and generate a particle effect diagram according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
[0043] In a third aspect, an embodiment of the present invention provides a device for implementing a particle effect, including: at least one processor and a memory;
[0044] The memory stores computer-executable instructions;
[0045] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the method for realizing the particle effect as described in any one of the first aspects.
[0046] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, a method for realizing a particle effect as described in any one of the first aspects is implemented.
[0047] The embodiment of the present invention provides a method, device, equipment and storage medium for realizing particle effects. First, the particle properties of each star particle emitted by a first emitter and the emission mode of the first emitter are obtained; the particle properties of each line particle emitted by a second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle and the emission mode of the second emitter are obtained; wherein the particle properties and the constraint conditions of each line particle are determined by the particle properties of each star particle; then, according to the particle properties of each star particle, the emission mode of the first emitter, the particle properties of each line particle, the emission mode of the second emitter and the constraint conditions, a particle effect graph is rendered and generated. By setting two particle emitters, the first emitter emits star particles and the second emitter emits line particles, the particle properties, the emission mode and the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle emitted by the two particle emitters are respectively obtained, and then the particle effect graph is rendered and generated, so that in the star-line cluster particle special effect, the line segment can appear or disappear gradually, so that the particle effect is better realized, and the constraint conditions (such as separation distance) for the appearance or disappearance (such as disconnection) of the line segment can be customized, which is flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0049] Figure 1 A schematic diagram of a scenario provided by an embodiment of the present invention;
[0050] Figure 2 A schematic flow chart of a method for implementing particle effects provided by an embodiment of the present invention;
[0051] Figure 3 A schematic diagram of particle effects provided by an embodiment of the present invention;
[0052] Figure 4 A schematic diagram of the structure of a device for realizing particle effects provided by an embodiment of the present invention;
[0053] Figure 5A schematic diagram of the hardware structure of a device for realizing particle effects provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0056] The star clusters in the existing UE4 official content sample projects are implemented based on the 3D neighboring grid NeighborGrid3D (used for neighboring particle traversal). The implementation method is: when the particle system is generated, a NeighborGrid3D is generated to divide the particle system space into several equal parts, and then during each frame of rendering particles, all particles are traversed, and according to the area in the NeighborGrid3D where the current particle is located, all particles in this area are found as neighboring particles of the current particle, the distance between the two particles is calculated, and the connection line is generated.
[0057] However, in the star cluster effect implementation in the existing UE4 official content sample project, the lines between the star particles will "jump" to appear / disappear, resulting in poor particle effects. In addition, because the NeighborGrid3D solution compares the distance between two particles and connects two particles based on the shortest distance, no matter how you customize the distance threshold for the appearance / disappearance (i.e., appearance or disappearance) of the line segments, it will not take effect. Therefore, the separation distance for the appearance / disappearance of the line segments cannot be customized, which has certain limitations.
[0058] In addition, stars and lines cannot be generated when the particle system moves dynamically. Because NeighborGrid3D is generated at the beginning of the particle system, the neighboring grid will move with the particle system during the subsequent movement of the particle system, which will cause some of the generated particles to be left out of the original birth area, exceeding the area that the current neighboring grid can cover, resulting in previously generated particles being unable to connect with subsequently generated particles. In layman's terms, if the line is broken, it cannot be connected again, leaving only stars, resulting in poor particle effects.
[0059] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0060] See also Figure 1 As shown, Figure 1 A schematic diagram of a scene provided for an embodiment of the present invention. The execution subject of the particle effect implementation method may be a computer device, such as a server. First, two particle emitters are set. For example, the first emitter is used as a star particle emitter, that is, the part that generates stars in a star-line cluster; the second emitter is used as a line particle emitter, that is, the part that generates lines in a star-line cluster. That is, the particles emitted by the first emitter are regarded as the part that generates stars in a star-line cluster, and are regarded as star particles; the particles emitted by the second emitter are regarded as the part that generates lines in a star-line cluster, and are regarded as line particles.
[0061] For the star part: First, you need to set the properties of the emitter Emitter to GPU particles, that is, GPU ComputeSim (only when GPU particles are turned on), so that the second emitter can read the particle properties. Secondly, set the emission mode (i.e. SpawnRate) of the number of particles generated per second, because stars are continuously emitted, and the number of emission values per second is temporarily set to BallCount, for example, N star particles are emitted per second. In addition, set the value of whether the particle will never die (i.e. Particle State-Kill Particles When Lifetime has Elapsed) to true (i.e. the particle will die), because stars are continuously generated / destroyed.
[0062] For the line part, first of all, you also need to set the attributes of the emitter to GPU Compute Sim. Secondly, add the Niagara (UE4 particle system) particle attribute reader AttributeReader (that is, used to read the particle attributes of the star emitter (position information, particle size, etc.), and fill in the name of the target emitter to be read (such as the name of the first emitter) in the corresponding column. Then, you need to set the particle emission mode to emit all particles at once (that is, SpawnBurstInstantaneous). At the same time, set Particle State-Kill Particles When lifetimeElapsed so that the line particles will never end their life cycle (unless the overall life cycle of the particle system ends). In this way, the number of line particles is fixed.
[0063] Specifically, the server respectively obtains the particle properties and emission modes of the particles emitted by the two particle emitters, as well as the constraints for presenting the gradual appearance or disappearance of each line particle, and then renders and generates a particle effect graph, thereby realizing that in the star-line cluster particle special effects, line segments can gradually appear or disappear. Therefore, the particle effect is better, and the constraints (such as separation distance) for the appearance or disappearance (such as disconnection) of line segments can be customized, which is flexible. In addition, due to the setting of the constraints, when the particle system moves dynamically, the stars and lines can gradually appear or disappear based on the change in the distance between the stars, thereby realizing a better particle effect.
[0064] How to achieve the particle effect can be seen in the following embodiments:
[0065] Figure 2 A schematic diagram of a method for implementing particle effects provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method for implementing the particle effect may include:
[0066] S101: Obtain particle properties of each star particle emitted by a first emitter and an emission mode of the first emitter.
[0067] The emission mode of the first emitter is to generate N star particles per second and the life cycle of each star particle is T. The particle attributes of the star particle include the star particle identifier and the position information of the star particle corresponding to the star particle identifier, the size of the star particle, and the color value of the star particle.
[0068] Specifically, the particle properties of each star particle emitted by the first emitter and the emission mode of the first emitter can be customized, and the server can obtain the configuration information of the first emitter, such as the position information of the star particle, the size of the star particle, the color value of the star particle, the number of star particles generated per second, and the life cycle T of each star particle.
[0069] S102: Obtaining particle properties of each line particle emitted by the second emitter, constraint conditions for presenting a gradual appearance or disappearance effect of each line particle, and obtaining an emission mode of the second emitter.
[0070] The particle attributes and constraints of each of the line particles are determined by the particle attributes of each of the star particles. The particle attributes of the line particles include the line particle identifier and the position information of the line particle corresponding to the line particle identifier, the size of the line particle, and the color value of the line particle.
[0071] Optionally, a method for obtaining the particle properties of each line particle emitted by the second emitter and the constraint conditions for presenting the effect of gradual appearance or disappearance of each line particle can be to determine the particle properties and constraint conditions of each line particle based on the particle properties of each star particle: for each line particle, based on the identification of the line particle, determine the identification of two target star particles connected to the line particle; based on the position information of the star particle corresponding to the identification of the two target star particles, the size of the star particle, and the color value of the star particle, determine the properties and constraint conditions of the line particle.
[0072] Specifically, the line setting logic can be implemented in the UE4 particle system shader writing module. First, the second emitter can read the target emitter ID, such as the target emitter name, through the particle attribute reader; then read the particle attributes of each star particle emitted by the first emitter, and then determine the constraint conditions according to the particle attributes of each star particle to achieve the gradual appearance or disappearance of the line segment. In addition, it is necessary to set the emission mode of the second emitter, for example, set the emission mode of the second emitter to emit all line particles at one time and each line particle has no life cycle. The second emitter provides the particle attributes of each emitted line particle, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter to the server for particle rendering.
[0073] S103, rendering and generating a particle effect graph according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
[0074] Specifically, based on the particle properties of the particles emitted by the two emitters, their respective emission modes, and the constraints that allow line segments to gradually appear or disappear, it is possible to achieve the gradual appearance / disappearance of line segments in the star cluster particle special effects, and when the particle system is moving, the line segments between old particles can still be connected even if they are broken due to a distance, and the separation distance for the appearance / disconnection of line segments can be customized. This not only ensures a good rendering effect, but also has flexibility.
[0075] The method for realizing the particle effect provided by the present invention first obtains the particle properties of each star particle emitted by the first emitter and the emission mode of the first emitter; obtains the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and obtains the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle; and then renders and generates a particle effect graph according to the particle properties of each star particle, the emission mode of the first emitter, the particle properties of each line particle, the emission mode of the second emitter, and the constraint conditions. By setting two particle emitters, the first emitter emits star particles and the second emitter emits line particles, respectively obtains the particle properties, emission mode, and constraint conditions for presenting the gradual appearance or disappearance effect of each line particle emitted by the two particle emitters, and then renders and generates a particle effect graph, it is realized that in the star-line cluster particle special effect, the line segment can appear or disappear gradually, so that the particle effect is better realized, and the constraint conditions (such as separation distance) for the appearance or disappearance (such as disconnection) of the line segment can be customized, which is flexible.
[0076] Optionally, the number of line particles may be determined by the emission mode of the first emitter, which may be achieved by the following steps:
[0077] Step a1: Calculate the number of lines generated between every two star particles according to the number N of star particles generated per second and the life cycle T of each star particle.
[0078] Step a2: using the number of lines as the number of all line particles emitted by the second emitter at one time.
[0079] Specifically, the process of determining the number of line particles can be: the number of particles emitted by the first emitter per second * the life cycle of the particle * (the number of particles emitted by the first emitter per second * the life cycle of the particle - 1) / 2. That is, the number of lines between stars for each two stars to generate a line can be calculated based on the total number of stars currently in the first emitter.
[0080] The first emitter generates N star particles per second, and the life cycle of the particles is T, then the number of line particles is: N*T*(N*T-1) / 2, where the total number of stars currently in the first emitter can be expressed as N*T. For example, assuming N=3, assuming T=2s, the number of line particles is 15.
[0081] Since star particles are continuously generated and have a life cycle, line particles have no life cycle, that is, line particles never die, and the number of line particles is related to the number of star particles. Therefore, if the current star particle life cycle ends, new star particles of the same number will be generated, so the number of line particles is fixed and can be used indefinitely (unless the overall life cycle of the particle system ends). It is only necessary to determine the properties of line particles based on different pairs of star particles, without the need to constantly copy line particles and then delete them.
[0082] Optionally, how to obtain the particle properties of the line particles and the constraints used to present the effect of each line particle gradually appearing or disappearing can be achieved through the following steps:
[0083] Step b1, obtaining the identifier of the currently running line particle, and using the currently running line particle as any line particle emitted by the second emitter;
[0084] Step b2: for any of the line particles, according to the identification of the line particle, determine the identifications of two target star particles connected to the line particle, and according to the identifications of the two target star particles, obtain the position information of the two target star particles, the sizes of the two target star particles, and the color values of the two target star particles;
[0085] Step b3: determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold.
[0086] Step b4: Determine the position information, size and color value of the line particle corresponding to the line particle according to the position information, size and color value of the two target star particles.
[0087] Among them, the identification of the line particles is associated with the order in which the star particles are generated in pairs. For example, if the total number of star particles in the current cycle is 3, the order of the generated star particles is star particle 1, star particle 2 and star particle 3. The identification of the corresponding line particles of the star particles identified as 1 and 2 is 1 (that is, star particle 1 and star particle 2 correspond to line particle 1), the identification of the corresponding line particles of the star particles identified as 1 and 3 is 2 (that is, star particle 1 and star particle 3 correspond to line particle 2), and the identification of the corresponding line particles of the star particles identified as 2 and 3 is 3 (that is, star particle 2 and star particle 3 correspond to line particle 3).
[0088] Specifically, for any line particle, based on the identifier of the line particle, the identifiers of the two star particles connected to the line particle can be determined. When determining the particle properties of the line particle (such as position, size, color, etc.), the particle properties of the two star particles (such as position, size, color, etc.) can be obtained based on the identifiers of the two connected star particles, and then based on the constraints, the rendering effect of the line particles and the star particles can be achieved.
[0089] Optionally, how to determine the constraint condition is described in detail. Determining the constraint condition corresponding to the particle according to the distance between the two target star particles and a preset distance threshold may include the following steps:
[0090] Step c1, according to the distance between the two target star particles and a preset distance threshold, a distance range in which the line particles gradually appear or disappear is obtained through a spline interpolation function;
[0091] Step c2: taking the distance range as the constraint condition.
[0092] The preset distance threshold here can be expressed as a line segment (or line) appearance / disappearance distance threshold.
[0093] In actual applications, you only need to set the position of each line and the result of the distance threshold between the line and the appearance / disappearance. This part of the logic can be written in the Niagara particle template, and the algorithm part can use the Niagara Module Script template to write logic in the shader language.
[0094] Among them, the input parameters can be: rReader: particle attribute reader of the star emitter, used to read the ID, size and color value of the star particle; CurrentIndex: the ID of the currently running line particle (wherein, particles processed in parallel have different logics according to different IDs); InBallCount: the upper limit of the number of particles used in the loop traversal. The output parameters can be: OutPos and OutPos2: the position coordinates (i.e., position information) of the two star particles (i.e., the two target star particles) connected by the line particle, which are used to set the position of the line later; OutSizeScale1 and OutSizeScale2: the particle size of the two star particles connected by the line particle, which are used to set the particles to appear / disappear gradually later; OutLinearColor1 and OutLinearColor2: the color of the two star particles connected by the line particle, which are used to set the particle color later.
[0095] Specifically, the parameters of the line emitter (i.e., the second emitter) can be: AttributeReader: used to read the particle attributes (position information, particle size, etc.) of the star emitter (i.e., the first emitter); BallCount: used to set the upper limit of the number of particles in the loop traversal (e.g., the number of line particles); FadeDistance: the distance threshold for the appearance / disappearance of particles (i.e., the preset distance threshold); SmoothMax: when the distance between star particles is greater than the value of (distance threshold * percentage), the particle line segment (i.e., the line segment connecting the two star particles) disappears; SmoothMin: when the distance between particles is less than the value of (distance threshold * percentage), the particle line segment also disappears. (When the distance between particles is between these two values, the line segment will appear, and because of the smoothstep (function, used for numerical smooth transition) function (i.e., spline interpolation function), this line segment will gradually appear / disappear on the boundary between SmoothMax and SmoothMin); SpriteWidth: the width of the line.
[0096] The percentage here can be determined by comparing the absolute value of the difference between the actual distance between the particles and the distance threshold (i.e., the preset distance threshold) with the distance threshold. The constraint condition can be the distance range between SmoothMin and SmoothMin. That is, according to the distance difference / distance threshold as the percentage of gradual appearance or disappearance, the width value in the size of the line particle is multiplied by the percentage to determine the changing width value.
[0097] Optionally, determining the position information of the line particle, the size of the line particle, and the color value of the line particle corresponding to the identifier of the line particle according to the position information of the two target star particles, the size of the two target star particles, and the color values of the two target star particles can be achieved by the following steps:
[0098] Step d1, determining the position information of the line particle according to the position information of the two target star particles, and aligning the line particle with the two target star particles.
[0099] Step d2: Determine the color value of the line particle according to the color values of the two target star particles.
[0100] Step d3: Determine the size of the line particle according to the distance between the two target star particles and the sizes of the two target star particles.
[0101] In practical applications, each line particle needs to be traversed to determine the particle properties of the line particle and other information. The above calculation can tell the number of lines between two star particles, so in this traversal line particle cycle, you only need to match the number of cycles between the stars according to the currently running line particle ID (i.e. ID value). For example, if the line particle ID is 2, it corresponds to the second cycle number, that is, the corresponding two star particles are star particle 1 and star particle 3.
[0102] End the current loop by identifying BreakFlag (a marker that is often used to record the exit condition in a program loop), that is, when the line particle matches the sequence number, immediately exit the current loop and record the star particles of the two segments of the current line. Then read the position, size and color of the corresponding star particle according to the AtrributeReader of the star emitter.
[0103] Optionally, determining the position information of the line particle according to the position information of the two target star particles may include the following steps:
[0104] Step d11, finding the midpoint position between the two target particles according to the position information of the two target star particles;
[0105] Step d12: Using the midpoint position as the position information of the line particle.
[0106] Specifically, according to the positions of the two particles, the UE4 native node is used to find the midpoint between the two particles, and this position is assigned to the position of the line particle.
[0107] Among them, align the line particle with the star particle (that is, tilt the line particle to ensure that the line particle is between two star particles): align one end and the other end will be automatically aligned.
[0108] Optionally, determining the color value of the line particle according to the color values of the two target star particles may include the following steps:
[0109] The color value of the line particle is obtained by interpolation calculation according to the color values of the two target star particles; or the color value of the line particle is obtained by multiplying the color values of the two target star particles.
[0110] Specifically, a color value is obtained by interpolating or multiplying the colors of the two star particles as the color value of the line particle.
[0111] Optionally, the size of the line particle includes a length value of the line particle and a width value of the line particle; and determining the size of the line particle according to the distance between the two target star particles and the sizes of the two target star particles may include the following steps:
[0112] Step d31, taking the distance between the two target star particles as the length value of the line particle;
[0113] Step d32: taking the average value of the sizes of the two target star particles as the width value of the line particle.
[0114] Specifically, the constraint conditions for the gradual appearance / disappearance of particles are determined by performing smoothstep interpolation based on the distance between two star particles and a preset distance threshold.
[0115] Optionally, rendering and generating a particle effect graph according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and the constraint condition may include the following steps:
[0116] Step e1, determining the gradually changing weight of the line particles according to the constraint conditions;
[0117] Step e2, determining change information of the color value of the wire particle and change information of the width value of the wire particle according to the weight, the color value of the wire particle and the width value of the wire particle;
[0118] Step e3, according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and according to the change information of the color value of the line particles and the change information of the width value of the line particles, each of the star particles and each of the line particles is rendered to generate a particle effect diagram.
[0119] Specifically, combined Figure 3 As shown, according to the distance range, the percentage, i.e., the weight of the gradual change of the line particle, can be obtained, and then the weight is multiplied by the color value of the line particle and the width value of the line particle to obtain the change information of the color value of the line particle (i.e., the color value currently corresponding to the gradual appearance / disappearance) and the change information of the width value of the line particle (i.e., the width value currently corresponding to the gradual appearance / disappearance). Then, based on the particle attributes, emission mode, and change information, particle rendering is performed to obtain a particle effect map, in which the line segments will not suddenly appear / disappear.
[0120] When the line particles gradually appear or disappear, the rendering effect is that the color corresponding to the color value of the line particles gradually deepens or becomes transparent, and the width value of the line particles gradually increases or decreases. Therefore, the Niagara particle system is used in conjunction with program logic to generate the particle effect of the star line cluster. In the star line cluster particle special effect, the line segments can appear / disappear gradually, and when the particle system is moving, the line segments between the old particles can still be connected even if they are broken due to exceeding the distance, and the rendered particle effect is better. In addition, the separation distance of the line segment appearance / disconnection can be customized, which is flexible.
[0121] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method, such as Figure 4 FIG. 1 is a schematic diagram of a structure of a device for realizing a particle effect according to an embodiment of the present invention. The device for realizing a particle effect may include:
[0122] A first acquisition module 401 is used to acquire the particle properties of each star particle emitted by a first emitter and the emission mode of the first emitter;
[0123] A second acquisition module 402 is used to acquire the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle;
[0124] The rendering module 403 is used to render and generate a particle effect diagram according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
[0125] Optionally, the emission mode of the first emitter is to generate N star particles per second and the life cycle of each star particle is T; the emission mode of the second emitter is to emit all line particles at one time and each line particle has no life cycle; the device may further include: a processing module; the processing module is used to:
[0126] According to the number N of star particles generated per second and the life cycle T of each star particle, the number of lines generated between every two star particles is calculated;
[0127] The number of lines is used as the number of all line particles emitted by the second emitter at one time.
[0128] Optionally, the particle attributes of the star particle include the star particle identifier, the position information of the star particle corresponding to the star particle identifier, the size of the star particle, and the color value of the star particle; the particle attributes of the line particle include the line particle identifier, the position information of the line particle corresponding to the line particle identifier, the size of the line particle, and the color value of the line particle; the second acquisition module is specifically used to:
[0129] Get the identifier of the currently running line particle, and use the currently running line particle as any line particle emitted by the second emitter;
[0130] For any of the line particles, according to the identification of the line particle, the identifications of two target star particles connected to the line particle are determined, and according to the identifications of the two target star particles, the position information of the two target star particles, the sizes of the two target star particles, and the color values of the two target star particles are obtained;
[0131] Determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold;
[0132] According to the position information of the two target star particles, the sizes of the two target star particles and the color values of the two target star particles, the position information of the line particle corresponding to the line particle, the size of the line particle and the color value of the line particle are determined.
[0133] Optionally, the second acquisition module is specifically used to:
[0134] According to the distance between the two target star particles and a preset distance threshold, a distance range in which the line particles gradually appear or disappear is obtained through a spline interpolation function;
[0135] The distance range is used as the constraint condition.
[0136] Optionally, the second acquisition module is specifically used to:
[0137] Determine the position information of the line particle according to the position information of the two target star particles, and align the line particle with the two target star particles;
[0138] Determining the color value of the line particle according to the color values of the two target star particles;
[0139] The size of the line particle is determined according to the distance between the two target star particles and the sizes of the two target star particles.
[0140] Optionally, the second acquisition module is specifically used to:
[0141] According to the position information of the two target star particles, finding the midpoint position between the two target particles;
[0142] The midpoint position is used as the position information of the line particle.
[0143] Optionally, the second acquisition module is specifically used to:
[0144] According to the color values of the two target star particles, the color value of the line particle is obtained by interpolation calculation; or,
[0145] The color value of the line particle is obtained by multiplying the color values of the two target star particles.
[0146] Optionally, the size of the line particle includes a length value of the line particle and a width value of the line particle; the second acquisition module is specifically used to: use the distance between the two target star particles as the length value of the line particle;
[0147] The average value of the sizes of the two target star particles is taken as the width value of the line particle.
[0148] Optional, rendering module, specifically used for:
[0149] According to the constraint condition, determining the gradually changing weight of the line particle;
[0150] Determining change information of the color value of the line particle and change information of the width value of the line particle according to the weight, the color value of the line particle and the width value of the line particle;
[0151] According to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and according to the change information of the color value of the line particles and the change information of the width value of the line particles, each of the star particles and each of the line particles is rendered to generate a particle effect diagram.
[0152] The device provided in the embodiment of the present invention can implement the method of the embodiment shown above, and its implementation principle and technical effect are similar, which will not be repeated here.
[0153] Figure 5 Schematic diagram of the hardware structure of the device for realizing the particle effect provided by the embodiment of the present invention. Figure 5 As shown, the device for implementing the particle effect provided in this embodiment includes: at least one processor 501 and a memory 502. The processor 501 and the memory 502 are connected via a bus 503.
[0154] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the method in the above method embodiment.
[0155] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0156] In the above Figure 5 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0157] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk storage.
[0158] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0159] An embodiment of the present invention further provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the method for realizing the particle effect of the above method embodiment is implemented.
[0160] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the above-mentioned method for realizing the particle effect when executed by a processor.
[0161] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0162] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0163] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for realizing particle effects, characterized in that: include: Obtaining particle properties of each star particle emitted by a first emitter and an emission mode of the first emitter; Obtaining the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle; A particle effect graph is generated by rendering according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
2. The method according to claim 1, characterized in that The emission mode of the first emitter is to generate N star particles per second and the life cycle of each star particle is T; the emission mode of the second emitter is to emit all line particles at one time and each line particle has no life cycle; the method further includes: According to the number N of star particles generated per second and the life cycle T of each star particle, the number of lines generated between every two star particles is calculated; The number of lines is used as the number of all line particles emitted by the second emitter at one time.
3. The method according to claim 1 or 2, characterized in that: The particle attributes of the star particle include the star particle identifier, the position information of the star particle corresponding to the star particle identifier, the size of the star particle, and the color value of the star particle; the particle attributes of the line particle include the line particle identifier, the position information of the line particle corresponding to the line particle identifier, the size of the line particle, and the color value of the line particle; The step of obtaining the particle properties of each line particle emitted by the second emitter and the constraint conditions for presenting the effect of each line particle gradually appearing or disappearing includes: Get the identifier of the currently running line particle, and use the currently running line particle as any line particle emitted by the second emitter; For any of the line particles, according to the identification of the line particle, the identifications of two target star particles connected to the line particle are determined, and according to the identifications of the two target star particles, the position information of the two target star particles, the sizes of the two target star particles, and the color values of the two target star particles are obtained; Determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold; According to the position information of the two target star particles, the sizes of the two target star particles and the color values of the two target star particles, the position information of the line particle corresponding to the line particle, the size of the line particle and the color value of the line particle are determined.
4. The method according to claim 3, characterized in that The step of determining the constraint condition corresponding to the line particle according to the distance between the two target star particles and a preset distance threshold comprises: According to the distance between the two target star particles and a preset distance threshold, a distance range in which the line particles gradually appear or disappear is obtained through a spline interpolation function; The distance range is used as the constraint condition.
5. The method according to claim 3, characterized in that: The step of determining the position information of the line particle, the size of the line particle, and the color value of the line particle corresponding to the identifier of the line particle according to the position information of the two target star particles, the size of the two target star particles, and the color value of the two target star particles comprises: Determine the position information of the line particle according to the position information of the two target star particles, and align the line particle with the two target star particles; Determining the color value of the line particle according to the color values of the two target star particles; The size of the line particle is determined according to the distance between the two target star particles and the sizes of the two target star particles.
6. The method according to claim 3, characterized in that The step of determining the position information of the line particle according to the position information of the two target star particles comprises: According to the position information of the two target star particles, finding the midpoint position between the two target particles; The midpoint position is used as the position information of the line particle.
7. The method according to claim 3, characterized in that Determining the color value of the line particle according to the color values of the two target star particles includes: According to the color values of the two target star particles, the color value of the line particle is obtained by interpolation calculation; or, The color value of the line particle is obtained by multiplying the color values of the two target star particles.
8. The method according to claim 3, characterized in that The size of the line particle includes a length value of the line particle and a width value of the line particle; and determining the size of the line particle according to the distance between the two target star particles and the sizes of the two target star particles includes: Taking the distance between the two target star particles as the length value of the line particle; The average value of the sizes of the two target star particles is taken as the width value of the line particle.
9. The method according to claim 2, characterized in that: The rendering and generating of the particle effect graph according to the particle attributes of each of the star particles, the emission mode of the first emitter, the particle attributes of each of the line particles, the emission mode of the second emitter and the constraint condition comprises: According to the constraint condition, determining the gradually changing weight of the line particle; Determining change information of the color value of the line particle and change information of the width value of the line particle according to the weight, the color value of the line particle and the width value of the line particle; According to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter, and according to the change information of the color value of the line particles and the change information of the width value of the line particles, each of the star particles and each of the line particles is rendered to generate a particle effect diagram.
10. A device for realizing particle effects, characterized in that: include: A first acquisition module, used to acquire the particle properties of each star particle emitted by the first emitter and the emission mode of the first emitter; A second acquisition module is used to acquire the particle properties of each line particle emitted by the second emitter, the constraint conditions for presenting the gradual appearance or disappearance effect of each line particle, and the emission mode of the second emitter; wherein the particle properties and constraint conditions of each line particle are determined by the particle properties of each star particle; The rendering module is used to render and generate a particle effect diagram according to the particle properties of each of the star particles, the emission mode of the first emitter, the particle properties of each of the line particles, the emission mode of the second emitter and the constraint conditions.
11. A device for realizing particle effects, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the method for realizing the particle effect according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the method for realizing the particle effect according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Method, system and device for writing calligraphy
CN103970987A
Lightning particle rendering method and device
CN110706149A
Illumination image generation method and device, equipment and medium
CN112802170A
Image generating system, program, and information storage medium
JP2002279446A
