WO2023109555A1 - 流体粒子的渲染方法、装置、系统及存储介质 - Google Patents

流体粒子的渲染方法、装置、系统及存储介质 Download PDF

Info

Publication number
WO2023109555A1
WO2023109555A1 PCT/CN2022/136692 CN2022136692W WO2023109555A1 WO 2023109555 A1 WO2023109555 A1 WO 2023109555A1 CN 2022136692 W CN2022136692 W CN 2022136692W WO 2023109555 A1 WO2023109555 A1 WO 2023109555A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame
positions
screen
frames
adjacent
Prior art date
Application number
PCT/CN2022/136692
Other languages
English (en)
French (fr)
Inventor
刘佳成
李奇
Original Assignee
北京字跳网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字跳网络技术有限公司 filed Critical 北京字跳网络技术有限公司
Publication of WO2023109555A1 publication Critical patent/WO2023109555A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/20Analysis of motion
    • G06T7/269Analysis of motion using gradient-based methods

Definitions

  • the embodiments of the present disclosure relate to the field of computer technology, and in particular to a method, device, system and storage medium for rendering fluid particles.
  • a single particle is rendered by using a trail renderer (Trail Renderer) component, so as to realize the trailing effect of the particle.
  • the Trail Renderer component uses the grid (mesh) to generate multiple meshes behind the mesh corresponding to a single particle to complete the trail rendering.
  • an embodiment of the present disclosure provides a method for rendering fluid particles, including:
  • N is a positive integer greater than or equal to 2;
  • At least one frame position of the same fluid particle is obtained by interpolation
  • performing trailing rendering of fluid particles based on non-adjacent N frame positions includes:
  • the non-adjacent N frame positions are meta-balled.
  • respectively setting corresponding particle sizes for non-adjacent N frame positions includes:
  • the particle size corresponding to non-adjacent N frame positions increases with the increase of sequence.
  • the rendering method of fluid particles further includes:
  • the distance between the screen positions of two adjacent frames is greater than or equal to the distance threshold, the distance between the screen positions of the two adjacent frames is reduced.
  • the distance threshold corresponding to the screen positions of two adjacent frames is determined by the following formula:
  • Distance threshold a ⁇ particle size 1 + b ⁇ particle size 2;
  • a and b are preset constants
  • particle size 1 and particle size 2 are particle sizes corresponding to screen positions of two adjacent frames.
  • the screen positions of the N frames include: the screen position of the first frame, the screen position of the third frame and the screen position of the fifth frame;
  • Reducing the distance between the screen positions of two adjacent frames includes:
  • the first distance threshold is based on the screen position of frame 1 The threshold determined by the particle size corresponding to the position and the screen position of the third frame;
  • the second distance threshold is the threshold determined based on the particle size corresponding to the screen position of frame 3 and the screen position of frame 5 respectively.
  • reducing the distance between the screen positions of two adjacent frames includes:
  • the distance vector Based on the fixed position, the distance vector, the distance between the screen positions of two adjacent frames and the distance threshold, determine the screen position after the distance is reduced.
  • the screen position after the distance is reduced is determined by the following formula:
  • Screen position after distance reduction fixed position+distance vector ⁇ (distance threshold ⁇ distance between screen positions of two adjacent frames).
  • the interpolation to obtain at least one frame position of the same fluid particle based on the positions of the consecutive N frames includes:
  • N is less than or equal to the preset frame number threshold, centering on the position of the Nth frame, at least one of the positions from the position of the first frame to the position of the N-1th frame is symmetrically obtained to obtain at least one of the same fluid particles frame position.
  • selecting non-adjacent N frame positions from the positions of the consecutive N frames and the at least one frame position comprises:
  • the consecutive N frames are 3 consecutive frames
  • the preset frame number threshold is 3 frames
  • the interpolation to obtain at least one frame position of the same fluid particle based on the positions of the consecutive N frames includes:
  • the position of the first frame is symmetrically centered on the position of the third frame to obtain the position of the fifth frame of the same fluid particle.
  • selecting non-adjacent N frame positions from the positions of the consecutive N frames and the at least one frame position comprises:
  • an embodiment of the present disclosure provides a fluid particle rendering device, including:
  • An acquisition unit configured to acquire the position of the same fluid particle in consecutive N frames in time series, where N is a positive integer greater than or equal to 2;
  • the interpolation unit is used to obtain at least one frame position of the same fluid particle through interpolation based on the positions of consecutive N frames;
  • a selection unit configured to select non-adjacent N frame positions from consecutive N frame positions and at least one frame position
  • the rendering unit is used for trailing rendering of fluid particles based on non-adjacent N frame positions.
  • the embodiments of the present disclosure further propose a system including at least one computing device and at least one storage device storing instructions, wherein the instructions, when executed by the at least one computing device, cause the at least one computing The device executes the steps of the fluid particle rendering method described in any embodiment of the first aspect.
  • the embodiments of the present disclosure also propose a computer-readable storage medium, the computer-readable storage medium stores programs or instructions, and when the programs or instructions are run by at least one computing device, at least one computing device executes The steps of the rendering method of fluid particles as described in any embodiment of the first aspect.
  • an embodiment of the present disclosure further proposes a computer program, including: instructions, which, when executed by a processor, cause the processor to execute the method for rendering fluid particles as described in any embodiment of the first aspect. step.
  • FIG. 1 is an exemplary flowchart of a method for rendering fluid particles provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of a rendering process of fluid particles provided by an embodiment of the present disclosure
  • Fig. 3 is a schematic diagram of a distance adjustment process between adjacent particles provided by an embodiment of the present disclosure
  • Fig. 4 is an exemplary flow chart of another fluid particle rendering method provided by an embodiment of the present disclosure.
  • FIG. 5 is an exemplary flow chart of another fluid particle rendering method provided by an embodiment of the present disclosure.
  • FIG. 6 is a schematic diagram of another rendering process of fluid particles provided by an embodiment of the present disclosure.
  • Fig. 7 is a schematic diagram of another distance adjustment process between adjacent particles provided by an embodiment of the present disclosure.
  • Fig. 8 is an exemplary block diagram of a fluid particle rendering device provided by an embodiment of the present disclosure.
  • Fig. 9 is an exemplary block diagram of a system including at least one computing device and at least one storage device storing instructions provided by an embodiment of the present disclosure
  • Fig. 10 is a schematic diagram of a disconnection phenomenon provided by an embodiment of the present disclosure.
  • FIG. 11 is a schematic diagram of a water drop-shaped trailing effect provided by an embodiment of the present disclosure.
  • Trail Renderer component will generate a large number of meshes, so it cannot be applied to mobile terminals with limited performance. Therefore, there is an urgent need to provide a trailing rendering solution for fluid particles to solve at least one of the foregoing technical problems.
  • At least one embodiment of the present disclosure provides a rendering method, device, system and storage medium of fluid particles.
  • Fig. 1 is an exemplary flow chart of a rendering method for fluid particles provided by an embodiment of the present disclosure.
  • the execution body of the rendering method can be the server or the mobile terminal.
  • the rendering method may include but not limited to the following steps 101 to 104:
  • step 101 the positions of the same fluid particle in consecutive N frames in time sequence are obtained, where N is a positive integer greater than or equal to 2.
  • Fluid particles are particles generated in the simulation space by the Vertex Shader.
  • the simulation space is a square plane area, and the aspect ratio of the plane area can be set to 16:9 to meet the screen aspect ratio of the server or mobile terminal.
  • the Y-axis coordinate range of the simulation space is minus 27.2 to plus 27.2
  • the X-axis coordinate range of the simulation space is minus 15.3 to plus 15.3
  • the origin of the simulation space is at the center of the simulation space.
  • the simulation space mentioned above can be understood as a particle space, therefore, the acquired position of the same fluid particle in consecutive N frames in time sequence can be understood as the particle space position of the fluid particle in N consecutive frames in time sequence.
  • the position of the same fluid particle in consecutive N frames in time series is recorded as: the position of the first frame, the position of the second frame, the position of the third frame, ..., the position of the Nth frame, where the position of the first frame can be understood as the current position of the fluid particle
  • the position of the frame, the second frame position to the Nth frame position can be understood as the position of the fluid particle history frame.
  • step 102 based on the positions of consecutive N frames, at least one frame position of the same fluid particle is obtained through interpolation.
  • the position of the N+1th frame, the N+2th frame position, or even more frame positions of the same fluid particle can be obtained by interpolation.
  • the trajectory formed by the positions of the consecutive N frames and the positions of the multi-frames obtained through interpolation is a straight line or a curved line (for example, a Bezier curve).
  • non-adjacent N frame positions are selected from consecutive N frame positions and at least one frame position.
  • step 104 trailing rendering of fluid particles is performed based on non-adjacent N frame positions.
  • metaball processing may be performed based on non-adjacent N frame positions, so as to realize the trailing effect of the fluid particles.
  • the specific process of metaball processing is a mature technology in the field, and will not be repeated here.
  • FIG. 2 is a schematic flow diagram of a trailing rendering process of fluid particles provided by an embodiment of the present disclosure, which is applicable to step 104 in FIG. 1 .
  • performing trailing rendering of fluid particles based on non-adjacent N frame positions may include but not limited to the following steps 201 and 202:
  • step 201 corresponding particle sizes and attenuation curves are respectively set for non-adjacent N frame positions.
  • Particle size can be understood as the diameter of the particle.
  • the particle size By setting the particle size, different trailing effects can be achieved. For example, the size of particles corresponding to non-adjacent N frame positions is increased with increasing order, and the final meta-ball processing can achieve a drop-shaped trailing effect.
  • the attenuation curve is the attenuation curve of the alpha channel of the particles from the center to the outside.
  • the alpha channel represents transparency. Therefore, the center of the particle is opaque, and gradually becomes transparent from the center to the outside according to the attenuation curve.
  • the decay curve is a cubic decay curve or a quintic decay curve.
  • step 202 based on the particle size and the attenuation curve, meta-ball processing is performed on non-adjacent N frame positions.
  • the particles at one frame position gradually become transparent from the center to the outside, and the particles at another frame position also gradually become transparent from the center to the outside. Therefore, the particles at the two frame positions are at the edge There will be an overlay effect, causing the alpha channel to change, that is, the transparency to change.
  • the transparency threshold can be set to determine whether the transparency of the superimposed particles at the edge of the two frames is greater than or equal to the transparency threshold. If it is greater than or equal to the transparency threshold, the particles at the two frames will be meta-processed.
  • the particle fusion of the two frame positions may not be completed, resulting in a disconnection phenomenon, as shown in the figure 10 shown. Whether it is a cubic decay curve or a quintic decay curve, there is a disconnect. Therefore, in order to solve the disjoint problem, the distance between adjacent particles needs to be reduced before performing meta-ball processing on non-adjacent N frame positions.
  • Fig. 3 is a schematic diagram of a distance adjustment process between adjacent particles provided by an embodiment of the present disclosure. Before the process is applied to step 202 shown in FIG. 2 , as shown in FIG. 3 , it may include but not limited to the following steps 301 to 304:
  • step 301 non-adjacent N frame positions are transformed into N frame screen positions in the screen coordinate system.
  • the acquired position of the same fluid particle in consecutive N frames in time sequence is the particle space position of the fluid particle in consecutive N frames in time sequence, not the screen space position of the mobile terminal, therefore, based on the particle space position of consecutive N frames, by interpolation Obtaining at least one frame position of the same fluid particle is also a position in the particle space, not the screen space position of the mobile terminal. Therefore, from the positions of consecutive N frames and at least one frame position, selecting non-adjacent N frame positions is also a particle space The position in the , not the screen space position of the mobile terminal.
  • the non-adjacent N frame positions are converted from the particle space to the N frame screen positions in the screen coordinate system, for example, the non-adjacent N frame positions are first normalized, and then converted to the screen position The screen position of N frames in the coordinate system.
  • the formula is as follows:
  • Screen position particle space position ⁇ particle space size ⁇ (screen size ⁇ 2).
  • Particle space position ⁇ particle space size is the normalization process.
  • step 302 based on the screen positions of N frames, the distance between the screen positions of two adjacent frames is determined.
  • the distance between the screen positions of two adjacent frames can be solved by using the existing distance calculation formula.
  • step 303 based on the respective particle sizes corresponding to the screen positions of the two adjacent frames, the distance thresholds corresponding to the screen positions of the two adjacent frames are determined.
  • the distance threshold corresponding to the screen positions of two adjacent frames is determined by the following formula:
  • Distance threshold a ⁇ particle size 1 + b ⁇ particle size 2;
  • a and b are preset constants
  • particle size 1 and particle size 2 are particle sizes corresponding to screen positions of two adjacent frames.
  • step 304 if the distance between the screen positions of two adjacent frames is greater than or equal to the distance threshold, the distance between the screen positions of two adjacent frames is reduced.
  • reducing the distance between the screen positions of two adjacent frames includes the following three steps S1 to S3:
  • the distance vector Based on the fixed position, the distance vector, the distance between the screen positions of two adjacent frames and the distance threshold, determine the screen position after the distance is reduced.
  • the screen position after the distance is reduced is determined by the following formula:
  • Screen position after distance reduction fixed position+distance vector ⁇ (distance threshold ⁇ distance between screen positions of two adjacent frames).
  • the screen positions of N frames are converted into normalized coordinates, and then step 202 shown in FIG.
  • the frame positions are subjected to meta-ball processing. It should be noted that non-adjacent N frame positions are N frame positions of normalized coordinates.
  • the distance threshold when the distance between adjacent particles is greater than or equal to the distance threshold, the position of the particle whose appearance time is earlier is changed to make it closer to the particle position of the current frame, so as to avoid A disjointed phenomenon occurs when the movement speed is fast.
  • the particle size and attenuation curve different smearing effects can be achieved.
  • the particle size corresponding to non-adjacent N frame positions increases with the sequence, and the final meta-ball processing can achieve a drop-shaped smear The effect, the drop-shaped smear effect is shown in Figure 11.
  • Fig. 4 is an exemplary flow chart of a fluid particle rendering method provided by an embodiment of the present disclosure, as shown in Fig. 4 , including the following steps 401 to 404:
  • step 401 the positions of the same fluid particle in consecutive N frames in time sequence are obtained, where N is a positive integer greater than or equal to 2.
  • step 402 if N is less than or equal to the preset frame number threshold, at least one of the position of the first frame to the position of the N-1th frame is symmetrically processed with the position of the Nth frame as the center to obtain the same fluid At least one frame position of the particle.
  • non-adjacent N frame positions are selected from consecutive N frame positions and at least one frame position.
  • step 404 trailing rendering of fluid particles is performed based on non-adjacent N frame positions.
  • Steps 401 , 403 and 404 are the same as steps 101 , 103 and 104 in FIG. 1 , and will not be repeated here.
  • the position of the same fluid particle in three consecutive frames in time sequence is recorded, that is, the movement path of the same fluid particle.
  • the position of the fluid particle in the current frame is recorded as the position of the first frame
  • the position of the fluid particle in the previous frame of the current frame is recorded as the position of the second frame, and so on.
  • the mobile device does not record the positions of the fluid particles in frame 4 and frame 5.
  • the positions of the water droplets in the three consecutive frames in the time series may be so close that they cannot be distinguished, directly use continuous
  • the position of 3 frames is processed by metaball, and the smearing effect is not obvious.
  • the position of the three frames is not directly metaballed, but based on the position of the three frames , at least one frame position of the fluid particle is obtained by interpolation, and then three non-adjacent frame positions are selected from the positions of three consecutive frames and at least one frame position obtained by interpolation, so as to be based on the three non-adjacent frame positions
  • the trailing rendering of the fluid particles avoids the problem that the trailing effect is not obvious due to the slow speed of the fluid particles and the short distance between the positions of three consecutive frames, and is suitable for the trailing rendering of a large number of fluid particles in a two-dimensional scene and is applicable on mobile.
  • Fig. 5 is an exemplary flowchart of a rendering method for fluid particles provided by an embodiment of the present disclosure.
  • the execution subject of the rendering method is a mobile terminal, such as a smart phone, a tablet computer and other mobile terminal devices.
  • the rendering method may include but not limited to the following steps 501 to 504:
  • step 501 the position of the same fluid particle in three consecutive frames in time sequence is acquired.
  • Fluid particles are particles generated in the simulation space by the Vertex Shader.
  • the simulation space is a square plane area, and the aspect ratio of the plane area can be set to 16:9 to meet the screen aspect ratio of the mobile terminal.
  • the Y-axis coordinate range of the simulation space is minus 27.2 to plus 27.2
  • the X-axis coordinate range of the simulation space is minus 15.3 to plus 15.3
  • the origin of the simulation space is at the center of the simulation space.
  • the simulation space mentioned above can be understood as a particle space, therefore, the acquired position of the same fluid particle in three consecutive frames in time series can be understood as the particle space position of the fluid particle in three consecutive frames in time series.
  • the position of the same fluid particle in three consecutive frames in time series is recorded as: the position of the first frame, the position of the second frame and the position of the third frame, where the position of the first frame can be understood as the position of the current frame of the fluid particle, and the position of the second frame and the position of the third frame can be understood as the position of the fluid particle history frame.
  • step 502 based on the positions of three consecutive frames, at least one frame position of the same fluid particle is obtained through interpolation.
  • the position of the 4th frame, the 5th frame, and even the 3rd frame of the same fluid particle can be obtained by interpolation.
  • the trajectory formed by the positions of the three consecutive frames and the positions of the three frames obtained through interpolation is a straight line or a curved line (for example, a Bezier curve).
  • step 503 3 non-adjacent frame positions are selected from the positions of 3 consecutive frames and at least one frame position.
  • the positions of 1, 2, and 4 frames can be selected, the positions of 1, 2, and 5 frames can be selected, and the positions of 1, 3, and 4 frames can be selected. 1, 3, 5 frame positions.
  • step 504 trailing rendering of fluid particles is performed based on non-adjacent 3-frame positions.
  • metaball processing may be performed based on three non-adjacent frame positions, so as to realize the trailing effect of the fluid particles.
  • the specific process of metaball processing is a mature technology in the field, and will not be repeated here.
  • metaball processing can only be performed on 3 frames of images, and in order to avoid the problem that the smearing effect is not obvious due to the relatively close positions of 3 consecutive frames, this embodiment
  • the position of the fifth frame of the same fluid particle is obtained through interpolation.
  • the position of the first frame is centered on the position of the third frame, and the position of the first frame is processed to obtain the same fluid particle The position of frame 5.
  • the trailing rendering of the fluid particles is performed at frame positions 1, 3, and 5.
  • FIG. 6 is a schematic diagram of another fluid particle rendering process provided by an embodiment of the present disclosure, which is applicable to step 504 in FIG. 5 .
  • performing trailing rendering of fluid particles based on non-adjacent 3-frame positions may include but not limited to the following steps 601 and 602:
  • step 601 corresponding particle sizes and attenuation curves are respectively set for three non-adjacent frame positions.
  • Particle size can be understood as the diameter of the particle.
  • the particle size of the particles corresponding to the three non-adjacent frame positions increases with the increase of sequence, and the final meta-ball processing can realize the drop-shaped trailing effect.
  • the positions of frames 1, 3, and 5 are recorded as frame positions 5, 3, and 1 according to the increasing order of timing.
  • the position of the first frame can be understood as the position of the current frame
  • the position of the third frame and The fifth frame is the historical frame position, then set the particle size corresponding to the first frame position to be the largest, and the particle size corresponding to the third frame position and the fifth frame position to decrease.
  • the attenuation curve is the attenuation curve of the alpha channel of the particles from the center to the outside.
  • the alpha channel represents transparency. Therefore, the center of the particle is opaque, and gradually becomes transparent from the center to the outside according to the attenuation curve.
  • the decay curve is a cubic decay curve or a quintic decay curve.
  • step 602 based on the particle size and the decay curve, meta-ball processing is performed on three non-adjacent frame positions.
  • the transparency threshold can be set to determine whether the transparency of the particle at the first frame position and the particle at the third frame position is greater than or equal to the transparency threshold after superimposing at the edge. Particles at the position of 3 frames undergo meta-ball processing. In addition, for the particles at the position of the third frame and the particles at the position of the fifth frame, it can be judged whether the transparency of the particle at the position of the third frame and the particle at the position of the fifth frame after being superimposed at the edge is greater than or equal to the transparency threshold, if greater than or equal to , the particle at the position of the third frame and the particle at the position of the fifth frame are subjected to meta-ball processing. In this way, after completing the particle meta-ball processing at frame 1, 3, and 5, a drop-shaped trailing effect can be achieved.
  • the particle fusion may not be completed, resulting in a disconnection phenomenon, as shown in Figure 10 Show. Whether it is a cubic decay curve or a quintic decay curve, there is a disconnect. Therefore, in order to solve the disjoint problem, the distance between adjacent particles needs to be reduced before performing meta-ball processing on non-adjacent 3-frame positions.
  • Fig. 7 is a schematic diagram of a distance adjustment process between adjacent particles provided by an embodiment of the present disclosure. This process is applied before step 602 shown in FIG. 6, as shown in FIG. 7, may include but not limited to the following steps 701 to 704:
  • step 701 the positions of 3 non-adjacent frames are transformed into screen positions of 3 frames in the screen coordinate system.
  • the obtained position of the same fluid particle in three consecutive frames in time series is the particle space position of the fluid particle in three consecutive frames in time series, not the screen space position of the mobile terminal, therefore, based on the particle space position of three consecutive frames, through interpolation Obtaining at least one frame position of the same fluid particle is also a position in the particle space, not the screen space position of the mobile terminal. Therefore, from the positions of 3 consecutive frames and at least one frame position, the selected 3 frame positions that are not adjacent are also particle space The position in the , not the screen space position of the mobile terminal.
  • the non-adjacent 3-frame positions are converted from the particle space to the 3-frame screen positions in the screen coordinate system, for example, the non-adjacent 3-frame positions are first normalized, and then converted to the screen 3-frame screen position in the coordinate system.
  • the formula is as follows:
  • Screen position particle space position ⁇ particle space size ⁇ (screen size ⁇ 2).
  • Particle space position ⁇ particle space size is the normalization process.
  • the spatial position of the particle in frame 1 is recorded as (firstPos.x, firstPos.y).
  • the size of the particle space is 15.3 ⁇ 27.2, that is, the Y-axis coordinate range of the particle space is minus 27.2 to plus 27.2, and the X-axis coordinate range of the particle space is minus 15.3 to plus 15.3.
  • the screen size is 720 ⁇ 1280.
  • the screen position of the first frame is recorded as (firstPos.x ⁇ 15.3 ⁇ 360, firstPos.y ⁇ 27.2 ⁇ 640).
  • the spatial position of the particle in the third frame is recorded as (thirdPos.x, thirdPos.y).
  • the screen position of the third frame is recorded as (thirdPos.x ⁇ 15.3 ⁇ 360, thirdPos.y ⁇ 27.2 ⁇ 640).
  • the spatial position of the particle in the fifth frame is recorded as (fifthPos.x, fifthPos.y). Then, the screen position of the fifth frame is recorded as (fifthPos.x ⁇ 15.3 ⁇ 360, fifthPos.y ⁇ 27.2 ⁇ 640).
  • step 702 based on the screen positions of the 3 frames, the distance between the screen positions of two adjacent frames is determined.
  • the screen positions of the first frame and the third frame are the screen positions of two adjacent frames, and the screen positions of the third frame and the fifth frame are also two adjacent screen positions .
  • the distance between the screen positions of two adjacent frames can be solved by using the existing distance calculation formula.
  • step 703 based on the respective particle sizes corresponding to the screen positions of the two adjacent frames, the distance thresholds corresponding to the screen positions of the two adjacent frames are determined.
  • the distance threshold corresponding to the screen positions of two adjacent frames is determined by the following formula:
  • Distance threshold a ⁇ particle size 1 + b ⁇ particle size 2;
  • a and b are preset constants
  • particle size 1 and particle size 2 are particle sizes corresponding to screen positions of two adjacent frames.
  • step 704 if the distance between the screen positions of two adjacent frames is greater than or equal to the distance threshold, the distance between the screen positions of two adjacent frames is reduced.
  • the screen position of the first frame is fixed, and the screen position of the third frame is adjusted position until the distance between the screen position of the first frame and the adjusted screen position of the third frame is less than the first distance threshold.
  • the adjusted screen position of the third frame is fixed, and the screen position of the fifth frame is adjusted until the adjusted The distance between the adjusted screen position of the third frame and the adjusted screen position of the fifth frame is smaller than the second distance threshold.
  • the distance between the screen position of the first frame and the screen position of the third frame is smaller than the first distance threshold, there is no need to adjust the distance.
  • the distance between the screen position of the third frame and the screen position of the fifth frame If the distance is greater than or equal to the second distance threshold, the screen position of the third frame is fixed, and the screen position of the fifth frame is adjusted until the distance between the screen position of the third frame and the adjusted screen position of the fifth frame is less than the second distance threshold.
  • reducing the distance between the screen positions of two adjacent frames includes the following three steps S1 to S3:
  • the screen position of the first frame is fixed.
  • the adjusted screen position of the third frame is fixed.
  • the screen position of the third frame is fixed.
  • the distance vector between the screen position of the first frame and the screen position of the third frame is the vector obtained by (the screen position of the first frame - the screen position of the third frame).
  • the distance vector between the adjusted screen position of the third frame and the screen position of the fifth frame is obtained by (adjusted screen position of the third frame - screen position of the fifth frame) vector.
  • the distance vector between the screen position of frame 3 and the screen position of frame 5 is the vector obtained by (screen position of frame 3 - screen position of frame 5).
  • the distance vector Based on the fixed position, the distance vector, the distance between the screen positions of two adjacent frames and the distance threshold, determine the screen position after the distance is reduced.
  • the screen position after the distance is reduced is determined by the following formula:
  • Screen position after distance reduction fixed position+distance vector ⁇ (distance threshold ⁇ distance between screen positions of two adjacent frames).
  • the adjusted screen position of the third frame the screen position of the first frame + the screen position of the first frame and The distance vector between the screen positions of the third frame ⁇ (the first distance threshold ⁇ the distance between the screen positions of the first frame and the screen positions of the third frame).
  • the adjusted screen position of the fifth frame the adjusted screen position of the third frame + the adjusted screen position of the third frame and the fifth frame
  • the distance vector between the screen positions ⁇ (the second distance threshold ⁇ the adjusted distance between the screen position of the third frame and the screen position of the fifth frame).
  • the adjusted screen position of the fifth frame the screen position of the third frame+the distance vector between the screen position of the third frame and the screen position of the fifth frame ⁇ ( The second distance threshold ⁇ the distance between the screen position of the 3rd frame and the screen position of the 5th frame).
  • the screen positions of three frames are converted into normalized coordinates, and then step 202 shown in FIG.
  • the frame positions are subjected to meta-ball processing. It should be noted that the three non-adjacent frame positions are the three frame positions of the normalized coordinates.
  • the distance threshold when the distance between adjacent particles is greater than or equal to the distance threshold, the position of the particle whose appearance time is earlier is changed to make it closer to the particle position of the current frame, so as to avoid A disjointed phenomenon occurs when the movement speed is fast.
  • the particle size and attenuation curve different smearing effects can be achieved. For example, the particle size corresponding to three non-adjacent frame positions increases with the increase of sequence, and the final meta-ball processing can realize the drop-like smearing effect The effect, the drop-shaped smear effect is shown in Figure 11.
  • FIG. 8 is a rendering device for fluid particles provided by an embodiment of the present disclosure.
  • the rendering device for fluid particles can be applied to mobile terminals, such as smart phones, tablet computers and other mobile terminal devices.
  • the fluid particle rendering device includes, but is not limited to: an acquisition unit 81 , an interpolation unit 82 , a selection unit 83 and a rendering unit 84 .
  • An acquisition unit 81 configured to acquire the position of the same fluid particle in consecutive N frames in time series, where N is a positive integer greater than or equal to 2;
  • An interpolation unit 82 configured to obtain at least one frame position of the same fluid particle by interpolation based on the positions of consecutive N frames;
  • a selection unit 83 configured to select non-adjacent N frame positions from consecutive N frame positions and at least one frame position
  • the rendering unit 84 is configured to perform trailing rendering of fluid particles based on non-adjacent N frame positions.
  • the rendering unit 84 is configured to: respectively set corresponding particle sizes and attenuation curves for non-adjacent N frame positions; perform meta-ball processing for non-adjacent N frame positions based on the particle size and attenuation curve.
  • the particle sizes corresponding to non-adjacent N frame positions increase with increasing sequence.
  • the rendering device for fluid particles may also include a distance adjustment unit 85 not shown in FIG.
  • a distance adjustment unit 85 For N frame screen positions, determine the distance between adjacent two frame screen positions; based on the respective particle sizes corresponding to adjacent two frame screen positions, determine the distance threshold corresponding to adjacent two frame screen positions; if the distance between adjacent two frame screen positions If the distance between them is greater than or equal to the distance threshold, the distance between the screen positions of two adjacent frames is reduced.
  • the rendering unit 84 performs meta-balling processing on non-adjacent N frame positions based on the particle size and the attenuation curve.
  • the distance threshold corresponding to the screen positions of two adjacent frames is determined by the following formula:
  • Distance threshold a ⁇ particle size 1 + b ⁇ particle size 2;
  • a and b are preset constants
  • particle size 1 and particle size 2 are particle sizes corresponding to screen positions of two adjacent frames.
  • the screen positions of the N frames include: the screen position of the first frame, the screen position of the third frame and the screen position of the fifth frame.
  • the distance adjustment unit 85 is used for:
  • the first distance threshold is based on the screen position of frame 1 The threshold determined by the particle size corresponding to the position and the screen position of the third frame;
  • the second distance threshold is the threshold determined based on the particle size corresponding to the screen position of frame 3 and the screen position of frame 5 respectively.
  • the distance adjustment unit 85 is used to: fix any position in the screen positions of two adjacent frames; determine the distance vector corresponding to the screen positions of two adjacent frames based on the fixed position; The distance between the screen positions of two adjacent frames and the distance threshold determine the screen position after the distance is reduced.
  • the screen position after the distance is reduced is determined by the following formula:
  • Screen position after distance reduction fixed position+distance vector ⁇ (distance threshold ⁇ distance between screen positions of two adjacent frames).
  • the interpolation unit 82 is configured to: if N is less than or equal to the preset frame number threshold, take the position of the Nth frame as the center, and at least one of the position of the 1st frame to the position of the N-1th frame Symmetrical processing is performed to obtain at least one frame position of the same fluid particle.
  • the consecutive N frames are 3 consecutive frames
  • the preset frame number threshold is 3 frames
  • the interpolation unit 82 is configured to: take the position of the third frame as the center, and perform symmetrical processing on the position of the first frame to obtain the position of the same fluid particle in the fifth frame.
  • the selection unit 83 is configured to: select the position of the first frame, the position of the third frame and the position of the fifth frame.
  • each unit in the fluid particle rendering device is only a logical function division. In actual implementation, there may be other division methods. For example, at least two units in the fluid particle rendering device can be implemented as one unit; each unit in the fluid particle rendering device can also be divided into multiple subunits. It can be understood that each unit or subunit can be realized by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may implement the described functionality using different methods for each particular application.
  • Fig. 9 is an exemplary block diagram of a system including at least one computing device and at least one storage device storing instructions provided by an embodiment of the present disclosure.
  • the system can be used for big data processing, and at least one computing device and at least one storage device can be deployed in a distributed manner, making the system a distributed data processing cluster.
  • the system includes: at least one computing device 91 , and at least one storage device 92 for storing instructions.
  • the storage device 92 in this embodiment may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the storage device 92 stores the following elements, executable units or data structures, or a subset thereof, or an extension thereof: an operating system and an application program.
  • the operating system includes various system programs, such as framework layer, core library layer, driver layer, etc., which are used to implement various basic tasks and handle hardware-based tasks.
  • the application program includes various application programs, such as a media player (Media Player), a browser (Browser), etc., and is used to implement various application tasks.
  • the program for implementing the fluid particle rendering method provided by the embodiments of the present disclosure may be included in the application program.
  • At least one computing device 91 invokes the program or instruction stored in the at least one storage device 92, for example, the program or instruction stored in the application program, and the at least one computing device 91 is used to execute the embodiment of the present disclosure Steps in various embodiments of the rendering method for fluid particles are provided.
  • the fluid particle rendering method provided by the embodiments of the present disclosure may be applied to the computing device 91 or implemented by the computing device 91 .
  • the computing device 91 may be an integrated circuit chip with signal processing capability. During implementation, each step of the above-mentioned method may be completed by an integrated logic circuit of hardware in the computing device 91 or instructions in the form of software.
  • the above computing device 91 may be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a ready-made programmable gate array (Field Programmable Gate Array, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the fluid particle rendering method provided by the embodiments of the present disclosure may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software units in the decoding processor.
  • the software unit may be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the storage device 92, and the computing device 91 reads the information in the storage device 92, and completes the steps of the method in combination with its hardware.
  • An embodiment of the present disclosure also proposes a computer-readable storage medium, the computer-readable storage medium stores a program or an instruction, and when the program or instruction is run by at least one computing device, at least one computing device executes the The steps of each embodiment of the rendering method are not repeated here to avoid repeated description.
  • the computing device may be the computing device 91 shown in FIG. 9 .
  • the computer readable storage medium is a non-transitory computer readable storage medium.
  • An embodiment of the present disclosure also proposes a computer program product, wherein the computer program product includes a computer program, the computer program is stored in a non-transitory computer-readable storage medium, and at least one processor of a computer reads and executes the computer program from the storage medium.
  • the computer program enables the computer to execute the steps of the embodiments such as the rendering method of fluid particles, and to avoid repeated descriptions, details are not repeated here.
  • the computer program product can write program codes for executing the operations of the embodiments of the present disclosure in any combination of one or more programming languages, and the programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional A procedural programming language such as "C" or similar programming language.
  • the program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server to execute.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本公开实施例涉及一种流体粒子的渲染方法、装置、系统及存储介质。本公开的至少一个实施例中,获取同一流体粒子在时序上连续N帧的位置后,并非直接对这N帧的位置进行融球处理,而是基于对这N帧的位置,插值得到该流体粒子的至少一帧位置,进而从连续N帧的位置和插值得到的至少一帧位置中,选择不相邻的N帧位置,从而基于不相邻的N帧位置进行该流体粒子的拖尾渲染。

Description

流体粒子的渲染方法、装置、系统及存储介质
相关申请的交叉引用
本申请是以CN申请号为202111521903.0,申请日为2021年12月13日的申请为基础,并主张其优先权,该CN申请的公开内容在此作为整体引入本申请中。
技术领域
本公开实施例涉及计算机技术领域,具体涉及一种流体粒子的渲染方法、装置、系统及存储介质。
背景技术
目前,流体粒子的拖尾效果可以采用多种方式渲染得到。
在相关技术中,通过采用拖尾渲染器(Trail Renderer)组件对单个粒子进行渲染,以实现该粒子的拖尾效果。Trail Renderer组件是利用网格(mesh)在单个粒子对应的mesh后生成多个mesh,以完成拖尾渲染。
发明内容
第一方面,本公开实施例提供一种流体粒子的渲染方法,包括:
获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数;
基于连续N帧的位置,通过插值得到同一流体粒子的至少一帧位置;
从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置;
基于不相邻的N帧位置进行流体粒子的拖尾渲染。
在一些实施例中,基于不相邻的N帧位置进行流体粒子的拖尾渲染包括:
对不相邻的N帧位置分别设置对应的粒子尺寸和衰减曲线;
基于粒子尺寸和衰减曲线,对不相邻的N帧位置进行融球处理。
在一些实施例中,对不相邻的N帧位置分别设置对应的粒子尺寸包括:
不相邻的N帧位置对应的粒子尺寸随时序的递增而递增。
在一些实施例中,基于粒子尺寸和衰减曲线,对不相邻的N帧位置进行融球处理之前,流体粒子的渲染方法还包括:
将不相邻的N帧位置转换至屏幕坐标系下的N帧屏幕位置;
基于N帧屏幕位置,确定相邻2帧屏幕位置之间的距离;
基于相邻2帧屏幕位置各自对应的粒子尺寸,确定相邻2帧屏幕位置对应的距离阈值;
若相邻2帧屏幕位置之间的距离大于或等于距离阈值,则将相邻2帧屏幕位置之间的距离进行缩小。
在一些实施例中,相邻2帧屏幕位置对应的距离阈值通过下式确定:
距离阈值=a×粒子尺寸1+b×粒子尺寸2;
其中,a和b为预设常数,粒子尺寸1和粒子尺寸2为相邻2帧屏幕位置各自对应的粒子尺寸。
在一些实施例中,N帧屏幕位置包括:第1帧屏幕位置、第3帧屏幕位置和第5帧屏幕位置;
将相邻2帧屏幕位置之间的距离进行缩小包括:
将第1帧屏幕位置固定,调整第3帧屏幕位置,直至第1帧屏幕位置与调整后的第3帧屏幕位置之间的距离小于第一距离阈值;第一距离阈值为基于第1帧屏幕位置和第3帧屏幕位置各自对应的粒子尺寸确定的阈值;
将调整后的第3帧屏幕位置固定,调整第5帧屏幕位置,直至调整后的第3帧屏幕位置与调整后的第5帧屏幕位置之间的距离小于第二距离阈值;第二距离阈值为基于第3帧屏幕位置和第5帧屏幕位置各自对应的粒子尺寸确定的阈值。
在一些实施例中,将相邻2帧屏幕位置之间的距离进行缩小包括:
将相邻2帧屏幕位置中的任一位置固定;
基于固定位置确定相邻2帧屏幕位置对应的距离向量;
基于固定位置、距离向量、相邻2帧屏幕位置之间的距离和距离阈值,确定距离缩小后的屏幕位置。
在一些实施例中,距离缩小后的屏幕位置通过下式确定:
距离缩小后的屏幕位置=固定位置+距离向量×(距离阈值÷相邻2帧屏幕位置之间的距离)。
在一些实施例中,所述基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置包括:
若N小于等于预设帧数阈值,则以第N帧的位置为中心,将第1帧的位置至第N-1帧的位置中的至少一个进行对称,得到所述同一流体粒子的至少一帧位置。
在一些实施例中,所述从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置包括:
从所述连续N帧的位置中选择X帧,并从所述至少一帧位置中选择Y帧;其中,X为小于N的正整数,Y为大于或等于1的正整数,且X+Y=N。
在一些实施例中,所述连续N帧为连续3帧,所述预设帧数阈值为3帧。
在一些实施例中,所述基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置包括:
以第3帧的位置为中心,将第1帧的位置进行对称,得到所述同一流体粒子的第5帧的位置。
在一些实施例中,所述从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置包括:
选择第1帧的位置、第3帧的位置和第5帧的位置。
第二方面,本公开实施例提供一种流体粒子的渲染装置,包括:
获取单元,用于获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数;
插值单元,用于基于连续N帧的位置,通过插值得到同一流体粒子的至少一帧位置;
选择单元,用于从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置;
渲染单元,用于基于不相邻的N帧位置进行流体粒子的拖尾渲染。
第三方面,本公开实施例还提出一种包括至少一个计算装置和至少一个存储指令的存储装置的系统,其中,所述指令在被所述至少一个计算装置运行时,促使所述至少一个计算装置执行如第一方面任一实施例所述流体粒子的渲染方法的步骤。
第四方面,本公开实施例还提出一种计算机可读存储介质,所述计算机可读存储介质存储程序或指令,当所述程序或指令被至少一个计算装置运行时,使至少一个计算装置执行如第一方面任一实施例所述流体粒子的渲染方法的步骤。
第五方面,本公开实施例还提出一种计算机程序,包括:指令,所述指令当由处理器执行时使所述处理器执行如第一方面任一实施例所述流体粒子的渲染方法的步骤。
附图说明
为了更清楚地说明本公开实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。
图1为本公开实施例提供的一种流体粒子的渲染方法的示例性流程图;
图2为本公开实施例提供的一种流体粒子的渲染流程示意图;
图3是本公开实施例提供的一种相邻粒子之间的距离调整流程示意图;
图4为本公开实施例提供的另一种流体粒子的渲染方法的示例性流程图;
图5为本公开实施例提供的又一种流体粒子的渲染方法的示例性流程图;
图6为本公开实施例提供的又一种流体粒子的渲染流程示意图;
图7是本公开实施例提供的另一种相邻粒子之间的距离调整流程示意图;
图8是本公开实施例提供的一种流体粒子的渲染装置的示例性框图;
图9是本公开实施例提供的一种包括至少一个计算装置和至少一个存储指令的存储装置的系统的示例性框图;
图10是本公开实施例提供的一种脱节现象示意图;
图11是本公开实施例提供的一种水滴状的拖尾效果示意图。
具体实施方式
为了能够更清楚地理解本公开的上述目的、特征和优点,下面结合附图和实施例对本公开作进一步的详细说明。可以理解的是,所描述的实施例是本公开的一部分实施例,而不是全部的实施例。此处所描述的具体实施例仅仅用于解释本公开,而非对本公开的限定。基于所描述的本公开的实施例,本领域普通技术人员所获得的所有其他实施例,都属于本公开保护的范围。
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。
如前所述,对于二维场景中大量流体粒子的拖尾渲染,Trail Renderer组件会生成大量的mesh,因而无法应用于性能受限的移动端。因此,亟需提供一种流体粒子的拖尾渲染方案,以解决前述至少一个技术问题。
为了解决相关技术存在的至少一个问题,本公开的至少一个实施例提供了一种流体粒子的渲染方法、装置、系统及存储介质。
图1为本公开实施例提供的一种流体粒子的渲染方法的示例性流程图。该渲染方法的执行主体可以为服务端,也可以为移动端。该渲染方法可以包括但不限于如下步骤101至步骤104:
在步骤101中,获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数。
流体粒子是通过顶点着色引擎(Vertex Shader)在模拟空间内生成的粒子。在一些实施例中,模拟空间是一个方形的平面区域,该平面区域的高宽比可以设置为16:9,以满足服务端或移动端的屏幕高宽比。例如,模拟空间的Y轴坐标范围是负27.2至正27.2,模拟空间的X轴坐标范围是负15.3至正15.3,模拟空间的原点在模拟空间的中心位置。
上述提及的模拟空间可以理解为是粒子空间,因此,获取的同一流体粒子在时序上连续N帧的位置可以理解为该流体粒子在时序上连续N帧的粒子空间位置。
同一流体粒子在时序上连续N帧的位置记为:第1帧位置、第2帧位置、第3帧位置、……、第N帧位置,其中,第1帧位置可以理解为该流体粒子当前帧的位置,第2帧位置至第N帧位置可以理解为该流体粒子历史帧的位置。
在步骤102中,基于连续N帧的位置,通过插值得到同一流体粒子的至少一帧位置。
基于连续N帧的位置,可以通过插值得到同一流体粒子的第N+1帧位置,第N+2帧位置,甚至更多帧位置。这连续N帧的位置和通过插值得到的多帧位置构成的轨迹为一条直线或一条曲线(例如贝塞尔曲线)。
在步骤103中,从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置。
从连续N帧的位置中选择X帧,并从至少一帧位置中选择Y帧;其中,X为小于N的正整数,Y为大于或等于1的正整数,且X+Y=N。
在步骤104中,基于不相邻的N帧位置进行流体粒子的拖尾渲染。
本实施例中,可以基于不相邻的N帧位置进行融球(metaball)处理,以实现该流体粒子的拖尾效果。其中,融球(metaball)处理的具体过程为本领域的成熟技术,不再赘述。
可见,本实施例在获取同一流体粒子在时序上连续N帧的位置后,并非直接对这N帧的位置进行融球(metaball)处理,而是基于对这N帧的位置,通过插值得到该流体粒子的至少一帧位置,进而从连续N帧的位置和通过插值得到的至少一帧位置中, 选择不相邻的N帧位置,从而基于不相邻的N帧位置进行该流体粒子的拖尾渲染,避免由于流体粒子速度较慢使得连续N帧的位置距离较近而导致的拖尾效果不明显问题,并且适用于二维场景中流体粒子的拖尾渲染。
图2为本公开实施例提供的一种流体粒子的拖尾渲染流程示意图,适用于图1中的步骤104。如图2所示,基于不相邻的N帧位置进行流体粒子的拖尾渲染可以包括但不限于以下步骤201和202:
在步骤201中,对不相邻的N帧位置分别设置对应的粒子尺寸和衰减曲线。
粒子尺寸可以理解为粒子的直径。通过设置粒子尺寸,可以实现不同的拖尾效果。例如,将不相邻的N帧位置对应的粒子尺寸随时序的递增而递增,最终融球处理可以实现水滴状的拖尾效果。
衰减曲线为粒子从圆心向外阿尔法(alpha)通道的衰减曲线,alpha通道表征透明度,因此,粒子的中心不透明,从中心向外依据衰减曲线逐渐变得透明。在一些实施例中,衰减曲线为立方衰减曲线或五次方衰减曲线。
在步骤202中,基于粒子尺寸和衰减曲线,对不相邻的N帧位置进行融球处理。
在设置粒子尺寸和衰减曲线后,某帧位置的粒子从中心向外逐渐变得透明,另一帧位置的粒子从中心向外也逐渐变得透明,因此,这两帧位置的粒子在边缘处会产生叠加效果,导致alpha通道发生改变,也即透明度发生变化。
因此,可以设置透明度阈值,判断这两帧位置的粒子在边缘处叠加后的透明度是否大于或等于透明度阈值,若大于或等于,则将这两帧位置的粒子进行融球处理。
在一些实施例中,考虑到流体粒子速度较快的场景下,若两帧位置之间的距离相对较远,那么可能无法完成这两帧位置的粒子融合,导致存在脱节现象,脱节现象如图10所示。无论是立方衰减曲线还是五次方衰减曲线,均存在脱节现象。因此,为了解决脱节问题,在对不相邻的N帧位置进行融球处理之前,需要先缩小相邻粒子之间的距离。
图3是本公开实施例提供的一种相邻粒子之间的距离调整流程示意图。该流程应用于图2所示的步骤202之前,如图3所示,可以包括但不限于以下步骤301至步骤304:
在步骤301中,将不相邻的N帧位置转换至屏幕坐标系下的N帧屏幕位置。
由于获取的同一流体粒子在时序上连续N帧的位置是该流体粒子在时序上连续N帧的粒子空间位置,而非移动端的屏幕空间位置,因此,基于连续N帧的粒子空间位 置,通过插值得到同一流体粒子的至少一帧位置也是粒子空间中的位置,而非移动端的屏幕空间位置,所以,从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置也是粒子空间中的位置,而非移动端的屏幕空间位置。
本实施例中,将不相邻的N帧位置由粒子空间转换至屏幕坐标系下的N帧屏幕位置,例如,首先将不相邻的N帧位置进行归一化处理,然后再转换为屏幕坐标系下的N帧屏幕位置。公式如下:
屏幕位置=粒子空间位置÷粒子空间尺寸×(屏幕尺寸÷2)。
粒子空间位置÷粒子空间尺寸即为归一化处理。
在步骤302中,基于N帧屏幕位置,确定相邻2帧屏幕位置之间的距离。
相邻2帧屏幕位置之间的距离可采用现有的距离计算公式求解。
在步骤303中,基于相邻2帧屏幕位置各自对应的粒子尺寸,确定相邻2帧屏幕位置对应的距离阈值。
本实施例中,相邻2帧屏幕位置对应的距离阈值通过下式确定:
距离阈值=a×粒子尺寸1+b×粒子尺寸2;
a和b为预设常数,粒子尺寸1和粒子尺寸2为相邻2帧屏幕位置各自对应的粒子尺寸。
在步骤304中,若相邻2帧屏幕位置之间的距离大于或等于距离阈值,则将相邻2帧屏幕位置之间的距离进行缩小。
在一些实施例中,将相邻2帧屏幕位置之间的距离进行缩小包括如下三个步骤S1至S3:
S1、将相邻2帧屏幕位置中的任一位置固定。即,将相邻2帧屏幕位置中的任一个,确定为固定位置。
S2、基于固定位置确定相邻2帧屏幕位置对应的距离向量。
S3、基于固定位置、距离向量、相邻2帧屏幕位置之间的距离和距离阈值,确定距离缩小后的屏幕位置。
本实施例中,距离缩小后的屏幕位置通过下式确定:
距离缩小后的屏幕位置=固定位置+距离向量×(距离阈值÷相邻2帧屏幕位置之间的距离)。
在相邻2帧屏幕位置之间的距离进行缩小后,将N帧屏幕位置转换为归一化坐标,然后执行图2所示的步骤202:基于粒子尺寸和衰减曲线,对不相邻的N帧位置 进行融球处理,需要说明的是,不相邻的N帧位置为归一化坐标的N帧位置。
可见,以上实施例中,通过设置距离阈值,在相邻粒子之间的距离大于或等于距离阈值时,改变其中出现时间较早的粒子位置,使之更靠近当前帧的粒子位置,避免在粒子运动速度较快时出现脱节的现象。另外,通过设置粒子尺寸和衰减曲线,可以实现不同的拖尾效果,例如,将不相邻的N帧位置对应的粒子尺寸随时序的递增而递增,最终融球处理可以实现水滴状的拖尾效果,水滴状的拖尾效果如图11所示。
图4为本公开实施例提供的一种流体粒子的渲染方法的示例性流程图,如图4所示,包括如下步骤401至404:
在步骤401中,获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数。
在步骤402中,若N小于等于预设帧数阈值,则以第N帧的位置为中心,将第1帧的位置至第N-1帧的位置中的至少一个进行对称处理,得到同一流体粒子的至少一帧位置。
在步骤403中,从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置。
从连续N帧的位置中选择X帧,并从至少一帧位置中选择Y帧;其中,X为小于N的正整数,Y为大于或等于1的正整数,且X+Y=N。
在步骤404中,基于不相邻的N帧位置进行流体粒子的拖尾渲染。
步骤401、403和404与图1中的步骤101、103和104相同,不再赘述。
可见,本实施例在获取同一流体粒子在时序上连续N帧的位置后,并非直接对这N帧的位置进行融球(metaball)处理,而是基于对这N帧的位置,通过插值得到该流体粒子的至少一帧位置,进而从连续N帧的位置和通过插值得到的至少一帧位置中,选择不相邻的N帧位置,从而基于不相邻的N帧位置进行该流体粒子的拖尾渲染,避免由于流体粒子速度较慢使得连续N帧的位置距离较近而导致的拖尾效果不明显问题,并且适用于二维场景中流体粒子的拖尾渲染。
目前,由于智能手机、平板电脑等移动端设备的性能限制,通常只记录同一流体粒子在时序上连续3帧的位置,也即同一个流体粒子的运动路径。例如,流体粒子在当前帧的位置记为第1帧的位置,流体粒子在当前帧的上一帧的位置记为第2帧的位置,依次类推,时间越早,对应的帧数越大。因此,移动端设备不记录流体粒子在第4帧的位置和第5帧的位置。
但是,若流体粒子的运动速度较小时,例如轻轻晃动水杯,水滴溅出来时速度较 小,那么水滴在时序上连续3帧的位置可能距离较近,以致于区分不开,直接以采用连续3帧的位置进行融球(metaball)处理,拖尾效果不明显。
因此,本公开的至少一个实施例中,获取同一流体粒子在时序上连续3帧的位置后,并非直接对这3帧的位置进行融球(metaball)处理,而是基于对这3帧的位置,通过插值得到该流体粒子的至少一帧位置,进而从连续3帧的位置和通过插值得到的至少一帧位置中,选择不相邻的3帧位置,从而基于不相邻的3帧位置进行该流体粒子的拖尾渲染,避免由于流体粒子速度较慢使得连续3帧的位置距离较近而导致的拖尾效果不明显问题,并且适用于二维场景中大量流体粒子的拖尾渲染以及适用于移动端。
图5为本公开实施例提供的一种流体粒子的渲染方法的示例性流程图。该渲染方法的执行主体为移动端,例如为智能手机、平板电脑等移动端设备。该渲染方法可以包括但不限于如下步骤501至步骤504:
在步骤501中,获取同一流体粒子在时序上连续3帧的位置。
流体粒子是通过顶点着色引擎(Vertex Shader)在模拟空间内生成的粒子。在一些实施例中,模拟空间是一个方形的平面区域,该平面区域的高宽比可以设置为16:9,以满足移动端的屏幕高宽比。例如,模拟空间的Y轴坐标范围是负27.2至正27.2,模拟空间的X轴坐标范围是负15.3至正15.3,模拟空间的原点在模拟空间的中心位置。
上述提及的模拟空间可以理解为是粒子空间,因此,获取的同一流体粒子在时序上连续3帧的位置可以理解为该流体粒子在时序上连续3帧的粒子空间位置。
同一流体粒子在时序上连续3帧的位置记为:第1帧位置、第2帧位置和第3帧位置,其中,第1帧位置可以理解为该流体粒子当前帧的位置,第2帧位置和第3帧位置可以理解为该流体粒子历史帧的位置。
在步骤502中,基于连续3帧的位置,通过插值得到同一流体粒子的至少一帧位置。
基于连续3帧的位置,可以通过插值得到同一流体粒子的第4帧位置、第5帧位置、甚至更3帧位置。这连续3帧的位置和通过插值得到的3帧位置构成的轨迹为一条直线或一条曲线(例如贝塞尔曲线)。
在步骤503中,从连续3帧的位置和至少一帧位置中,选择不相邻的3帧位置。
例如,通过插值得到了第4帧位置和第5帧位置,那么,可以选择1、2、4帧位置,可以选择1、2、5帧位置,可以选择1、3、4帧位置,可以选择1、3、5帧位置。
在步骤504中,基于不相邻的3帧位置进行流体粒子的拖尾渲染。
本实施例中,可以基于不相邻的3帧位置进行融球(metaball)处理,以实现该流体粒子的拖尾效果。其中,融球(metaball)处理的具体过程为本领域的成熟技术,不再赘述。
可见,本实施例在获取同一流体粒子在时序上连续3帧的位置后,并非直接对这3帧的位置进行融球(metaball)处理,而是基于对这3帧的位置,通过插值得到该流体粒子的至少一帧位置,进而从连续3帧的位置和通过插值得到的至少一帧位置中,选择不相邻的3帧位置,从而基于不相邻的3帧位置进行该流体粒子的拖尾渲染,避免由于流体粒子速度较慢使得连续3帧的位置距离较近而导致的拖尾效果不明显问题,并且适用于二维场景中流体粒子的拖尾渲染以及适用于移动端。
在一些实施例中,由于移动端的性能限制,仅可以对3帧图像进行融球(metaball)处理,并且为了避免连续3帧的位置离得较近导致拖尾效果不明显的问题,本实施例中,在获取同一流体粒子在时序上连续3帧的位置后,仅保留第1帧的位置和第3帧的位置,丢弃第2帧的位置。另外,为了凑够3帧,本实施例中通过插值得到同一流体粒子的第5帧位置,例如,以第3帧的位置为中心,将第1帧的位置进行中心对称处理,得到同一流体粒子的第5帧的位置。这样,本实施例就以1、3、5帧位置进行该流体粒子的拖尾渲染。
图6为本公开实施例提供的又一种流体粒子的渲染流程示意图,适用于图5中的步骤504。如图6所示,基于不相邻的3帧位置进行流体粒子的拖尾渲染可以包括但不限于以下步骤601和602:
在步骤601中,对不相邻的3帧位置分别设置对应的粒子尺寸和衰减曲线。
粒子尺寸可以理解为粒子的直径。通过设置粒子尺寸,可以实现不同的拖尾效果。例如,将不相邻的3帧位置对应的粒子尺寸随时序的递增而递增,最终融球处理可以实现水滴状的拖尾效果。以1、3、5帧位置为例,1、3、5帧位置按照时序的递增排列记为5、3、1帧位置,其中,第1帧位置可以理解为当前帧位置,第3帧和第5帧为历史帧位置,那么设置第1帧位置对应的粒子尺寸最大,第3帧位置和第5帧位置对应的粒子尺寸递减。
衰减曲线为粒子从圆心向外阿尔法(alpha)通道的衰减曲线,alpha通道表征透明度,因此,粒子的中心不透明,从中心向外依据衰减曲线逐渐变得透明。在一些实施例中,衰减曲线为立方衰减曲线或五次方衰减曲线。
在步骤602中,基于粒子尺寸和衰减曲线,对不相邻的3帧位置进行融球处理。
以1、3、5帧位置为例,在设置粒子尺寸和衰减曲线后,第1帧位置的粒子从中心向外逐渐变得透明,第3帧位置的粒子从中心向外也逐渐变得透明,因此,第1帧位置的粒子和第3帧位置的粒子在边缘处会产生叠加效果,导致alpha通道发生改变,也即透明度发生变化。
因此,可以设置透明度阈值,判断第1帧位置的粒子和第3帧位置的粒子在边缘处叠加后的透明度是否大于或等于透明度阈值,若大于或等于,则将第1帧位置的粒子和第3帧位置的粒子进行融球处理。另外,对于第3帧位置的粒子和第5帧位置的粒子,可以判断第3帧位置的粒子和第5帧位置的粒子在边缘处叠加后的透明度是否大于或等于透明度阈值,若大于或等于,则将第3帧位置的粒子和第5帧位置的粒子进行融球处理。这样,完成1、3、5帧位置的粒子融球处理后,可以实现水滴状的拖尾效果。
在一些实施例中,考虑到流体粒子速度较快的场景下,1、3、5帧位置之间的距离相对较远,那么可能无法完成粒子融合,导致存在脱节现象,脱节现象如图10所示。无论是立方衰减曲线还是五次方衰减曲线,均存在脱节现象。因此,为了解决脱节问题,在对不相邻的3帧位置进行融球处理之前,需要先缩小相邻粒子之间的距离。
图7是本公开实施例提供的一种相邻粒子之间的距离调整流程示意图。该流程应用于图6所示的步骤602之前,如图7所示,可以包括但不限于以下步骤701至步骤704:
在步骤701中,将不相邻的3帧位置转换至屏幕坐标系下的3帧屏幕位置。
由于获取的同一流体粒子在时序上连续3帧的位置是该流体粒子在时序上连续3帧的粒子空间位置,而非移动端的屏幕空间位置,因此,基于连续3帧的粒子空间位置,通过插值得到同一流体粒子的至少一帧位置也是粒子空间中的位置,而非移动端的屏幕空间位置,所以,从连续3帧的位置和至少一帧位置中,选择不相邻的3帧位置也是粒子空间中的位置,而非移动端的屏幕空间位置。
本实施例中,将不相邻的3帧位置由粒子空间转换至屏幕坐标系下的3帧屏幕位置,例如,首先将不相邻的3帧位置进行归一化处理,然后再转换为屏幕坐标系下的3帧屏幕位置。公式如下:
屏幕位置=粒子空间位置÷粒子空间尺寸×(屏幕尺寸÷2)。
粒子空间位置÷粒子空间尺寸即为归一化处理。
例如,第1帧粒子空间位置记为(firstPos.x,firstPos.y)。粒子空间尺寸为15.3×27.2,也即粒子空间的Y轴坐标范围是负27.2至正27.2,粒子空间的X轴坐标范围是负15.3至正15.3。屏幕尺寸为720×1280。那么,第1帧屏幕位置记为(firstPos.x÷15.3×360,firstPos.y÷27.2×640)。
又例如,第3帧粒子空间位置记为(thirdPos.x,thirdPos.y)。那么,第3帧屏幕位置记为(thirdPos.x÷15.3×360,thirdPos.y÷27.2×640)。
又例如,第5帧粒子空间位置记为(fifthPos.x,fifthPos.y)。那么,第5帧屏幕位置记为(fifthPos.x÷15.3×360,fifthPos.y÷27.2×640)。
在步骤702中,基于3帧屏幕位置,确定相邻2帧屏幕位置之间的距离。
以1、3、5帧屏幕位置为例,第1帧屏幕位置和第3帧屏幕位置为相邻2帧屏幕位置,第3帧屏幕位置和第5帧屏幕位置也为相邻2帧屏幕位置。相邻2帧屏幕位置之间的距离可采用现有的距离计算公式求解。
在步骤703中,基于相邻2帧屏幕位置各自对应的粒子尺寸,确定相邻2帧屏幕位置对应的距离阈值。
本实施例中,相邻2帧屏幕位置对应的距离阈值通过下式确定:
距离阈值=a×粒子尺寸1+b×粒子尺寸2;
a和b为预设常数,粒子尺寸1和粒子尺寸2为相邻2帧屏幕位置各自对应的粒子尺寸。
以1、3、5帧屏幕位置为例,第1帧屏幕位置和第3帧屏幕位置为相邻2帧屏幕位置,对应的距离阈值记为第一距离阈值,那么第一距离阈值=a×第1帧屏幕位置对应的粒子尺寸+b×第3帧屏幕位置对应的粒子尺寸。另外,第3帧屏幕位置和第5帧屏幕位置为相邻2帧屏幕位置,对应的距离阈值记为第二距离阈值,那么第二距离阈值=a×第3帧屏幕位置对应的粒子尺寸+b×第5帧屏幕位置对应的粒子尺寸。
在步骤704中,若相邻2帧屏幕位置之间的距离大于或等于距离阈值,则将相邻2帧屏幕位置之间的距离进行缩小。
以1、3、5帧屏幕位置为例,若第1帧屏幕位置和第3帧屏幕位置之间的距离大于或等于第一距离阈值,则将第1帧屏幕位置固定,调整第3帧屏幕位置,直至第1帧屏幕位置与调整后的第3帧屏幕位置之间的距离小于第一距离阈值。
另外,若调整后的第3帧屏幕位置和第5帧屏幕位置之间的距离大于或等于第二距离阈值,则将调整后的第3帧屏幕位置固定,调整第5帧屏幕位置,直至调整后的 第3帧屏幕位置与调整后的第5帧屏幕位置之间的距离小于第二距离阈值。
需要说明的是,若第1帧屏幕位置和第3帧屏幕位置之间的距离小于第一距离阈值,则无需调整该距离,同时,若第3帧屏幕位置和第5帧屏幕位置之间的距离大于或等于第二距离阈值,则将第3帧屏幕位置固定,调整第5帧屏幕位置,直至第3帧屏幕位置与调整后的第5帧屏幕位置之间的距离小于第二距离阈值。
在一些实施例中,将相邻2帧屏幕位置之间的距离进行缩小包括如下三个步骤S1至S3:
S1、将相邻2帧屏幕位置中的任一位置固定。
以1、3、5帧屏幕位置为例,若第1帧屏幕位置和第3帧屏幕位置之间的距离大于或等于第一距离阈值,则将第1帧屏幕位置固定。
若调整后的第3帧屏幕位置和第5帧屏幕位置之间的距离大于或等于第二距离阈值,则将调整后的第3帧屏幕位置固定。
若第3帧屏幕位置和第5帧屏幕位置之间的距离大于或等于第二距离阈值,则将第3帧屏幕位置固定。
S2、基于固定位置确定相邻2帧屏幕位置对应的距离向量。
将第1帧屏幕位置固定后,第1帧屏幕位置和第3帧屏幕位置之间的距离向量为(第1帧屏幕位置-第3帧屏幕位置)得到的向量。
将调整后的第3帧屏幕位置固定后,调整后的第3帧屏幕位置和第5帧屏幕位置之间的距离向量为(调整后的第3帧屏幕位置-第5帧屏幕位置)得到的向量。
将第3帧屏幕位置固定后,第3帧屏幕位置和第5帧屏幕位置之间的距离向量为(第3帧屏幕位置-第5帧屏幕位置)得到的向量。
S3、基于固定位置、距离向量、相邻2帧屏幕位置之间的距离和距离阈值,确定距离缩小后的屏幕位置。
本实施例中,距离缩小后的屏幕位置通过下式确定:
距离缩小后的屏幕位置=固定位置+距离向量×(距离阈值÷相邻2帧屏幕位置之间的距离)。
以1、3、5帧屏幕位置为例,若将第1帧屏幕位置固定,调整第3帧屏幕位置,则调整后的第3帧屏幕位置=第1帧屏幕位置+第1帧屏幕位置和第3帧屏幕位置之间的距离向量×(第一距离阈值÷第1帧屏幕位置和第3帧屏幕位置之间的距离)。
若将调整后的第3帧屏幕位置固定,调整第5帧屏幕位置,则调整后的第5帧屏 幕位置=调整后的第3帧屏幕位置+调整后的第3帧屏幕位置和第5帧屏幕位置之间的距离向量×(第二距离阈值÷调整后的第3帧屏幕位置和第5帧屏幕位置之间的距离)。
若将第3帧屏幕位置固定,调整第5帧屏幕位置,则调整后的第5帧屏幕位置=第3帧屏幕位置+第3帧屏幕位置和第5帧屏幕位置之间的距离向量×(第二距离阈值÷第3帧屏幕位置和第5帧屏幕位置之间的距离)。
在相邻2帧屏幕位置之间的距离进行缩小后,将3帧屏幕位置转换为归一化坐标,然后执行图2所示的步骤202:基于粒子尺寸和衰减曲线,对不相邻的3帧位置进行融球处理,需要说明的是,不相邻的3帧位置为归一化坐标的3帧位置。
可见,以上实施例中,通过设置距离阈值,在相邻粒子之间的距离大于或等于距离阈值时,改变其中出现时间较早的粒子位置,使之更靠近当前帧的粒子位置,避免在粒子运动速度较快时出现脱节的现象。另外,通过设置粒子尺寸和衰减曲线,可以实现不同的拖尾效果,例如,将不相邻的3帧位置对应的粒子尺寸随时序的递增而递增,最终融球处理可以实现水滴状的拖尾效果,水滴状的拖尾效果如图11所示。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员能够理解,本公开实施例并不受所描述的动作顺序的限制,因为依据本公开实施例,某些步骤可以采用其他顺序或者同时进行。另外,本领域技术人员能够理解,说明书中所描述的实施例均属于可选实施例。
图8为本公开实施例提供的一种流体粒子的渲染装置,该流体粒子的渲染装置可以应用于移动端,例如为智能手机、平板电脑等移动端设备。该流体粒子的渲染装置包括但不限于:获取单元81、插值单元82、选择单元83和渲染单元84。
获取单元81,用于获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数;
插值单元82,用于基于连续N帧的位置,通过插值得到同一流体粒子的至少一帧位置;
选择单元83,用于从连续N帧的位置和至少一帧位置中,选择不相邻的N帧位置;
渲染单元84,用于基于不相邻的N帧位置进行流体粒子的拖尾渲染。
在一些实施例中,渲染单元84用于:对不相邻的N帧位置分别设置对应的粒子尺寸和衰减曲线;基于粒子尺寸和衰减曲线,对不相邻的N帧位置进行融球处理。
在一些实施例中,不相邻的N帧位置对应的粒子尺寸随时序的递增而递增。
在一些实施例中,流体粒子的渲染装置还可以包括图8中未示出的距离调整单元85,用于:将不相邻的N帧位置转换至屏幕坐标系下的N帧屏幕位置;基于N帧屏幕位置,确定相邻2帧屏幕位置之间的距离;基于相邻2帧屏幕位置各自对应的粒子尺寸,确定相邻2帧屏幕位置对应的距离阈值;若相邻2帧屏幕位置之间的距离大于或等于距离阈值,则将相邻2帧屏幕位置之间的距离进行缩小。
相应地,渲染单元84在距离调整单元85将相邻2帧屏幕位置之间的距离进行缩小后,基于粒子尺寸和衰减曲线,对不相邻的N帧位置进行融球处理。
在一些实施例中,相邻2帧屏幕位置对应的距离阈值通过下式确定:
距离阈值=a×粒子尺寸1+b×粒子尺寸2;
a和b为预设常数,粒子尺寸1和粒子尺寸2为相邻2帧屏幕位置各自对应的粒子尺寸。
在一些实施例中,N帧屏幕位置包括:第1帧屏幕位置、第3帧屏幕位置和第5帧屏幕位置。
距离调整单元85用于:
将第1帧屏幕位置固定,调整第3帧屏幕位置,直至第1帧屏幕位置与调整后的第3帧屏幕位置之间的距离小于第一距离阈值;第一距离阈值为基于第1帧屏幕位置和第3帧屏幕位置各自对应的粒子尺寸确定的阈值;
将调整后的第3帧屏幕位置固定,调整第5帧屏幕位置,直至调整后的第3帧屏幕位置与调整后的第5帧屏幕位置之间的距离小于第二距离阈值;第二距离阈值为基于第3帧屏幕位置和第5帧屏幕位置各自对应的粒子尺寸确定的阈值。
在一些实施例中,距离调整单元85用于:将相邻2帧屏幕位置中的任一位置固定;基于固定位置确定相邻2帧屏幕位置对应的距离向量;基于固定位置、距离向量、相邻2帧屏幕位置之间的距离和距离阈值,确定距离缩小后的屏幕位置。
在一些实施例中,距离缩小后的屏幕位置通过下式确定:
距离缩小后的屏幕位置=固定位置+距离向量×(距离阈值÷相邻2帧屏幕位置之间的距离)。
在一些实施例中,插值单元82用于:若N小于等于预设帧数阈值,则以第N帧的位置为中心,将第1帧的位置至第N-1帧的位置中的至少一个进行对称处理,得到所述同一流体粒子的至少一帧位置。
在一些实施例中,选择单元83用于:从所述连续N帧的位置中选择X帧,并从所述至少一帧位置中选择Y帧;其中,X为小于N的正整数,Y为大于或等于1的正整数,且X+Y=N。
在一些实施例中,所述连续N帧为连续3帧,所述预设帧数阈值为3帧。
在一些实施例中,插值单元82用于:以第3帧的位置为中心,将第1帧的位置进行对称处理,得到所述同一流体粒子的第5帧的位置。
在一些实施例中,选择单元83用于:选择第1帧的位置、第3帧的位置和第5帧的位置。
以上各实施例公开的流体粒子的渲染装置的技术细节可以参考流体粒子的渲染方法各实施例的描述,为避免重复,不再赘述。
在一些实施例中,流体粒子的渲染装置中各单元的划分仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如流体粒子的渲染装置中的至少两个单元可以实现为一个单元;流体粒子的渲染装置中的各单元也可以划分为多个子单元。可以理解的是,各个单元或子单元能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能。
图9是本公开实施例提供的一种包括至少一个计算装置和至少一个存储指令的存储装置的系统的示例性框图。在一些实施例中,该系统可用于大数据处理,至少一个计算装置和至少一个存储装置可以为分布式部署,使该系统为分布式数据处理集群。
如图9所示,系统包括:至少一个计算装置91、至少一个存储指令的存储装置92。可以理解,本实施例中的存储装置92可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。
在一些实施方式中,存储装置92存储了如下的元素,可执行单元或者数据结构,或者他们的子集,或者他们的扩展集:操作系统和应用程序。
操作系统,包含各种系统程序,例如框架层、核心库层、驱动层等,用于实现各种基础任务以及处理基于硬件的任务。应用程序,包含各种应用程序,例如媒体播放器(Media Player)、浏览器(Browser)等,用于实现各种应用任务。实现本公开实施例提供的流体粒子的渲染方法的程序可以包含在应用程序中。
在本公开实施例中,至少一个计算装置91通过调用至少一个存储装置92存储的程序或指令,例如,可以是应用程序中存储的程序或指令,至少一个计算装置91用于 执行本公开实施例提供的流体粒子的渲染方法各实施例的步骤。
本公开实施例提供的流体粒子的渲染方法可以应用于计算装置91中,或者由计算装置91实现。计算装置91可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过计算装置91中的硬件的集成逻辑电路或者软件形式的指令完成。上述的计算装置91可以是通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
本公开实施例提供的流体粒子的渲染方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件单元组合执行完成。软件单元可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储装置92,计算装置91读取存储装置92中的信息,结合其硬件完成方法的步骤。
本公开实施例还提出一种计算机可读存储介质,所述计算机可读存储介质存储程序或指令,当所述程序或指令被至少一个计算装置运行时,使至少一个计算装置执行如流体粒子的渲染方法各实施例的步骤,为避免重复描述,在此不再赘述。其中,计算装置可以为图9所示的计算装置91。在一些实施例中,计算机可读存储介质为非暂态计算机可读存储介质。
本公开实施例还提出一种计算机程序产品,其中,该计算机程序产品包括计算机程序,该计算机程序存储在非暂态计算机可读存储介质中,计算机的至少一个处理器从存储介质读取并执行该计算机程序,使得计算机执行如流体粒子的渲染方法各实施例的步骤,为避免重复描述,在此不再赘述。
计算机程序产品可以以一种或多种程序设计语言的任意组合来编写用于执行本公开实施例操作的程序代码,程序设计语言包括面向对象的程序设计语言,诸如Java、C++等,还包括常规的过程式程序设计语言,诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算设备上执行、部分地在用户设备上执行、作为一个独立的软件包执行、部分在用户计算设备上部分在远程计算设备上执行、或者完全在远程计算设备或服务器上执行。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵 盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本公开的范围之内并且形成不同的实施例。
本领域的技术人员能够理解,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
虽然结合附图描述了本公开的实施方式,但是本领域技术人员可以在不脱离本公开的精神和范围的情况下做出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。

Claims (18)

  1. 一种流体粒子的渲染方法,包括:
    获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数;
    基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置;
    从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置;
    基于所述不相邻的N帧位置,进行所述流体粒子的拖尾渲染。
  2. 根据权利要求1所述的渲染方法,其中,所述基于所述不相邻的N帧位置,进行所述流体粒子的拖尾渲染包括:
    对所述不相邻的N帧位置中的每一个,分别设置粒子尺寸和衰减曲线;
    基于所述粒子尺寸和所述衰减曲线,对所述不相邻的N帧位置进行融球处理。
  3. 根据权利要求2所述的渲染方法,其中,所述不相邻的N帧位置对应的粒子尺寸随时序的递增而递增。
  4. 根据权利要求2所述的渲染方法,所述基于所述粒子尺寸和所述衰减曲线,对所述不相邻的N帧位置进行融球处理之前,还包括:
    将所述不相邻的N帧位置,转换至屏幕坐标系下的N帧屏幕位置;
    基于所述N帧屏幕位置,确定相邻2帧屏幕位置之间的距离;
    基于相邻2帧屏幕位置中的每一个各自对应的粒子尺寸,确定相邻2帧屏幕位置对应的距离阈值;
    在所述相邻2帧屏幕位置之间的距离大于或等于所述距离阈值的情况下,缩小所述相邻2帧屏幕位置之间的距离。
  5. 根据权利要求4所述的渲染方法,其中,所述相邻2帧屏幕位置对应的距离阈值通过下式确定:
    距离阈值=a×粒子尺寸1+b×粒子尺寸2;
    其中,a和b为预设常数,粒子尺寸1和粒子尺寸2为相邻2帧屏幕位置中的每一个各自对应的粒子尺寸。
  6. 根据权利要求4所述的渲染方法,其中,所述N帧屏幕位置包括第1帧屏幕位置、第3帧屏幕位置和第5帧屏幕位置;
    所述缩小所述相邻2帧屏幕位置之间的距离包括:
    将所述第1帧屏幕位置固定,调整所述第3帧屏幕位置,直至所述第1帧屏幕位置与调整后的第3帧屏幕位置之间的距离小于第一距离阈值,所述第一距离阈值为基于所述第1帧屏幕位置和所述第3帧屏幕位置各自对应的粒子尺寸确定的阈值;
    将所述调整后的第3帧屏幕位置固定,调整所述第5帧屏幕位置,直至所述调整后的第3帧屏幕位置与调整后的第5帧屏幕位置之间的距离小于第二距离阈值,所述第二距离阈值为基于所述第3帧屏幕位置和所述第5帧屏幕位置各自对应的粒子尺寸确定的阈值。
  7. 根据权利要求4至6任一项所述的渲染方法,其中,所述缩小所述相邻2帧屏幕位置之间的距离包括:
    将所述相邻2帧屏幕位置中的任一个,确定为固定位置;
    基于所述固定位置,确定所述相邻2帧屏幕位置对应的距离向量;
    基于所述固定位置、所述距离向量、所述相邻2帧屏幕位置之间的距离和所述距离阈值,确定距离缩小后的屏幕位置。
  8. 根据权利要求7所述的渲染方法,其中,所述距离缩小后的屏幕位置通过下式确定:
    距离缩小后的屏幕位置=固定位置+距离向量×(距离阈值÷相邻2帧屏幕位置之间的距离)。
  9. 根据权利要求1所述的渲染方法,其中,所述基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置包括:
    在N小于或等于预设帧数阈值的情况下,以第N帧的位置为中心,将第1帧的位置至第N-1帧的位置中的至少一个进行对称处理,得到所述同一流体粒子的至少一帧位置。
  10. 根据权利要求1所述的渲染方法,其中,所述从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置包括:
    从所述连续N帧的位置中选择X帧,并从所述至少一帧位置中选择Y帧;其中,X为小于N的正整数,Y为大于或等于1的正整数,且X+Y=N。
  11. 根据权利要求9所述的渲染方法,其中,所述连续N帧为连续3帧,所述预设帧数阈值为3帧。
  12. 根据权利要求11所述的渲染方法,其中,所述基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置包括:
    以第3帧的位置为中心,将第1帧的位置进行对称处理,得到所述同一流体粒子的第5帧的位置。
  13. 根据权利要求12所述的渲染方法,其中,所述从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置包括:
    选择第1帧的位置、第3帧的位置和第5帧的位置。
  14. 根据权利要求1所述的渲染方法,其中,所述连续N帧的位置和所述至少一帧位置构成的轨迹为一条直线或一条贝塞尔曲线。
  15. 一种流体粒子的渲染装置,包括:
    获取单元,用于获取同一流体粒子在时序上连续N帧的位置,其中,N为大于或等于2的正整数;
    插值单元,用于基于所述连续N帧的位置,通过插值得到所述同一流体粒子的至少一帧位置;
    选择单元,用于从所述连续N帧的位置和所述至少一帧位置中,选择不相邻的N帧位置;
    渲染单元,用于基于所述不相邻的N帧位置,进行所述流体粒子的拖尾渲染。
  16. 一种包括至少一个计算装置和至少一个存储指令的存储装置的系统,其中, 所述指令在被所述至少一个计算装置运行时,促使所述至少一个计算装置执行如权利要求1至14任一项所述流体粒子的渲染方法的步骤。
  17. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储程序或指令,当所述程序或指令被至少一个计算装置运行时,使至少一个计算装置执行如权利要求1至14任一项所述流体粒子的渲染方法的步骤。
  18. 一种计算机程序,包括:
    指令,所述指令当由处理器执行时使所述处理器执行根据权利要求1至14任一项所述流体粒子的渲染方法的步骤。
PCT/CN2022/136692 2021-12-13 2022-12-05 流体粒子的渲染方法、装置、系统及存储介质 WO2023109555A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111521903.0 2021-12-13
CN202111521903.0A CN114202598A (zh) 2021-12-13 2021-12-13 一种流体粒子的渲染方法、装置、系统及存储介质

Publications (1)

Publication Number Publication Date
WO2023109555A1 true WO2023109555A1 (zh) 2023-06-22

Family

ID=80653267

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/136692 WO2023109555A1 (zh) 2021-12-13 2022-12-05 流体粒子的渲染方法、装置、系统及存储介质

Country Status (2)

Country Link
CN (1) CN114202598A (zh)
WO (1) WO2023109555A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114202598A (zh) * 2021-12-13 2022-03-18 北京字跳网络技术有限公司 一种流体粒子的渲染方法、装置、系统及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102722647A (zh) * 2012-05-30 2012-10-10 北京像素软件科技股份有限公司 一种基于运动路径生成条带粒子路径的方法及装置
US20170206625A1 (en) * 2016-01-18 2017-07-20 Advanced Micro Devices, Inc. Method and apparatus to accelerate rendering of graphics images
CN109688346A (zh) * 2018-12-28 2019-04-26 广州华多网络科技有限公司 一种拖尾特效渲染方法、装置、设备及存储介质
CN112700518A (zh) * 2020-12-28 2021-04-23 北京字跳网络技术有限公司 拖尾视觉效果的生成方法、视频的生成方法、电子设备
CN114202598A (zh) * 2021-12-13 2022-03-18 北京字跳网络技术有限公司 一种流体粒子的渲染方法、装置、系统及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102722647A (zh) * 2012-05-30 2012-10-10 北京像素软件科技股份有限公司 一种基于运动路径生成条带粒子路径的方法及装置
US20170206625A1 (en) * 2016-01-18 2017-07-20 Advanced Micro Devices, Inc. Method and apparatus to accelerate rendering of graphics images
CN109688346A (zh) * 2018-12-28 2019-04-26 广州华多网络科技有限公司 一种拖尾特效渲染方法、装置、设备及存储介质
CN112700518A (zh) * 2020-12-28 2021-04-23 北京字跳网络技术有限公司 拖尾视觉效果的生成方法、视频的生成方法、电子设备
CN114202598A (zh) * 2021-12-13 2022-03-18 北京字跳网络技术有限公司 一种流体粒子的渲染方法、装置、系统及存储介质

Also Published As

Publication number Publication date
CN114202598A (zh) 2022-03-18

Similar Documents

Publication Publication Date Title
CN100576893C (zh) 一种集成于视频处理芯片的图形osd控制器
TWI698841B (zh) 地圖區域合併的資料處理方法及裝置
US10164459B2 (en) Selective rasterization
CN109035383B (zh) 一种体积云的绘制方法、装置及计算机可读存储介质
WO2023109555A1 (zh) 流体粒子的渲染方法、装置、系统及存储介质
US9600137B2 (en) Providing selection areas for selectable objects in graphical interface
CN108228050B (zh) 一种图片缩放方法、装置以及电子设备
CN117372631B (zh) 一种多视角图像生成模型的训练方法、应用方法
CN103605506B (zh) 一种图形用户界面资源的显示方法及终端
CN110544214A (zh) 一种图像修复方法、装置及电子设备
CN106910162A (zh) 基于fpga的图像缩放处理方法及装置
TWI691206B (zh) 浮水印添加處理方法、裝置及客戶端
US10783685B2 (en) Banner image generation
WO2023083171A1 (zh) 图像数据流的处理方法、装置及电子设备
CN113132658B (zh) 基于仿生图像传感器的数据处理方法、装置、设备和介质
WO2020186372A1 (zh) 一种逆色调映射方法、系统、设备及计算机可读介质
WO2020041962A1 (zh) 一种并行反卷积计算方法、单引擎计算方法及相关产品
CN112732252A (zh) 一种动态生成ui的方法、装置和电子设备
US20240185454A1 (en) Particle rendering method and apparatus
CN115984154A (zh) 一种图像融合的方法、装置、存储介质及电子设备
WO2019114044A1 (zh) 图像处理方法、装置、电子设备及计算机可读存储介质
KR20230034351A (ko) 얼굴 이미지 표시 방법, 장치, 전자기기 및 저장매체
CN110038301B (zh) 数据处理方法、装置、电子设备及存储介质
CN111523539A (zh) 一种文字检测方法及装置
CN112269957A (zh) 图片处理方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22906305

Country of ref document: EP

Kind code of ref document: A1