Special effects generation method and device
By dynamically calculating and changing the target anchor point position, the problem of fixed curvature of laser and lightning special effects curves in the existing technology is solved, and the natural arc presentation of special effects and the improvement of user experience is achieved.
Patent Information
- Application Number
- CN202211303748.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-24
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2042-10-24
AI Technical Summary
It is difficult for the existing technology to dynamically change the curve curvature of laser and lightning special effects in the fields of games, film and television, resulting in the generated special effects being rigid and unnatural and reducing the user experience.
By receiving special effect generation instructions, determine the target emission point and emission direction, calculate the target anchor position of the target display special effect, and dynamically change the target anchor position using the linear interpolation function to generate a natural arc-shaped special effect.
The natural arc-shaped presentation of special effects during the mobile transformation process is realized, and the effect is more natural and flexible, improving the user experience.
Smart Images

Figure CN115766974B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a special effect generation method, a special effect generation device, a computing device, and a computer-readable storage medium. Background Art
[0002] With the development of science and technology and the progress of the times, more and more fields involve the production of special effects, such as the field of games, film and television, etc. In various current application scenarios, in order to enhance the visual effects, special effects are generally added to the game screen, animation screen, film and television screen, etc., but for laser and lightning special effects, only direct or fixed curve special effects are supported. In the Unity engine, the native curvature change solution is difficult to reverse the historical position and it is difficult to produce the "stickiness" required for special effects. The laser and lightning special effects produced are difficult to change dynamically, making the presented effect relatively dull and unnatural, reducing the user experience. Summary of the invention
[0003] In view of this, the embodiment of the present application provides a special effect generation method. The present application also relates to a special effect generation device, a computing device, and a computer-readable storage medium to solve the above problems existing in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a special effect generation method is provided, comprising:
[0005] receiving a special effect generation instruction for a target display special effect, and determining a target emission point for the target display special effect and an emission direction of the target emission point in response to the special effect generation instruction;
[0006] Determine the target position of the target display special effect in the current image frame according to the target emission point and the emission direction;
[0007] Acquire the initial position of the target display special effect based on the target position;
[0008] Calculate at least one target anchor point position of the target display special effect according to the target emission point and the initial position;
[0009] The target display special effect is generated in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0010] According to a second aspect of an embodiment of the present application, a special effect generating device is provided, comprising:
[0011] A first determination module is configured to receive a special effect generation instruction for a target display special effect, and determine a target emission point for the target display special effect and an emission direction of the target emission point in response to the special effect generation instruction;
[0012] A second determination module is configured to determine a target position of the target display special effect in a current image frame according to the target emission point and the emission direction;
[0013] A first acquisition module is configured to acquire an initial position of the target display special effect based on the target position;
[0014] A calculation module, configured to calculate at least one target anchor point position of the target display special effect according to the target emission point and the initial position;
[0015] A generation module is configured to generate the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0016] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the special effect generation method when executing the computer instructions.
[0017] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the computer instructions are executed by a processor, the steps of the special effect generation method are implemented.
[0018] The special effects generation method provided in the present application receives a special effects generation instruction for a target display special effect, determines a target emission point and an emission direction of the target emission point for the target display special effect in response to the special effects generation instruction; determines a target position of the target display special effect in a current image frame according to the target emission point and the emission direction; obtains an initial position of the target display special effect based on the target position; calculates at least one target anchor point position of the target display special effect according to the target emission point and the initial position; and generates the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0019] An embodiment of the present application determines the target launch point and initial position of the target display special effect, and calculates at least one target anchor point position of the target display special effect based on a linear interpolation function, so that the target anchor point position of the target display special effect can be dynamically changed, so that the display effect presented by the target display special effect changes according to the target anchor point position, and no longer just presents a direct state for movement and change, thereby achieving the target display special effect. The special effect can present a natural arc state during the movement and transformation process, and the presentation effect is more natural and flexible, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1aThis is a scene schematic diagram of a special effect generation method provided by an embodiment of the present application;
[0021] Figure 1b It is a schematic diagram of a scene top view of a special effect generation method provided in an embodiment of the present application;
[0022] Figure 2 is a flow chart of a special effect generation method provided by an embodiment of the present application;
[0023] Figure 3 is a curve diagram corresponding to the target display special effect provided in an embodiment of the present application;
[0024] Figure 4 It is a processing flow chart of a special effect generation method applied to a game scene provided by an embodiment of the present application;
[0025] Figure 5 It is a structural schematic diagram of a special effect generating device provided in one embodiment of the present application;
[0026] Figure 6 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0027] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0028] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0029] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0030] First, the terms involved in one or more embodiments of the present application are explained.
[0031] Property Binder: Property binder, through which highly customized data can be transmitted to Visual EffectGraph.
[0032] Linear interpolation: Linear interpolation refers to the interpolation method in which the interpolation function is a first-order polynomial, and the interpolation error at the interpolation node is zero. Compared with other interpolation methods, such as parabolic interpolation, linear interpolation is simple and convenient.
[0033] Perlin Noise: Perlin noise is a powerful algorithm in the field of procedural content generation, which is often used in games and visual media such as movies. It can be used to generate terrain, fire effects, and to simulate special effects such as water and clouds.
[0034] In existing practical applications, whether in games, film and television, or other fields, special effects are involved in production and generation. However, special effects such as lasers and lightning can only support direct or fixed curve effects, and cannot dynamically change the curvature of the special effects curve, making the generated special effects appear rather dull and unnatural.
[0035] In the present application, a special effect generation method is provided. The present application also relates to a special effect generation device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0036] Figure 1a and Figure 1b Schematic diagrams of scenes of a special effect generation method provided according to an embodiment of the present application are respectively shown.
[0037] like Figure 1a As shown, the display of the target display special effects in the initial image frame and the current image frame are respectively shown. The state of the target display special effects in the initial image frame is basically on the same horizontal line. In the current image frame, the target display special effects are in a state of moving from the initial position to the target position. During the movement, it can be obviously seen that the target display special effects presents an arc, and is not in the same horizontal state as in the initial image frame.
[0038] Figure 1b Shows a top view of the effect during application for the target, such as Figure 1b As shown, the target display special effect presents an arc state during the conversion from the target position in the initial image frame to the target position in the current image frame, that is, during the conversion process between the initial position and the target position.
[0039] Compared with the existing special effect realization effects, the special effect generation method provided in one embodiment of the present application can realize the dynamic change of the target anchor point position of the target display special effect, so that the display effect presented by the target display special effect changes according to the target anchor point position, which is more natural and improves the user experience.
[0040] Figure 2 A flowchart of a special effect generation method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0041] Step 202: receiving a special effect generation instruction for a target display special effect, and determining a target emission point and an emission direction of the target emission point for the target display special effect in response to the special effect generation instruction.
[0042] Among them, target display special effects refer to special effects that need to be generated and displayed. For example, in a game scene, it is necessary to generate corresponding whip special effects and archery special effects according to the operation of the game player; in anime pictures, it is necessary to generate and display special effects; in the film and television field, it is necessary to use special effects such as waving a whip and dancing with a sword.
[0043] Special effect generation instructions refer to instructions used to generate target display special effects; target launch point refers to the starting position used to display target display special effects. For example, if a game player swings a whip, the position of the game player's hand swinging the whip is the target launch point; the launch direction can be understood as the display direction of the target display special effects. For example, if a game player swings the whip straight ahead, the front is the launch direction, and if he swings the whip to the right, the right is the launch direction.
[0044] Specifically, the application terminal may receive a special effect generation instruction of a target display special effect sent from a server, and the application terminal may determine the starting position for displaying the target display special effect, i.e., the target emission point of the target display special effect, and determine the display direction of the target display special effect, i.e., the emission direction of the target emission point, in response to the special effect generation instruction. The application terminal may be a computer, tablet computer, mobile phone or other smart device.
[0045] In practical applications, games, animation, film and television and other fields all involve the production and generation of special effects. In a specific implementation provided in the present application, a game application scenario is taken as an example to illustrate that a special effect generation instruction from a game player to generate a lightning whip special effect is received, and in response to the generation instruction to generate the lightning whip special effect, the position at which a game character controlled by the game player swings the lightning whip special effect is determined, and the position is the target launch point, and the direction in which the game character swings the lightning whip special effect is determined to be directly in front of the game character.
[0046] Determining the target launch point and launch direction of the target display special effect is a prerequisite step for generating the target display special effect. Before generating the target display special effect, first determine the target launch point and the launch direction of the target launch point of the target display special effect, which is conducive to the subsequent generation of the target display special effect.
[0047] Step 204: Determine the target position of the target display special effect in the current image frame according to the target emission point and the emission direction.
[0048] Among them, the target position refers to the position reached or hit by the target display special effect based on the launch direction of the target launch point. Taking the target launch point as a game character as an example, the game player controls the game character to swing the whip forward, and the position hit by the whip is the target position of the target display special effect in the current image frame.
[0049] In practical applications, the target position of the target display special effect in the current image frame is not only related to the above-mentioned target emission point and its emission direction, but also can be determined according to the emission distance of the target display special effect.
[0050] Based on this, in an implementation manner provided by the present application, determining the target position of the target display special effect in the current image frame according to the target emission point and the emission direction includes:
[0051] Based on the target emission point and the preset distance, the target position of the target display special effect in the current image frame is determined in the emission direction.
[0052] The preset distance refers to the preset distance from the target launch point in the launch direction, that is, the distance from the target launch point based on the launch direction of the target display special effect, and the preset distance can be obtained from a database or a configuration file. The preset distance is related to the target object corresponding to the generated target display special effect, and the target object can be a whip, a sword, etc. For example, if the generated target display special effect is a whip, the preset distance can be the length of the whip, such as 3 meters; if the generated target display special effect is a sword, the preset distance can be the length of the sword, such as 1 meter.
[0053] Specifically, before determining the target position, a preset distance can be obtained from a database or configuration file. The preset distance is used to determine the target position of the target display special effect. When the preset distance is obtained, the target position of the target display special effect can be further determined based on the target launch point, launch direction and preset distance.
[0054] Continuing with the above example, taking the preset distance of 3 meters as an example, after the application terminal determines the target launch point and launch direction of the target display special effect based on the special effect generation instruction of the target display special effect, it obtains the preset distance of 3 meters from the database or configuration file. If there is no obstacle within 3 meters from the target launch point in the launch direction, the target display special effect can be displayed 3 meters from the target launch point based on the launch direction, and the position 3 meters away from the target launch point in the launch direction is the target position; if there is an obstacle within 3 meters from the target launch point in the launch direction, the distance displayed by the target display special effect from the target launch point based on the launch direction is the distance from the target launch point to the obstacle, which is obviously less than the preset distance of 3 meters. Therefore, the position from the target launch point to the obstacle based on the launch direction is the target position.
[0055] When the target position of the target display special effect in the current image frame has been determined, the initial position of the target display special effect can be further determined according to the target position, so that the target display special effect finally generated is more realistic.
[0056] Step 206: Acquire the initial position of the target display special effect based on the target position.
[0057] In the process of generating the target display special effect, each image frame will correspond to the target position of the target display special effect in the image frame. Based on this, the initial position can be understood as the target position of the target display special effect in the initial image frame before the current image frame. For example, if the current image frame is the 30th image frame, the initial position can be the target position of the target display special effect in the 10th image frame, or the target position of the target display special effect in the 20th image frame. The determination of the initial position needs to be determined based on the initial image frame.
[0058] Specifically, the position of the target display special effect in the current image frame is determined, the frame before the current image frame is determined as the initial image frame based on the current image frame, and the initial position of the target display special effect in the initial image frame is further determined in the initial image frame.
[0059] In practical applications, the effects presented by special effects such as lightning and lasers will constantly change. This is because each position corresponding to special effects such as lightning and lasers is different (the form of the special effects is different, and the position of the anchor point on the special effects strip determines the form of the special effects). Each different position can be calculated with reference to different video frames. In order to make the special effects present better effects, it is necessary to make the video frames corresponding to each position connect and convert. Therefore, in the implementation provided by the present application, in order to make the special effects transition from the initial video frame to the current video frame naturally, it is necessary to determine the different positions where the target display special effects are located.
[0060] In one implementation manner provided by the present application, obtaining the initial position of the target display special effect based on the target position includes:
[0061] determining an initial image frame based on the current image frame;
[0062] An initial position of the target display special effect is determined in the initial image frame.
[0063] Based on the above content, the initial image frame refers to the first image frame in the target video interval, and the target video interval refers to the video interval that needs to generate the target display special effect. For example, taking the video frames corresponding to the target video interval as the 10th image frame to the 30th image frame, the current image frame is the 30th image frame, and the initial image frame is the 10th image frame; taking the video frames corresponding to the target video interval as the 20th image frame to the 50th image frame, the current image frame is the 50th image frame, and the initial image frame is the 20th image frame. The initial position is the target position of the target display special effect in the initial image frame. Continuing with the above example, the initial image frame is the 10th image frame, then the initial position is the target position of the target display special effect in the 10th image frame.
[0064] Specifically, first, determine the target video interval based on the current image frame, determine the first image frame of the target video interval as the initial image frame, and determine the target position of the target display special effect in the initial image frame as the initial position of the target display special effect.
[0065] Continuing with the above example, based on the current image frame being the 30th image frame, the target video interval is determined to be the 10th image frame to the 30th image frame, then the initial image frame can be determined to be the 10th image frame, and the target position of the target display special effect in the 10th image frame is determined as the initial position.
[0066] An initial image frame of the target display special effect is determined according to the current image frame, and a target position of the target display special effect is determined in the initial image frame, and the target position is the initial position of the target display special effect.
[0067] Furthermore, the determination of the initial image frame can be achieved based on the following method:
[0068] In one implementation manner provided by the present application, determining an initial image frame based on the current image frame includes:
[0069] Acquire a video frame rate, and determine an image adjustment frame number based on the video frame rate, wherein the image adjustment frame number is the number of image frames set according to the video frame rate;
[0070] An initial image frame is determined according to the image adjustment frame number and the current image frame.
[0071] Specifically, the video frame rate refers to the video frame rate of the video to which the target display special effect belongs, and the video frame rate can be 25 frames per second, 60 frames per second, etc. The image adjustment frame number refers to the number of image frames set according to the video frame rate of the video to which the target display video belongs.
[0072] In practical applications, the video frame rate is usually 24 frames per second, 25 frames per second, and 60 frames per second. In a specific embodiment of the present application, different image adjustment frames can be set for different video frame rates according to the image frame adjustment coefficient, and corresponding image adjustment frame rules can be formed. For example, if the image frame adjustment coefficient is set to 0.5, the corresponding image adjustment frame number for a video frame rate of 24 frames per second is 12 frames, the corresponding image adjustment frame number for 25 frames per second is 13 frames, and the corresponding image adjustment frame number for 60 frames per second is 30 frames; if the image frame adjustment coefficient is set to 0.33, the corresponding image adjustment frame number for a video frame rate of 24 frames per second is 8 frames, the corresponding image adjustment frame number for 25 frames per second is 8 frames, and the corresponding image adjustment frame number for 60 frames per second is 20 frames. The setting of the above-mentioned image frame adjustment coefficient can be set according to the actual application situation, and the present application does not make any limitation here. The corresponding image adjustment frame number can be determined based on the image frame adjustment coefficient.
[0073] Get the video frame rate of the video to which the target display special effect belongs, and get the image adjustment frame rule corresponding to the video frame rate from the configuration file, determine the image adjustment frame number based on the image adjustment frame rule, and further determine the initial image frame based on the current image frame and the image adjustment frame number.
[0074] Taking the video frame rate of 60 frames per second as an example, the image adjustment frame rule corresponding to the video frame rate of 60 frames per second is obtained. If the image frame adjustment coefficient set in the image adjustment frame rule is 0.5, it can be determined that the number of image adjustment frames is 30 frames. If the current image frame is the 50th image frame, then the initial image frame is the 20th image frame; if the image frame adjustment coefficient set in the image adjustment frame rule is 0.33, it can be determined that the number of image adjustment frames is 20 frames. If the current image frame is the 50th image frame, then the initial image frame is the 30th image frame.
[0075] Furthermore, after the initial image frame is determined, the initial position of the target display special effect can be determined in the initial image frame.
[0076] In one implementation manner provided by the present application, determining the initial position of the target display special effect in the initial image frame includes:
[0077] Reading an image frame position queue, wherein the image frame position queue stores image frame information of each image frame and a target position corresponding to each image frame;
[0078] The initial image frame is searched in the image frame position queue, and a target position corresponding to the initial image frame is determined as an initial position of the target display special effect.
[0079] The image frame position queue refers to a queue used to store image frame information of each image frame and a target position corresponding to each image frame.
[0080] In a specific implementation provided by the present application, after determining the current image frame and the target position, it is necessary to further determine the initial image frame and the initial position according to the current image frame and the target position. In the implementation process, querying historical data will increase the workload of the application terminal and reduce the data processing speed. Therefore, a specific implementation provided by the present application solves the above problem by creating an image frame position queue.
[0081] Specifically, the image frame position queue is read, and the initial image frame is queried in the image frame position queue. When the initial image frame is queried, the target position corresponding to the initial image frame is determined based on the target position corresponding to each image frame stored in the image frame position queue, and the target position is determined as the initial position of the target display special effect in the initial image frame.
[0082] Continuing with the above example, the image frame position queue is read, and the 20th image frame is found in the image frame position queue to be the initial image frame. The target position corresponding to the 20th image frame is obtained, and the target position corresponding to the 20th image frame is determined as the initial position of the target display special effect.
[0083] By creating an image frame position queue to store the image frame information of each image frame and the target position corresponding to each image frame, the stored data in the image frame position queue can be read at any time during the execution process, so that it can be used immediately after being checked, thereby reducing the computing workload of the terminal and improving the processing speed.
[0084] By determining the target position of the target display special effect in the initial image frame, that is, the initial position of the target display special effect, it is possible to pave the way for calculating at least one target anchor point position of the target display special effect.
[0085] Step 208: Calculate at least one target anchor point position of the target display special effect according to the target emission point and the initial position.
[0086] The target anchor point position refers to the position between the target launch point and the initial position of the target display special effect. Specifically, Figure 3 FIG. 4 shows a curve diagram corresponding to a target display special effect in an embodiment provided by the present application. Figure 3As shown, generating a target display special effect requires not only the above-mentioned target launch point, target position and initial position, but also the target anchor point position of the target display special effect needs to be calculated based on the target launch point and the initial position.
[0087] Before calculating the target anchor point positions of the target display special effect, the number of target anchor point positions needs to be determined first, and the corresponding number of target anchor point positions is calculated according to the number of target anchor point positions.
[0088] In one implementation provided by the present application, calculating at least one target anchor point position of the target display special effect according to the target launch point and the initial position includes:
[0089] Determine the number of target anchor points;
[0090] Acquire a linear interpolation parameter corresponding to each target anchor point according to the number of the target anchor points;
[0091] The target anchor point position corresponding to each target anchor point is calculated based on the target emission point, the target position, the initial position and each linear interpolation parameter.
[0092] The linear interpolation parameter is a parameter used for interpolation calculation in the linear interpolation function. The linear interpolation function may be a lerp interpolation function. The lerp interpolation function is taken as an example for description, see the following formula (1):
[0093] lerp(y1,y2,weight)=y1+(y2-y1)*weight (1)
[0094] Wherein, y1 is the target launch point, y2 is the target position or initial position, weight is a linear interpolation parameter, and the value of weight is a real number between [0, 1]. The lerp function value calculated by the above formula (1) is the initial anchor point position or target anchor point position of the target display special effect.
[0095] Specifically, after determining the number of target anchor points for the target display special effect, the linear interpolation parameters corresponding to each target anchor point are obtained according to the number of target anchor points, and combined with Figure 3 Provide explanations, Figure 3 Three target anchor points are provided, namely target anchor point 1, target anchor point 2 and target anchor point 3. According to the above three target anchor points, the target launch point and the initial position, it can be determined that the linear interpolation parameter corresponding to the target launch point is 0, the linear interpolation parameter corresponding to target anchor point 1 is 0.25, the linear interpolation parameter corresponding to target anchor point 2 is 0.5, the linear interpolation parameter corresponding to target anchor point 3 is 0.75, and the linear interpolation parameter corresponding to the initial position is 1.
[0096] The value of the linear interpolation parameter is related to the number of target anchor points. The number of target anchor points is different, and the corresponding linear interpolation parameter value is different. The above is the process of taking the linear interpolation parameter corresponding to 3 target anchor points. If the number of target anchor points is 7, the linear interpolation parameter corresponding to the target emission point is 0, and the linear interpolation parameter corresponding to the initial position is 1. The linear interpolation parameters corresponding to the 7 target anchor points are 0.125, 0.25, 0.375, 0.5, 0.625, 0.75 and 0.875 respectively. The more the number of target anchor points, the denser the values of the linear interpolation parameters are, and the display effect of the target display special effects obtained will be smoother and more continuous. The determination of the number of target anchor points can be determined based on the above-mentioned image adjustment frame number, and can be specifically determined based on the actual application situation. This application does not make any limitation here.
[0097] Specifically, in a specific implementation of the present application, two interpolations are required according to the above formula (1) to determine the target anchor point position of the target display special effect. In the first interpolation process, what needs to be determined is the initial anchor point position of the target display special effect. The initial anchor point position refers to the position between the target launch point and the target position. In this process, y1 is the target launch point, y2 is the target position, and the value of weight is determined as a real number between [0, 1] according to the number of initial anchor points. Based on the above formula (1), the first interpolation results lerp1, lerp2, lerp3... and so on corresponding to each initial anchor point are calculated. According to the first interpolation result, the initial anchor point position corresponding to each initial anchor point can be obtained.
[0098] Before the second interpolation process, the weight to be used for the second interpolation needs to be calculated according to the function f. Furthermore, the first interpolation results lerp1, lerp2, lerp3, etc. corresponding to each initial anchor point position are respectively substituted into the function f to calculate the corresponding calculation results, which will be used as the weight for the second interpolation calculation. Among them, the function f needs to have the following characteristics:
[0099] a. Both the domain and range are between 0 and 1; b. Monotonically increasing.
[0100] Specifically, in the second interpolation process, y1 is the target launch point, y2 is the initial position, and the new weight is substituted into the above formula (1) for calculation to obtain new interpolation results lerp1', lerp2', lerp3', etc. The calculated lerp1', lerp2', lerp3', etc. are assigned to the target anchor point, and the target anchor point position corresponding to each target anchor point can be obtained.
[0101] Function f needs to satisfy the above two features a and b, but this application does not limit the specific formula of function f.
[0102] Specifically, function f is used to calculate the curvature of the curve of the target display special effect. In function f, weight can determine the curvature of the curve of the target display special effect. Each initial anchor point position can obtain the corresponding interpolation result after the first linear interpolation mentioned above. After the interpolation result is remapped and calculated by function f and the second interpolation is completed, the second interpolation result is assigned to each corresponding target anchor point to obtain the target anchor point position corresponding to each target anchor point, so that the target display special effect can present the curve characteristics. Correspondingly, the curvature characteristics of function f in the image in the rectangular coordinate system are the curvature characteristics that the curve of the target display special effect can show. Since the information in the image frame position queue is updated every frame, when the target position stops moving, the initial position will get closer and closer to the target position along the path of the target position, so that the y1 and y2 of the curvature interpolation are closer and closer, making the synthesized curve look "straight". This process makes the visual effect of the target display special effect have a "rebound" feeling.
[0103] Furthermore, in an implementation manner provided in the present application, the number of target anchor points for displaying target special effects can be determined according to the number of image adjustment frames.
[0104] In one implementation manner provided in the present application, determining the number of target anchor points includes:
[0105] The number of target anchor points is determined according to the image adjustment frame number, wherein the image adjustment frame number is the number of image frames set according to the video frame rate.
[0106] Specifically, before calculating the target anchor point position of the target display special effect, the number of target anchor points can be determined first, and then the target anchor point position can be calculated. After the number of target anchor points is determined, there will be corresponding linear interpolation parameters corresponding to each target anchor point, so that the linear interpolation parameters can be used to calculate the position of each target anchor point of the target display special effect. In one embodiment provided in the present application, the number of target anchor points can be determined according to the image adjustment frame number.
[0107] Similarly, take the video frame rate of 60 frames per second as an example. According to the video frame rate of 60 frames per second, the image adjustment frame number is determined to be 30 frames. If the current image frame is the 50th image frame, the initial image frame is determined to be the 20th image frame according to the image adjustment frame number of 30 frames. That is, the target video interval includes a total of 31 image frames. Excluding the initial image frame and the current image frame, it can be determined that the remaining image frames are a total of 29 frames, and the number of target anchor points for the target display special effects is 29.
[0108] It should be noted that these 29 target anchor points are only cached and will be used as the initial position when the current frame is 51-79. Every time a video effect plays a frame, the current target position needs to be registered into the queue, and this frame will become the initial image frame of the frame 30 frames later.
[0109] Step 210: Generate the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0110] Specifically, after the target launch point, initial position and at least one target anchor point position of the target display special effect have been determined, the points corresponding to these positions can be connected in sequence, and the connected display effect can be displayed in the current image frame to generate the target display special effect.
[0111] Through the implementation method provided by the present application, not only can the target display special effect be generated, but also the dynamic change of the curve change of the target display special effect can be realized. In practical applications, in order to make the presentation effect of the generated target display special effect smoother, noise can be superimposed on the target display special effect on the basis of the generated target display special effect to achieve a smoother and more random presentation effect of the target display special effect.
[0112] Based on this, in an implementation manner provided in the present application, after generating the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position, the method further includes:
[0113] Get sampling noise;
[0114] The sampling noise is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively.
[0115] Among them, sampling noise refers to the noise used to be superimposed on the target display special effect to make it smoother and more random. The sampling noise can be Perlin noise, Simplex noise, Value noise, etc. After obtaining the sampling noise, the sampling noise is superimposed on the target launch point, initial position and target anchor position of the target display special effect to achieve the smoothness and continuity of the target display special effect.
[0116] The process of obtaining sampling noise can be achieved in the following ways:
[0117] In one implementation manner provided in the present application, obtaining sampling noise includes:
[0118] Establishing a sampling space, and performing noise sampling in the sampling space to obtain initial sampling noise;
[0119] An interpolation calculation is performed on the initial sampling noise to obtain the sampling noise.
[0120] The sampling space refers to a space established for sampling noise. The sampling space can be a one-dimensional space, a two-dimensional space, or a three-dimensional space. The specific situation is determined according to the actual application, and this application does not make any limitation here.
[0121] The initial sampling noise can be understood as the noise randomly collected in the sampling space, which has a strong randomness. The sampling noise refers to the noise obtained by interpolation calculation based on the initial sampling noise. Compared with the initial sampling noise, the special effects generated by using sampling noise will be more natural and smoother.
[0122] Specifically, a sampling space is established, noise sampling is performed in the sampling space to obtain initial sampling noise, and interpolation calculation is performed on the initial sampling noise to obtain sampling noise.
[0123] The above is the process of obtaining sampling noise. Correspondingly, the application process of sampling noise is as follows:
[0124] In an implementation manner provided by the present application, the sampling noise is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively, including:
[0125] respectively calculating sampling offsets of sampling noise corresponding to the target emission point, the initial position and the at least one target anchor point position;
[0126] Based on the correspondence between each sampling offset and the target emission point, the initial position and the at least one target anchor point position, each sampling offset is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively.
[0127] The sampling offset refers to the positional deviation between the sampling noise and the target launch point, initial position, and target anchor point position of the target display special effect.
[0128] Specifically, the position deviation between the target launch point, initial position and target anchor point position of the target display special effect and the acquired sampling noise is calculated, and based on the position deviation corresponding to each position, the original position of the target launch point, initial position and target anchor point position of the target display special effect is adjusted.
[0129] Taking Perlin noise as an example, the position deviation between the Perlin noise and the target emission point, initial position and target anchor point position of the target display special effect is calculated, and the target emission point, initial position and target anchor point position of the target display special effect are adjusted according to the position deviation to make the presentation effect of the target display special effect more natural, smoother and more continuous.
[0130] By superimposing sampling noise on the generated target display special effects, the target display special effects can be further adjusted based on the already generated target display special effects, so that the presented target display special effects are smoother and more natural.
[0131] The special effects generation method provided in the present application receives a special effects generation instruction for a target display special effect, determines a target emission point and an emission direction of the target emission point for the target display special effect in response to the special effects generation instruction; determines a target position of the target display special effect in a current image frame according to the target emission point and the emission direction; obtains an initial position of the target display special effect based on the target position; calculates at least one target anchor point position of the target display special effect according to the target emission point and the initial position; and generates the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0132] An embodiment of the present application determines the target launch point and initial position of the target display special effect, and calculates at least one target anchor point position of the target display special effect based on a linear interpolation function, so that the target anchor point position of the target display special effect can be dynamically changed, so that the display effect presented by the target display special effect changes according to the target anchor point position, and no longer just presents a direct state for movement and change, thereby achieving the target display special effect. The special effect can present a natural arc state during the movement and transformation process, and the presentation effect is more natural and flexible, thereby improving the user experience.
[0133] The following combination Figure 4 , taking the application of the special effect generation method provided by this application in a game scene as an example, the special effect generation method is further described. Figure 4 A processing flow chart of a special effect generation method applied to a game scene provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0134] Step 402: receiving a special effect generation instruction for a lightning whip special effect, and determining a target emission point of the lightning whip special effect and an emission direction of the target emission point in response to the special effect generation instruction.
[0135] A special effect generation instruction of a lightning whip special effect is received, and in response to the special effect generation instruction, a target emission point A of the lightning whip special effect and an emission direction of the target emission point A are determined to be straight ahead.
[0136] Step 404: Based on the target emission point and the preset distance, determine the target position of the lightning whip special effect in the current image frame in the emission direction.
[0137] Based on the target launch point A and the preset distance of 3 cm, the target position B of the lightning whip special effect in the 50th image frame is determined directly in front of the target launch point A.
[0138] Step 406: Obtain the video frame rate of the game to which the lightning whip special effect belongs, and determine the image adjustment frame number based on the video frame rate.
[0139] The video frame rate of the game to which the lightning whip special effect belongs is obtained to be 60 frames per second, and the image adjustment frame number is determined to be 30 frames based on the video frame rate of 60 frames per second.
[0140] Step 408: determining an initial image frame according to the current image frame and the image adjustment frame number, and determining an initial position of the lightning whip special effect in the initial image frame.
[0141] According to the 50th image frame and the image adjustment frame number of 30 frames, the initial image frame is determined to be the 20th image frame, and the initial position C of the lightning whip special effect in the 20th image frame is determined in the 20th image frame.
[0142] Step 410: Determine the number of target anchor points of the lightning whip special effect according to the image adjustment frame number, and obtain the linear interpolation parameters corresponding to each target anchor point.
[0143] According to the image adjustment frame number of 30 frames, the number of target anchor points of the lightning whip special effect is determined to be 29, and the linear interpolation parameters corresponding to each target anchor point are obtained.
[0144] Step 412: Calculate the target anchor point position corresponding to each target anchor point based on the target emission point, the target position, the initial position and each linear interpolation parameter.
[0145] 29 target anchor point positions are calculated based on the target launch point A, target position B, initial position C and the linear interpolation parameters corresponding to each target anchor point.
[0146] Step 414: Generate the lightning whip special effect in the current image frame based on the target emission point, the target position, the initial position and the at least one target anchor point position.
[0147] A lightning whip special effect is generated in the 50th image frame based on the target launch point A, the target position B, the initial position C and the 29 target anchor point positions.
[0148] An embodiment of the present application determines the target launch point and initial position of the target display special effect, and calculates at least one target anchor point position of the target display special effect based on a linear interpolation function, so that the target anchor point position of the target display special effect can be dynamically changed, so that the display effect presented by the target display special effect changes according to the target anchor point position, and no longer just presents a direct state for movement and change, thereby achieving the target display special effect. The special effect can present a natural arc state during the movement and transformation process, and the presentation effect is more natural and flexible, thereby improving the user experience.
[0149] Corresponding to the above method embodiment, the present application also provides a special effect generation device embodiment, Figure 5 FIG. 1 is a schematic diagram showing the structure of a special effect generating device provided by an embodiment of the present application. Figure 5 As shown, the device comprises:
[0150] The first determination module 502 is configured to receive a special effect generation instruction for a target display special effect, and determine a target emission point for the target display special effect and an emission direction of the target emission point in response to the special effect generation instruction;
[0151] A second determination module 504 is configured to determine a target position of the target display special effect in the current image frame according to the target emission point and the emission direction;
[0152] A first acquisition module 506 is configured to acquire an initial position of the target display special effect based on the target position;
[0153] A calculation module 508 is configured to calculate at least one target anchor point position of the target display special effect according to the target launch point and the initial position;
[0154] The generation module 510 is configured to generate the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position.
[0155] Optionally, the second determining module 504 is further configured to:
[0156] Based on the target emission point and the preset distance, the target position of the target display special effect in the current image frame is determined in the emission direction.
[0157] Optionally, the first acquisition module 506 is further configured to:
[0158] determining an initial image frame based on the current image frame;
[0159] An initial position of the target display special effect is determined in the initial image frame.
[0160] Optionally, the first acquisition module 506 is further configured to:
[0161] Acquire a video frame rate, and determine an image adjustment frame number based on the video frame rate, wherein the image adjustment frame number is the number of image frames set according to the video frame rate;
[0162] An initial image frame is determined according to the image adjustment frame number and the current image frame.
[0163] Optionally, the first acquisition module 506 is further configured to:
[0164] Reading an image frame position queue, wherein the image frame position queue stores image frame information of each image frame and a target position corresponding to each image frame;
[0165] The initial image frame is searched in the image frame position queue, and a target position corresponding to the initial image frame is determined as an initial position of the target display special effect.
[0166] Optionally, the calculation module 508 is further configured to:
[0167] Determine the number of target anchor points;
[0168] Acquire a linear interpolation parameter corresponding to each target anchor point according to the number of the target anchor points;
[0169] The target anchor point position corresponding to each target anchor point is calculated based on the target emission point, the target position, the initial position and each linear interpolation parameter.
[0170] Optionally, the calculation module 508 is further configured to:
[0171] The number of target anchor points is determined according to the image adjustment frame number, wherein the image adjustment frame number is the number of image frames set according to the video frame rate.
[0172] Optionally, the device further comprises:
[0173] A second acquisition module is configured to acquire sampling noise;
[0174] The superposition module is configured to superimpose the sampling noise on the target emission point, the initial position and the at least one target anchor point position respectively.
[0175] Optionally, the second acquisition module is further configured to:
[0176] Establishing a sampling space, and performing noise sampling in the sampling space to obtain initial sampling noise;
[0177] An interpolation calculation is performed on the initial sampling noise to obtain the sampling noise.
[0178] Optionally, the superposition module is further configured as follows:
[0179] respectively calculating sampling offsets of sampling noise corresponding to the target emission point, the initial position and the at least one target anchor point position;
[0180] Based on the correspondence between each sampling offset and the target emission point, the initial position and the at least one target anchor point position, each sampling offset is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively.
[0181] By determining the target launch point and initial position of the target display special effect, and calculating at least one target anchor point position of the target display special effect based on the linear interpolation function, the target anchor point position of the target display special effect can be dynamically changed, so that the display effect presented by the target display special effect changes according to the target anchor point position, and no longer just presents a direct state for movement and change, so that the target display special effect can present a natural arc state during the movement and transformation process, and the presented effect is more natural and flexible, thereby improving the user experience.
[0182] The above is a schematic scheme of a special effect generation device of this embodiment. It should be noted that the technical scheme of the special effect generation device and the technical scheme of the special effect generation method described above are of the same concept, and the details not described in detail in the technical scheme of the special effect generation device can be referred to the description of the technical scheme of the special effect generation method described above.
[0183] Figure 6 The block diagram of a computing device 600 according to an embodiment of the present application is shown. The components of the computing device 600 include but are not limited to a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and the database 650 is used to store data.
[0184] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0185] In one embodiment of the present application, the above components of the computing device 600 and Figure 6 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 6 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0186] The computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 600 may also be a mobile or stationary server.
[0187] Among them, when the processor 620 executes the computer instructions, the steps of the special effect generation method are implemented.
[0188] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the special effect generation method described above are of the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the special effect generation method described above.
[0189] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the special effect generation method as described above.
[0190] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the special effect generation method described above are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the special effect generation method described above.
[0191] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0192] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0193] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0194] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0195] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A special effect generation method, characterized in that: include: receiving a special effect generation instruction for a target display special effect, and determining a target emission point for the target display special effect and an emission direction of the target emission point in response to the special effect generation instruction; Determine the target position of the target display special effect in the current image frame according to the target emission point and the emission direction; Acquire an initial position of the target display special effect in an initial image frame based on the target position, wherein the initial image frame is the first image frame in a target video interval, and the target video interval is a video interval for generating the target display special effect; Calculate at least one target anchor point position of the target display special effect according to the target emission point and the initial position; The target emission point, the at least one target anchor point position and the initial position are sequentially connected to generate the target display effect in the current image frame.
2. The method according to claim 1, characterized in that Determining a target position of the target display special effect in the current image frame according to the target emission point and the emission direction includes: Based on the target emission point and the preset distance, the target position of the target display special effect in the current image frame is determined in the emission direction.
3. The method according to claim 1, characterized in that Acquiring the initial position of the target display special effect based on the target position includes: determining an initial image frame based on the current image frame; An initial position of the target display special effect is determined in the initial image frame.
4. The method according to claim 3, characterized in that Determining an initial image frame based on the current image frame includes: Acquire a video frame rate, and determine an image adjustment frame number based on the video frame rate, wherein the image adjustment frame number is the number of image frames set according to the video frame rate; An initial image frame is determined according to the image adjustment frame number and the current image frame.
5. The method according to claim 3, characterized in that Determining the initial position of the target display special effect in the initial image frame includes: Reading an image frame position queue, wherein the image frame position queue stores image frame information of each image frame and a target position corresponding to each image frame; The initial image frame is searched in the image frame position queue, and a target position corresponding to the initial image frame is determined as an initial position of the target display special effect.
6. The method according to claim 1, characterized in that Calculating at least one target anchor point position of the target display special effect according to the target emission point and the initial position, including: Determine the number of target anchor points; Acquire a linear interpolation parameter corresponding to each target anchor point according to the number of the target anchor points; The target anchor point position corresponding to each target anchor point is calculated based on the target emission point, the target position, the initial position and each linear interpolation parameter.
7. The method according to claim 6, characterized in that Determine the number of target anchor points, including: The number of target anchor points is determined according to the image adjustment frame number, wherein the image adjustment frame number is the number of image frames set according to the video frame rate.
8. The method according to claim 1, characterized in that After generating the target display special effect in the current image frame based on the target emission point, the initial position and the at least one target anchor point position, the method further includes: Get sampling noise; The sampling noise is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively.
9. The method according to claim 8, characterized in that Get sampling noise, including: Establishing a sampling space, and performing noise sampling in the sampling space to obtain initial sampling noise; An interpolation calculation is performed on the initial sampling noise to obtain the sampling noise.
10. The method according to claim 8, characterized in that Superimposing the sampling noise on the target emission point, the initial position and the at least one target anchor point position respectively includes: respectively calculating sampling offsets of sampling noise corresponding to the target emission point, the initial position and the at least one target anchor point position; Based on the correspondence between each sampling offset and the target emission point, the initial position and the at least one target anchor point position, each sampling offset is superimposed on the target emission point, the initial position and the at least one target anchor point position respectively.
11. A special effect generating device, characterized in that: include: A first determination module is configured to receive a special effect generation instruction for a target display special effect, and determine a target emission point for the target display special effect and an emission direction of the target emission point in response to the special effect generation instruction; A second determination module is configured to determine a target position of the target display special effect in a current image frame according to the target emission point and the emission direction; A first acquisition module is configured to acquire an initial position of the target display special effect in an initial image frame based on the target position, wherein the initial image frame is the first image frame in a target video interval, and the target video interval is a video interval for generating the target display special effect; A calculation module, configured to calculate at least one target anchor point position of the target display special effect according to the target emission point and the initial position; A generation module is configured to sequentially connect the target emission point, the at least one target anchor point position and the initial position to generate the target display special effect in the current image frame.
12. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer instructions, the steps of the method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method described in any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Video special effect adding method and device, and intelligent mobile terminal
CN108022279A
Image special effect display method, device and electronic device
CN109068053A