CN116993877A - Method, device and storage medium for simulating special effect of object drifting - Google Patents
Method, device and storage medium for simulating special effect of object drifting Download PDFInfo
- Publication number
- CN116993877A CN116993877A CN202311005139.0A CN202311005139A CN116993877A CN 116993877 A CN116993877 A CN 116993877A CN 202311005139 A CN202311005139 A CN 202311005139A CN 116993877 A CN116993877 A CN 116993877A
- Authority
- CN
- China
- Prior art keywords
- particle
- special effect
- attribute
- target image
- preset
- 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.)
- Granted
Links
- 230000000694 effects Effects 0.000 title claims abstract description 119
- 238000000034 method Methods 0.000 title claims abstract description 31
- 239000002245 particle Substances 0.000 claims abstract description 127
- 238000004088 simulation Methods 0.000 claims abstract description 40
- 238000004364 calculation method Methods 0.000 claims abstract description 28
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 23
- 238000012545 processing Methods 0.000 claims abstract description 21
- 238000005259 measurement Methods 0.000 claims abstract description 8
- 238000004458 analytical method Methods 0.000 claims abstract description 7
- 239000011159 matrix material Substances 0.000 claims abstract description 7
- 230000006870 function Effects 0.000 claims description 20
- 238000012986 modification Methods 0.000 claims description 18
- 230000004048 modification Effects 0.000 claims description 18
- 238000007667 floating Methods 0.000 claims description 9
- 230000008859 change Effects 0.000 claims description 7
- 230000007306 turnover Effects 0.000 claims description 6
- 238000010276 construction Methods 0.000 claims description 3
- 238000004590 computer program Methods 0.000 claims 2
- 238000009877 rendering Methods 0.000 claims 2
- 230000009466 transformation Effects 0.000 description 7
- 101100491335 Caenorhabditis elegans mat-2 gene Proteins 0.000 description 5
- 230000000007 visual effect Effects 0.000 description 5
- 230000005484 gravity Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000013519 translation Methods 0.000 description 3
- 230000009471 action Effects 0.000 description 2
- 238000003384 imaging method Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 241000533950 Leucojum Species 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000010606 normalization Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 238000012827 research and development Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T13/00—Animation
- G06T13/20—3D [Three Dimensional] animation
- G06T13/60—3D [Three Dimensional] animation of natural phenomena, e.g. rain, snow, water or plants
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/80—Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
- H04N21/81—Monomedia components thereof
- H04N21/816—Monomedia components thereof involving special video data, e.g 3D video
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/80—Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
- H04N21/85—Assembly of content; Generation of multimedia applications
- H04N21/854—Content authoring
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2210/00—Indexing scheme for image generation or computer graphics
- G06T2210/56—Particle system, point based geometry or rendering
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Generation (AREA)
Abstract
The invention relates to the field of special effects display, and discloses a method for simulating a special effect of object drift, which comprises the following steps: receiving a target image to be subjected to special effect simulation; according to a center analysis algorithm, performing center calculation processing on the preset particle clustering attribute to obtain a particle center point coordinate; according to a size operation formula, performing matrix field size calculation on the particle clustering attribute to obtain a particle rectangular field and a particle rectangular field size value; performing distance measurement and calculation on a display interface of the target image and a particle rectangular field size value to obtain a display distance value; judging whether the display distance value is smaller than zero; if the display distance value is smaller than zero, modifying and drawing the particle cluster attribute to obtain a special effect drawing pixel set; and performing filter drawing processing on the target image to obtain the target image with the special effect simulation of object drift. In the embodiment of the invention, the technical problem that the current filter effect has poor display effect on the special effect of the object drifting of different image shapes and sizes is solved.
Description
Technical Field
The present invention relates to the field of displaying special effects, and in particular, to a method, an apparatus, and a storage medium for simulating a special effect of an object falling.
Background
Filters are indeed very common applications in the field of graphics processing, and play an important role in particular in the field of special effects. The filters may change the appearance, color, contrast, etc. properties of the image or video, thereby providing a unique visual experience to the user.
However, in the existing market, there are general problems that the development degree of the filter effect is not high and the customization ability is limited. This is mainly due to the following reasons:
1. algorithm complexity and performance requirements, filters typically require complex operations and processing of images. In practical application, the filter algorithm is required to have a good effect, and also consider the consumption of computing resources and the requirement of real-time performance. For some complex filter effects, it is difficult to combine both high quality effects and real-time performance.
2. General applicability and applicability filters on the market are generally designed to meet a wide range of user demands, so their design targets are general applicability and applicability in order to cover more application scenes. This results in the effect of the filter may not fully meet certain specific requirements, limiting its ability to customize.
3. Development resources and time costs, development of filter effects requires a significant amount of time and effort. For some filter effects, which are more complex or unique, more research and development work may be required. This makes customizing the filter effect more difficult and expensive.
Therefore, in order to solve the technical problem that the current filter effect is not customized for different image displays, and the display effect of special effects on objects with different image shapes and sizes is not good, a new technology is needed to solve the current problem.
Disclosure of Invention
The invention mainly aims to solve the technical problems that the current filter effect is insufficient in customization of different image displays and the display effect of special effects on drifting of objects with different image shapes and sizes is poor.
The first aspect of the invention provides a method for simulating a special effect of object drift, comprising the following steps:
receiving a target image to be subjected to special effect simulation;
according to a preset center analysis algorithm, performing center calculation processing on the preset particle clustering attribute to obtain a particle center point coordinate;
according to a preset size operation formula, performing matrix field size calculation on the particle clustering attribute to obtain a particle rectangular field size value;
performing distance measurement and calculation on the display interface of the target image and the particle rectangular field size value to obtain a display distance value;
judging whether the display distance value is smaller than zero or not;
if the display distance value is smaller than zero, modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm to obtain a special effect drawing pixel set;
and according to the special effect drawing pixel set, performing filter drawing processing on the target image to obtain the target image with the special effect simulation of object drift.
Optionally, in a first implementation manner of the first aspect of the present invention, the particle cluster attribute includes: the method comprises the steps of clustering attribute and a particle index table, wherein particle generation processing is carried out on a preset particle cluster according to a preset center analysis algorithm, and the step of obtaining a particle center point comprises the following steps:
substituting the clustering attribute into a preset speed operation formula based on the particle index table to obtain a target particle speed;
substituting the target particle speed and the clustering attribute into a preset center measuring and calculating formula to obtain the particle center point coordinate.
Optionally, in a second implementation manner of the first aspect of the present invention, the speed operation formula includes:
wherein V is the target particle velocity, a, b, c, d is a constant, j is an index value of the target particle in the particle index table, and FUbo.
Optionally, in a third implementation manner of the first aspect of the present invention, the center calculating formula includes:
Center=Vec2((uv-e)*FUbo.uparticleSpeed+rand(j)+f*cos(FUbo.uCompletion+sin(j)),mod(sin(j)+V*(FUbo.uCompletion*g*(h+FUbo.uparticleSpeed))),
wherein Center is a particle Center point coordinate, vec2 () is a two-dimensional vector constructor, uv is a current pixel point coordinate, e, f, g, h, z is a constant, j is an index value of a target particle in the particle index table, fubo.uparticlespeed is a particle change speed of a cluster attribute, fubo.u completions is a change period of the cluster attribute, V is a target particle speed, rand () is a random function, and mod () is a modulo function.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the performing distance measurement on the display interface of the target image and the particle rectangular field size value to obtain a display distance value includes:
according to a preset vector field calculation formula, performing distance measurement and calculation on a display interface of the target image and the particle rectangular field size value to obtain a display distance value, wherein the vector field calculation formula comprises:
Result=rectSDF(aspect-Center,Vec2(rectSize,0)),
wherein Result is a display distance value, rectSDF () is a vector field calculation function, aspect is an aspect ratio of a display interface, center is a rectangular field size value, vec2 () is a two-dimensional vector construction function, rectSize is a particle radius value.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm, to obtain a special effect drawing pixel set includes:
constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
based on a preset turnover algorithm, performing turnover modification treatment on the particle cluster attribute to obtain a cluster modification attribute;
and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm, to obtain a special effect drawing pixel set further includes:
constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
performing rotation modification processing on the particle cluster attribute based on a preset rotation algorithm to obtain a cluster modification attribute;
and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
Optionally, in a seventh implementation manner of the first aspect of the present invention, performing filter drawing processing on the target image according to the special effect drawing pixel set to obtain a target image with special effect simulation of object drift includes:
analyzing the overlapping range of the special effect drawing pixel set and the target image to obtain an overlapping drawing pixel set;
and assigning the overlapped drawing pixel set to an alpha channel of the target image to generate the target image with the object floating special effect simulation.
The second aspect of the present invention provides an object-drift special effect simulation apparatus, comprising: a memory and at least one processor, the memory having instructions stored therein, the memory and the at least one processor being interconnected by a line; the at least one processor invokes the instructions in the memory to cause the object-drift special effect simulation apparatus to perform the object-drift special effect simulation method described above.
A third aspect of the present invention provides a computer-readable storage medium having instructions stored therein that, when executed on a computer, cause the computer to perform the above-described object drift special effect simulation method.
In the embodiment of the invention, the effect that different object forms randomly drift under the combined action of gravity and wind force is simulated by modifying the relevant parameters such as the configuration element type, the gravity, the wind speed direction, the filter element number and the like of the particle data and the particle clustering attribute, so that the overall visual effect of an original video can be greatly improved, the technical problem that the current filter effect is insufficient in customization of different image displays and the display effect of the special effect that objects with different image shapes and sizes drift is poor is solved.
Drawings
FIG. 1 is a schematic diagram of a first embodiment of a special effect simulation method for object drift in an embodiment of the present invention;
FIG. 2 is one embodiment of a step 102 of an object drift effect simulation method in accordance with an embodiment of the present invention;
FIG. 3 is a first embodiment of a method for simulating a special effect of object drift 106 according to an embodiment of the present invention;
FIG. 4 is a second embodiment of a step 106 of the special effect simulation method for object drift in accordance with the present invention;
FIG. 5 is one embodiment of step 107 of the special effect simulation method for object drift in accordance with the present invention;
FIG. 6 is a schematic diagram of an embodiment of an apparatus for simulating special effects of object drift in accordance with an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a method, equipment and a storage medium for simulating a special effect of object drifting.
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the present disclosure has been illustrated in the drawings in some form, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and examples of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.
In describing embodiments of the present disclosure, the term "comprising" and its like should be taken to be open-ended, i.e., including, but not limited to. The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first," "second," and the like, may refer to different or the same object. Other explicit and implicit definitions are also possible below.
For easy understanding, the following describes a specific flow of an embodiment of the present invention, referring to fig. 1, and one embodiment of the method for simulating the special effect of object drift in the embodiment of the present invention includes:
101. receiving a target image to be subjected to special effect simulation;
in this embodiment, the target image to be subjected to special effect simulation is received, and the target image may be an image in which video data is split into video frames, so that special effect simulation may be performed on video data, and the processing before this step is just to split the video data into each video frame image.
102. According to a preset center analysis algorithm, performing center calculation processing on the preset particle clustering attribute to obtain a particle center point coordinate;
in this embodiment, based on the particle system theory, a certain number of particle units (the number of the particle units can be controlled by a user) are generated within the current frame time point range, the random determination of the center positions of the particles is performed, the natural random presentation of the objects in the real physical environment is simulated, the particles are subjected to the physical imaging on the basis, namely, the current particle positions are presented with an object (such as petals, snowflakes, meteor rain, etc.), and finally, after the particles are subjected to the physical imaging, the object is subjected to random transformation (rotation, scaling, twisting, etc.), so that images with different visual angles are formed, and finally, the random drifting images in the real 3D physical environment are presented. Therefore, the user only needs to set various attributes of the particle cluster, and conduct the particle cluster attribute data into a simulation system, and the particle center point coordinates are generated after calculation based on the particle cluster attributes by a preset center analysis algorithm.
Further, referring to fig. 2, fig. 2 is an embodiment of a step 102 of the method for simulating an effect of object drift in an embodiment of the present invention, where the particle cluster attribute includes: cluster attributes, particle index table, the following may be performed at step 102:
1021. substituting the clustering attribute into a preset speed operation formula based on the particle index table to obtain a target particle speed;
1022. substituting the target particle speed and the clustering attribute into a preset center measuring and calculating formula to obtain the particle center point coordinate.
In 1021-1022 steps, different particles in the particle index table are different in corresponding index values, in order to find a central coordinate for one clustered particle, the particle index values in the particle index table are traversed, a speed operation formula is substituted in sequence, a target particle speed is calculated, and then central point coordinate data are analyzed based on the target particle speed and the cluster attribute.
Specifically, the speed operation formula includes:
wherein V is the target particle velocity, a, b, c, d is a constant, j is an index value of the target particle in the particle index table, and FUbo.
Programming data using floating point numbers may be as follows:
float speed=0.3f+rand(cos(j))*(0.7f+0.5f*cos(j/(float(fUbo.uParticleCount)*0.25f)))。
specifically, the center calculating formula includes:
Center=Vec2((uv-e)*FUbo.uparticleSpeed+rand(j)+f*cos(FUbo.uCompletion+sin(j)),mod(sin(j)+V*(FUbo.uCompletion*g*(h+FUbo.uparticleSpeed)),z)),
wherein Center is a particle Center point coordinate, vec2 () is a two-dimensional vector constructor, uv is a current pixel point coordinate, e, f, g, h, z is a constant, j is an index value of a target particle in the particle index table, fubo.uparticlespeed is a particle change speed of a cluster attribute, fubo.u completions is a change period of the cluster attribute, V is a target particle speed, rand () is a random function, and mod () is a modulo function.
Programming data using floating point numbers may be as follows: vec2 center=vec2 (- (0.25 f-uv.y) fUbo.uparticle speed+rand (j) +0.1f cos (fUbo.ucomposition+sin (j)), mod (sin (j)
+speed*(fUbo.uCompletion*1.5f*(0.1f+fUbo.uParticleSpeed)),1.0f))。
103. According to a preset size operation formula, performing matrix field size calculation on the particle clustering attribute to obtain a particle rectangular field size value;
104. performing distance measurement and calculation on the display interface of the target image and the particle rectangular field size value to obtain a display distance value;
in step 103-104, the size rectSize of the particle cluster attribute is calculated by using rectsize=0.001+speed 0.012×2 through the target particle Speed, and then the particle rectangular field and the particle rectangular field size value are calculated by using a size calculation formula through the size rectSize.
The relationship of the current coordinates to the rectangle (inside, on the boundary, or outside the rectangle).
Specifically, the following steps may be performed at 104:
1041. according to a preset vector field calculation formula, performing distance measurement and calculation on a display interface of the target image and the particle rectangular field size value to obtain a display distance value, wherein the vector field calculation formula comprises:
Result=rectSDF(aspect-Center,Vec2(rectSize,0)),
wherein Result is a display distance value, rectSDF () is a vector field calculation function, aspect is an aspect ratio of a display interface, center is a rectangular field size value, vec2 () is a two-dimensional vector construction function, rectSize is a particle radius value.
Programming data using floating point numbers may be as follows:
float rectSize=0.001+speed*0.012*2.0f;
vec2 currentCoord=uv;
/(with y-axis as normalization standard)
currentCoord*=aspect;
center*=aspect;
float sdfResult=rectSDF(currentCoord-center,vec2(rectSize),0.0f);
rectsize=0.001+speed 0.012 x 2.0f calculates the size of the rectangle for the line code. It uses a variable speed and some numerical operations to finally get a size value of floating point type. vec2currentCoord = uv; and assigning the input two-dimensional coordinate uv to the variable currentCoord to represent the current coordinate position. currentCoord = aspect; and center = aspect; to normalize because both texture coordinates and rectangular center coordinates are relative to the aspect ratio, the two lines of code multiply the coordinates by aspect (i.e., the aspect ratio) to normalize.
floatsdfresult=rectsdf (currentcode-center, vec2 (rectSize), 0.0 f); a function named rectSDF is called for this line of code, the distance of the current coordinates from the center of the rectangle is calculated and the distance is stored in the variable sdfsresult. The parameters of the function include the current coordinates minus the rectangular center coordinates, the size of the rectangle (vector vec2 (rectSize)) and a floating point number constant of 0.0f. The function calculates a normalized value based on the distance, which represents the relationship of the current coordinates to the rectangle (inside, on the boundary, or outside the rectangle).
105. Judging whether the display distance value is smaller than zero or not;
in this embodiment, it is analyzed whether the value of rectSDF above is less than zero.
106. If the display distance value is smaller than zero, modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm to obtain a special effect drawing pixel set;
in this embodiment, if rectSDF is less than zero, the particle location is indicated on the display interface. And modifying and drawing the particle cluster attribute through a set special effect drawing algorithm, and drawing the pixel set by the special effect.
Further, referring to fig. 3, fig. 3 is a first embodiment of a step 106 of the special effect simulation method for object drift in the embodiment of the present invention, the step 106 may perform the following operations:
1061. constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
1062. based on a preset turnover algorithm, performing turnover modification treatment on the particle cluster attribute to obtain a cluster modification attribute;
1063. and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
In steps 1061-1063, the parameters configuration of the 3D transform is performed by some random factor parameters, and then converted into a 2D transform:
vec2tempCoord=currentCoord-center;
the following transformation operations are performed in the rectangular coordinate system corresponding to the current sdf
vec2 scaleSize=vec2(rectSize*2.0f);
tempCoord=tempCoord/scaleSize;
This part of the code is to remap the coordinates temp oord into the rectangular coordinate system corresponding to the current SDF (SignedDistanceField) for subsequent transformation operations.
First, by vec2 scale=vec2 (rectSize 2.0f); a scaling factor is calculated that is twice the rectangular size rectSize. This is done to keep the unit length of the distance field function consistent in the rectangular coordinate system.
Then, by tempoord = tempoord/scaleSize; the coordinates temp oord is divided by scaleSize, which enables scaling of the coordinates. This operation will restrict the range of the original coordinates temp to the interval of [ -1,1], i.e. normalize it to a unit range in the rectangular coordinate system to which the current SDF corresponds. By this one-step scaling operation, subsequent geometric operations, such as rotation, translation, etc., can be more conveniently performed in the rectangular coordinate system.
After obtaining the blank pixel frame, modifying the particle cluster attribute, wherein the specific implementation code can be as follows:
the principle of particle inversion// 2): angle estimation (symmetry axis rotates to positive Y axis position, then turns over and remaps)
Angle of symmetry: included angle clockwise with positive Y axis
float symmetryTheta=-PI*(45.0f/180.0f);
mat2symmetryMat=mat2(cos(symmetryTheta),sin(symmetryTheta),-sin(symmetryTheta),cos(symmetryTheta));
tempCoord=symmetryMat*tempCoord;
The reverse/reverse rotation 180 DEG
floatflipTheta=PI*fUbo.uCompletion*speed;
The original texture address is mapped by// and the remapping is thought by trigonometric function, and after rotation, the geometry is stretched corresponding to Wen Su
tempCoord.x=tempCoord.x/cos(flipTheta)。
Further, referring to fig. 4, fig. 4 is a second embodiment of a step 106 of the special effect simulation method for object drift in the embodiment of the present invention, the step 106 may perform the following operations:
1064. constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
1065. performing rotation modification processing on the particle cluster attribute based on a preset rotation algorithm to obtain a cluster modification attribute;
1066. and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
In steps 1064-1066, the parameters configuration of the 3D transform is performed by some random factor parameters, and then converted into a 2D transform:
vec2 tempCoord=currentCoord-center;
the following transformation operations are performed in the rectangular coordinate system corresponding to the current sdf
vec2 scaleSize=vec2(rectSize*2.0f);
tempCoord=tempCoord/scaleSize;
This part of the code is to remap the coordinates temp oord into the rectangular coordinate system corresponding to the current SDF (SignedDistanceField) for subsequent transformation operations.
First, by vec2 scale=vec2 (rectSize 2.0f); a scaling factor is calculated that is twice the rectangular size rectSize. This is done to keep the unit length of the distance field function consistent in the rectangular coordinate system.
Then, by tempoord = tempoord/scaleSize; the coordinates temp oord is divided by scaleSize, which enables scaling of the coordinates. This operation will restrict the range of the original coordinates temp to the interval of [ -1,1], i.e. normalize it to a unit range in the rectangular coordinate system to which the current SDF corresponds. By this one-step scaling operation, subsequent geometric operations, such as rotation, translation, etc., can be more conveniently performed in the rectangular coordinate system.
After obtaining the blank pixel frame, modifying the particle cluster attribute, wherein the specific implementation code can be as follows:
/(3) particle rotation
float angle=MAX_RORATE_ANGLE*speed*fUbo.uCompletion*1.0f;
mat2 mat=mat2(cos(angle),sin(angle),-sin(angle),cos(angle));
tempCoord=mat*tempCoord;
The/(center point) moves to the origin (0.0 f )
tempCoord+=vec2(0.5f);
float ANGLE = max_rate_angle x speed x f ubo.u completion x 1.0f is the calculated ANGLE of rotation ANGLE. Max_rate_angle is a constant for controlling the maximum rotation ANGLE. By multiplying speed, fUbo.uCompensation and 1.0f, the speed and degree of completion of the rotation can be controlled according to external parameters.
mat2 mat=mat 2 (cos (angle), sin (angle), -sin (angle), cos (angle)); to create a 2x2 matrix mat, cos (angle) and sin (angle) are used to represent the element values of the rotation matrix.
tempoord = mat tempoord is a multiplication of the matrix mat with the coordinates tempoord (a rotation operation of the coordinates is achieved.
tempoord+=vec2 (0.5 f) to shift the coordinates tempoord, the center point is moved to the origin (0.5 f ). This step may be to handle the transformation of the texture coordinate system from the top left corner to the center. The code performs transformation operations such as rotation, scaling, translation and the like on the current pixel coordinates through basic mathematical operation and space geometric mapping so as to realize specific visual effects.
107. And according to the special effect drawing pixel set, performing filter drawing processing on the target image to obtain the target image with the special effect simulation of object drift.
In this embodiment, the pixel color is processed and selected according to the range and the coordinate position of the particle, and the mixing effect of the particle and the background pixel is achieved through the mixing operation, so that the filter effect is finally generated, and the target image with the special effect simulation of the object drifting is obtained.
Further, referring to fig. 5, fig. 5 is an embodiment of step 107 of the special effect simulation method for object drift in the embodiment of the present invention, where step 107 may perform the following operations:
1071. analyzing the overlapping range of the special effect drawing pixel set and the target image to obtain an overlapping drawing pixel set;
1072. and assigning the overlapped drawing pixel set to an alpha channel of the target image to generate the target image with the object floating special effect simulation.
In steps 1071-1702, the following code form may be employed:
vec4imgColor=vec4(0.0f);
the// texture addressing constraint, exceeding the texture boundary, transparent processing
if(tempCoord.x<0.0f||tempCoord.x>1.0f||tempCoord.y<0.0f||tempCoord.y>1.0f){
Out-of-range addressing
imgColor=vec4(0.0f);
}else{
Site selection within the normal range
imgColor=texture(uTexture1,tempCoord);
if(imgColor.a<=0.0f){
imgColor=vec4(0.0f);
}
}
One pixel meeting two particle ranges simultaneously, performing special coverage treatment
if(sdfResult<=0.0f){
imgColor=fragColor;
}else{
Hybrid with the last ground color
imgColor=mix(fragColor,imgColor,imgColor.a);
}
fragColor=imgColor;
vec4bgColor=texture(uTexture2,vTexPosition1);
fragColor=mix(bgColor,fragColor,fragColor.a);
glFragColor=fragColor;
The code mainly realizes the mixing effect of particles and background pixels and forms the final filter effect. vec4 imgcolor=vec4 (0.0 f); to create a color variable imgColor with an initial value of zero, the final pixel color is stored.
if (temp. x <0.0 f|temp. x >1.0 f|temp. y <0.0 f|temp. y >1.0 f) is a check to see if the coordinates temp are outside the texture boundary (0-1 range), if so, the imgColor is set to a fully transparent black (vec 4 (0.0 f)).
else is if the coordinates are within the texture range, then the following operations are performed:
imgcolor=texture (uTexture 1, tempoord) is a pixel color obtained from texture uTexture1 in coordinates of tempoord.
If (imgColor. A < = 0.0 f) is to check whether the alpha component of the acquired pixel color is equal to or less than 0.0, and if so, the imgColor is set to a fully transparent black (vec 4 (0.0 f)).
if (sdfResult < = 0.0 f) is a check if a certain condition (possibly related to the range of other particles) is met, if so, the following is performed:
imgcolor = fragColor; to assign the current primitive color fragColor to the imgColor.
else is that if the previous condition is not satisfied, the following operations are performed:
imgcolor=mix (fragColor, imgColor. A) is to mix the fragColor and imgColor using a mix function, the mixing ratio being the alpha component of imgColor. The purpose here is to mix the two colors while maintaining partial transparency.
The fragcolor=mix (bgColor, fragColor, fragcolor.a) is to mix bgColor (background color) and fragColor again using mix function, the mixing ratio is the alpha component of fragColor. The purpose here is to finally mix the mixed result with the background color.
glFragColor = fragColor is to assign the final mixed color to the glFragColor as the final output color.
In the embodiment of the invention, the effect that different object forms randomly drift under the combined action of gravity and wind force is simulated by modifying the relevant parameters such as the configuration element type, the gravity, the wind speed direction, the filter element number and the like of the particle data and the particle clustering attribute, so that the overall visual effect of an original video can be greatly improved, the technical problem that the current filter effect is insufficient in customization of different image displays and the display effect of the special effect that objects with different image shapes and sizes drift is poor is solved.
Fig. 6 is a schematic structural diagram of an object-drift special effect simulation device according to an embodiment of the present invention, where the object-drift special effect simulation device 600 may have a relatively large difference due to different configurations or performances, and may include one or more processors (central processing units, CPU) 610 (e.g., one or more processors) and a memory 620, and one or more storage media 630 (e.g., one or more mass storage devices) storing application programs 633 or data 632. Wherein the memory 620 and the storage medium 630 may be transitory or persistent storage. The program stored in the storage medium 630 may include one or more modules (not shown), each of which may include a series of instruction operations in the object drift special effect simulation apparatus 600. Still further, the processor 610 may be configured to communicate with the storage medium 630 to execute a series of instruction operations in the storage medium 630 on the object-drift special effect simulation apparatus 600.
The object-based special effects simulation apparatus 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input/output interfaces 660, and/or one or more operating systems 631, such as Windows Serve, mac OS X, unix, linux, free BSD, and the like. It will be appreciated by those skilled in the art that the structure of the object-drift special effect simulation apparatus shown in fig. 6 is not limiting on the object-drift special effect simulation apparatus, and may include more or fewer components than shown, or may combine certain components, or may be arranged in different components.
The present invention also provides a computer readable storage medium, which may be a non-volatile computer readable storage medium, or may be a volatile computer readable storage medium, where instructions are stored in the computer readable storage medium, when the instructions are executed on a computer, cause the computer to perform the steps of the object drift special effect simulation method.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Moreover, although operations are depicted in a particular order, this should be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented in multiple implementations separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.
Claims (10)
1. The method for simulating the special effect of the object falling is characterized by comprising the following steps:
receiving a target image to be subjected to special effect simulation;
according to a preset center analysis algorithm, performing center calculation processing on the preset particle clustering attribute to obtain a particle center point coordinate;
according to a preset size operation formula, performing matrix field size calculation on the particle clustering attribute to obtain a particle rectangular field size value;
performing distance measurement and calculation on the display interface of the target image and the particle rectangular field size value to obtain a display distance value;
judging whether the display distance value is smaller than zero or not;
if the display distance value is smaller than zero, modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm to obtain a special effect drawing pixel set;
and according to the special effect drawing pixel set, performing filter drawing processing on the target image to obtain the target image with the special effect simulation of object drift.
2. The method of claim 1, wherein the particle cluster attribute comprises: the method comprises the steps of clustering attribute and a particle index table, wherein particle generation processing is carried out on a preset particle cluster according to a preset center analysis algorithm, and the step of obtaining a particle center point comprises the following steps:
substituting the clustering attribute into a preset speed operation formula based on the particle index table to obtain a target particle speed;
substituting the target particle speed and the clustering attribute into a preset center measuring and calculating formula to obtain the particle center point coordinate.
3. The method for simulating a special effect of object drift as set forth in claim 2, wherein the velocity calculation formula includes:
wherein V is the target particle velocity, a, b, c, d is a constant, j is an index value of the target particle in the particle index table, and FUbo.
4. The method of claim 2, wherein the center calculation formula comprises:
Center=Vec2((uv-e)*FUbo.uparticleSpeed+rand(j)+f*cos(FUbo.uCompletion+sin(j)),mod(sin(j)+V*(FUbo.uCompletion*g*(h+FUbo.uparticleSpeed)),z)),
wherein Center is a particle Center point coordinate, vec2 () is a two-dimensional vector constructor, uv is a current pixel point coordinate, e, f, g, h, z is a constant, j is an index value of a target particle in the particle index table, fubo.uparticlespeed is a particle change speed of a cluster attribute, fubo.u completions is a change period of the cluster attribute, V is a target particle speed, rand () is a random function, and mod () is a modulo function.
5. The method for simulating the special effect of object drift as set forth in claim 1, wherein the step of measuring the distance between the display interface of the target image and the size of the rectangular field of particles to obtain a display distance value includes:
according to a preset vector field calculation formula, performing distance measurement and calculation on a display interface of the target image and the particle rectangular field size value to obtain a display distance value, wherein the vector field calculation formula comprises:
Result=rectSDF(aspect-Center,Vec2(rectSize,0)),
wherein Result is a display distance value, rectSDF () is a vector field calculation function, aspect is an aspect ratio of a display interface, center is a rectangular field size value, vec2 () is a two-dimensional vector construction function, rectSize is a particle radius value.
6. The method for simulating the special effect of the object floating in the present invention according to claim 1, wherein the modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm to obtain a special effect drawing pixel set includes:
constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
based on a preset turnover algorithm, performing turnover modification treatment on the particle cluster attribute to obtain a cluster modification attribute;
and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
7. The method for simulating a special effect of object drift as set forth in claim 1, wherein the modifying and drawing the particle cluster attribute according to a preset special effect drawing algorithm to obtain a special effect drawing pixel set further includes:
constructing a blank pixel frame based on the particle radius value of the particle cluster attribute;
performing rotation modification processing on the particle cluster attribute based on a preset rotation algorithm to obtain a cluster modification attribute;
and modifying the pixel value of the blank pixel frame based on the clustering modification attribute to obtain a special effect drawing pixel set.
8. The method for simulating the special effect of object drift as set forth in claim 1, wherein the performing filter rendering processing on the target image according to the special effect rendering pixel set to obtain the target image with the special effect of object drift comprises:
analyzing the overlapping range of the special effect drawing pixel set and the target image to obtain an overlapping drawing pixel set;
and assigning the overlapped drawing pixel set to an alpha channel of the target image to generate the target image with the object floating special effect simulation.
9. An object-drift special effect simulation apparatus, characterized in that the object-drift special effect simulation apparatus comprises: a memory and at least one processor, the memory having instructions stored therein, the memory and the at least one processor being interconnected by a line;
the at least one processor invoking the instructions in the memory to cause the object-drift special effect simulation apparatus to perform the object-drift special effect simulation method of any of claims 1-8.
10. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the object drift special effect simulation method according to any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311005139.0A CN116993877B (en) | 2023-08-09 | 2023-08-09 | Method, device and storage medium for simulating special effect of object drifting |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311005139.0A CN116993877B (en) | 2023-08-09 | 2023-08-09 | Method, device and storage medium for simulating special effect of object drifting |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116993877A true CN116993877A (en) | 2023-11-03 |
CN116993877B CN116993877B (en) | 2024-10-11 |
Family
ID=88530014
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311005139.0A Active CN116993877B (en) | 2023-08-09 | 2023-08-09 | Method, device and storage medium for simulating special effect of object drifting |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116993877B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102867334A (en) * | 2012-08-23 | 2013-01-09 | 苏州两江科技有限公司 | Real-time snowflake deposition simulation method based on particle system model |
WO2018227102A1 (en) * | 2017-06-09 | 2018-12-13 | Sony Interactive Entertainment Inc. | Optimized deferred lighting and foveal adaptation of particles and simulation models in a foveated rendering system |
CN111338532A (en) * | 2020-02-28 | 2020-06-26 | 珠海豹趣科技有限公司 | Method and device for displaying shape special effect and computer readable storage medium |
CN112700517A (en) * | 2020-12-28 | 2021-04-23 | 北京字跳网络技术有限公司 | Method for generating visual effect of fireworks, electronic equipment and storage medium |
CN112802170A (en) * | 2021-02-07 | 2021-05-14 | 北京字节跳动网络技术有限公司 | Illumination image generation method, apparatus, device, and medium |
CN114742931A (en) * | 2022-04-28 | 2022-07-12 | 北京字跳网络技术有限公司 | Method and device for rendering image, electronic equipment and storage medium |
CN116310013A (en) * | 2023-01-30 | 2023-06-23 | 网易(杭州)网络有限公司 | Animation rendering method, device, computer equipment and computer readable storage medium |
-
2023
- 2023-08-09 CN CN202311005139.0A patent/CN116993877B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102867334A (en) * | 2012-08-23 | 2013-01-09 | 苏州两江科技有限公司 | Real-time snowflake deposition simulation method based on particle system model |
WO2018227102A1 (en) * | 2017-06-09 | 2018-12-13 | Sony Interactive Entertainment Inc. | Optimized deferred lighting and foveal adaptation of particles and simulation models in a foveated rendering system |
CN111338532A (en) * | 2020-02-28 | 2020-06-26 | 珠海豹趣科技有限公司 | Method and device for displaying shape special effect and computer readable storage medium |
CN112700517A (en) * | 2020-12-28 | 2021-04-23 | 北京字跳网络技术有限公司 | Method for generating visual effect of fireworks, electronic equipment and storage medium |
CN112802170A (en) * | 2021-02-07 | 2021-05-14 | 北京字节跳动网络技术有限公司 | Illumination image generation method, apparatus, device, and medium |
CN114742931A (en) * | 2022-04-28 | 2022-07-12 | 北京字跳网络技术有限公司 | Method and device for rendering image, electronic equipment and storage medium |
CN116310013A (en) * | 2023-01-30 | 2023-06-23 | 网易(杭州)网络有限公司 | Animation rendering method, device, computer equipment and computer readable storage medium |
Non-Patent Citations (2)
Title |
---|
JUSSI LEINONEN 等: "Snowflake Melting Simulation Using Smooth Particle Hydrodynamics", 《AGU ADVANCING EARTH AND SPACE SCIENCES》, 6 February 2018 (2018-02-06) * |
陈姚节 等: "降雨仿真中粒子分布区域模型的优化", 《科学技术与工程》, 31 July 2018 (2018-07-31) * |
Also Published As
Publication number | Publication date |
---|---|
CN116993877B (en) | 2024-10-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9275493B2 (en) | Rendering vector maps in a geographic information system | |
WO2017113731A1 (en) | 360-degree panoramic displaying method and displaying module, and mobile terminal | |
CN103247072B (en) | The method and device at three-dimensional rotation interface is realized based on Android system | |
US7170527B2 (en) | Interactive horizon mapping | |
AU2019226134B2 (en) | Environment map hole-filling | |
CN108022285B (en) | Map rendering method and device | |
US9965893B2 (en) | Curvature-driven normal interpolation for shading applications | |
CN114511662A (en) | Method, apparatus, electronic device and storage medium for rendering images | |
US20200302579A1 (en) | Environment map generation and hole filling | |
CN110917617A (en) | Method, device and equipment for generating water ripple image and storage medium | |
WO2017113729A1 (en) | 360-degree image loading method and loading module, and mobile terminal | |
CN112580213A (en) | Method and apparatus for generating display image of electric field lines, and storage medium | |
JP2023527438A (en) | Geometry Recognition Augmented Reality Effect Using Real-time Depth Map | |
Boreskov et al. | Computer Graphics: From Pixels to Programmable Graphics Hardware | |
AU2020215351A1 (en) | Viewability metrics of a multidimensional object in a multidimensional digital environment | |
CN114820980A (en) | Three-dimensional reconstruction method and device, electronic equipment and readable storage medium | |
CN116993877B (en) | Method, device and storage medium for simulating special effect of object drifting | |
Ohkawara et al. | Experiencing GPU path tracing in online courses | |
CN112862981B (en) | Method and apparatus for presenting a virtual representation, computer device and storage medium | |
US10559122B2 (en) | System and method for computing reduced-resolution indirect illumination using interpolated directional incoming radiance | |
CN116778053B (en) | Target engine-based map generation method, device, equipment and storage medium | |
CN114359456B (en) | Picture pasting method and device, electronic equipment and readable storage medium | |
Ragnemalm | Polygons feel no pain | |
US20240371079A1 (en) | Face-Oriented Geometry Streaming | |
Fober | Radiance Textures for Rasterizing Ray-Traced Data |
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 |