CN112446942B - Special effect rendering method and device, electronic equipment and storage medium - Google Patents

Special effect rendering method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112446942B
CN112446942B CN202011241946.9A CN202011241946A CN112446942B CN 112446942 B CN112446942 B CN 112446942B CN 202011241946 A CN202011241946 A CN 202011241946A CN 112446942 B CN112446942 B CN 112446942B
Authority
CN
China
Prior art keywords
initial
virtual
density
target
grid
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011241946.9A
Other languages
Chinese (zh)
Other versions
CN112446942A (en
Inventor
戴强
王延青
刘斌
马重阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202011241946.9A priority Critical patent/CN112446942B/en
Publication of CN112446942A publication Critical patent/CN112446942A/en
Application granted granted Critical
Publication of CN112446942B publication Critical patent/CN112446942B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/02Non-photorealistic rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computing Systems (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The present disclosure relates to a special effect rendering method, a device, an electronic apparatus, and a storage medium, the method comprising obtaining initial parameters of virtual particles of a simulation target substance in response to a special effect rendering trigger instruction, the initial parameters characterizing layout information and motion information of the virtual particles in an initial state; determining target key points of target objects in a target page; the virtual particles are rendered based on the initial parameters to generate a first special effect of the target substance flowing from the target keypoint. By utilizing the embodiment of the invention, real-time online special effect rendering can be realized, the reality of the rendered special effect is improved, and the simulation effect is improved.

Description

Special effect rendering method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of special effect rendering, in particular to a special effect rendering method, a device, electronic equipment and a storage medium.
Background
Special effect simulation based on physical properties of substances is an important piece of content in the fields of computer graphics, digital entertainment (such as games, etc.), and virtual reality. In the related art, during special effect simulation of continuous substances such as water, jelly and the like, SPH (Smoothed Particle Hydrodynamics, smooth virtual particle fluid dynamics) and MPM (Material Point Method, substance point method) are mainly used for performing offline simulation and simulation on a large number of virtual particles, so that real-time online simulated rendering cannot be realized and a relatively real simulation effect cannot be realized.
Disclosure of Invention
The disclosure provides a special effect rendering method, a device, electronic equipment and a storage medium, which at least solve the problems that real-time online simulation rendering cannot be realized and the simulation effect is poor in the related technology. The technical scheme of the present disclosure is as follows:
according to a first aspect of an embodiment of the present disclosure, there is provided a special effect rendering method, including:
responding to a special effect rendering trigger instruction, and acquiring initial parameters of virtual particles of a simulation target substance, wherein the initial parameters represent layout information and motion information of the virtual particles in an initial state;
determining target key points of target objects in a target page;
rendering the virtual particles based on the initial parameters to generate a first special effect of the target substance flowing out of the target key point.
Optionally, the initial parameters include an initial density, and the rendering the virtual particles based on the initial parameters to generate the first special effect of the target substance flowing from the target keypoint includes:
determining the initial position of the virtual particle on the target page according to the target key point and the initial density;
determining initial color information of the virtual particles according to a density-color mapping relation, the initial density and the initial position, wherein the density-color mapping relation represents the mapping relation between the average density and the color of the virtual particles on each pixel point;
Rendering the virtual particles based on the initial color information and the initial shape corresponding to the virtual particles to generate a first special effect of the target substance flowing out of the target key point.
Optionally, the initial parameters further include an initial velocity, and before rendering the virtual particle based on the initial color information and the initial shape corresponding to the virtual particle to generate the first special effect of the target substance flowing from the target key point, the method further includes:
converting the magnitude and direction of the initial velocity of the virtual particles into a target vector starting from the initial position;
stretching the initial shape corresponding to the virtual particle according to the target vector to obtain a target shape of the virtual particle;
the rendering the virtual particle based on the initial color information and the initial shape corresponding to the virtual particle to generate a first special effect that the target substance flows out from the target key point includes:
rendering the virtual particles based on the initial color information and the target shape to generate a first special effect of the target substance flowing from the target keypoint.
Optionally, the virtual particles comprise a first number of virtual particles; the determining the initial color information of the virtual particles according to the density-color mapping relation, the initial density and the initial position includes:
sequentially rendering a preset texture of each virtual particle at the initial position of the target page according to each virtual particle to obtain a target texture;
extracting the transparency of the position of each virtual particle from the target texture, and taking the transparency of the position of each virtual particle as the density weight of each virtual particle;
calculating the sum of the density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles;
calculating the sum of the density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles and the initial density of the first number of virtual particles;
determining the average density of each pixel point according to the sum of the density weights and the sum of the density weights;
and determining initial color information of the virtual particles on each pixel point according to the density color mapping relation and the average density on each pixel point.
Optionally, after determining the initial color information of the virtual particles on each pixel point according to the density-color mapping relationship and the average density on each pixel point, the method further includes:
acquiring the preset transparency corresponding to each pixel point;
and updating the initial color information of the virtual particles on each pixel point based on the preset transparency corresponding to each pixel point.
Optionally, the initial parameters further include: the initial particle network transmission parameters represent physical properties transmitted to a target grid among physical properties of the virtual particles, and the target grid is obtained by conducting grid subdivision on the target page; the method further comprises the steps of:
determining the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles;
determining a mesh transmission parameter of the target mesh at the moment next to the current moment according to the physical attribute of the target mesh at the current moment, wherein the mesh transmission parameter characterizes the physical attribute transmitted to the virtual particle in the physical attribute of the target mesh;
determining the speed of the virtual particles at the next moment based on the mesh transmission parameters of the target mesh at the next moment;
Determining the position of the virtual particle at the next moment according to the speed of the virtual particle at the next moment, the physical attribute of the target grid at the next moment and the initial position;
determining the density of the virtual particles at the next moment according to the positions of the virtual particles at the next moment;
updating the first special effect to a second special effect of the target substance flowing on the target page based on the density of the next moment, the position of the next moment and the speed of the next moment.
Optionally, the virtual particles include a first number of virtual particles, and determining, according to the position of the virtual particles at the next time, the density of the virtual particles at the next time includes:
determining the number of virtual particles in the preset range of each virtual particle according to the position of the virtual particle at the next moment;
and calculating the density of each virtual particle at the next moment according to the number of the virtual particles in the preset range of each virtual particle.
Optionally, the calculating the density of each virtual particle at the next moment according to the number of virtual particles in the preset range of each virtual particle includes:
Determining an initial density value of each virtual particle at the next moment according to a mapping relation between the number of the virtual particles and the density value and the number of the virtual particles in a preset range of each virtual particle;
taking the virtual particles with the initial density value larger than or equal to a first density threshold value at the next moment as first virtual particles, and taking the first density threshold value as the density of the first virtual particles at the next moment;
taking the virtual particles with the initial density value smaller than or equal to a second density threshold value at the next moment as second virtual particles, and taking the second density threshold value as the density of the second virtual particles at the next moment;
taking the virtual particles with the initial density value at the next moment being larger than the second density threshold and smaller than the first density threshold as third virtual particles, and taking the initial density value of the third virtual particles at the next moment as the density of the third virtual particles at the next moment;
wherein the first density threshold is greater than the second density threshold.
Optionally, the target grid includes a second number of sub-grids; the initial particle network transmission parameters comprise: initial mass and initial momentum; the physical properties include mass and momentum, the virtual particles include a first number of virtual particles, and determining the physical properties of the target grid at the current time according to the initial grid transmission parameters of the virtual particles includes:
Taking the subgrid where each virtual particle is located and the subgrid adjacent to the subgrid as the subgrid associated with each virtual particle, and taking each virtual particle as the associated virtual particle of the subgrid associated with each virtual particle;
calculating transmission influence factors of each virtual particle on the sub-grids associated with each virtual particle according to a moving least square method;
and calculating the mass and the momentum of each sub-network at the current moment according to the initial mass, the initial momentum and the corresponding transmission influence factors of the associated virtual particles of each sub-network.
Optionally, the initial particle network transmission parameters further include: initial deformation gradient, initial volume, and initial elasticity parameters; the physical attribute also comprises stress information; the determining the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles further comprises:
calculating the relative distance between the associated virtual particles of each sub-grid and each sub-grid at the current moment;
determining the elasticity of each sub-grid at the current moment based on a preset elasticity model, the corresponding relative distance of each sub-grid, the initial volume of the associated virtual particles of each sub-grid, the initial deformation gradient and initial elasticity parameters;
Calculating the gravity of each sub-grid at the current moment according to the mass and the gravity acceleration of each sub-grid at the current moment;
and taking the gravity and the elasticity of the second number of sub-grids at the current moment as stress information of the target grid at the current moment.
Optionally, before calculating the gravity of each sub-grid at the current moment according to the mass and the gravity acceleration of each sub-grid at the current moment, the method further comprises:
acquiring direction offset information corresponding to the target grid;
updating the gravity acceleration of each sub-grid at the current moment according to the direction offset information to obtain updated gravity acceleration of each sub-grid at the current moment;
the calculating the gravity of each sub-grid at the current moment according to the mass and the gravity acceleration of each sub-grid at the current moment comprises: and calculating the gravity of each sub-grid at the current moment according to the mass of each sub-grid at the current moment and the updated gravity acceleration.
Optionally, after updating the first special effect to the second special effect of the target substance flowing on the target page based on the density of the next moment, the position of the next moment and the speed of the next moment, updating the next moment to the current moment, the method further includes:
Updating the speed, density and position of the virtual particles at the next moment to the updated speed, density and position of the virtual particles at the current moment respectively;
and repeating the steps from the physical attribute of the target grid at the current moment to the speed based on the density at the next moment, the position at the next moment and the speed at the next moment according to the updated speed, density and position of the virtual particle at the current moment according to the initial grid transmission parameters of the virtual particle, and updating the first special effect into a second special effect of the target substance flowing in the target page so as to update the second special effect into a third special effect of the target substance flowing in the target page.
Optionally, the initial parameters further include initial elasticity parameters, and when the target substance is solid state software, the method further includes:
acquiring the volume of the virtual particles at the updated current moment;
calculating the ratio of the volume of the virtual particles at the updated current moment to the initial volume;
calculating the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
And updating the stress information of the target grid based on the elastic parameters of the virtual particles at the updated current moment.
Optionally, the initial parameters further include an initial deformation gradient, and the method further includes:
acquiring an angular momentum matrix and a rotational inertia matrix of the virtual particles at the updated current moment;
determining the deformation gradient of the virtual particles at the updated current moment according to the angular momentum matrix, the moment of inertia matrix and the initial deformation gradient;
and updating the stress information of the target grid based on the deformation gradient of the virtual particles at the updated current moment.
According to a second aspect of the embodiments of the present disclosure, there is provided a special effect rendering apparatus, including:
an initial parameter acquisition module configured to execute an initial parameter for acquiring virtual particles of a simulation target substance in response to a special effect rendering trigger instruction, the initial parameter representing layout information and motion information of the virtual particles in an initial state;
the target key point determining module is configured to determine target key points of target objects in the target page;
and a special effect rendering module configured to perform rendering of the virtual particles based on the initial parameters to generate a first special effect of the target substance flowing out of the target keypoint.
Optionally, the initial parameters include an initial density, and the special effect rendering module includes:
an initial position determining unit configured to perform determining an initial position of the virtual particle on the target page according to the target key point and the initial density;
an initial color information determining unit configured to perform determination of initial color information of the virtual particles according to a density color mapping relationship, which characterizes a mapping relationship between an average density of the virtual particles on each pixel point and a color, the initial density, and the initial position;
and an effect rendering unit configured to perform rendering of the virtual particles based on the initial color information and an initial shape corresponding to the virtual particles, to generate a first effect in which the target substance flows out from the target key point.
Optionally, the initial parameters further include an initial speed, and the special effect rendering module further includes:
a vector conversion unit configured to perform conversion of a magnitude and a direction of an initial velocity of the virtual particle into a target vector starting from the initial position;
a stretching processing unit configured to perform stretching processing on an initial shape corresponding to the virtual particle according to the target vector to obtain a target shape of the virtual particle;
The special effect rendering unit is further configured to perform rendering of the virtual particles based on the initial color information and the target shape to generate a first special effect in which the target substance flows out from the target keypoint.
Optionally, the virtual particles comprise a first number of virtual particles; the initial color information determination unit includes:
a target texture rendering unit configured to perform rendering of a preset texture of each virtual particle in sequence according to the initial position of each virtual particle on the target page, so as to obtain a target texture;
a density weight determining unit configured to extract a transparency of a position where each virtual particle is located from the target texture, and take the transparency of the position where each virtual particle is located as a density weight of each virtual particle;
a density weight sum calculating unit configured to perform calculation of a sum of density weights of virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles;
a density weighted sum calculating unit configured to perform calculation of a density weighted sum of virtual particles on each pixel point of the target texture based on the density weights of the first number of virtual particles and the initial densities of the first number of virtual particles;
An average density determining unit configured to perform determination of an average density on each pixel point according to a sum of the density weights and a sum of the density weights;
and the initial color information determining subunit is configured to determine initial color information of the virtual particles on each pixel point according to the density color mapping relation and the average density on each pixel point.
Optionally, the initial color information determining unit further includes:
the preset transparency acquisition unit is configured to acquire the preset transparency corresponding to each pixel point;
and the initial color information updating unit is configured to update the initial color information of the virtual particles on each pixel point based on the preset transparency corresponding to each pixel point.
Optionally, the initial parameters further include: the initial particle network transmission parameters represent physical properties transmitted to a target grid among physical properties of the virtual particles, and the target grid is obtained by conducting grid subdivision on the target page; the apparatus further comprises:
the grid physical attribute determining module is configured to determine the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles;
A mesh transmission parameter determination module configured to perform determining a mesh transmission parameter of the target mesh at a time next to the current time according to a physical attribute of the target mesh at the current time, the mesh transmission parameter characterizing a physical attribute transferred to the virtual particle among the physical attributes of the target mesh;
a particle velocity update module configured to perform determining a velocity of the virtual particle at the next time instant based on a mesh transmission parameter of the target mesh at the next time instant;
a particle location update module configured to perform determining a location of the virtual particle at the next time instant based on a speed of the virtual particle at the next time instant, a physical attribute of the target grid at the next time instant, and the initial location;
a particle density update module configured to perform determining a density of the virtual particles at the next time based on a position of the virtual particles at the next time;
a first effect updating module configured to execute updating the first effect to a second effect in which the target substance flows on the target page based on the density at the next time, the position at the next time, and the speed at the next time.
Optionally, the virtual particles include a first number of virtual particles, and the particle density update module includes:
a virtual particle number determination unit configured to perform determination of a virtual particle number within the preset range of each virtual particle according to a position of the virtual particle at the next time;
and a density calculating unit configured to perform calculation of a density of each virtual particle at the next time according to the number of virtual particles within the preset range of each virtual particle.
Optionally, the density calculating unit includes:
an initial density value determining unit configured to determine an initial density value of each virtual particle at the next time according to a mapping relationship between the number of virtual particles and the density value and the number of virtual particles within the preset range of each virtual particle;
a first density determining unit configured to execute virtual particles having an initial density value at the next time that is equal to or greater than a first density threshold as first virtual particles, and to use the first density threshold as a density of the first virtual particles at the next time;
a second density determining unit configured to execute virtual particles having an initial density value at the next time point of equal to or less than a second density threshold value as second virtual particles, the second density threshold value being a density of the second virtual particles at the next time point;
A third density determining unit configured to perform, as a third virtual particle, a virtual particle having an initial density value at the next time that is greater than the second density threshold and smaller than the first density threshold, and to take an initial density value of the third virtual particle at the next time as a density of the third virtual particle at the next time;
wherein the first density threshold is greater than the second density threshold.
Optionally, the target grid includes a second number of sub-grids; the initial particle network transmission parameters comprise: initial mass and initial momentum; the physical properties include mass and momentum, the virtual particles include a first number of virtual particles, and the grid physical property determination module includes:
an associated grid determining unit configured to perform, as a sub-grid associated with each virtual particle, a sub-grid in which the each virtual particle is located, and a sub-grid adjacent to the located sub-grid;
an associated virtual particle determination unit configured to perform an associated virtual particle that makes the each virtual particle a sub-grid associated with the each virtual particle;
a transmission influence factor calculation unit configured to perform calculation of a transmission influence factor of each virtual particle on a sub-grid associated with the each virtual particle according to a moving least square method;
And the mass and momentum calculating unit is configured to calculate the mass and the momentum of each sub-network at the current moment according to the initial mass, the initial momentum and the corresponding transmission influence factors of the associated virtual particles of each sub-network.
Optionally, the initial particle network transmission parameters further include: initial deformation gradient, initial volume, and initial elasticity parameters; the physical attribute also comprises stress information; the grid physical attribute determination module further includes:
a relative distance calculating unit configured to perform calculation of a relative distance between the associated virtual particle of each sub-grid and each sub-grid at the current time;
an elasticity determining unit configured to determine an elasticity of each sub-grid at the current time based on a preset elasticity model, a relative distance corresponding to each sub-grid, an initial volume of associated virtual particles of each sub-grid, an initial deformation gradient, and an initial elasticity parameter;
a gravity calculation unit configured to perform calculation of gravity of each sub-grid at the current time based on mass and gravity acceleration of each sub-grid at the current time;
And the stress information determining unit is configured to take the gravity and the elasticity of the second number of sub-grids at the current moment as stress information of the target grid at the current moment.
Optionally, the grid physical attribute determining module further includes:
a direction offset information acquisition unit configured to perform acquisition of direction offset information corresponding to the target mesh;
a gravitational acceleration updating unit configured to update gravitational acceleration of each sub-grid at the current time according to the direction offset information, and obtain updated gravitational acceleration of each sub-grid at the current time;
the gravity calculation unit is further configured to perform a calculation of the gravity of each sub-grid at the current time according to the mass of each sub-grid at the current time and the updated gravity acceleration.
Optionally, after updating the first special effect to the second special effect of the target substance flowing on the target page based on the density of the next moment, the position of the next moment and the speed of the next moment, updating the next moment to the current moment, the apparatus further includes:
A parameter updating module configured to perform updating of the speed, density and position of the virtual particle at the next moment to the speed, density and position of the virtual particle at the updated current moment, respectively;
and the second special effect updating module is configured to execute the steps of repeating the steps of determining the physical attribute of a target grid at the current moment to the second special effect of the target substance flowing in the target page based on the density, the position and the position of the next moment according to the updated current moment according to the initial grid transmission parameters of the virtual particles, and updating the first special effect to the second special effect of the target substance flowing in the target page according to the density, the position and the position of the next moment.
Optionally, the initial parameters further include initial elasticity parameters, and when the target substance is solid state software, the device further includes:
a volume acquisition module configured to perform acquisition of a volume of the virtual particle at the updated current time;
a volume ratio calculation module configured to perform calculation of a ratio between a volume of the virtual particles at the updated current time and an initial volume;
The elastic parameter updating module is configured to execute the calculation of the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
and the first stress information updating module is configured to execute the updating of the stress information of the target grid based on the elastic parameters of the virtual particles at the updated current moment.
Optionally, the initial parameters further include an initial deformation gradient, and the apparatus further includes:
a matrix acquisition module configured to perform acquisition of an angular momentum matrix and a moment of inertia matrix of the virtual particles at the updated current time;
a deformation gradient determining module configured to perform determining a deformation gradient of the virtual particle at the updated current time according to the angular momentum matrix, the moment of inertia matrix, and the initial deformation gradient;
and the second stress information updating module is configured to execute the updating of the stress information of the target grid based on the deformation gradient of the virtual particle at the updated current moment.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any of the first aspects above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the method of any one of the first aspects of embodiments of the present disclosure.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any one of the first aspects of embodiments of the present disclosure.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
by presetting initial parameters of virtual particles for simulating target substances and determining target key points of target objects in a target page, a first special effect of simulating the real-time online flowing of the target substances from the target key points can be realized, and the preset initial parameters can represent layout information and motion information of the virtual particles in an initial state, so that the authenticity of the rendered special effect can be greatly improved, and the simulation effect is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure and do not constitute an undue limitation on the disclosure.
Fig. 1 is a flowchart illustrating a special effect rendering method according to an exemplary embodiment.
FIG. 2 is a flow chart illustrating a first special effects method for rendering virtual particles based on initial parameters to generate a target substance flowing from a target keypoint, according to an exemplary embodiment;
FIG. 3 is a flow chart illustrating a method for determining initial color information for a virtual particle based on density color mapping, initial density, and initial position, according to an exemplary embodiment;
FIG. 4 is a schematic diagram of a virtual particle not rendered with color information, according to an example embodiment;
FIG. 5 is a flow chart illustrating an effect update based on a first effect according to an exemplary embodiment;
FIG. 6 is a flowchart illustrating a method of determining a physical property of a target grid at a current time based on an initial mass and initial momentum of a first number of virtual particles, according to an exemplary embodiment;
FIG. 7 is a flowchart illustrating another method for determining physical properties of a target grid at a current time based on initial grid drive parameters of virtual particles, according to an exemplary embodiment;
FIG. 8 is a block diagram of an effect rendering apparatus, shown in accordance with an exemplary embodiment;
fig. 9 is a block diagram of an electronic device for effect rendering, according to an example embodiment.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
Fig. 1 is a flowchart illustrating a special effect rendering method according to an exemplary embodiment, and as shown in fig. 1, the special effect rendering method is used in an electronic device such as a terminal, an edge computing node, and the like, and includes the following steps.
In step S101, initial parameters of virtual particles of a simulation target substance are acquired in response to the special effect rendering trigger instruction.
In an alternative embodiment, the user enters the target page for special effect rendering, and then triggers the special effect rendering triggering instruction, and obtains initial parameters of virtual particles simulating the target substance.
In the embodiments of the present disclosure, the target substance may be a continuous substance; alternatively, the target substance may be a liquid such as water, beverage, or the like; alternatively, the target substance may be solid soft body such as snow, jelly, etc.
In the embodiment of the present specification, virtual particles may be used to simulate a target substance at the time of special effect rendering. Specifically, the number of virtual particles simulating the target substance may be a first number, alternatively, the first number may be at least two, alternatively, the first number may be one; in an alternative embodiment, the number of corresponding virtual particles may be set in combination with the computational power of the device; specifically, the stronger the computing power of the device, the more the corresponding number of virtual particles can be; conversely, the weaker the computing power of the device, the smaller the number of corresponding virtual particles, and in general, the better the simulation effect of the special effect that the number of virtual particles is larger.
In the embodiment of the present specification, the initial parameters characterize layout information and motion information of the virtual particles in an initial state. In a specific embodiment, the initial parameters may include physical properties of at least one particle of initial density, initial velocity, elastic parameters, initial mass, initial position, initial volume, initial momentum, and initial deformation gradient; wherein the initial momentum is the product of the initial velocity and the initial mass; alternatively, the elastic parameter may include, but is not limited to, at least one of Young's modulus and Poisson's ratio of the substance.
In step S103, a target key point of the target object in the target page is determined.
In an alternative embodiment, the target keypoints of the target object in the target page with the fixed scene may be preset keypoints in the target page, for example, in a fixed scene simulating a high-level waterfall, since the position of the mountain in the fixed scene is fixed, and accordingly, the target keypoints may be edges (preset keypoints) of the mountain with the fixed position.
In another alternative embodiment, in the case of dynamic changes in the scene in the target page, determining the target keypoints of the target object in the target page may include: detecting a target object in a target page; extracting key points in the target object; a target keypoint is determined from the keypoints.
In an alternative embodiment, the target object may be an object from which the target substance flows out, and in particular, the target object may be different according to the actual application scenario, for example, a scenario simulating a human tear, the target object may be a human face, and the corresponding target substance may be a tear. For example, in a scene simulating a mountain fall, the target object may be a mountain, and the corresponding target substance may be water; for example, a scene in which snow rolls off a snow mountain is simulated, the target object may be a snow mountain, and the corresponding target substance may be snow.
In addition, in practical application, multiple scenes can be simulated based on one target object, for example, when the target object is a human face, in addition to the scene simulating human tear, the scene simulating human running water, human running nasal discharge, human cerebral sack water (corresponding to water flowing out of human ears) and the like can be simulated, and under the condition that one target object corresponds to multiple scenes, the single scene simulation according to the practical requirement can be combined, and at least two scenes can be simulated simultaneously.
In an optional embodiment, in a case that one target object corresponds to a plurality of scenes, extracting the key points in the target object may include extracting the key points corresponding to the plurality of scenes of the target object; correspondingly, before the target key point is determined from the key points, a preset scene selection instruction may be received, and correspondingly, the determining the target key point from the key points may include taking the key point corresponding to the preset scene selection instruction as the target key point. Optionally, the preset scene selection instruction may have different triggering modes in combination with different scenes, for example, the preset scene selection instruction corresponding to the scene simulating the tearing of a person may be triggered by detecting the eye blinking action of the person; the preset scene selection instruction corresponding to the scene simulating the inflow of the human brain bag can be triggered by detecting the action of the brain bag.
In addition, the above-mentioned triggering preset scene selection instruction is only an example, and in practical applications, other triggering methods may be adopted, for example, the preset scene selection instruction may be triggered by a time setting method, and in a specific embodiment, for example, a scene simulating a tear of a person is triggered by 5 seconds, a scene simulating water of a person is triggered by 10 seconds, and the like.
In another optional embodiment, before extracting the key point in the target object or detecting the target object in the target page, the receiving the preset scene selection instruction may also correspond to extracting the key point in the target object corresponding to the preset scene selection instruction.
In an alternative embodiment, detecting the target object and extracting key points of the target object may incorporate corresponding artificial intelligence techniques.
In step S105, virtual particles are rendered based on the initial parameters to generate a first special effect in which the target substance flows out from the target key point.
In an alternative embodiment, as shown in fig. 2, rendering the virtual particles based on the initial parameters to generate a first effect of the target substance flowing from the target keypoint may comprise the steps of:
In step S201, determining an initial position of the virtual particle on the target page according to the target key point and the initial density;
in practical applications, the initial density of a virtual particle may characterize the number of virtual particles within a predetermined range of the virtual particle; correspondingly, under the condition that the number of virtual particles in an initial state and the number of virtual particles in a preset range of each virtual particle are determined, the relative position relation of the virtual particles is fixed, and then, by combining the target key points, the initial position of the first number of virtual particles in the target page under the condition that the target substance to be simulated flows out from the target key points can be determined.
In the above embodiment, the initial position of the virtual particle on the target page is determined by combining the target key points detected in the actual application scene, so that the requirements of different dynamic scenes can be met, and the dynamic determination of the special effect rendering position is realized.
In step S203, initial color information of the virtual particles is determined according to the density-color mapping relationship, the initial density, and the initial position.
In this embodiment of the present disclosure, a density-color mapping relationship may be obtained in advance, and specifically, the density-color mapping relationship may represent a mapping relationship between an average density and a color of virtual particles on each pixel point. In a specific embodiment, the density-color mapping relationship may be: vec3 color=pow (color 0, 2.0×r×r), where vec3 color may represent a color on a certain pixel point covered by at least one virtual particle (generally at least two), and color0 is a preset reference color; vec3 represents a three-dimensional floating point array, i.e., the color information is a three-dimensional floating point array. r is the average density of the virtual particles on the pixel, and pow (color 0, 2.0×r) represents the power of 2.0×r returned to color 0.
In a specific embodiment, when the target substance is water, color0 may be RGB38, 150, 179.
In an alternative embodiment, as shown in fig. 3, determining the initial color information of the virtual particles according to the density-color mapping relation, the initial density, and the initial position may include the steps of:
in step S301, a preset texture of each virtual particle is sequentially rendered according to an initial position of each virtual particle on a target page, so as to obtain a target texture;
in step S303, the transparency of the position of each virtual particle is extracted from the target texture, and the transparency of the position of each virtual particle is taken as the density weight of each virtual particle;
in step S305, calculating the sum of the density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles;
in step S307, calculating a sum of density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles and the initial densities of the first number of virtual particles;
in step S309, determining an average density on each pixel point according to the sum of the density weights and the sum of the density weights;
In step S311, initial color information of the virtual particles on each pixel point is determined according to the density-color mapping relationship and the average density on each pixel point.
In an alternative embodiment, the preset texture of the virtual particles may be rendered on an off-screen floating point texture. In this embodiment of the present disclosure, the off-screen floating-point texture may be a texture preset in the cache, and the rendering of virtual particles may be simulated on the off-screen floating-point texture. The density weight of each virtual particle characterizes the weight of each virtual particle on the covered pixel point.
In one particular embodiment, the average density at each pixel point may be obtained by dividing the density weight by the sum of the density weights.
Correspondingly, the initial color information of the virtual particles on each pixel point is taken as the initial color information of the first number of virtual particles.
In the above embodiment, by simulating the rendering of the virtual particles in advance, the weight of each virtual particle on the covered pixel point can be determined in combination with the simulated rendering result, so that the initial color information of the virtual particle on each pixel point can be rapidly determined, and data support is provided for the subsequent rendering in the actual target page, so that the color of the place with the higher density of the subsequent virtual particle (usually more intense collision) is whiter, and the reality of the special effect is greatly improved.
In an alternative embodiment, to better simulate a liquid such as water, the method may further include, after step S311:
acquiring preset transparency corresponding to each pixel point;
updating initial color information of virtual particles on each pixel point based on the preset transparency corresponding to each pixel point;
accordingly, taking the initial color information of the virtual particles on each pixel point as the initial color information of the first number of virtual particles includes taking the updated initial color information of the virtual particles on each pixel point as the initial color information of the first number of virtual particles.
In an alternative embodiment, the preset transparency may be a transparency determined by combining the sum of the density weights of the virtual particles on each pixel, and in a specific embodiment, the preset transparency may be mask_val=clip (d.y, p1, p 2), where mask_val is a preset transparency corresponding to each pixel, d.y is a sum of the density weights of the virtual particles on each pixel, and p1 is a transparency lower limit value set by combining the actual transparency of the transparent liquid such as water; p2 is the transparency upper limit value set for the actual transparency of the transparent liquid such as the bound water, in a specific embodiment, it is assumed that p1=0.0, p2=0.8, and clip (d.y, 0.0, 0.8) indicates that when the sum of the density weights of the virtual particles at any pixel point is equal to or greater than 0.8, 0.8 is returned; returning to 0 when the sum of the density weights of the virtual particles on any pixel point is less than or equal to 0.0; when the sum of the density weights of the virtual particles on any pixel point is greater than 0.0 and is less than 0.8, the method returns to d.y. Accordingly, the updated initial color information of the virtual particles on each pixel point may be gl_fragcolor=vec4 (color, mask_val), and color is the initial color information of the virtual particles on each pixel point. vec4 represents the color data stored.
In the above embodiment, the simulation effect of simulating the transparent liquid can be effectively improved by updating the preset transparency corresponding to each pixel point into the initial color information corresponding to each pixel point.
In step S205, virtual particles are rendered based on the initial color information and the initial shape corresponding to the virtual particles to generate a first special effect in which the target substance flows out from the target key point.
In the embodiment of the present specification, the first special effect may be a special effect in an initial state in which the simulation target substance flows out from the target key point. In practical applications, when rendering virtual particles, the virtual particles are often square (i.e. initial shape) with a preset texture (preset circular aperture), specifically, as shown in fig. 4, fig. 4 is a schematic diagram of a virtual particle that is not rendered with color information according to an exemplary embodiment.
In this embodiment of the present disclosure, when the first number of virtual particles is rendered, a full-screen rectangular patch corresponding to the target page may be drawn in advance, and the corresponding virtual particles are rendered on each pixel point by combining initial color information and initial shape of the first number of virtual particles in the full-screen rectangular patch, so as to generate a first special effect that the target substance flows out from the target key point.
As can be seen from the technical solutions provided in the embodiments of the present disclosure, by presetting initial parameters of virtual particles simulating a target substance and determining a target key point of a target object in a target page, a first special effect of simulating a real-time online flow of the target substance from the target key point can be achieved, and the preset initial parameters can represent layout information and motion information of the virtual particles in an initial state, so that the reality of the rendered special effect can be greatly improved, and the simulation effect is improved.
In an alternative embodiment, before rendering the virtual particle based on the initial color information and the initial shape corresponding to the virtual particle to generate the first special effect of the target substance flowing from the target key point, the method may further include:
converting the magnitude and direction of the initial velocity of the virtual particles into a target vector starting from the initial position;
stretching the initial shape corresponding to the virtual particle according to the target vector to obtain the target shape of the virtual particle;
rendering the virtual particles based on the initial color information and the initial shape corresponding to the virtual particles to generate a first special effect of the target substance flowing from the target key point includes:
The virtual particles are rendered based on the initial color information and the target shape to generate a first special effect of the target substance flowing from the target keypoint.
The virtual particles based on the squares are directly rendered, so that granular feel is often existed, and the simulated special effects are distorted.
In this embodiment of the present disclosure, in order to reduce a distorted particle feel generated during rendering and improve a special effect simulation effect of rendering, a size and a direction of an initial speed of each virtual particle may be converted into a target vector from an initial position of the virtual particle, and correspondingly, according to the target vector corresponding to each virtual particle, a stretching process is performed on each corresponding initial shape from each initial position to obtain a target shape of a first number of virtual particles, where the target shape of the virtual particle may be a parallelogram, and correspondingly, a preset circular aperture in the initial shape is stretched from a circular shape to an oval shape.
In the above embodiment, the target vector starting from the initial position of the virtual particle is generated according to the magnitude and direction of the virtual particle velocity, and the initial shape of the virtual particle is stretched in combination with the target vector, so that the distorted granular sensation generated during rendering can be reduced, the reality of the rendering special effect is greatly improved, and the simulation effect is improved.
In an alternative embodiment, in the dynamic scenario, the rendered special effects need to be updated continuously, and correspondingly, as shown in fig. 5, fig. 5 is a flowchart illustrating updating of the special effects on the basis of the first special effects according to an exemplary embodiment, and specifically may include the following steps:
in step S501, determining a physical attribute of the target grid at the current moment according to the initial grid transmission parameter of the virtual particle;
in this embodiment of the present disclosure, the target page may be divided into target grids including the second number of sub-grids in advance, that is, the target grids are obtained by performing grid division on the target page. Specifically, the number of sub-grids (second number) may be set in conjunction with the size of the actual page. Accordingly, the initial mesh transmission parameters of the first number of virtual particles at the current time may be transferred to the target mesh. In embodiments of the present disclosure, the initial mesh transmission parameter may characterize a physical attribute of the virtual particle that is transferred to the target mesh.
In an alternative embodiment, the initial mesh transmission parameters may include an initial mass and an initial momentum, and the physical properties of the target mesh may include the mass and momentum, respectively; as shown in fig. 6, determining the physical properties of the target mesh at the current time may include the steps of:
In step S601, a sub-grid in which each virtual particle is located, and a sub-grid adjacent to the located sub-grid are regarded as sub-grids associated with each virtual particle, and each virtual particle is regarded as an associated virtual particle of the sub-grid associated with each virtual particle.
In an alternative embodiment, the adjacent subgrid of a certain subgrid may be a k-order grid adjacent to the subgrid, for example, if k=1, one subgrid is diffused around the subgrid to obtain an adjacent subgrid of the subgrid, and taking the target grid of 3*3 as an example, one subgrid is diffused around the middle subgrid to obtain 8 adjacent subgrids; if k=2, two sub-grids are spread around the sub-grid. Specifically, the size of k can be set according to practical application requirements.
In step S603, a transmission influence factor of each virtual particle on the sub-grid associated with each virtual particle is calculated according to the moving least square method.
In the embodiment of the present disclosure, the transmission influencing factor of each virtual particle on the sub-grid associated with each virtual particle characterizes the mass and momentum of each virtual particle, and the influence degree of the mass and momentum on the sub-grid associated with each virtual particle.
Specifically, the transmission influence factor of each virtual particle on the sub-grid associated with each virtual particle can be calculated in sequence according to the position of each virtual particle, the position of the sub-grid associated with each virtual particle and the relative distance between the two positions and by combining a least square method.
In step S605, the mass and momentum of each sub-network at the current moment is calculated from the initial mass, initial momentum and corresponding transmission influencing factors of the associated virtual particles of each sub-network.
In an alternative embodiment, the quality of each sub-network at the current time may be calculated in conjunction with the following formula:
wherein,representing the quality of the ith sub-grid at the current moment; />Representing the transmission influence factor of the p-th associated virtual particle on the ith sub-grid at the current moment (assuming that the current moment is n moment) (also representing the transmission influence factor of the ith sub-grid on the p-th associated virtual particle at the current moment); />All associated virtual particles representing an ith sub-gridThe transmission influence factors of the ith sub-grid at the current moment; />The mass of the p-th virtual particle at the current time (the mass of the virtual particle is unchanged at different times) is represented.
In an alternative embodiment, the momentum of each sub-network at the current time may be calculated in combination with the following formula:
wherein,representing the momentum of the ith sub-grid at the current moment,/->Representing the position of the ith sub-grid (the position of the grid is unchanged at different moments); />The position of the p-th associated virtual particle at the current time (at the initial time, i.e., the initial position); />Representing the speed of the p-th associated virtual particle at the current time; />And->The affine transformation relation used for maintaining the local velocity can reduce the loss of angular momentum information in the process of converting the momentum of the virtual particles into grid momentum. Specifically, the->Can be a matrix capable of representing the angular momentum of the first number of virtual particles at a moment next to the current moment (angular momentum matrix for short)>A matrix capable of representing moment of inertia of the first number of virtual particles at the present moment (simply referred to as moment of inertia matrix);
in particular, the method comprises the steps of,,/>wherein (1)>Representing transmission influence factors of all associated sub-grids of the p-th virtual particle on the p-th virtual particle at the current moment; />Representing the speed of the ith sub-grid at a time next to the current time.
In the above embodiment, the transmission influence factor of each virtual particle on the sub-grid associated with each virtual particle is calculated by combining the least square method, so that the special effect generation speed can be effectively accelerated, the requirement on the calculation force of equipment is greatly reduced, the wide popularization of the special effect on a large number of equipment with different calculation forces is facilitated, and the quality and momentum of the virtual particle can be transmitted to the grid by combining the transmission influence factor of the virtual particle on the associated sub-grid, and the change of the target substance in the motion process is simulated.
In an alternative embodiment, the initial mesh transmission parameters may further include: initial deformation gradient, initial volume, and initial elasticity parameters; correspondingly, the physical attribute of the target grid can also comprise stress information; accordingly, as shown in fig. 7, according to the initial particle network transmission parameter of the virtual particle, determining the physical attribute of the target mesh at the current moment may further include:
in step S701, calculating a relative distance between each sub-grid and an associated virtual particle of each sub-grid at the current time;
in step S703, determining an elasticity of each sub-grid at the current moment based on the preset elasticity model, the relative distance corresponding to each sub-grid, the initial volume of the associated virtual particle of each sub-grid, the initial deformation gradient, and the initial elasticity parameter;
in step S705, the gravity of each sub-grid at the current time is calculated according to the mass and the gravity acceleration of each sub-grid at the current time;
in step S707, the gravity and the elasticity of the second number of sub-grids at the current moment are used as stress information of the target grid at the current moment.
In an alternative embodiment, the preset elasticity module may include, but is not limited to, a Neo-Hookean superelastic constitutive model or a Fixed-coroted elasticity model.
In the above embodiment, the physical properties of the virtual particles are transferred to the target mesh by combining the initial deformation gradient, the initial volume and the initial elasticity parameters of the virtual particles, so as to simulate the internal force and gravity change of the substance.
In an alternative embodiment, before step S705, the method further includes:
obtaining direction offset information corresponding to a target grid;
updating the gravity acceleration of each sub-grid at the current moment according to the direction offset information to obtain the updated gravity acceleration of each sub-grid at the current moment;
according to the mass and the gravity acceleration of each sub-grid at the current moment, calculating the gravity of each sub-grid at the current moment comprises: and calculating the gravity of each sub-grid at the current moment according to the mass of each sub-grid at the current moment and the updated gravity acceleration.
In practical application, when the device is shifted (moved, rotated, swayed, etc.), the gyroscope event will be triggered, and at this time, the direction shift information corresponding to the gyroscope event is the direction shift information of the target grid, and correspondingly, the gravity acceleration of each sub-grid can be updated by combining the direction shift information, so as to adjust the stress information (gravity in the stress information) of each sub-grid, and further realize the special effect that the gyroscope event can be correspondingly moved, rotated or swayed along with the movement, rotation or swaying of the device.
In step S503, the mesh transmission parameters of the target mesh at the time next to the current time are determined according to the physical properties of the target mesh at the current time.
In the embodiment of the specification, the mesh transmission parameter characterizes the physical attribute transmitted to the virtual particle in the physical attribute of the target mesh; in an alternative embodiment, the mesh transmission parameter may include momentum, and accordingly, the mesh transmission parameter for determining the next time of the target mesh at the current time may be represented by the following formula:
wherein g represents the acceleration of gravity,representing the spring force experienced by the ith sub-grid at the current time. />Representing the weight of the ith sub-grid at the current time. />Representing the momentum of the ith sub-grid at the current moment; />Representing the momentum of the ith sub-grid at the next moment of the current moment; />Representing the simulation time step (i.e. the time difference between the current moment and the moment next to the current moment).
In an alternative embodiment, the simulation time step may be on the order of 10 -4 Second. The smaller the simulation time step, the higher the frequency of simulation effect updates, and correspondingly, the faster the flow rate of the target substance.
In step S505, the velocity of the virtual particle at the next time is determined based on the mesh transmission parameter of the target mesh at the next time.
In an alternative embodiment, determining the velocity of each virtual particle at the next moment may use the following formula:
wherein,the momentum of the p-th virtual particle at the moment next to the current moment is represented, and the mass of the virtual particle is unchanged, so that after the momentum of the virtual particle at the moment next to the current moment is obtained, the speed of the virtual particle at the moment next to the current moment can be obtained by combining the mass of the virtual particle; />Representing transmission influence factors of all associated sub-grids of the p-th virtual particle on the p-th virtual particle at the next moment; />Representing the momentum of the ith sub-grid at the next instant in time.
In step S507, determining the position of the virtual particle at the next moment according to the speed of the virtual particle at the next moment, the physical attribute of the target grid at the next moment and the initial position;
in an alternative embodiment, the position of the first number of virtual particles at the next time instant is determined according to the implicit Euler method in combination with the velocity of the first number of virtual particles at the next time instant, the mass and momentum of the target mesh in the physical properties of the target mesh at the next time instant and the initial position of the first number of virtual particles.
In step S509, the density of the virtual particles at the next time is determined according to the positions of the virtual particles at the next time;
in a specific embodiment, determining the density of the virtual particles at the next time may include: determining the number of virtual particles in a preset range of each virtual particle according to the position of the virtual particle at the next moment; and calculating the density of each virtual particle at the next moment according to the number of the virtual particles in the preset range of each virtual particle.
In the embodiment of the present disclosure, the number of virtual particles within the preset range of each virtual particle may be the number of virtual particles within the range formed by the preset radius centering on each virtual particle. In an alternative embodiment, the preset texture of each virtual particle may be sequentially rendered on the off-screen floating point texture according to the position of each virtual particle at the next moment to obtain the target texture corresponding to the next moment, and then the number of times of rendering the virtual particle in the preset range is sampled from the target texture corresponding to the next moment with each virtual particle as the center to obtain the number of virtual particles in the preset range of each virtual particle.
In a specific embodiment, calculating the density of each virtual particle at the next time according to the number of virtual particles within the preset range of each virtual particle may include:
in an alternative embodiment, the number of virtual particles in the preset range of each virtual particle may be directly substituted into the mapping relationship between the number of virtual particles and the density, so as to obtain the density of each virtual particle at the next moment.
In the embodiment of the present disclosure, the mapping relationship between the number of virtual particles and the density value is as follows:
float density = exp( 0.025*count)
where density is the density and count is the number of virtual particles.
In the above embodiment, the number of virtual particles in the preset range of each virtual particle is counted in combination with the position of the virtual particle at the next moment, and the density of the virtual particles can be updated in combination with the mapping relationship between the number of virtual particles and the density.
In another alternative embodiment, to ensure that the color change of the subsequent special effects is smooth, calculating the density of each virtual particle at the next time according to the number of virtual particles within the preset range of each virtual particle may include:
determining an initial density value of each virtual particle at the next moment according to the mapping relation between the number of the virtual particles and the density value and the number of the virtual particles in a preset range of each virtual particle;
Taking the virtual particles with the initial density value larger than or equal to the first density threshold value at the next moment as first virtual particles, and taking the first density threshold value as the density of the first virtual particles at the next moment;
taking the virtual particles with the initial density value smaller than or equal to a second density threshold value at the next moment as second virtual particles, and taking the second density threshold value as the density of the second virtual particles at the next moment;
taking the virtual particles with the initial density value larger than the second density threshold value and smaller than the first density threshold value at the next moment as third virtual particles, and taking the initial density value of the third virtual particles at the next moment as the density of the third virtual particles at the next moment;
wherein the first density threshold is greater than the second density threshold.
In a specific embodiment, the first density threshold may be 0.9 and the second density threshold may be 0.1.
In the above embodiment, by mapping the density of the virtual particles to a preset interval, the effect of the subsequent rendering can be effectively ensured, the color change is gentle, and the simulation effect is improved.
In step S511, the first special effect is updated to the second special effect in which the target substance flows on the target page based on the density at the next time, the position at the next time, and the speed at the next time.
In an alternative embodiment, updating the first effect to a second effect of the target substance flowing on the target page based on the density at the next time, the location at the next time, and the speed at the next time may include
Determining color information of the virtual particles at the next moment according to the density-color mapping relation, the density at the next moment and the position at the next moment;
and rendering the virtual particles based on the color information at the next moment and the initial shape corresponding to the virtual particles so as to update the first special effect into a second special effect of the target substance flowing on the target page.
Optionally, before rendering the virtual particle based on the color information of the next time and the initial shape corresponding to the virtual particle to update the first special effect to the second special effect of the target substance flowing in the target page, step S511 may further include:
stretching the initial shape corresponding to the virtual particle according to the speed of the next moment to obtain the target shape of the virtual particle at the next moment;
accordingly, rendering the virtual particles based on the color information at the next time and the initial shape corresponding to the virtual particles to update the first effect to the second effect of the target substance flowing in the target page may include rendering the virtual particles based on the color information at the next time and the target shape at the next time to update the first effect to the second effect of the target substance flowing in the target page.
In the embodiment of the present disclosure, the specific details of the step S511 may be referred to the step S105, which is not described herein.
In addition, the special effects are updated continuously along with the time, but the special effects at the subsequent moment are not necessarily flowing out of the target key points, and the target substances can still flow out of the target key points or not flow out of the target key points in combination with the actual scene requirements and the actual operations.
In the above embodiment, the target page is split into the target grids including the second number of sub-grids, and then the physical properties of the virtual particles, such as mass, speed, position, density, and the like, and the physical properties of the target grids are mutually transferred, so that the special effect change at the next moment can be simulated, and the real-time update of the special effect is realized.
In practical applications, the next time may be updated to the current time over time, and correspondingly, after updating the first special effect to the second special effect that the target substance flows in the target page, the method may further include:
and updating the mass, momentum and position of the first number of virtual particles at the next moment to the mass, momentum and position of each virtual particle at the updated current moment respectively, and repeating the steps S501-S511 based on the mass, momentum and position of each virtual particle at the updated current moment to update the second special effect of the target substance flowing in the target page to the third special effect of the target substance flowing in the target page.
In an alternative embodiment, the elastic parameters of the liquid substance do not change during the flow process, but some solid state software changes with the pressure during the flow process, and the elastic parameters of the virtual particles change; specifically, the volume of the virtual particles becomes smaller as the pressure increases, and accordingly, the elastic parameters such as young's modulus and poisson's ratio become larger, and the substance becomes stiffer (for example, the harder the snow becomes). Correspondingly, the elastic parameters of the virtual particles need to be updated, and the elastic parameters are used for updating the elastic force in the stress information of the grid at the next moment so as to simulate various elastic and elastoplastic materials, and when the target substance is solid software, the method can further comprise:
acquiring the volume of the virtual particles at the updated current moment;
calculating the ratio of the volume of the virtual particles at the updated current moment to the initial volume;
calculating the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
and updating the stress information of the target grid based on the updated elastic parameters of the virtual particles at the current moment.
In an alternative embodiment, when the elastic parameters are Young's modulus and Poisson's ratio; the scheme for updating the elastic parameters can be realized by combining the following formulas:
Wherein,representing the ratio of the volume of the p-th virtual particle at the updated current moment to the initial volume;for the preset proportion parameter, +.>Representing an initial poisson's ratio; />Representing the initial Young's modulus; />Representing the Young's modulus of the p-th virtual particle at the updated current moment; />Representing the poisson's ratio of the p-th virtual particle at the updated current time.
In the above embodiment, by combining the volume change condition of the virtual particles in the movement process of the solid-state software, the elastic parameters such as Young's modulus and Poisson's ratio of the substance are updated, so that the property that the solid-state software substance becomes smaller and harder along with the increase of pressure can be effectively simulated, and the simulation effect of the special effect is greatly improved.
In an alternative embodiment, the deformation gradient of the virtual particle also changes during the movement process, so as to form an elastic force on the target grid, and correspondingly, the method further includes:
acquiring an angular momentum matrix and a moment of inertia matrix of the virtual particles at the updated current moment;
according to the angular momentum matrix, the moment of inertia matrix and the initial deformation gradient, determining the deformation gradient of the virtual particles at the updated current moment;
and updating the stress information of the target grid based on the deformation gradient of the virtual particles at the updated current moment.
In an alternative embodiment, the following formula may be used to determine the deformation gradient of each virtual particle at the updated current time:
wherein,representing the deformation gradient of the p-th virtual particle at the updated current moment; />,/>Can be a matrix capable of representing the angular momentum of the first number of virtual particles at the updated current moment (angular momentum matrix for short)>A matrix capable of representing moment of inertia of the first number of virtual particles at the updated current time (simply referred to as moment of inertia matrix); />Representing an initial deformation gradient; />Representing a simulation time step.
Specifically, the step S703 of updating the stress information of the target mesh based on the deformation gradient of the virtual particle at the updated current time may be referred to, and will not be described herein.
In the above embodiment, by combining the updated angular momentum matrix, the updated moment of inertia matrix and the updated initial deformation gradient of the virtual particle, the deformation gradient of the virtual particle in the motion process may be updated, so as to simulate the change situation of stress information such as pressure (i.e. the elastic force received by the target grid) on the target grid in the motion process of the virtual particle.
In the above embodiment, the target page is split into the target grids including the second number of sub-grids, and then the physical properties of the virtual particles, such as mass, speed, position, density, and the like, and the physical properties of the target grids are mutually transferred, so that the special effect change at different moments can be simulated, and vivid special effect simulation can be realized.
Fig. 8 is a block diagram of an effect rendering apparatus according to an exemplary embodiment. Referring to fig. 8, the apparatus includes:
an initial parameter obtaining module 810 configured to perform obtaining initial parameters of the virtual particles of the simulation target substance in response to the special effect rendering trigger instruction, the initial parameters characterizing layout information and motion information of the virtual particles in an initial state;
a target keypoint determination module 820 configured to perform determining target keypoints of target objects in the target page;
the effect rendering module 830 is configured to perform rendering of the virtual particles based on the initial parameters to generate a first effect of the target substance flowing from the target keypoint.
Optionally, the initial parameters include an initial density, and the special effect rendering module 830 includes:
an initial position determining unit configured to perform determining an initial position of the virtual particle on the target page according to the target key point and the initial density;
an initial color information determination unit configured to perform determination of initial color information of the virtual particles according to a density color mapping relationship, which characterizes a mapping relationship between an average density of the virtual particles on each pixel point and a color, an initial density, and an initial position;
And an effect rendering unit configured to perform rendering of the virtual particles based on the initial color information and an initial shape corresponding to the virtual particles to generate a first effect in which the target substance flows out from the target keypoints.
Optionally, the initial parameters further include an initial speed, and the special effect rendering module 830 further includes:
a vector conversion unit configured to perform conversion of a magnitude and a direction of an initial velocity of the virtual particle into a target vector starting from an initial position;
the stretching processing unit is configured to perform stretching processing on the initial shape corresponding to the virtual particle according to the target vector to obtain the target shape of the virtual particle;
the special effect rendering unit is further configured to perform rendering of the virtual particles based on the initial color information and the target shape to generate a first special effect in which the target substance flows out from the target keypoint.
Optionally, the virtual particles comprise a first number of virtual particles; the initial color information determination unit includes:
the target texture rendering unit is configured to sequentially render preset textures of each virtual particle at the initial position of the target page according to each virtual particle to obtain target textures;
a density weight determining unit configured to perform extraction of transparency of a position where each virtual particle is located from the target texture, and take the transparency of the position where each virtual particle is located as a density weight of each virtual particle;
A density weight sum calculating unit configured to perform calculation of a sum of density weights of the virtual particles on each pixel point of the target texture based on the density weights of the first number of virtual particles;
a density weighted sum calculating unit configured to perform calculation of a density weighted sum of the virtual particles on each pixel point of the target texture based on the density weights of the first number of virtual particles and the initial densities of the first number of virtual particles;
an average density determining unit configured to perform determination of an average density on each pixel point according to a sum of the density weights and a sum of the density weights;
an initial color information determination subunit configured to perform determination of initial color information of the virtual particles on each pixel point according to the density color mapping relationship and the average density on each pixel point.
Optionally, the initial color information determining unit further includes:
the preset transparency acquisition unit is configured to acquire the preset transparency corresponding to each pixel point;
and the initial color information updating unit is configured to update the initial color information of the virtual particles on each pixel point based on the preset transparency corresponding to each pixel point.
Optionally, the initial parameters further include: the initial particle network transmission parameters represent physical properties transmitted to a target grid in physical properties of virtual particles, and the target grid is obtained by conducting grid subdivision on a target page; the device further comprises:
the grid physical attribute determining module is configured to determine the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles;
the network grain transmission parameter determining module is configured to determine network grain transmission parameters of the target grid at the next moment of the current moment according to the physical properties of the target grid at the current moment, and the network grain transmission parameters represent the physical properties transmitted to the virtual particles in the physical properties of the target grid;
a particle velocity update module configured to perform determining a velocity of the virtual particle at a next time based on a mesh transmission parameter of the target mesh at the next time;
a particle position updating module configured to perform determining a position of the virtual particle at a next time according to a speed of the virtual particle at the next time, a physical attribute of the target mesh at the next time, and an initial position;
a particle density update module configured to perform determining a density of the virtual particles at a next time based on a position of the virtual particles at the next time;
And a first special effect updating module configured to execute updating the first special effect to a second special effect of the target substance flowing on the target page based on the density at the next moment, the position at the next moment and the speed at the next moment.
Optionally, the virtual particles include a first number of virtual particles, and the particle density update module includes:
a virtual particle number determination unit configured to perform determination of a virtual particle number within a preset range of each virtual particle according to a position of the virtual particle at a next time;
and a density calculating unit configured to perform calculation of a density of each virtual particle at a next time based on the number of virtual particles within a preset range of each virtual particle.
Optionally, the density calculating unit includes:
an initial density value determining unit configured to perform determining an initial density value of each virtual particle at a next time according to a mapping relationship between the number of virtual particles and the density value and the number of virtual particles within a preset range of each virtual particle;
a first density determining unit configured to execute virtual particles having an initial density value equal to or higher than a first density threshold value at a next time as first virtual particles, and to use the first density threshold value as a density of the first virtual particles at the next time;
A second density determining unit configured to execute virtual particles having an initial density value at a next time of equal to or less than a second density threshold value as second virtual particles, the second density threshold value being a density of the second virtual particles at the next time;
a third density determining unit configured to execute virtual particles having an initial density value at a next time greater than the second density threshold and smaller than the first density threshold as third virtual particles, and to execute the initial density value of the third virtual particles at the next time as densities of the third virtual particles at the next time;
wherein the first density threshold is greater than the second density threshold.
Optionally, the target grid comprises a second number of sub-grids; the initial mesh transmission parameters include: initial mass and initial momentum; the physical properties include mass and momentum, the virtual particles include a first number of virtual particles, and the grid physical property determination module includes:
an associated grid determining unit configured to execute a sub-grid in which each virtual particle is located, and a sub-grid adjacent to the located sub-grid as a sub-grid associated with each virtual particle;
an associated virtual particle determination unit configured to execute each virtual particle as an associated virtual particle of a sub-grid associated with each virtual particle;
A transmission influence factor calculation unit configured to perform calculation of a transmission influence factor of each virtual particle on a sub-grid associated with each virtual particle according to a moving least square method;
and a mass-quantity calculating unit configured to perform calculation of mass and momentum of each sub-network at the current time according to the initial mass, initial momentum and corresponding transmission influence factors of the associated virtual particles of each sub-network.
Optionally, the initial mesh transmission parameters further include: initial deformation gradient, initial volume, and initial elasticity parameters; the physical properties also include stress information; the grid physical attribute determining module further includes:
a relative distance calculation unit configured to perform calculation of a relative distance between the associated virtual particle of each sub-grid and each sub-grid at the current time;
the elastic force determining unit is configured to determine the elastic force of each sub-grid at the current moment based on a preset elastic model, the corresponding relative distance of each sub-grid, the initial volume of the associated virtual particle of each sub-grid, the initial deformation gradient and the initial elastic parameters;
a gravity calculation unit configured to perform calculation of a gravity of each sub-grid at a current time based on a mass of each sub-grid at the current time and a gravity acceleration;
And the stress information determining unit is configured to take the gravity and the elasticity of the second number of sub-grids at the current moment as stress information of the target grid at the current moment.
Optionally, the grid physical attribute determining module further includes:
a direction offset information acquisition unit configured to perform acquisition of direction offset information corresponding to the target mesh;
the gravity acceleration updating unit is configured to update the gravity acceleration of each sub-grid at the current moment according to the direction deviation information to obtain updated gravity acceleration of each sub-grid at the current moment;
the gravity calculation unit is further configured to perform a calculation of the gravity of each sub-grid at the current time based on the mass of each sub-grid at the current time and the updated gravity acceleration.
Optionally, after updating the first special effect to the second special effect of the target substance flowing in the target page based on the density at the next time, the position at the next time and the speed at the next time, updating the next time to the current time, the apparatus further includes:
the parameter updating module is configured to update the speed, the density and the position of the virtual particle at the next moment to the speed, the density and the position of the virtual particle at the updated current moment respectively;
The second special effect updating module is configured to execute the steps of repeating the initial particle network transmission parameters according to the virtual particles based on the updated speed, density and position of the virtual particles at the current moment, determining the physical attribute of the target grid at the current moment to a second special effect of the target substance flowing in the target page based on the density at the next moment, the position at the next moment and the speed at the next moment, and updating the first special effect to a third special effect of the target substance flowing in the target page.
Optionally, the initial parameters further include initial elasticity parameters, and when the target substance is solid-state software, the apparatus further includes:
a volume acquisition module configured to perform acquisition of a volume of the virtual particle at the updated current time;
the volume ratio calculating module is configured to execute calculation of the ratio of the volume of the virtual particles at the updated current moment to the initial volume;
the elastic parameter updating module is configured to execute the calculation of the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
the first stress information updating module is configured to update stress information of the target grid based on the elastic parameters of the virtual particles at the updated current moment.
Optionally, the initial parameters further include an initial deformation gradient, and the apparatus further includes:
the matrix acquisition module is configured to acquire an angular momentum matrix and a rotational inertia matrix of the virtual particles at the updated current moment;
the deformation gradient determining module is configured to determine the deformation gradient of the virtual particle at the updated current moment according to the angular momentum matrix, the moment of inertia matrix and the initial deformation gradient;
and the second stress information updating module is configured to update the stress information of the target grid based on the deformation gradient of the virtual particle at the updated current moment.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Fig. 9 is a block diagram illustrating an electronic device for effect rendering, which may be a terminal, according to an exemplary embodiment, and an internal structure diagram thereof may be as shown in fig. 9. The electronic device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of effect rendering. The display screen of the electronic equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the electronic equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the disclosed aspects and is not limiting of the electronic device to which the disclosed aspects apply, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an exemplary embodiment, there is also provided an electronic device including: a processor; and a memory for storing the processor-executable instructions, wherein the processor is configured to execute the instructions to implement the effect rendering method as in the embodiments of the present disclosure.
In an exemplary embodiment, a storage medium is also provided, which when executed by a processor of an electronic device, enables the electronic device to perform the special effects rendering method in the embodiments of the present disclosure.
In an exemplary embodiment, a computer program product containing instructions that, when run on a computer, cause the computer to perform the effect rendering method in the embodiments of the present disclosure is also provided.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (28)

1. A special effect rendering method is characterized by comprising the following steps of
Responding to a special effect rendering trigger instruction, and acquiring initial parameters of virtual particles of a simulation target substance, wherein the initial parameters represent layout information and motion information of the virtual particles in an initial state; the initial parameters include an initial density;
determining target key points of target objects in a target page;
Determining the initial position of the virtual particle on the target page according to the target key point and the initial density;
determining initial color information of the virtual particles according to a density-color mapping relation, the initial density and the initial position, wherein the density-color mapping relation represents the mapping relation between the average density and the color of the virtual particles on each pixel point;
rendering the virtual particles based on the initial color information and the initial shape corresponding to the virtual particles to generate a first special effect of the target substance flowing out of the target key point.
2. The special effect rendering method of claim 1, wherein the initial parameters further comprise an initial velocity, the method further comprising, prior to rendering the virtual particles based on the initial color information and an initial shape corresponding to the virtual particles to generate a first special effect of the target substance flowing from the target keypoint:
converting the magnitude and direction of the initial velocity of the virtual particles into a target vector starting from the initial position;
stretching the initial shape corresponding to the virtual particle according to the target vector to obtain a target shape of the virtual particle;
The rendering the virtual particle based on the initial color information and the initial shape corresponding to the virtual particle to generate a first special effect that the target substance flows out from the target key point includes:
rendering the virtual particles based on the initial color information and the target shape to generate a first special effect of the target substance flowing from the target keypoint.
3. The special effect rendering method of claim 1, wherein the virtual particles comprise a first number of virtual particles; the determining the initial color information of the virtual particles according to the density-color mapping relation, the initial density and the initial position includes:
sequentially rendering a preset texture of each virtual particle at the initial position of the target page according to each virtual particle to obtain a target texture;
extracting the transparency of the position of each virtual particle from the target texture, and taking the transparency of the position of each virtual particle as the density weight of each virtual particle;
calculating the sum of the density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles;
Calculating the sum of the density weights of the virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles and the initial density of the first number of virtual particles;
determining the average density of each pixel point according to the sum of the density weights and the sum of the density weights;
and determining initial color information of the virtual particles on each pixel point according to the density color mapping relation and the average density on each pixel point.
4. The special effect rendering method according to claim 3, wherein after determining the initial color information of the virtual particles on each pixel point according to the density color mapping relation and the average density on each pixel point, the method further comprises:
acquiring the preset transparency corresponding to each pixel point;
and updating the initial color information of the virtual particles on each pixel point based on the preset transparency corresponding to each pixel point.
5. The special effect rendering method according to any one of claims 1 to 4, wherein the initial parameters further include: the initial particle network transmission parameters represent physical properties transmitted to a target grid among physical properties of the virtual particles, and the target grid is obtained by conducting grid subdivision on the target page; the method further comprises the steps of:
Determining the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles;
determining a mesh transmission parameter of the target mesh at the moment next to the current moment according to the physical attribute of the target mesh at the current moment, wherein the mesh transmission parameter characterizes the physical attribute transmitted to the virtual particle in the physical attribute of the target mesh;
determining the speed of the virtual particles at the next moment based on the mesh transmission parameters of the target mesh at the next moment;
determining the position of the virtual particle at the next moment according to the speed of the virtual particle at the next moment, the physical attribute of the target grid at the next moment and the initial position;
determining the density of the virtual particles at the next moment according to the positions of the virtual particles at the next moment;
updating the first special effect to a second special effect of the target substance flowing on the target page based on the density of the next moment, the position of the next moment and the speed of the next moment.
6. The special effect rendering method of claim 5, wherein the virtual particles comprise a first number of virtual particles, and wherein determining the density of the virtual particles at the next time based on the position of the virtual particles at the next time comprises:
Determining the number of virtual particles in the preset range of each virtual particle according to the position of the virtual particle at the next moment;
and calculating the density of each virtual particle at the next moment according to the number of the virtual particles in the preset range of each virtual particle.
7. The special effect rendering method according to claim 6, wherein calculating the density of each virtual particle at the next time according to the number of virtual particles within the preset range of each virtual particle comprises:
determining an initial density value of each virtual particle at the next moment according to a mapping relation between the number of the virtual particles and the density value and the number of the virtual particles in a preset range of each virtual particle;
taking the virtual particles with the initial density value larger than or equal to a first density threshold value at the next moment as first virtual particles, and taking the first density threshold value as the density of the first virtual particles at the next moment;
taking the virtual particles with the initial density value smaller than or equal to a second density threshold value at the next moment as second virtual particles, and taking the second density threshold value as the density of the second virtual particles at the next moment;
Taking the virtual particles with the initial density value at the next moment being larger than the second density threshold and smaller than the first density threshold as third virtual particles, and taking the initial density value of the third virtual particles at the next moment as the density of the third virtual particles at the next moment;
wherein the first density threshold is greater than the second density threshold.
8. The special effect rendering method of claim 5, wherein the target grid comprises a second number of sub-grids; the initial particle network transmission parameters comprise: initial mass and initial momentum; the physical properties include mass and momentum, the virtual particles include a first number of virtual particles, and the determining the physical properties of the target grid at the current time according to the initial grid transmission parameters of the virtual particles includes:
taking the subgrid where each virtual particle is located and the subgrid adjacent to the subgrid as the subgrid associated with each virtual particle, and taking each virtual particle as the associated virtual particle of the subgrid associated with each virtual particle;
calculating transmission influence factors of each virtual particle on the sub-grids associated with each virtual particle according to a moving least square method;
And calculating the mass and the momentum of each sub-network at the current moment according to the initial mass, the initial momentum and the corresponding transmission influence factors of the associated virtual particles of each sub-network.
9. The special effect rendering method of claim 8, wherein the initial mesh transmission parameters further comprise: initial deformation gradient, initial volume, and initial elasticity parameters; the physical attribute also comprises stress information; the determining the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles further comprises:
calculating the relative distance between the associated virtual particles of each sub-grid and each sub-grid at the current moment;
determining the elasticity of each sub-grid at the current moment based on a preset elasticity model, the corresponding relative distance of each sub-grid, the initial volume of the associated virtual particles of each sub-grid, the initial deformation gradient and initial elasticity parameters;
calculating the gravity of each sub-grid at the current moment according to the mass and the gravity acceleration of each sub-grid at the current moment;
and taking the gravity and the elasticity of the second number of sub-grids at the current moment as stress information of the target grid at the current moment.
10. The special effect rendering method of claim 9, wherein before calculating the gravity of each sub-grid at the current time according to the mass and the gravity acceleration of each sub-grid at the current time, the method further comprises:
acquiring direction offset information corresponding to the target grid;
updating the gravity acceleration of each sub-grid at the current moment according to the direction offset information to obtain updated gravity acceleration of each sub-grid at the current moment;
the calculating the gravity of each sub-grid at the current moment according to the mass and the gravity acceleration of each sub-grid at the current moment comprises: and calculating the gravity of each sub-grid at the current moment according to the mass of each sub-grid at the current moment and the updated gravity acceleration.
11. The special effect rendering method according to claim 5, wherein after updating the first special effect to the second special effect of the target substance flowing on the target page based on the density of the next time, the position of the next time, and the speed of the next time, the method further comprises:
Updating the speed, density and position of the virtual particles at the next moment to the updated speed, density and position of the virtual particles at the current moment respectively;
and repeating the steps from the physical attribute of the target grid at the current moment to the speed based on the density at the next moment, the position at the next moment and the speed at the next moment according to the updated speed, density and position of the virtual particle at the current moment according to the initial grid transmission parameters of the virtual particle, and updating the first special effect into a second special effect of the target substance flowing in the target page so as to update the second special effect into a third special effect of the target substance flowing in the target page.
12. The special effect rendering method of claim 11, wherein the initial parameters further comprise initial elasticity parameters, and wherein when the target substance is solid state software, the method further comprises:
acquiring the volume of the virtual particles at the updated current moment;
calculating the ratio of the volume of the virtual particles at the updated current moment to the initial volume;
calculating the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
And updating the stress information of the target grid based on the elastic parameters of the virtual particles at the updated current moment.
13. The special effect rendering method of claim 11, wherein the initial parameters further comprise an initial deformation gradient, the method further comprising:
acquiring an angular momentum matrix and a rotational inertia matrix of the virtual particles at the updated current moment;
determining the deformation gradient of the virtual particles at the updated current moment according to the angular momentum matrix, the moment of inertia matrix and the initial deformation gradient;
and updating the stress information of the target grid based on the deformation gradient of the virtual particles at the updated current moment.
14. A special effect rendering apparatus, comprising:
an initial parameter acquisition module configured to execute an initial parameter for acquiring virtual particles of a simulation target substance in response to a special effect rendering trigger instruction, the initial parameter representing layout information and motion information of the virtual particles in an initial state; the initial parameters include an initial density;
the target key point determining module is configured to determine target key points of target objects in the target page;
A special effect rendering module, the special effect rendering module comprising: an initial position determining unit configured to perform determining an initial position of the virtual particle on the target page according to the target key point and the initial density; an initial color information determining unit configured to perform determination of initial color information of the virtual particles according to a density color mapping relationship, which characterizes a mapping relationship between an average density of the virtual particles on each pixel point and a color, the initial density, and the initial position; and an effect rendering unit configured to perform rendering of the virtual particles based on the initial color information and an initial shape corresponding to the virtual particles, to generate a first effect in which the target substance flows out from the target key point.
15. The special effects rendering apparatus of claim 14, wherein the initial parameters further comprise an initial speed, the special effects rendering module further comprising:
a vector conversion unit configured to perform conversion of a magnitude and a direction of an initial velocity of the virtual particle into a target vector starting from the initial position;
a stretching processing unit configured to perform stretching processing on an initial shape corresponding to the virtual particle according to the target vector to obtain a target shape of the virtual particle;
The special effect rendering unit is further configured to perform rendering of the virtual particles based on the initial color information and the target shape to generate a first special effect in which the target substance flows out from the target keypoint.
16. The special effects rendering apparatus of claim 14, wherein the virtual particles comprise a first number of virtual particles; the initial color information determination unit includes:
a target texture rendering unit configured to perform rendering of a preset texture of each virtual particle in sequence according to the initial position of each virtual particle on the target page, so as to obtain a target texture;
a density weight determining unit configured to extract a transparency of a position where each virtual particle is located from the target texture, and take the transparency of the position where each virtual particle is located as a density weight of each virtual particle;
a density weight sum calculating unit configured to perform calculation of a sum of density weights of virtual particles on each pixel point of the target texture according to the density weights of the first number of virtual particles;
a density weighted sum calculating unit configured to perform calculation of a density weighted sum of virtual particles on each pixel point of the target texture based on the density weights of the first number of virtual particles and the initial densities of the first number of virtual particles;
An average density determining unit configured to perform determination of an average density on each pixel point according to a sum of the density weights and a sum of the density weights;
and the initial color information determining subunit is configured to determine initial color information of the virtual particles on each pixel point according to the density color mapping relation and the average density on each pixel point.
17. The special effect rendering apparatus of claim 16, wherein the initial color information determination unit further comprises:
the preset transparency acquisition unit is configured to acquire the preset transparency corresponding to each pixel point;
and the initial color information updating unit is configured to update the initial color information of the virtual particles on each pixel point based on the preset transparency corresponding to each pixel point.
18. The special effect rendering apparatus of any one of claims 14 to 17, wherein the initial parameters further include: the initial particle network transmission parameters represent physical properties transmitted to a target grid among physical properties of the virtual particles, and the target grid is obtained by conducting grid subdivision on the target page; the apparatus further comprises:
The grid physical attribute determining module is configured to determine the physical attribute of the target grid at the current moment according to the initial grid transmission parameters of the virtual particles;
a mesh transmission parameter determination module configured to perform determining a mesh transmission parameter of the target mesh at a time next to the current time according to a physical attribute of the target mesh at the current time, the mesh transmission parameter characterizing a physical attribute transferred to the virtual particle among the physical attributes of the target mesh;
a particle velocity update module configured to perform determining a velocity of the virtual particle at the next time instant based on a mesh transmission parameter of the target mesh at the next time instant;
a particle location update module configured to perform determining a location of the virtual particle at the next time instant based on a speed of the virtual particle at the next time instant, a physical attribute of the target grid at the next time instant, and the initial location;
a particle density update module configured to perform determining a density of the virtual particles at the next time based on a position of the virtual particles at the next time;
A first effect updating module configured to execute updating the first effect to a second effect in which the target substance flows on the target page based on the density at the next time, the position at the next time, and the speed at the next time.
19. The special effects rendering apparatus of claim 18, wherein the virtual particles comprise a first number of virtual particles, the particle density update module comprising:
a virtual particle number determination unit configured to perform determination of a virtual particle number within the preset range of each virtual particle according to a position of the virtual particle at the next time;
and a density calculating unit configured to perform calculation of a density of each virtual particle at the next time according to the number of virtual particles within the preset range of each virtual particle.
20. The special effect rendering apparatus according to claim 19, wherein the density calculating unit includes:
an initial density value determining unit configured to determine an initial density value of each virtual particle at the next time according to a mapping relationship between the number of virtual particles and the density value and the number of virtual particles within the preset range of each virtual particle;
A first density determining unit configured to execute virtual particles having an initial density value at the next time that is equal to or greater than a first density threshold as first virtual particles, and to use the first density threshold as a density of the first virtual particles at the next time;
a second density determining unit configured to execute virtual particles having an initial density value at the next time point of equal to or less than a second density threshold value as second virtual particles, the second density threshold value being a density of the second virtual particles at the next time point;
a third density determining unit configured to perform, as a third virtual particle, a virtual particle having an initial density value at the next time that is greater than the second density threshold and smaller than the first density threshold, and to take an initial density value of the third virtual particle at the next time as a density of the third virtual particle at the next time;
wherein the first density threshold is greater than the second density threshold.
21. The special effects rendering apparatus of claim 18, wherein the target grid comprises a second number of sub-grids; the initial particle network transmission parameters comprise: initial mass and initial momentum; the physical properties include mass and momentum, the virtual particles include a first number of virtual particles, and the grid physical property determination module includes:
An associated grid determining unit configured to perform, as a sub-grid associated with each virtual particle, a sub-grid in which the each virtual particle is located, and a sub-grid adjacent to the located sub-grid;
an associated virtual particle determination unit configured to perform an associated virtual particle that makes the each virtual particle a sub-grid associated with the each virtual particle;
a transmission influence factor calculation unit configured to perform calculation of a transmission influence factor of each virtual particle on a sub-grid associated with the each virtual particle according to a moving least square method;
and the mass and momentum calculating unit is configured to calculate the mass and the momentum of each sub-network at the current moment according to the initial mass, the initial momentum and the corresponding transmission influence factors of the associated virtual particles of each sub-network.
22. The special effects rendering apparatus of claim 21, wherein the initial mesh transmission parameters further comprise: initial deformation gradient, initial volume, and initial elasticity parameters; the physical attribute also comprises stress information; the grid physical attribute determination module further includes:
a relative distance calculating unit configured to perform calculation of a relative distance between the associated virtual particle of each sub-grid and each sub-grid at the current time;
An elasticity determining unit configured to determine an elasticity of each sub-grid at the current time based on a preset elasticity model, a relative distance corresponding to each sub-grid, an initial volume of associated virtual particles of each sub-grid, an initial deformation gradient, and an initial elasticity parameter;
a gravity calculation unit configured to perform calculation of gravity of each sub-grid at the current time based on mass and gravity acceleration of each sub-grid at the current time;
and the stress information determining unit is configured to take the gravity and the elasticity of the second number of sub-grids at the current moment as stress information of the target grid at the current moment.
23. The special effects rendering apparatus of claim 22, wherein the grid physical attribute determination module further comprises:
a direction offset information acquisition unit configured to perform acquisition of direction offset information corresponding to the target mesh;
a gravitational acceleration updating unit configured to update gravitational acceleration of each sub-grid at the current time according to the direction offset information, and obtain updated gravitational acceleration of each sub-grid at the current time;
The gravity calculation unit is further configured to perform a calculation of the gravity of each sub-grid at the current time according to the mass of each sub-grid at the current time and the updated gravity acceleration.
24. The special effects rendering apparatus of claim 18, wherein after updating the first special effects to the second special effects of the target substance flowing on the target page based on the density of the next time, the position of the next time, and the speed of the next time, the apparatus further comprises:
a parameter updating module configured to perform updating of the speed, density and position of the virtual particle at the next moment to the speed, density and position of the virtual particle at the updated current moment, respectively;
and the second special effect updating module is configured to execute the steps of repeating the steps of determining the physical attribute of a target grid at the current moment to the second special effect of the target substance flowing in the target page based on the density, the position and the position of the next moment according to the updated current moment according to the initial grid transmission parameters of the virtual particles, and updating the first special effect to the second special effect of the target substance flowing in the target page according to the density, the position and the position of the next moment.
25. The special effects rendering apparatus of claim 24, wherein the initial parameters further comprise initial elasticity parameters, and wherein when the target substance is solid state software, the apparatus further comprises:
a volume acquisition module configured to perform acquisition of a volume of the virtual particle at the updated current time;
a volume ratio calculation module configured to perform calculation of a ratio between a volume of the virtual particles at the updated current time and an initial volume;
the elastic parameter updating module is configured to execute the calculation of the elastic parameter of the virtual particle at the updated current moment according to the initial elastic parameter of the virtual particle and the corresponding ratio;
and the first stress information updating module is configured to execute the updating of the stress information of the target grid based on the elastic parameters of the virtual particles at the updated current moment.
26. The special effects rendering apparatus of claim 24, wherein the initial parameters further comprise an initial deformation gradient, the apparatus further comprising:
a matrix acquisition module configured to perform acquisition of an angular momentum matrix and a moment of inertia matrix of the virtual particles at the updated current time;
A deformation gradient determining module configured to perform determining a deformation gradient of the virtual particle at the updated current time according to the angular momentum matrix, the moment of inertia matrix, and the initial deformation gradient;
and the second stress information updating module is configured to execute the updating of the stress information of the target grid based on the deformation gradient of the virtual particle at the updated current moment.
27. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the special effect rendering method of any one of claims 1 to 13.
28. A computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the special effect rendering method of any one of claims 1 to 13.
CN202011241946.9A 2020-11-09 2020-11-09 Special effect rendering method and device, electronic equipment and storage medium Active CN112446942B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011241946.9A CN112446942B (en) 2020-11-09 2020-11-09 Special effect rendering method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011241946.9A CN112446942B (en) 2020-11-09 2020-11-09 Special effect rendering method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112446942A CN112446942A (en) 2021-03-05
CN112446942B true CN112446942B (en) 2023-12-19

Family

ID=74736593

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011241946.9A Active CN112446942B (en) 2020-11-09 2020-11-09 Special effect rendering method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112446942B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378445B (en) * 2021-05-10 2024-02-02 中国科学院过程工程研究所 Gas-liquid multiphase system calculation method and system based on discrete simulation
CN113486591B (en) * 2021-07-13 2022-04-19 吉林大学 Gravity multi-parameter data density weighted inversion method for convolutional neural network result
CN113521738B (en) * 2021-08-11 2024-07-16 网易(杭州)网络有限公司 Special effect generation method and device, computer readable storage medium and electronic equipment
CN115994972A (en) * 2021-10-18 2023-04-21 北京字节跳动网络技术有限公司 Special effect processing method and equipment
CN113689534B (en) * 2021-10-25 2022-03-01 腾讯科技(深圳)有限公司 Physical special effect rendering method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101710465A (en) * 2009-12-16 2010-05-19 西南石油大学 Method for simulating drilling tool lifting for drilling simulator
WO2019052313A1 (en) * 2017-09-13 2019-03-21 腾讯科技(深圳)有限公司 Liquid simulation method, liquid interaction method and apparatus
CN109583385A (en) * 2018-11-30 2019-04-05 深圳市脸萌科技有限公司 Face image processing process, device, electronic equipment and computer storage medium
CN110427131A (en) * 2019-07-26 2019-11-08 珠海豹趣科技有限公司 Cartoon display method and device based on pressing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101710465A (en) * 2009-12-16 2010-05-19 西南石油大学 Method for simulating drilling tool lifting for drilling simulator
WO2019052313A1 (en) * 2017-09-13 2019-03-21 腾讯科技(深圳)有限公司 Liquid simulation method, liquid interaction method and apparatus
CN109583385A (en) * 2018-11-30 2019-04-05 深圳市脸萌科技有限公司 Face image processing process, device, electronic equipment and computer storage medium
CN110427131A (en) * 2019-07-26 2019-11-08 珠海豹趣科技有限公司 Cartoon display method and device based on pressing

Also Published As

Publication number Publication date
CN112446942A (en) 2021-03-05

Similar Documents

Publication Publication Date Title
CN112446942B (en) Special effect rendering method and device, electronic equipment and storage medium
EP4006843A1 (en) Animation implementation method and apparatus, electronic device, and storage medium
EP4009282A1 (en) Animation processing method and apparatus, and computer storage medium and electronic device
CN110827383B (en) Attitude simulation method and device of three-dimensional model, storage medium and electronic equipment
CN104200506B (en) Three-dimension GIS massive vector data rendering intent and device
US7864181B1 (en) Shape friction: shape preservation of simulated objects in computer animation
US7864180B1 (en) Methods and apparatus for auto-scaling properties of simulated objects
CN112363402B (en) Gait training method and device of foot type robot based on model-related reinforcement learning, electronic equipment and medium
CN105243375B (en) A kind of motion characteristic extracting method and device
CN103400023A (en) Soft tissue deformation simulation method
US20190108300A1 (en) Methods for realistic and efficient simulation of moving objects
CN109191593A (en) Motion control method, device and the equipment of virtual three-dimensional model
CN108491619A (en) Based on physics and the non-physical complex scene fluid structurecoupling efficient analogy method mixed
CN112598769A (en) Special effect rendering method and device, electronic equipment and computer readable storage medium
CN111494945A (en) Virtual object processing method and device, storage medium and electronic equipment
US8194079B2 (en) Inertial field generator: a method for controllably coupling kinematic character motions to dynamically simulated elements
CN110427864A (en) A kind of image processing method, device and electronic equipment
CN109407825A (en) Interactive approach and device based on virtual objects
CN105528188B (en) The method and apparatus of browsing pictures
CN109542210B (en) Virtual engine-based arm motion simulation reduction method and storage medium
CN106200923A (en) The control method of a kind of virtual reality system and device
CN115661935B (en) Human body action accuracy determining method and device
CN109597480A (en) Man-machine interaction method, device, electronic equipment and computer readable storage medium
CN115861500B (en) 2D model collision body generation method and device
CN117557699B (en) Animation data generation method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant