The present application claims priority of the Chinese Patent Application No. 202210273163.1, filed on Mar. 18, 2022, the disclosure of which is incorporated herein by reference in its entirety.
The present disclosure relates to the technical field of image effect processing, such as an effect video generating method and apparatus, a device, and a storage medium.
Most of simulation algorithms for fluid objects (referred to as fluid) are implemented based on Position Base Dynamic (PBD) algorithm. The principle is to abstract the fluid into multiple particles and calculate motion states of the particles in each frame, so as to generate a fluid motion effect video. However, this algorithm has a large budget and cannot generate the fluid motion effect video in real time.
The method, the apparatus, the device, and the storage medium for generate the effect video provided by the present disclosure can reduce calculation amount for simulating fluid motion, thereby improving the efficiency of generating the fluid motion effect video.
In a first aspect, the present disclosure provides an effect video generating method, which includes:
In a second aspect, the present disclosure further provides an effect video generating apparatus, which includes:
In a third aspect, the present disclosure further provides an electronic device, which includes:
In a fourth aspect, the present disclosure further provides a computer-readable medium, on which computer programs are stored, the computer programs, when executed by a processing apparatus, implement the above-mentioned effect video generating method.
In a fifth aspect, the present disclosure further provides a computer program product, including computer programs carried on a non-transitory computer-readable medium, the computer programs include program code for executing the above-mentioned effect video generating method.
Embodiments of the present disclosure will be described below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, the present disclosure can be embodied in various forms, and these embodiments are provided for understanding the present disclosure. The drawings and embodiments of the present disclosure are for exemplary purposes only.
It should be understood that various steps recorded in the implementation modes of the method of the present disclosure may be performed according to different orders and/or performed in parallel. In addition, the implementation modes of the method may include additional steps and/or steps omitted or unshown. The scope of the present disclosure is not limited in this aspect.
The term “including” and variations thereof used in this article are open-ended inclusion, namely “including but not limited to”. The term “based on” refers to “at least partially based on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one other embodiment”; and the term “some embodiments” means “at least some embodiments”. Relevant definitions of other terms may be given in the description hereinafter.
Concepts such as “first” and “second” mentioned in the present disclosure are only used to distinguish different apparatuses, modules or units, and are not intended to limit orders or interdependence relationships of functions performed by these apparatuses, modules or units.
Modifications of “one” and “more” mentioned in the present disclosure are schematic rather than restrictive, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as “one or more”.
Names of messages or information exchanged among multiple apparatus in the embodiments of the present disclosure are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
S110: determining motion information of virtual fluid in a current frame and first state information of virtual fluid surface in a previous frame.
The virtual fluid is placed in a virtual container. The motion information in the current frame may include a motion speed and acceleration. The first state information in the previous frame may include first disturbance information, first fluid surface orientation information, a first fluid surface motion speed and a first swing amplitude. The first disturbance information may be the information of waves generated by the disturbance added to the fluid surface in the previous frame; The first fluid surface orientation information may be characterized by the normal information (such as normal vector) of the fluid surface in the previous frame.
The ways to determine the motion information of the virtual fluid in the current frame may be as follows: determining motion information of a mobile terminal in the current frame as the motion information of the virtual fluid in the current frame; or identifying limbs of a character in a picture, and determining motion information of the limbs of the character in the current frame as the motion information of the virtual fluid in the current frame.
In the embodiment, when a user turns on a camera in a terminal device, a virtual container (such as a transparent virtual water cup or a transparent virtual fish tank, etc.) is generated in a current picture, and a virtual fluid (such as water, milk or colored drinks, etc.) is generated in the virtual container. When the user swings the mobile terminal, the virtual container and the virtual fluid move with the swinging mobile terminal, or limbs of a character (such as head, legs, body or arms, etc.) are detected in the picture; and when the limbs of the character move, the virtual container and the virtual fluid move with the motion of the limbs of the character. In the embodiment, the motion state of the virtual fluid in the virtual container is simulated, so that the virtual fluid moves with the motion of the container like the real fluid.
The ways to determine the motion information of the virtual fluid in the current frame may be as follows: acquiring first position information of the virtual fluid in the current frame and second position information in the previous frame; determining the motion speed of the virtual fluid in the current frame according to the first position information and the second position information; acquiring a motion speed of the virtual fluid in the previous frame; and determining the acceleration of the virtual fluid in the current frame according to the motion speed of the virtual fluid in the current frame and the motion speed in the previous frame.
In the embodiment, the virtual fluid moves with the virtual container, and the position information of the virtual fluid may be determined by the position information of a center point of the virtual container. If the motion information of the mobile terminal in the current frame is determined as the motion information of the virtual fluid in the current frame, the virtual container moves with the mobile terminal, so the position information of the virtual container may be determined by acquiring the position information of any point of the mobile terminal. If the motion information of the limbs of the character in the current frame is determined as the motion information of the virtual fluid in the current frame, the virtual container moves with the motion of the limbs of the character, so the position information of the virtual container may be determined by acquiring the position information of any key point of the limbs of the character. Assuming that the three-dimensional position coordinates of the center point of the virtual container in the current frame are Pt, and the three-dimensional position coordinates of the center point of the virtual container in the previous frame are Pt-1, the motion speed of the virtual fluid in the current frame is ut=Pt−Pt-1, and the acceleration is dt=ut−ut-1. A plurality of parameters appearing in the embodiment are all three-dimensional parameters, and the following description will not be repeated.
S120: determining second state information of the virtual fluid surface in the current frame based on the motion information and the first state information.
The second state information includes second fluid surface orientation information and second disturbance information. The second disturbance information may be the information of waves generated by the disturbance added to the fluid surface in the current frame; and the second fluid surface orientation information may be characterized by the normal information (such as normal vector) of the fluid surface in the current frame.
The process of determining the second state information of the virtual fluid surface in the current frame based on the motion information and the first state information may be as follows: determining a second swing amplitude and initial fluid surface orientation information of the virtual fluid surface in the current frame according to the motion information and the first state information; determining the second fluid surface orientation information based on the second swing amplitude and the initial fluid surface orientation information; and determining the second disturbance information based on the second swing amplitude and the first disturbance information.
The initial fluid surface orientation information may be an initial normal vector of the fluid surface of the current frame.
In the embodiment, the process of determining the initial fluid surface orientation information of the virtual fluid surface in the current frame according to the motion information and the first state information may be as follows: determining a second fluid surface motion speed according to the acceleration and the first fluid surface motion speed; acquiring a set rotation matrix corresponding to a set Euler angle; and determining the initial fluid surface orientation information according to the set rotation matrix and the second fluid surface motion speed.
the process of determining the second fluid surface motion speed according to the acceleration and the first fluid surface motion speed may be calculated according to the following formula: vt=0.6·vt-1−0.4·dt-1. The set Euler angle may be (0, 180°, 0), and the set rotation matrix corresponding to the set Euler angle may be a four-element rotation matrix rotating around the set Euler angle. The set rotation matrix may be expressed as Qu, and the process of determining the initial fluid surface orientation information according to the set rotation matrix and the second fluid surface motion speed may be calculated according to the following formula: Nt=Qu·(−0.5·vt+0.5n), where n is a gravity vector (0,1,0).
The ways to determine the second swing amplitude of the virtual fluid surface in the current frame according to the motion information and the first state information may be as follows: determining a first angular velocity of the virtual fluid surface in the previous frame; and determining the second swing amplitude based on the first angular velocity, the first swing amplitude, the motion speed and the first fluid surface orientation information.
The formula for determining the second swing amplitude based on the first angular velocity, the first swing amplitude, the motion speed and the first fluid surface orientation information may be expressed as: mt=0.02 (mt-1.x+0.05·Nt-1.x+At-1.z, mt-1.y+0.002·ut.y, mt-1.z+0.05·Nt-1.z+At-1.x), where mt is the second swing amplitude in the current frame, mt-1.x, mt-1.y, mt-1.z is the x-direction component, the y-direction component and the z-direction component of the second swing amplitude, respectively, Nt-1.x, Nt-1.z are the x-direction component and the z-direction component of the first fluid surface orientation information, respectively, and At-1.x, At-1.z: are the x-direction component and z-direction component of the first angular velocity, respectively.
The way to determine a second angular velocity of the virtual fluid surface in the current frame may be as follows: acquiring a first rotation matrix of the virtual fluid in the previous frame and a second rotation matrix in the current frame; determining rotation axis information according to the first rotation matrix and the second rotation matrix, and acquiring the first angular velocity of the virtual fluid surface in the previous frame; and determining the second angular velocity according to the first angular velocity and the rotation axis information.
Both the first rotation matrix and the second rotation matrix may be obtained by an attitude sensor (such as a gyro sensor) installed in the mobile terminal. The process of determining the rotation axis information according to the first rotation matrix and the second rotation matrix may be: converting a matrix multiplied by the second rotation matrix and the first rotation matrix to obtain the rotation axis information. Assuming that the second rotation matrix is expressed as Qt, the first rotation matrix is expressed as Qt-1, and the rotation axis ct is obtained by transforming the Qt·Qt-1. Then the formula for determining the second angular velocity according to the first angular velocity and the rotation axis information may be: At=Qu·(0.5·(0.9·At-1+0.09·At-1ct)−0.5·n), where n is the gravity vector. Similarly, the first angular velocity of the virtual fluid surface in the previous frame can also be calculated according to the above formula.
In the embodiment, in order to simulate the real fluid motion state, it is necessary to consider the swing amplitude of the fluid surface. The ways to determine the second fluid surface orientation information based on the second swing amplitude and the initial fluid surface orientation information may be as follows: determining a disturbance angle according to the initial fluid surface orientation information and the gravity vector; determining a disturbance vector based on the disturbance angle and a volume of the virtual container; and determining the second fluid surface orientation information according to the disturbance vector, the second swing amplitude and the initial fluid surface orientation information.
The calculation formula of the disturbance angle may be:
where Nt is the initial fluid surface orientation information and n is the gravity vector. The calculation formula of the disturbance vector may be expressed as:
timestamp of the current frame, and β is the disturbance angle. The calculation formula for determining the second fluid surface orientation information according to the disturbance vector, the second swing amplitude and the initial fluid surface orientation information is: wt=Γ(mt.x*st.x+0.25·Nt.x, 1.0, mt.z*st.y+0.25·Nt.z), where Γ( ) represents normalizing the vector, mt.x, mt.z represent the x-direction component and the z-direction component of the second swing amplitude, respectively, Nt.x, Nt.z represent the x-direction component and the z-direction component of the initial fluid surface orientation information, respectively, and st.x, st.y represent the x-direction component and the y-direction component of the disturbance vector, respectively.
The calculation formula for determining the second disturbance information based on the second swing amplitude and the first disturbance information may be: ht=0.2 ht-1+0.8·(0.5·√{square root over (5·|mt|)}+0.5)7.5, where ht is the second disturbance information in the current frame, ht-1 is the first disturbance information in the previous frame.
S130: rendering a fluid surface state of the current frame according to the second fluid surface orientation information and the second disturbance information to obtain a fluid motion effect map corresponding to the current frame.
After acquiring the second fluid surface orientation information wt and the second disturbance information ht of the current frame, the wt and ht are transmitted to the rendering shader to obtain the fluid motion effect map corresponding to the current frame.
The process of rendering the fluid surface state of the current frame according to the second fluid surface orientation information and the second disturbance information to obtain the fluid motion effect map corresponding to the current frame may be as follows: determining an initial fluid surface state according to the second fluid surface orientation information; superposing the second disturbance information on the initial fluid surface state to obtain a target fluid surface state; and rendering the target fluid surface state to obtain a fluid motion effect image corresponding to the current frame.
The second fluid surface orientation information is represented by a normal vector, which is perpendicular to the fluid surface, so the plane function corresponding to the initial fluid surface state may be obtained according to the normal vector. The way to superpose the second disturbance information on the initial fluid surface state may be as follows: inputting the second disturbance information into a set noise function to obtain a noise function carrying the second disturbance information, and linearly superimposing the noise function with a plane function corresponding to the initial surface state to obtain a state function corresponding to the target fluid surface state. Finally, the target fluid surface state is rendered based on the state function, and the fluid motion effect image corresponding to the current frame is obtained. For example,
The technical scheme of the embodiment of the present disclosure, which includes: determining motion information of virtual fluid in a current frame and first state information of virtual fluid surface in a previous frame, the virtual fluid is placed in a virtual container; determining second state information of the virtual fluid surface in the current frame based on the motion information and the first state information, the second state information includes second fluid surface orientation information and second disturbance information; and rendering a fluid surface state of the current frame according to the second fluid surface orientation information and the second disturbance information to obtain a fluid motion effect map corresponding to the current frame. According to the embodiment of the present disclosure, the fluid surface state is rendered through the second fluid surface orientation information and the second disturbance information of the current frame, and the fluid motion effect map corresponding to the current frame is obtained, so that the calculation amount for simulating the fluid motion can be reduced, and the efficiency of generating the fluid motion effect video can be improved.
In an embodiment, the motion information includes a motion speed and acceleration, and the first state information includes first disturbance information, first fluid surface orientation information, a first fluid surface motion speed and a first swing amplitude.
In an embodiment, the motion information determining module 210 is further configured to:
In an embodiment, the motion information determining module 210 is further configured to:
In an embodiment, the second state information determining module 220 is further configured to:
In an embodiment, the second state information determining module 220 is further configured to:
In an embodiment, the second state information determining module 220 is further configured to:
In an embodiment, the second state information determining module 220 is further configured to:
In an embodiment, the second state information determining module 220 is further configured to:
In an embodiment, the fluid motion effect map acquisition module 230 is further configured to:
The above-mentioned apparatus can execute the methods provided by all the above-mentioned embodiments of the present disclosure, and has corresponding functional modules and effects for executing the above-mentioned methods. For technical details that are not described in detail in the embodiments, the methods provided by all the previous embodiments of the present disclosure may be referred to.
Referring to
As illustrated in
Usually, the following apparatus may be connected to the I/O interface 305: an input apparatus 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, or the like; an output apparatus 307 including, for example, a liquid crystal display (LCD), a loudspeaker, a vibrator, or the like; a storage apparatus 308 including, for example, a magnetic tape, a hard disk, or the like; and a communication apparatus 309. The communication apparatus 309 may allow the electronic device 300 to be in wireless or wired communication with other devices to exchange data. While
According to some embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried by a non-transitory computer-readable medium. The computer program includes program codes for performing the methods shown in the flowcharts. In such embodiments, the computer program may be downloaded online through the communication apparatus 309 and installed, or may be installed from the storage apparatus 308, or may be installed from the ROM 302. When the computer program is executed by the processing apparatus 301, the above-mentioned functions defined in the methods of some embodiments of the present disclosure are performed.
The above-mentioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. For example, the computer-readable storage medium may be, but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of the computer-readable storage medium may include but not be limited to: an electrical connection with one or more wires, a portable computer disk, 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 compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination of them. In the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus or device. In the present disclosure, the computer-readable signal medium may include a data signal that propagates in a baseband or as a part of a carrier and carries computer-readable program codes. The data signal propagating in such a manner may take a plurality of forms, including but not limited to an electromagnetic signal, an optical signal, or any appropriate combination thereof. The computer-readable signal medium may also be any other computer-readable medium than the computer-readable storage medium. The computer-readable signal medium may send, propagate or transmit a program used by or in combination with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted by using any suitable medium, including but not limited to an electric wire, a fiber-optic cable, radio frequency (RF) and the like, or any appropriate combination of them.
In some implementation modes, the client and the server may communicate with any network protocol currently known or to be researched and developed in the future such as hypertext transfer protocol (HTTP), and may communicate (via a communication network) and interconnect with digital data in any form or medium. Examples of communication networks include a local area network (LAN), a wide area network (WAN), the Internet, and an end-to-end network (e.g., an ad hoc end-to-end network), as well as any network currently known or to be researched and developed in the future.
The above-mentioned computer-readable medium may be included in the above-mentioned electronic device, or may also exist alone without being assembled into the electronic device.
The above-mentioned computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device is caused to: determine motion information of virtual fluid in a current frame and first state information of virtual fluid surface in a previous frame, the virtual fluid is placed in a virtual container; determine second state information of the virtual fluid surface in the current frame based on the motion information and the first state information, the second state information includes second fluid surface orientation information and second disturbance information; and render a fluid surface state of the current frame according to the second fluid surface orientation information and the second disturbance information to obtain a fluid motion effect map corresponding to the current frame.
The computer program codes for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof. The above-mentioned programming languages include but are not limited to object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the “C” programming language or similar programming languages. The program code may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the scenario related to the remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of codes, including one or more executable instructions for implementing specified logical functions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may also occur out of the order noted in the accompanying drawings. For example, two blocks shown in succession may, in fact, can be executed substantially concurrently, or the two blocks may sometimes be executed in a reverse order, depending upon the functionality involved. It should also be noted that, each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may also be implemented by a combination of dedicated hardware and computer instructions.
The modules or units involved in the embodiments of the present disclosure may be implemented in software or hardware. Among them, the name of the module or unit does not constitute a limitation of the unit itself under certain circumstances.
The functions described herein above may be performed, at least partially, by one or more hardware logic components. For example, without limitation, available exemplary types of hardware logic components include: a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), an application specific standard product (ASSP), a system on chip (SOC), a complex programmable logical device (CPLD), etc.
In the context of the present disclosure, the machine-readable medium may be a tangible medium that may include or store a program for use by or in combination 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 includes, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semi-conductive system, apparatus or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage medium include electrical connection with one or more wires, portable computer disk, hard disk, random-access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, the embodiments of the present disclosure discloses an effect video generating method, which includes the following steps:
According to one or more embodiments of the present disclosure, the motion information includes a motion speed and acceleration, and the first state information includes first disturbance information, first fluid surface orientation information, a first fluid surface motion speed and a first swing amplitude.
According to one or more embodiments of the present disclosure, determining the motion information of the virtual fluid in the current frame includes:
According to one or more embodiments of the present disclosure, determining the motion information of the virtual fluid in the current frame includes:
According to one or more embodiments of the present disclosure, determining the second state information of the virtual fluid surface in the current frame based on the motion information and the first state information includes:
According to one or more embodiments of the present disclosure, determining the second swing amplitude of the virtual fluid surface in the current frame according to the motion information and the first state information includes:
According to one or more embodiments of the present disclosure, determining a second angular velocity of the virtual fluid surface in the current frame includes:
According to one or more embodiments of the present disclosure, determining the initial fluid surface orientation information of the virtual fluid surface in the current frame according to the motion information and the first state information includes:
According to one or more embodiments of the present disclosure, determining the second fluid surface orientation information based on the second swing amplitude and the initial fluid surface orientation information includes:
According to one or more embodiments of the present disclosure, rendering the fluid surface state of the current frame according to the second fluid surface orientation information and the second disturbance information to obtain the fluid motion effect map corresponding to the current frame includes:
Number | Date | Country | Kind |
---|---|---|---|
202210273163.1 | Mar 2022 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2023/079811 | 3/6/2023 | WO |