Fluid rendering method and apparatus, electronic device, and storage medium
By storing the control point position information of the Bézier curve into a texture map, and using the Bézier curve to describe the 2D cross-sectional shape of the fluid for rendering, the problem of large storage space and bandwidth of pre-baked animation sequences is solved, and real-time rendering of fluid effects is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2024-12-25
- Publication Date
- 2026-06-26
AI Technical Summary
In existing technologies, pre-baked animation sequences for wave rendering require a large amount of storage space and bandwidth, making them unsuitable for generating complex wave effects in real time.
By storing the control point location information of the Bézier curve into a texture map, and using the Bézier curve to describe the 2D cross-sectional shape of the fluid for rendering, the amount of data is reduced, and the storage and bandwidth requirements are lowered.
It enables real-time generation of fluid effects on both PC and mobile devices, reduces data volume and storage requirements, and is suitable for game engines on multiple platforms.
Smart Images

Figure CN122273101A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a fluid rendering method, apparatus, electronic device, and storage medium. Background Technology
[0002] In naval warfare games and virtual reality applications, realistic ocean rendering is key to enhancing immersion. Among these features, breaking waves are a complex and dynamic natural phenomenon in the ocean, characterized by waves breaking at their tips after accumulating sufficient energy.
[0003] Currently, pre-baked animation sequences are commonly used to simulate simple wave effects. However, pre-baked animation sequences require a large amount of storage space and bandwidth, making them unsuitable for generating complex wave effects in real time. Summary of the Invention
[0004] In view of this, embodiments of this application provide a fluid rendering method, apparatus, electronic device, and storage medium to solve the problem that pre-baked animation sequences require a large amount of storage space and bandwidth, making them unsuitable for generating complex wave effects in real time.
[0005] In a first aspect, embodiments of this application provide a fluid rendering method, including:
[0006] Obtain a preset texture map and a fluid mesh model of the target fluid; wherein, the preset texture map stores: the position information of control points on each Bézier curve under multiple animation frames;
[0007] Based on the texture coordinates of each grid vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each grid vertex are determined from each Bézier curve in each animation frame. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve.
[0008] Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, determine the position information of each grid vertex in each animation frame;
[0009] Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in a preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
[0010] Secondly, embodiments of this application also provide a fluid rendering apparatus, including:
[0011] The acquisition module is used to acquire a preset texture map and a fluid mesh model of the target fluid; wherein, the preset texture map stores the position information of control points on each Bézier curve in multiple animation frames;
[0012] The determination module is used to determine the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from each Bézier curve in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve.
[0013] The determining module is further configured to determine the position information of each grid vertex in each animation frame based on the position information of the control points on the target Bézier curve and the target Bézier parameters;
[0014] The generation module is used to offset the position of each mesh vertex in a preset height direction according to the position information of each mesh vertex in the multiple animation frames, so as to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
[0015] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the method described in any of the first aspects.
[0016] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the method described in any of the first aspects.
[0017] This application provides a fluid rendering method, apparatus, electronic device, and storage medium. The method includes: acquiring a preset texture map and a fluid mesh model of the target fluid; determining the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from each Bézier curve in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model; determining the position information of each mesh vertex in each animation frame based on the position information of control points on the target Bézier curve and the target Bézier parameters; and offsetting the position of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate a fluid animation of the target fluid. By storing the position information of the control points of the Bézier curve in the texture map and using the Bézier curve to describe the 2D cross-sectional shape of the fluid for fluid rendering, the amount of data is reduced, and the storage and bandwidth requirements are lowered, making it suitable for real-time rendering. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 1 ;
[0020] Figure 2 A schematic diagram of the Bezier spline provided in the embodiments of this application. Figure 1 ;
[0021] Figure 3 A schematic diagram of the Bezier spline provided in the embodiments of this application. Figure 2 ;
[0022] Figure 4 A schematic diagram of control point storage provided in the embodiments of this application. Figure 1 ;
[0023] Figure 5 A schematic diagram of control point storage provided in the embodiments of this application. Figure 2 ;
[0024] Figure 6 A schematic diagram of a BSAT texture provided in an embodiment of this application;
[0025] Figure 7 A schematic diagram of the 2D cross-sectional shape of the rolling wave provided in an embodiment of this application;
[0026] Figure 8A schematic diagram of the fluid mesh model provided in the embodiments of this application;
[0027] Figure 9 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 2 ;
[0028] Figure 10 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 3 ;
[0029] Figure 11 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 4 ;
[0030] Figure 12 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 5 ;
[0031] Figure 13 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 6 ;
[0032] Figure 14 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 7 ;
[0033] Figure 15 This is a schematic diagram of the structure of the fluid rendering apparatus provided in the embodiments of this application;
[0034] Figure 16 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0036] First, let me explain the technical terms used in this application:
[0037] Bezier Curve: A Bezier curve is a parametric curve defined by control points, widely used in computer graphics, computer-aided design (CAD), and animation. Common types include quadratic Bezier curves (defined by 3 control points) and cubic Bezier curves (defined by 4 control points).
[0038] Bezier Spline: Also known as a composite Bezier curve, a Bezier spline is a mathematical method for defining smooth curves using control points, widely used in computer graphics. A Bezier spline is composed of multiple Bezier curve segments, each defined by a set of control points.
[0039] BSAT: Bezier Spline Animation Texture, an animated texture based on Bezier Spline curves, used to store and reproduce the shape and animation of waves. It is not a fixed term, but a coined word to describe this case.
[0040] VAT: Vertex Animation Texture, which stores vertex animation information through textures.
[0041] Breaking Wave: The phenomenon where ocean waves break at their tips after accumulating enough energy, resulting in complex dynamic shapes.
[0042] Shader: A program used to perform lighting, rendering, and other graphics calculations on graphics hardware.
[0043] Keyframe: A keyframe defines the state at a specific point in time in an animation, and is used for interpolation to generate the complete animation.
[0044] Noise: In computer graphics, a texture or function used to add randomness and detail.
[0045] DCC: Digital Content Creation, tools for creating digital content, such as Maya and Houdini.
[0046] Texture mapping: a common dataset in computer graphics.
[0047] Currently, pre-baked animation sequences are used to simulate simple wave effects. However, these pre-baked animation sequences require a large amount of storage space and bandwidth, making them unsuitable for generating complex wave effects in real time, especially on mobile devices. Based on this, this application proposes a data compression method using Bézier curves. By storing the position information of the control points of the Bézier curves into a texture map and using Bézier curves to describe the 2D cross-sectional shape of the fluid for fluid rendering (such as wave rendering), the amount of data is greatly reduced, and the storage and bandwidth requirements are lowered. This achieves data compression and efficient storage, is suitable for multiple platforms, and can generate fluid effects in real time within game engines deployed on both PC and mobile devices.
[0048] Figure 1 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 1 In this embodiment, the executing entity can be an electronic device, such as a mobile phone or computer.
[0049] like Figure 1 As shown, the method may include:
[0050] S101. Obtain the preset texture map and the fluid mesh model of the target fluid.
[0051] The target fluid could be, for example, rolling waves, which are a complex and dynamic natural phenomenon in the ocean, characterized by waves breaking at their tips after accumulating enough energy.
[0052] The preset texture map stores the position information of control points on each Bézier curve across multiple animation frames. Taking a third-order Bézier curve as an example, a Bézier curve is defined by four control points, such as P0, P1, P2, and P3.
[0053] An action frame consists of N Bézier curves connected end-to-end, where N is greater than or equal to 2. Adjacent Bézier curves are connected through shared endpoints (which are control points) to form a Bézier spline. In other words, the N Bézier curves connected end-to-end form a Bézier spline to create a smooth wave cross-sectional shape. The Bézier curves can accurately describe the smooth shape of the waves, and the mathematical properties of the curves make efficient calculation possible in the shader.
[0054] Figure 2 A schematic diagram of the Bezier spline provided in the embodiments of this application. Figure 1 ,like Figure 2 As shown, the control points of one Bézier curve include P0, P1, P2, and P3, and the control points of another Bézier curve include P3, P4, P5, and P6, with P3 as the shared endpoint.
[0055] In order to ensure a smooth transition of the curve, the control points of adjacent curve segments need to satisfy P3-P2=P4-P3, so as to ensure that the curve is first-order differentiable at the connection point and appears smooth and continuous.
[0056] The following relationship exists between the total number of Bézier curves (TotalCurve) and the number of control points (PointsCount) on a Bézier spline:
[0057]
[0058] The position information of control points on each Bézier curve across multiple animation frames is stored in a preset texture map. Each pixel of the preset texture map stores the position information of one control point. For example, a Bézier spline containing 8 Bézier curve segments requires 25 control points, which can be stored in only 25 pixels. The control points can be stored in the V direction of the preset texture map. Figure 3 A schematic diagram of the Bezier spline provided in the embodiments of this application. Figure 2 ,like Figure 3 As shown, the 25 control points are marked as 0, 1, 2...24 respectively. It can be seen that the wave cross-sectional shape was formed by using Bezier splines.
[0059] Figure 4 A schematic diagram of control point storage provided in the embodiments of this application. Figure 1 , Figure 5 A schematic diagram of control point storage provided in the embodiments of this application. Figure 2 ,like Figure 4 , Figure 5 As shown, the position information of 25 control points is stored in 25 pixels along the V direction of a preset texture map. The coordinate system of the preset texture map is a UV coordinate system, and the texture coordinates (UV coordinates) are represented as (u,v), where u and v range from 0 to 1. The texture coordinates of the top-left pixel are (0,0), and the texture coordinates of the bottom-right pixel are (1,1). In this example, because the position information of 25 control points is stored, the height of the preset texture map is 25 pixels.
[0060] The UV space of the preset texture map, generally called Texture Space or UV Space, is a two-dimensional coordinate system, usually called Texture Coordinates or UV Coordinates, denoted by U and V. Generally, U represents the horizontal axis (row) and V represents the vertical axis (column).
[0061] An animation frame corresponds to a point in time, and different animation frames correspond to different points in time. One column of the preset texture map is used to store the position information of the control points on each Bézier curve at the same point in time. That is, the position information of the control points on each Bézier curve at different points in time is stored in different columns of the preset texture map. The height of the preset texture map represents the number of control points in an animation frame, and the width represents the number of animation frames.
[0062] It's worth noting that, to optimize data volume, the number of animation frames can be standardized to 1024 frames, and in practical applications, it can be further reduced to 512 or 256 frames. Preset texture maps can be called Bezier Spline Animation Textures (BSAT), similar to the concept of Vertex Animation Textures (VAT). VAT records vertex animation information in the texture map, while BSAT saves animation information expressed or driven by Bezier curves in the texture map. Figure 6 This is a schematic diagram of the BSAT texture provided in the embodiments of this application, such as... Figure 6 As shown, different colors in the BSAT map represent different control point location information. Black represents a smaller location value, and as the control point location value increases, the color gradually changes from black to red.
[0063] Will Figure 6 The BSAT texture in the image is flipped 90 degrees. Figure 7 A schematic diagram of the 2D cross-sectional shape of the wave provided in the embodiments of this application, as shown below. Figure 7 As shown, U represents time and V represents the vertical axis. The position information of 25 control points is stored in the pixels in the V direction of the preset texture map. It can be seen that in this BSAT map, the U direction represents the 2D cross-sectional shape of the wave at different times. As time changes, the 2D cross-sectional shape of the wave changes.
[0064] This involves creating a fluid mesh model of the target fluid. The fluid mesh model is a two-dimensional mesh model of the target fluid, such as a wave mesh model. The fluid mesh model includes multiple mesh vertices.
[0065] It is worth noting that since the preset texture map stores 2D cross-sectional information (i.e., the position information of control points), the amount of data can be greatly reduced. In addition, the use of Bézier curves further reduces the amount of data. Therefore, theoretically, it is expected that storing 100 different shapes of waves will only require a texture size of less than 2048×512 pixels, making the amount of data extremely concise.
[0066] It is worth noting that the position information of the control points on the Bézier curve is stored in a preset texture map. The height of the preset texture map is the number of control points in the V direction, and the width is the number of animation frames in the U direction. Based on this, the four control points P0, P1, P2, and P3 of the Bézier curve can be read from the preset texture map.
[0067] S102. Based on the texture coordinates of each mesh vertex on the fluid mesh model, determine the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from each Bézier curve in each animation frame.
[0068] The fluid mesh model is located in UV space. The texture coordinates of each mesh vertex on the fluid mesh model are obtained. Based on the texture coordinates of each mesh vertex, the target Bézier curve and target Bézier parameters corresponding to each mesh vertex are determined from each Bézier curve in each animation frame. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve. The start control point and the end control point can be understood as the two endpoints of the Bézier curve.
[0069] The Bezier parameter t (i.e., parameterized variable, local parameter, interpolation parameter) ∈ [0,1] is a unitless parameter ranging from 0 to 1, representing the target parameterized position between the starting control point and the ending control point of the Bezier curve. For example, when t = 0, the target parameterized position is the starting control point; when t = 1, the target parameterized position is the ending control point; and the intermediate value of t (e.g., t = 0.5) represents the target parameterized position as the middle position on the curve.
[0070] S103. Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, determine the position information of each grid vertex in each animation frame.
[0071] The target Bézier curve has four control points, such as P0, P1, P2, and P3. Based on the position information of the control points on the target Bézier curve corresponding to each grid vertex and the target Bézier parameters, the parametric equation of the Bézier curve is used to calculate the position information of each grid vertex in each animation frame.
[0072] The parametric equation of the Bézier curve is:
[0073] B(t)=(1-t) 3 P0+3(1-t) 2 tP1+3(1-t)t 2 P2+t 3 P3,t∈[0,1]
[0074] Substituting the position information of P0, P1, P2, P3 and the target Bessel parameter t into the above parametric equation, we obtain the position information B(t) of each grid vertex.
[0075] S104. Based on the position information of each grid vertex in multiple animation frames, offset the position of each grid vertex in the preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid.
[0076] The preset height direction is perpendicular to the texture plane of the fluid mesh model, and the texture plane of the fluid mesh model is the plane corresponding to the UV space of the fluid mesh model. Figure 8 A schematic diagram of the fluid mesh model provided in the embodiments of this application, as shown below. Figure 8 As shown, the preset height direction is the Z direction, which is perpendicular to the UV plane where the fluid mesh model is located. Offsetting the position of the mesh vertices is essentially setting the height of the mesh vertices in the preset height direction (Z direction).
[0077] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid. In other words, by restoring the vertex offset information, the fluid mesh model is expanded into a 3D continuous surface, and the generated fluid animation is a 3D animation. The height of the grid vertex can be obtained by offsetting the position of the grid vertex in the preset height direction, and the fluid mesh model is a 3D mesh model.
[0078] In this embodiment, the above steps S101-S104 can be executed using a shader in a game engine. By reading pre-baked preset texture maps, the 2D cross-sectional shape of the wave can be efficiently restored, vertex offset information can be restored for model rendering, and fluid animation can be generated. Thus, the 2D cross-sectional shape of the wave can be efficiently calculated and restored in the shader. It is suitable for PC and mobile devices, realizing real-time generation and high performance of fluid animation. Furthermore, by creating a variety of different preset texture maps, a rich library of 2D cross-sectional shapes of waves is provided, realizing the diversity and batch generation of fluid shapes.
[0079] Figure 9 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 2 ,like Figure 9 As shown, in an optional implementation, step S101, obtaining the preset texture map, may include:
[0080] S201. Identify at least two non-adjacent keyframes from a plurality of animation frames.
[0081] Among them, at least two keyframes are non-adjacent animation frames among multiple animation frames, and at least two keyframes can include the first animation frame and the last animation frame among multiple animation frames.
[0082] S202. Based on the curve drawing operation input for at least two keyframes, obtain the position information of control points on each Bézier curve under at least two keyframes.
[0083] Input curve drawing operations for at least two keyframes, where the curve drawing operations are used to draw Bézier splines for each keyframe respectively, for example, drawing Bézier splines by dragging and dropping according to actual needs.
[0084] Based on the curve drawing operation, the Bézier splines are drawn for each keyframe. Once the Bézier splines are drawn, the position information of the control points on the Bézier curve can be obtained. In other words, the position information of the control points on the Bézier curve for each keyframe is obtained based on the curve drawing operation.
[0085] S203. Based on the position information of the control points on each Bézier curve in at least two key frames, obtain the position information of the control points on each Bézier curve in other frames.
[0086] Other frames are the animation frames other than at least two keyframes among multiple animation frames. Interpolation is performed based on the position information of the control points on the Bézier curves in the at least two keyframes to obtain the position information of the control points on the Bézier curves in the other frames. In other words, the position information of the control points on the Bézier curves in the intermediate frames between non-adjacent keyframes is formed by interpolating between them.
[0087] For example, interpolation is performed on the position information of the first control point on the first segment of the Bézier curve in keyframe 1 and the position information of the first control point on the first segment of the Bézier curve in keyframe 2 to obtain the position information of the first control point on the first segment of the Bézier curve of the animation frame between keyframe 1 and keyframe 2.
[0088] Interpolation is performed on the position information of the second control point on the second segment of the Bézier curve of keyframe 2 to obtain the position information of the second control point on the second segment of the Bézier curve of the animation frame between keyframe 1 and keyframe 2. It is worth noting that the number of animation frames between two non-adjacent keyframes is not limited to one, and can be selected according to the actual situation. This embodiment does not make any special limitation on this.
[0089] If at least two keyframes include the first and last animation frames among multiple animation frames, then only the first and last spline shapes need to be created, and the middle can be achieved through interpolation.
[0090] S204. Store the position information of the control points on each Bézier curve in multiple animation frames to the preset texture map.
[0091] In this system, one animation frame corresponds to one time point, and different animation frames correspond to different time points. The position information of the control points on each Bézier curve under multiple animation frames is stored in different columns of the preset texture map.
[0092] For example, keyframes are frames 1, 101, 120, 138, 156, and 166. By drawing the corresponding Bézier splines, a 2D cross-sectional shape of a wave is defined. Through interpolation, the Bézier splines of intermediate frames 2-100, 102-119, 121-137, 139-155, and 127-165 are interpolated. Then, the position information of the control points on each Bézier curve in all animation frames is stored in a preset texture map.
[0093] It is worth noting that keyframe animation software can be used to perform the above steps S201-S203. Keyframe animation software can include, for example, Houdini and Unity, which support batch production and export of Bézier curves, enabling mass production and offering high convenience.
[0094] In this embodiment, by drawing Bézier curves at keyframes and using the position information of control points on the Bézier curves at keyframes, the position information of control points on the Bézier curves at other animation frames is obtained. This achieves diverse fluid forms, provides a rich library of wave shapes to meet the requirements of rich visual effects in games, and through the development of a dedicated toolchain, supports artists and designers to easily create and configure different wave shapes in batches.
[0095] Figure 10 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 3 ,like Figure 10 As shown, in an optional embodiment, step S102, which determines the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from the Bézier curves in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model, may include:
[0096] S301. Obtain the target Bezier parameters and target curve index based on the texture coordinates of the mesh vertices.
[0097] S302. Determine the Bézier curve corresponding to the target curve index as the target Bézier curve.
[0098] In this context, each animation frame's Bézier spline is composed of multiple Bézier curve segments, and the target curve index is the curve index of the target Bézier curve within the corresponding Bézier spline. For an animation frame, each Bézier curve within that frame has a curve index.
[0099] Based on the texture coordinates of the mesh vertices, the target Bézier parameters corresponding to the mesh vertices and the target curve index of the target Bézier curve can be determined. Then, the Bézier curve corresponding to the target curve index is determined as the target Bézier curve.
[0100] In an optional implementation, if the texture coordinates of a mesh vertex exceed a preset texture coordinate threshold, the preset texture coordinate threshold is determined as the target Bezier parameter; the target curve index is determined based on the total number of control points on each Bezier curve in each animation frame.
[0101] The texture coordinates of the mesh vertices can be v coordinates, and the preset texture coordinate threshold can be a threshold value of the v coordinate, such as 1.0. That is, if the v coordinate of the mesh vertex exceeds the preset texture coordinate threshold, the target Bezier parameter t is determined to be 1.0.
[0102] The target curve index is determined using the following formula, based on the total number of control points on each Bézier curve in each animation frame:
[0103] i = PointsCount - 4
[0104] j = i / 3
[0105] Where j is the target curve index, PointsCount is the total number of control points on each Bézier curve in each animation frame, and i is the index of the starting control point on the Bézier curve corresponding to the target curve index in each animation frame.
[0106] For example, when PointsCount = 25, there are a total of 8 Bézier curves, and i = 21, which means that the target curve index corresponds to the 21st control point out of 25 control points on the starting control point of the Bézier curve. The curve indices are 0-7, so we get (25-4) / 3 = 7, that is, the target curve index is 7, which means the last Bézier curve.
[0107] The total number of control points on each Bézier curve in each animation frame is the total number of control points on each Bézier spline in each animation frame.
[0108] In an optional implementation, if the texture coordinates of the mesh vertices do not exceed a preset texture coordinate threshold, the target curve index and target Bézier parameters are determined based on the texture coordinates of the mesh vertices and the number of Bézier curves in each animation frame.
[0109] If the texture coordinates of the mesh vertices do not exceed the preset texture coordinate threshold (i.e., the v-coordinate is less than or equal to the preset texture coordinate threshold), then the target curve index and target Bézier parameters are determined using the following formula based on the texture coordinates of the mesh vertices and the number of Bézier curves in each animation frame. The number of Bézier curves in each animation frame is the sum of the number of Bézier curves in each animation frame. For example, if there are a total of 8 Bézier curves, then the total number of control points in that animation frame is 3 × 8 + 1 = 25 control points. That is, this Bézier spline consists of 8 Bézier curves and 25 control points.
[0110] j = int(v × CurvesCount)
[0111] t = v × CurvesCount - j
[0112] i = j × 3
[0113] Where v is the v coordinate of the grid vertex, j is the target curve index, i is the index of the starting control point on the Bézier curve corresponding to the target curve index in the control points of each animation frame, CurvesCount is the number of curves of each Bézier curve in each animation frame, and int represents rounding.
[0114] For example, taking a Bézier spline composed of 8 Bézier curves as an example, it has 25 control points. When v is 0.1 and CurvesCount is 8, then j is 0 and i is 0, that is, the target curve index is 0, which indicates the first Bézier curve.
[0115] The target Bezier parameter t is the decimal part of v×CurvesCount. For example, if v is 0.1 and CurvesCount is 8, then the decimal part is 0.8, that is, the target Bezier parameter is 0.8.
[0116] In this embodiment, based on the texture coordinates of the mesh vertices, the target Bézier curve and target Bézier parameters corresponding to the mesh vertices are determined, thereby enabling the texture coordinates to be mapped onto the Bézier curve, and thus determining the position information of the mesh vertices for position offset. The use of Bézier curves to describe the 2D cross-sectional shape of the fluid for fluid rendering reduces the amount of data, lowers storage and bandwidth requirements, and is suitable for real-time rendering.
[0117] Figure 11 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 4 ,like Figure 11As shown, in an optional implementation, step S104, which involves offsetting the positions of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate a fluid animation of the target fluid, may include:
[0118] S401. Based on the position information of each grid vertex in multiple animation frames, offset each grid vertex in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0119] The preset height direction is perpendicular to the texture plane of the fluid mesh model. The texture plane of the fluid mesh model is the plane corresponding to the UV space of the fluid mesh model. Based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in the preset height direction to obtain the offset mesh vertices in multiple animation frames.
[0120] S402. Based on the texture coordinates of each mesh vertex, determine the target mesh vertices in multiple animation frames from the mesh vertices after offset in multiple animation frames.
[0121] In this embodiment, the texture coordinates of the mesh vertices are UV coordinates. Based on the texture coordinates of each mesh vertex, target mesh vertices in multiple animation frames are determined from the mesh vertices after offset in multiple animation frames. The U coordinates in the texture coordinates of the target mesh vertices satisfy the preset U coordinate conditions. That is, the mesh vertices whose U coordinates satisfy the preset U coordinate conditions in each animation frame are determined as target mesh vertices. The preset U coordinate conditions can be selected according to the actual situation. This embodiment does not make any special limitations on this.
[0122] S403. Offset the target mesh vertices in multiple animation frames in the preset texture direction of the texture plane to generate the fluid animation of the target fluid.
[0123] The preset texture direction of the texture plane can be the U direction, where U represents time. For each animation frame, the target mesh vertices of each animation frame are time-shifted along the U direction of the texture plane of the fluid mesh model, so that the mesh vertices of each animation frame fall in a staggered manner along the U direction to generate the fluid animation of the target fluid. For example, the target mesh vertex of the first animation frame is shifted from the first animation frame to the second animation frame. After the shift, the height of the target mesh vertex of the second animation frame is the same as the height of the target mesh vertex of the first animation frame. After the shift, the height of the target mesh vertex of the first animation frame can be 0. The target mesh vertex of the second animation frame is shifted from the second animation frame to the third animation frame. After the shift, the height of the target mesh vertex of the third animation frame is the same as the height of the target mesh vertex of the second animation frame.
[0124] It is worth noting that in the specific implementation process, a one-dimensional guide map or noise function can be used to calculate the time offset of the target mesh vertex based on the texture coordinates of the target mesh vertex, and then the target mesh vertex is time-shifted based on the time offset.
[0125] In this embodiment, by time-shifting the target grid vertices while not time-shifting other grid vertices, the fluid falls staggered along the horizontal axis (U direction), achieving a time-shifting effect. The fluid shapes at different locations are not exactly the same, realizing diverse fluid forms, improving shape diversity and dynamism, meeting the game's demand for rich visual effects, and having strong scalability to adapt to different needs. It can be further combined with realistic fluid simulation and special effects to achieve more realistic effects.
[0126] Figure 12 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 5 ,like Figure 11 As shown, in an optional implementation, step S104, which involves offsetting the positions of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate a fluid animation of the target fluid, may include:
[0127] S501. Based on the position information of each grid vertex in multiple animation frames, offset each grid vertex in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0128] The preset height direction is perpendicular to the texture plane of the fluid mesh model. The texture plane of the fluid mesh model is the plane corresponding to the UV space of the fluid mesh model. Based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in the preset height direction to obtain the offset mesh vertices in multiple animation frames.
[0129] S502. Based on preset random noise, noise processing is performed on each grid vertex after offset in multiple animation frames in the preset height direction to generate fluid animation of the target fluid.
[0130] And / or,
[0131] S503. Based on preset random noise, noise processing is performed on each mesh vertex after offset in multiple animation frames in the preset texture direction corresponding to the texture plane to generate the fluid animation of the target fluid.
[0132] The preset height direction is the Z direction, and the preset texture direction is the U direction, where the U direction represents time. Based on preset random noise, noise processing is performed on each grid vertex after offset in multiple animation frames in the preset height direction. That is, the preset random noise is used to adjust the height of each grid vertex after offset in the preset height direction to perform noise processing on the grid vertex after offset in the preset height direction. And / or, based on preset random noise, noise processing is performed on each grid vertex after offset in multiple animation frames in the preset texture direction. That is, the preset random noise is used to adjust the U coordinate of each grid vertex after offset in the preset texture direction to perform noise processing on the grid vertex after offset in the preset texture direction to generate the fluid animation of the target fluid.
[0133] In this embodiment, by adding noise to the mesh noise in the height direction and / or time dimension, the falling fluid becomes more staggered, which increases the naturalness and randomness of the fluid shape, realizes diverse fluid forms, improves shape diversity and dynamism, meets the needs of games for rich visual effects, and is highly scalable, adaptable to different needs, and can be further combined with realistic fluid simulation and special effects to achieve more realistic effects.
[0134] Figure 13 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 6 ,like Figure 13 As shown, in an optional implementation, step S104, which involves offsetting the positions of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate a fluid animation of the target fluid, may include:
[0135] S601. Based on the position information of each grid vertex in multiple animation frames, offset each grid vertex in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0136] The preset height direction is perpendicular to the texture plane of the fluid mesh model. The texture plane of the fluid mesh model is the plane corresponding to the UV space of the fluid mesh model. Based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in the preset height direction to obtain the offset mesh vertices in multiple animation frames.
[0137] S602. Determine the edge mesh vertices from the mesh vertices after offsetting from multiple animation frames.
[0138] Based on the texture coordinates of each mesh vertex in multiple animation frames, edge mesh vertices are determined from the offset mesh vertices in multiple animation frames. The edge mesh vertices are the mesh vertices located on the upper edge of the fluid mesh model.
[0139] S603. Adjust the height of the edge mesh vertices to the preset height in the preset height direction to generate the fluid animation of the target fluid.
[0140] In the preset height direction, the height of the edge mesh vertices is adjusted to the preset height. Here, the fluid can be rolling waves, and the preset height can be the height of the original ocean level. In other words, the height of the edge mesh vertices is adjusted to match the height of the original ocean level to seamlessly connect with the original ocean, achieving a smooth transition, avoiding abrupt height changes, and providing strong scalability to adapt to different needs.
[0141] Figure 14 A flowchart illustrating the fluid rendering method provided in this application embodiment. Figure 7 ,like Figure 14 As shown, in an optional implementation, step S104, which involves offsetting the positions of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate a fluid animation of the target fluid, may include:
[0142] S701. Based on the position information of each grid vertex in multiple animation frames, offset each grid vertex in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0143] The preset height direction is perpendicular to the texture plane of the fluid mesh model. The texture plane of the fluid mesh model is the plane corresponding to the UV space of the fluid mesh model. Based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in the preset height direction to obtain the offset mesh vertices in multiple animation frames.
[0144] S702. Calculate the normal vector of each offset grid vertex.
[0145] S703. Perform lighting rendering on the fluid mesh model based on the normal vector to generate fluid animation of the target fluid.
[0146] Based on the texture coordinates and height of each mesh vertex after offset in each animation frame, the normal vector of each mesh vertex after offset in each animation frame is calculated. Based on the normal vector of the offset mesh vertex, the normal vector of each pixel between adjacent offset mesh vertices in the fluid mesh model is interpolated. Based on the normal vector of each pixel, the fluid mesh model is lit and rendered to generate the fluid animation of the target fluid.
[0147] In this embodiment, the fluid animation of the target fluid is obtained by calculating the normal vector of the fluid mesh model and then performing lighting rendering. This achieves diverse fluid shapes, improves shape diversity and dynamism, meets the needs of games for rich visual effects, and is highly scalable, adaptable to different needs. It can be further combined with realistic fluid simulation and special effects to achieve more realistic effects.
[0148] Figure 15 This is a schematic diagram of the structure of a fluid rendering apparatus provided in an embodiment of this application. This apparatus can be integrated into an electronic device.
[0149] like Figure 15 As shown, the device may include:
[0150] The acquisition module 801 is used to acquire a preset texture map and a fluid mesh model of the target fluid; wherein, the preset texture map stores the position information of control points on each Bézier curve under multiple animation frames;
[0151] The determination module 802 is used to determine the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from each Bézier curve in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve.
[0152] The determination module 802 is also used to determine the position information of each grid vertex in each animation frame based on the position information of the control points on the target Bézier curve and the target Bézier parameters;
[0153] The generation module 803 is used to offset the position of each grid vertex in a preset height direction according to the position information of each grid vertex in multiple animation frames, so as to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
[0154] In an optional implementation, the acquisition module 801 is specifically used for:
[0155] Identify at least two non-adjacent keyframes from a set of multiple animation frames;
[0156] Based on the curve drawing operation input for at least two keyframes, obtain the position information of control points on each Bézier curve under at least two keyframes;
[0157] Based on the position information of the control points on each Bézier curve in at least two keyframes, obtain the position information of the control points on each Bézier curve in other frames. Other frames are animation frames other than at least two keyframes among multiple animation frames.
[0158] Store the position information of control points on each Bézier curve in multiple animation frames into a preset texture map.
[0159] In an optional implementation, the acquisition module 801 is specifically used for:
[0160] Interpolation is performed on the position information of control points on each Bézier curve in at least two keyframes to obtain the position information of control points on each Bézier curve in other frames.
[0161] In an optional implementation, the determining module 802 is specifically used for:
[0162] Based on the texture coordinates of the mesh vertices, obtain the target Bezier parameters and the target curve index;
[0163] The Bézier curve corresponding to the target curve index is determined as the target Bézier curve.
[0164] In an optional implementation, the determining module 802 is specifically used for:
[0165] If the texture coordinates of a mesh vertex exceed a preset texture coordinate threshold, then the preset texture coordinate threshold is determined as the target Bezier parameter;
[0166] The target curve index is determined based on the total number of control points on each Bézier curve in each animation frame.
[0167] In an optional implementation, the determining module 802 is specifically used for:
[0168] If the texture coordinates of the mesh vertices do not exceed the preset texture coordinate threshold, the target curve index and target Bézier parameters are determined based on the texture coordinates of the mesh vertices and the number of Bézier curves in each animation frame.
[0169] In an optional implementation, the generation module 803 is specifically used for:
[0170] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0171] Based on the texture coordinates of each mesh vertex, the target mesh vertices of multiple animation frames are determined from the mesh vertices after offset from multiple animation frames;
[0172] Offset the target mesh vertices in multiple animation frames along the preset texture direction on the texture plane to generate fluid animation of the target fluid.
[0173] In an optional implementation, the generation module 803 is specifically used for:
[0174] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0175] Based on preset random noise, noise processing is applied to each mesh vertex offset across multiple animation frames in a preset height direction to generate fluid animation of the target fluid; and / or,
[0176] Based on preset random noise, noise processing is performed on each mesh vertex after offset in multiple animation frames in the preset texture direction corresponding to the texture plane to generate the fluid animation of the target fluid.
[0177] In an optional implementation, the generation module 803 is specifically used for:
[0178] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0179] Determine the edge mesh vertices from the offset mesh vertices across multiple animation frames;
[0180] In the preset height direction, adjust the height of the edge mesh vertices to the preset height to generate the fluid animation of the target fluid.
[0181] In an optional implementation, the generation module 803 is specifically used for:
[0182] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0183] Calculate the normal vector of each offset grid vertex;
[0184] The fluid mesh model is illuminated and rendered based on the normal vectors to generate a fluid animation of the target fluid.
[0185] In this embodiment, the acquisition module is used to acquire a preset texture map and a fluid mesh model of the target fluid. The preset texture map stores the position information of control points on each Bézier curve in multiple animation frames. The determination module is used to determine the target Bézier curve and target Bézier parameters corresponding to each mesh vertex in each animation frame based on the texture coordinates of each mesh vertex in the fluid mesh model. The target Bézier parameters indicate the target parameterized position between the start and end control points of the target Bézier curve. The determination module is also used to determine the position information of each mesh vertex in each animation frame based on the position information of the control points on the target Bézier curve and the target Bézier parameters. The generation module is used to offset the position of each mesh vertex in a preset height direction based on the position information of each mesh vertex in multiple animation frames to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model. By storing the position information of the control points of the Bézier curve in the texture map and using Bézier curves to describe the 2D cross-sectional shape of the fluid for fluid rendering, the amount of data is reduced, and the storage and bandwidth requirements are lowered, making it suitable for real-time rendering.
[0186] Figure 16 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 16 As shown, the device may include a processor 901, a memory 902, and a bus 903. The memory 902 stores machine-readable instructions executable by the processor 901. When the electronic device is running, the processor 901 communicates with the memory 902 via the bus 903. The processor 901 executes the machine-readable instructions to perform the following steps:
[0187] Obtain a preset texture map and a fluid mesh model of the target fluid; the preset texture map stores the position information of control points on each Bézier curve in multiple animation frames;
[0188] Based on the texture coordinates of each grid vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each grid vertex are determined from each Bézier curve in each animation frame. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve.
[0189] Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, determine the position information of each grid vertex in each animation frame;
[0190] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
[0191] In one optional implementation, obtaining a preset texture map includes:
[0192] Identify at least two non-adjacent keyframes from a set of multiple animation frames;
[0193] Based on the curve drawing operation input for at least two keyframes, obtain the position information of control points on each Bézier curve under at least two keyframes;
[0194] Based on the position information of the control points on each Bézier curve in at least two keyframes, obtain the position information of the control points on each Bézier curve in other frames. Other frames are animation frames other than at least two keyframes among multiple animation frames.
[0195] Store the position information of control points on each Bézier curve in multiple animation frames into a preset texture map.
[0196] In an optional implementation, based on the position information of control points on each Bézier curve in at least two keyframes, the position information of control points on each Bézier curve in other frames is obtained, including:
[0197] Interpolation is performed on the position information of control points on each Bézier curve in at least two keyframes to obtain the position information of control points on each Bézier curve in other frames.
[0198] In an optional implementation, based on the texture coordinates of each mesh vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each mesh vertex are determined from the Bézier curves in each animation frame, including:
[0199] Based on the texture coordinates of the mesh vertices, obtain the target Bezier parameters and the target curve index;
[0200] The Bézier curve corresponding to the target curve index is determined as the target Bézier curve.
[0201] In an optional implementation, the target Bezier parameters and target curve index are obtained based on the texture coordinates of the mesh vertices, including:
[0202] If the texture coordinates of a mesh vertex exceed a preset texture coordinate threshold, then the preset texture coordinate threshold is determined as the target Bezier parameter;
[0203] The target curve index is determined based on the total number of control points on each Bézier curve in each animation frame.
[0204] In an optional implementation, the target Bezier parameters and target curve index are obtained based on the texture coordinates of the mesh vertices, including:
[0205] If the texture coordinates of the mesh vertices do not exceed the preset texture coordinate threshold, the target curve index and target Bézier parameters are determined based on the texture coordinates of the mesh vertices and the number of Bézier curves in each animation frame.
[0206] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0207] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0208] Based on the texture coordinates of each mesh vertex, the target mesh vertices of multiple animation frames are determined from the mesh vertices after offset from multiple animation frames;
[0209] Offset the target mesh vertices in multiple animation frames along the preset texture direction on the texture plane to generate fluid animation of the target fluid.
[0210] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0211] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0212] Based on preset random noise, noise processing is applied to each mesh vertex offset across multiple animation frames in a preset height direction to generate fluid animation of the target fluid; and / or,
[0213] Based on preset random noise, noise processing is performed on each mesh vertex after offset in multiple animation frames in the preset texture direction corresponding to the texture plane to generate the fluid animation of the target fluid.
[0214] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0215] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0216] Determine the edge mesh vertices from the offset mesh vertices across multiple animation frames;
[0217] In the preset height direction, adjust the height of the edge mesh vertices to the preset height to generate the fluid animation of the target fluid.
[0218] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0219] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0220] Calculate the normal vector of each offset grid vertex;
[0221] The fluid mesh model is illuminated and rendered based on the normal vectors to generate a fluid animation of the target fluid.
[0222] In this embodiment, the processor executes machine-readable instructions to acquire a preset texture map and a fluid mesh model of the target fluid. Based on the texture coordinates of each mesh vertex on the fluid mesh model, the processor determines the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from the Bézier curves in each animation frame. Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, the processor determines the position information of each mesh vertex in each animation frame. Based on the position information of each mesh vertex in multiple animation frames, the processor offsets the position of each mesh vertex in a preset height direction to generate the fluid animation of the target fluid. By storing the position information of the control points of the Bézier curve in the texture map and using Bézier curves to describe the 2D cross-sectional shape of the fluid for fluid rendering, the amount of data is reduced, and the storage and bandwidth requirements are lowered, making it suitable for real-time rendering.
[0223] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following steps:
[0224] Obtain a preset texture map and a fluid mesh model of the target fluid; the preset texture map stores the position information of control points on each Bézier curve in multiple animation frames;
[0225] Based on the texture coordinates of each grid vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each grid vertex are determined from each Bézier curve in each animation frame. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve.
[0226] Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, determine the position information of each grid vertex in each animation frame;
[0227] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
[0228] In one optional implementation, obtaining a preset texture map includes:
[0229] Identify at least two non-adjacent keyframes from a set of multiple animation frames;
[0230] Based on the curve drawing operation input for at least two keyframes, obtain the position information of control points on each Bézier curve under at least two keyframes;
[0231] Based on the position information of the control points on each Bézier curve in at least two keyframes, obtain the position information of the control points on each Bézier curve in other frames. Other frames are animation frames other than at least two keyframes among multiple animation frames.
[0232] Store the position information of control points on each Bézier curve in multiple animation frames into a preset texture map.
[0233] In an optional implementation, based on the position information of control points on each Bézier curve in at least two keyframes, the position information of control points on each Bézier curve in other frames is obtained, including:
[0234] Interpolation is performed on the position information of control points on each Bézier curve in at least two keyframes to obtain the position information of control points on each Bézier curve in other frames.
[0235] In an optional implementation, based on the texture coordinates of each mesh vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each mesh vertex are determined from the Bézier curves in each animation frame, including:
[0236] Based on the texture coordinates of the mesh vertices, obtain the target Bezier parameters and the target curve index;
[0237] The Bézier curve corresponding to the target curve index is determined as the target Bézier curve.
[0238] In an optional implementation, the target Bezier parameters and target curve index are obtained based on the texture coordinates of the mesh vertices, including:
[0239] If the texture coordinates of a mesh vertex exceed a preset texture coordinate threshold, then the preset texture coordinate threshold is determined as the target Bezier parameter;
[0240] The target curve index is determined based on the total number of control points on each Bézier curve in each animation frame.
[0241] In an optional implementation, the target Bezier parameters and target curve index are obtained based on the texture coordinates of the mesh vertices, including:
[0242] If the texture coordinates of the mesh vertices do not exceed the preset texture coordinate threshold, the target curve index and target Bézier parameters are determined based on the texture coordinates of the mesh vertices and the number of Bézier curves in each animation frame.
[0243] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0244] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0245] Based on the texture coordinates of each mesh vertex, the target mesh vertices of multiple animation frames are determined from the mesh vertices after offset from multiple animation frames;
[0246] Offset the target mesh vertices in multiple animation frames along the preset texture direction on the texture plane to generate fluid animation of the target fluid.
[0247] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0248] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0249] Based on preset random noise, noise processing is applied to each mesh vertex offset across multiple animation frames in a preset height direction to generate fluid animation of the target fluid; and / or,
[0250] Based on preset random noise, noise processing is performed on each mesh vertex after offset in multiple animation frames in the preset texture direction corresponding to the texture plane to generate the fluid animation of the target fluid.
[0251] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0252] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0253] Determine the edge mesh vertices from the offset mesh vertices across multiple animation frames;
[0254] In the preset height direction, adjust the height of the edge mesh vertices to the preset height to generate the fluid animation of the target fluid.
[0255] In an optional implementation, based on the position information of each mesh vertex in multiple animation frames, the position of each mesh vertex is offset in a preset height direction to render the fluid mesh model and generate a fluid animation of the target fluid, including:
[0256] Based on the position information of each grid vertex in multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in multiple animation frames.
[0257] Calculate the normal vector of each offset grid vertex;
[0258] The fluid mesh model is illuminated and rendered based on the normal vectors to generate a fluid animation of the target fluid.
[0259] In this embodiment, the computer program, executed by the processor, acquires a preset texture map and a fluid mesh model of the target fluid. Based on the texture coordinates of each mesh vertex on the fluid mesh model, it determines the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from the Bézier curves in each animation frame. Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, it determines the position information of each mesh vertex in each animation frame. Based on the position information of each mesh vertex in multiple animation frames, it offsets the position of each mesh vertex in a preset height direction to generate the fluid animation of the target fluid. By storing the position information of the control points of the Bézier curve in the texture map and using the Bézier curve to describe the 2D cross-sectional shape of the fluid for fluid rendering, the amount of data is reduced, and the storage and bandwidth requirements are lowered, making it suitable for real-time rendering.
[0260] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.
[0261] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0262] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0263] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0264] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0265] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0266] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A fluid rendering method, characterized in that, include: Obtain a preset texture map and a fluid mesh model of the target fluid; wherein, the preset texture map stores: the position information of control points on each Bézier curve under multiple animation frames; Based on the texture coordinates of each grid vertex on the fluid mesh model, the target Bézier curve and target Bézier parameters corresponding to each grid vertex are determined from each Bézier curve in each animation frame. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve. Based on the position information of the control points on the target Bézier curve and the target Bézier parameters, determine the position information of each grid vertex in each animation frame; Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in a preset height direction to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
2. The method according to claim 1, characterized in that, The process of obtaining the preset texture map includes: Identify at least two non-adjacent keyframes from the plurality of animation frames; Based on the curve drawing operation input for the at least two keyframes, obtain the position information of the control points on each Bézier curve under the at least two keyframes; Based on the position information of the control points on each Bézier curve under the at least two key frames, the position information of the control points on each Bézier curve under other frames is obtained, wherein the other frames are the animation frames other than the at least two key frames among the plurality of animation frames; The position information of the control points on each Bézier curve in the multiple animation frames is stored in the preset texture map.
3. The method according to claim 2, characterized in that, The step of obtaining the position information of the control points on each Bézier curve in other frames based on the position information of the control points on each Bézier curve in at least two key frames includes: Interpolation is performed on the position information of the control points on each Bézier curve in the at least two keyframes to obtain the position information of the control points on each Bézier curve in the other frames.
4. The method according to claim 1, characterized in that, The step of determining the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from the Bézier curves in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model includes: Based on the texture coordinates of the mesh vertices, obtain the target Bezier parameters and the target curve index; The Bézier curve corresponding to the target curve index is determined as the target Bézier curve.
5. The method according to claim 4, characterized in that, The step of obtaining the target Bezier parameters and target curve index based on the texture coordinates of the mesh vertices includes: If the texture coordinates of the mesh vertex exceed a preset texture coordinate threshold, then the preset texture coordinate threshold is determined as the target Bezier parameter; The target curve index is determined based on the total number of control points on each Bézier curve in each animation frame.
6. The method according to claim 4, characterized in that, The step of obtaining the target Bezier parameters and target curve index based on the texture coordinates of the mesh vertices includes: If the texture coordinates of the mesh vertex do not exceed the preset texture coordinate threshold, then the target curve index and the target Bézier parameter are determined based on the texture coordinates of the mesh vertex and the number of Bézier curves in each animation frame.
7. The method according to claim 1, characterized in that, The step of offsetting the positions of each grid vertex in a preset height direction according to the position information of each grid vertex in the multiple animation frames to render the fluid mesh model and generate the fluid animation of the target fluid includes: Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in the multiple animation frames; Based on the texture coordinates of each mesh vertex, the target mesh vertex under the multiple animation frames is determined from the mesh vertices after offset under the multiple animation frames; Offset the target mesh vertices under the multiple animation frames in the preset texture direction of the texture plane to generate the fluid animation of the target fluid.
8. The method according to claim 1, characterized in that, The step of offsetting the positions of each grid vertex in a preset height direction according to the position information of each grid vertex in the multiple animation frames to render the fluid mesh model and generate the fluid animation of the target fluid includes: Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in the multiple animation frames; Based on preset random noise, noise processing is applied to each grid vertex offset below the plurality of animation frames in the preset height direction to generate the fluid animation of the target fluid; and / or, Based on preset random noise, noise processing is performed on each mesh vertex after offset in the multiple animation frames in the preset texture direction corresponding to the texture plane to generate the fluid animation of the target fluid.
9. The method according to claim 1, characterized in that, The step of offsetting the positions of each grid vertex in a preset height direction according to the position information of each grid vertex in the multiple animation frames to render the fluid mesh model and generate the fluid animation of the target fluid includes: Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in the multiple animation frames; Determine the edge mesh vertices from the offset mesh vertices across multiple animation frames; In the preset height direction, the height of the edge mesh vertices is adjusted to the preset height to generate the fluid animation of the target fluid.
10. The method according to claim 1, characterized in that, The step of offsetting the positions of each grid vertex in a preset height direction according to the position information of each grid vertex in the multiple animation frames to render the fluid mesh model and generate the fluid animation of the target fluid includes: Based on the position information of each grid vertex in the multiple animation frames, the position of each grid vertex is offset in the preset height direction to obtain the offset grid vertices in the multiple animation frames; Based on the offset mesh vertices, calculate the normal vector of each offset mesh vertex; The fluid mesh model is illuminated and rendered based on the normal vector to generate a fluid animation of the target fluid.
11. A fluid rendering apparatus, characterized in that, include: The acquisition module is used to acquire a preset texture map and a fluid mesh model of the target fluid; wherein, the preset texture map stores the position information of control points on each Bézier curve in multiple animation frames; The determination module is used to determine the target Bézier curve and target Bézier parameters corresponding to each mesh vertex from each Bézier curve in each animation frame based on the texture coordinates of each mesh vertex on the fluid mesh model. The target Bézier parameters are used to indicate the target parameterized position between the start control point and the end control point of the target Bézier curve. The determining module is further configured to determine the position information of each grid vertex in each animation frame based on the position information of the control points on the target Bézier curve and the target Bézier parameters; The generation module is used to offset the position of each mesh vertex in a preset height direction according to the position information of each mesh vertex in the multiple animation frames, so as to render the fluid mesh model and generate the fluid animation of the target fluid. The preset height direction is perpendicular to the texture plane of the fluid mesh model.
12. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the method according to any one of claims 1 to 10.