Water surface rendering method, device, storage medium and computer equipment

By splitting the water surface model into a close-up water surface model with a high triangle mesh density and a long-range water surface model with a low triangle mesh density, and rendering according to the inter-frame position offset of the virtual characters in the world space, the problems of low efficiency and poor effect of large-area water surface rendering in the existing technology are solved, and efficient and effective water surface rendering is achieved.

CN114299209BActive Publication Date: 2025-03-14ARC GAMES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111660196.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-03-14
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When rendering large-area water surfaces, vertex disturbances lead to excessive memory consumption and low efficiency; while simple normal disturbances cannot achieve water ripple in the perspective of the planar view, and the rendering effect cannot be guaranteed.

Method used

The triangle grid density of the close-up surface model is adopted with a circular long-up surface model and a close-up surface model nested in the long-up surface model and moving with the character. By calculating the inter-frame position offset of the virtual character in world space, the sampling offset of the close-up surface model and the reverse offset of the long-up surface model are determined, and the two are rendered respectively.

Benefits of technology

It improves the rendering efficiency of large-area water surfaces, ensures the rendering effect, reduces memory pressure, avoids performance overhead, and achieves the effect of the long-distance water surface model not moving with virtual characters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299209B_ABST
    Figure CN114299209B_ABST
Patent Text Reader

Abstract

The present invention discloses a water surface rendering method, device, storage medium and computer equipment, which are mainly capable of improving the rendering efficiency of large-area water surfaces and ensuring the rendering effect of large-area water surfaces. The method includes: determining the inter-frame position offset of a virtual character located in a target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character; according to the inter-frame position offset of the virtual character in the world space, determining the sampling offset when the near water surface model is perturbed, and determining the reverse offset of the vertices of the distant water surface model when the virtual character has a position offset; based on the sampling offset and the reverse offset, rendering the near water surface model and the distant water surface model respectively. The present invention is suitable for rendering large-area water surfaces.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to a water surface rendering method, device, storage medium and computer equipment. Background Art

[0002] There is usually water surface in the game scene, and the rendering effect of the water surface directly affects the game experience of the game players.

[0003] At present, in the process of water surface rendering, vertex perturbation or normal perturbation is usually used to simulate water ripples. However, for large water surfaces, vertex perturbation requires the entire water body to be modeled with fine triangles, which will lead to excessive memory consumption and low efficiency of water surface rendering. On the other hand, simply using normal perturbation on the water surface will result in poor or even no ripples on the water surface from a horizontal perspective, so the rendering effect cannot be guaranteed. Summary of the invention

[0004] The present invention provides a water surface rendering method, device, storage medium and computer equipment, which are mainly capable of improving the rendering efficiency of a large area of ​​water surface and ensuring the rendering effect of a large area of ​​water surface.

[0005] According to a first aspect of the present invention, there is provided a water surface rendering method, comprising:

[0006] Determining an inter-frame position offset of a virtual character located in a target virtual water surface in a world space, wherein a water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and a triangle mesh density of the near water surface model is greater than a triangle mesh density of the distant water surface model;

[0007] Determine, according to the inter-frame position offset of the virtual character in the world space, a sampling offset when performing vertex perturbation on the near-view water surface model, and determine a reverse offset of the vertices of the far-view water surface model when the position offset of the virtual character occurs;

[0008] Based on the sampling offset and the reverse offset, the near-view water surface model and the far-view water surface model are rendered respectively.

[0009] Optionally, the sampling offset includes a first sampling offset and a second sampling offset, and determining the sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space includes:

[0010] Determine the first sampling offset according to a position offset of the virtual character in a world space generated in a current frame image and a previous frame image corresponding to the current frame image;

[0011] The second sampling offset is determined according to a position offset of the virtual character in the world space generated in a current frame image and two previous frames of images corresponding to the current frame image.

[0012] Optionally, determining the first sampling offset according to a position offset of the virtual character in a world space generated in a current frame image and a previous frame image corresponding to the current frame image includes:

[0013] Dividing the position offset of the virtual character in the world space generated in the current frame image and the previous frame image by the size of the near-field water surface model in the world space to obtain a first division result;

[0014] Multiplying the first division result by the transformation matrix from the world space to the near-view water surface model space to obtain a first sampling offset;

[0015] The determining the second sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of images corresponding to the current frame image includes:

[0016] Dividing the position offset of the virtual character in the world space generated in the current frame image and the previous two frames image by the size of the near-view water surface model in the world space to obtain a second division result;

[0017] The second division result is multiplied by the transformation matrix from the world space to the near-view water surface model space to obtain a second sampling offset.

[0018] Optionally, rendering the near-view water surface model based on the sampling offset includes:

[0019] According to the texture coordinates corresponding to any vertex in the near-view water surface model and the first sampling offset, sampling the height map corresponding to the previous frame image to obtain a target pixel corresponding to any vertex in the near-view water surface model;

[0020] Determine, according to the height map corresponding to the previous frame image, first vertex heights corresponding to four pixels adjacent to the target pixel respectively;

[0021] According to the texture coordinates corresponding to any vertex in the near-view water surface model and the second sampling offset, the height maps corresponding to the previous two frames of images are sampled to obtain a second vertex height corresponding to any vertex in the near-view water surface model;

[0022] The first vertex height and the second vertex height are mixed to obtain a third vertex height corresponding to any vertex in the near-view water surface model;

[0023] The near-view water surface model is perturbed by vertices based on the third vertex height to achieve rendering of the near-view water surface model.

[0024] Optionally, the method further comprises:

[0025] According to the height of the third vertex corresponding to any vertex in the near-view water surface model, a height map corresponding to the current frame image is drawn.

[0026] Optionally, the method further comprises:

[0027] Determine the first world space coordinates of the target vertex of the near-view water surface model and the second world space coordinates corresponding to any vertex in the near-view water surface model, wherein the target vertex is the vertex in the near-view water surface model corresponding to the texture space coordinate origin corresponding to the near-view water surface model;

[0028] Determine a first modified texture coordinate corresponding to any vertex in the near-view water surface model according to the first world space coordinate, the second world space coordinate, the size of the near-view water surface model in the world space, and a transformation matrix from the world space to the near-view water surface model space;

[0029] The non-tiled map is sampled based on the first modified texture coordinates to achieve rendering of the near-field water surface model.

[0030] Optionally, the distant water surface model vertices include inner vertices and outer vertices, the inner vertices follow the near water surface model to move, and the determining of the reverse offset of the distant water surface model vertices when the virtual character is offset in position includes:

[0031] Determine the offset of the current position of the outer layer vertex relative to the original position when the position of the virtual character is offset;

[0032] Determining weights corresponding to the outer-layer vertices according to virtual texture coordinates corresponding to the outer-layer vertices;

[0033] Based on the weight and the offset, a reverse offset corresponding to the outer vertex is determined.

[0034] Optionally, rendering the distant water surface model based on the reverse offset includes:

[0035] The outer layer vertices are controlled to move in reverse based on the reverse offset, so that when the position of the virtual character is offset, the distant water surface model is controlled not to move in the world space.

[0036] Optionally, the method further comprises:

[0037] Determine the third world space coordinates corresponding to the texture space coordinate origin of the distant water surface model, and the fourth world space coordinates corresponding to any vertex in the distant water surface model;

[0038] Determine a second modified texture coordinate corresponding to any vertex in the distant water surface model according to the third world space coordinate, the fourth world space coordinate, the size of the distant water surface model in the world space, and a transformation matrix from the world space to the distant water surface model space;

[0039] The non-tiled map is sampled based on the second modified texture coordinates to achieve rendering of the distant water surface model.

[0040] According to a second aspect of the present invention, there is provided a water surface rendering device, comprising:

[0041] A first determining unit is used to determine the inter-frame position offset of the virtual character located in the target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model embedded in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model;

[0042] A second determining unit is used to determine a sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space, and to determine a reverse offset of the vertices of the far-view water surface model when the position offset of the virtual character occurs;

[0043] A rendering unit is used to render the near-view water surface model and the far-view water surface model respectively based on the sampling offset and the reverse offset.

[0044] Optionally, the sampling offset includes a first sampling offset and a second sampling offset, and the second determining unit includes: a first determining module and a second determining module,

[0045] The first determination module is used to determine the first sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous frame image corresponding to the current frame image;

[0046] The second determination module is used to determine the second sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of images corresponding to the current frame image.

[0047] Optionally, the first determination module is specifically configured to divide the position offset of the virtual character in the world space generated in the current frame image and the previous frame image by the size of the near-view water surface model in the world space to obtain a first division result; and multiply the first division result by the transformation matrix from the world space to the near-view water surface model space to obtain a first sampling offset;

[0048] The second determination module is specifically used to divide the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of image by the size of the near-field water surface model in the world space to obtain a second division result;

[0049] The second division result is multiplied by the transformation matrix from the world space to the near-view water surface model space to obtain a second sampling offset.

[0050] Optionally, the rendering unit includes: a sampling module, a superposition module and a disturbance module.

[0051] The sampling module is used to sample the height map corresponding to the previous frame image according to the texture coordinates corresponding to any vertex in the near-view water surface model and the first sampling offset to obtain a target pixel corresponding to any vertex in the near-view water surface model; and determine the first vertex heights corresponding to four pixels adjacent to the target pixel according to the height map corresponding to the previous frame image;

[0052] The sampling module is further used to sample the height maps corresponding to the previous two frames of images according to the texture coordinates corresponding to any vertex in the near-view water surface model and the second sampling offset, so as to obtain the second vertex height corresponding to any vertex in the near-view water surface model;

[0053] The superposition module is used to mix the first vertex height and the second vertex height to obtain a third vertex height corresponding to any vertex in the near-view water surface model;

[0054] The disturbance module is used to perform vertex disturbance on the near-view water surface model based on the third vertex height to achieve rendering of the near-view water surface model.

[0055] Optionally, the rendering unit further includes: a drawing module,

[0056] The drawing module is used to draw a height map corresponding to the current frame image according to the height of the third vertex corresponding to any vertex in the near-view water surface model.

[0057] Optionally, the rendering unit further includes: a third determining module,

[0058] The third determination module is used to determine the first world space coordinates of the target vertex of the near-view water surface model and the second world space coordinates corresponding to any vertex in the near-view water surface model, wherein the target vertex is the vertex in the near-view water surface model corresponding to the origin of the texture space coordinates corresponding to the near-view water surface model;

[0059] The third determination module is further used to determine a first modified texture coordinate corresponding to any vertex in the near-view water surface model according to the first world space coordinate, the second world space coordinate, the size of the near-view water surface model in the world space, and the transformation matrix from the world space to the near-view water surface model space;

[0060] The sampling module is further used to sample the non-tiled map based on the first modified texture coordinates to achieve rendering of the near-field water surface model.

[0061] Optionally, the distant water surface model vertices include inner vertices and outer vertices, and the inner vertices move with the near water surface model.

[0062] The first determination module is further used to determine the offset of the current position of the outer layer vertex relative to the original position when the virtual character is offset;

[0063] The first determination module is further used to determine the weight corresponding to the outer layer vertex according to the defined virtual texture coordinates corresponding to the outer layer vertex;

[0064] The second determination module is further used to determine the reverse offset corresponding to the outer vertex based on the weight and the offset.

[0065] Optionally, the rendering unit further includes: an offset module,

[0066] The offset module is used to control the outer layer vertices to move in reverse based on the reverse offset, so as to control the distant water surface model not to move in the world space when the virtual character is offset in position.

[0067] Optionally, the third determination module is further used to determine a third world space coordinate corresponding to the texture space coordinate origin of the distant water surface model, and a fourth world space coordinate corresponding to any vertex in the distant water surface model;

[0068] The third determination module is further used to determine the second modified texture coordinate corresponding to any vertex in the distant water surface model according to the third world space coordinate, the fourth world space coordinate, the size of the distant water surface model in the world space and the transformation matrix from the world space to the distant water surface model space;

[0069] The sampling module is further used to sample the non-tiled map based on the second modified texture coordinates to achieve rendering of the distant water surface model.

[0070] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned water surface rendering method when executed by a processor.

[0071] According to a fourth aspect of the present invention, there is provided a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned water surface rendering method when executing the program.

[0072] The present invention provides a water surface rendering method, device, storage medium and computer equipment. Compared with the current method of simply using vertex perturbation or normal perturbation, the present invention can determine the inter-frame position offset of a virtual character located in a target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model embedded in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; at the same time, according to the inter-frame position offset of the virtual character in the world space, the sampling offset when the vertex perturbation of the near water surface model is determined, and the reverse offset of the vertices of the distant water surface model when the virtual character has a position offset is determined; finally, based on the sampling offset and the reverse offset, the near water surface model and the distant water surface model are rendered respectively. Since the water surface model is split into a near-field water surface model with a higher triangular mesh density and a far-field water surface model with a lower triangular mesh density, when the near-field water surface model moves with the character, the sampling offsets of the vertices of the near-field water surface model are calculated to perturb its vertices to simulate water surface ripples, thereby ensuring the rendering effect of the water surface. At the same time, since the triangular mesh density in the far-field water surface model is lower, the memory pressure can be reduced, the increase in performance overhead can be avoided, and the rendering efficiency of the water surface can be improved. When the virtual character moves, the reverse offset of the far-field water surface model vertices is controlled by calculating the reverse offset, thereby achieving the effect that the far-field water surface model does not move with the virtual character. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0074] Figure 1 A flow chart of a water surface rendering method provided by an embodiment of the present invention is shown;

[0075] Figure 2 A flow chart of another water surface rendering method provided by an embodiment of the present invention is shown;

[0076] Figure 3 A schematic diagram of water surface rendering provided by an embodiment of the present invention is shown;

[0077] Figure 4 A schematic structural diagram of a water surface rendering device provided by an embodiment of the present invention is shown;

[0078] Figure 5 A schematic structural diagram of another water surface rendering device provided by an embodiment of the present invention is shown;

[0079] Figure 6 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0080] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0081] Currently, for large water surfaces, vertex perturbation requires the entire water body to be modeled with fine triangles, which will lead to excessive memory consumption and low efficiency in water surface rendering. For simple normal perturbation, when the character looks at the water surface up close, it will be found that there are no ripples in the water, so the rendering effect cannot be guaranteed.

[0082] In order to solve the above problems, an embodiment of the present invention provides a water surface rendering method, such as Figure 1 As shown, the method includes:

[0083] 101. Determine the inter-frame position offset of the virtual character located in the target virtual water surface in the world space.

[0084] The water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model embedded in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than that of the distant water surface model.

[0085] In order to overcome the defects of high performance overhead and low water surface rendering efficiency caused by simple vertex perturbation, or poor water surface rendering effect caused by simple normal perturbation, the embodiments of the present invention respectively construct a near-view water surface model with a larger triangle mesh density and a distant water surface model with a smaller triangle mesh density. When the virtual character observes the water surface at a close distance, the near-view water surface model is perturbed with vertices to ensure the water surface rendering effect. At the same time, since the triangle density of the distant water surface model is much lower than that of the near-view water surface model, when rendering the water surface, the performance overhead can be reduced and the rendering efficiency of the water surface can be improved.

[0086] For the embodiments of the present invention, in order to achieve the above-mentioned beneficial effects, it is necessary to use preset 3D modeling software, such as 3dsMax software, to construct a near-view water surface model and a distant water surface model respectively. In the process of constructing the near-view water surface model and the distant water surface model, two plane meshes are used as the near-view water surface model and the distant water surface model respectively, wherein the area of ​​the near-view water surface model is smaller than the area of ​​the distant water surface model, such as the area of ​​the near-view water surface model is 1 square meter, and the area of ​​the distant water surface model is 100 square meters. In addition, the triangular mesh density of the distant water surface model is much smaller than the triangular mesh density of the near-view water surface model, such as the triangular meshes of the near-view water surface model are more than 100,000, and the triangular meshes of the distant water surface model do not exceed 20. Furthermore, the distant water surface model is not actually a complete plane, but a blank plane mesh is reserved in the middle. The size of the blank space is the same as the mesh size of the near water surface, that is, the distant water surface model is a ring, and the near water surface model is nested in the blank area of ​​the distant water surface model. When the virtual character moves in the target virtual water surface, the near water surface model will move with the virtual character. The distant water surface model is equivalent to a child node of the near water surface model and moves with the near water surface model.

[0087] In a specific application scenario, when a virtual character moves, since the near-field water surface model will move with the virtual character, it is necessary to calculate the sampling offset of the near-field water surface model vertices for the height map during the vertex perturbation of the near-field water surface model. In the process of calculating the sampling offset, it is necessary to first determine the inter-frame position offset of the virtual character in the world space. Specifically, each frame of the virtual character in the target virtual water surface is collected in real time, and then the position information of the virtual character in the world space in each frame is determined. Based on the position information of the virtual character in the world space in the previous and next frames, the position offset of the virtual character in the world space in the previous and next frames can be determined, so as to determine the sampling offset for the height map according to the inter-frame position offset of the virtual character in the world space.

[0088] 102. Determine a sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space, and determine a reverse offset of the vertices of the far-view water surface model when the position offset of the virtual character occurs.

[0089] For the embodiment of the present invention, in the process of performing vertex perturbation on the foreground water surface model, since the height map corresponding to each frame image where the virtual character is located is a height map of the water area surrounding the location of the virtual character in the current frame, when the virtual character moves in the target virtual water surface, it is necessary to first determine the impact of the movement of the virtual character on the texture coordinates, and then sample the height map. In a specific application scenario, three height maps can be set, and different image frames correspond to different height maps. For example, the first frame image corresponds to height map A, the second frame image corresponds to height map B, and the third frame image corresponds to height map C. When it is necessary to determine the vertex heights of the foreground water surface model in the third frame image, it is necessary to sample height map A and height map B respectively, and mix the vertex heights sampled from height map A and height map B. At the same time, it is necessary to use the vertex heights sampled from height map A and height map B to draw height map C. When it is necessary to determine the vertex heights of the foreground water surface model in the fourth frame image, it is necessary to sample height map B and height map C respectively, and mix the vertex heights sampled from height map B and height map C. At the same time, height map A is redrawn using the vertex heights sampled from height map B and height map C.

[0090] Since the position information of the virtual character in the current frame image is offset relative to the position information in the previous frame image and the previous two frames image, during sampling, the previous frame image and the previous two frames image can no longer be directly collected according to the original texture coordinates (UV coordinates) corresponding to the vertices of the near-field water surface model, and it is necessary to first calculate the sampling offset according to the inter-frame position offset of the virtual character, wherein the sampling offset includes a first sampling offset and a second sampling offset. With respect to the specific calculation process of the sampling offset, as an optional implementation, the method includes: determining the first sampling offset according to the position offset of the virtual character in the current frame image and the previous frame image corresponding to the current frame image in the world space; determining the second sampling offset according to the position offset of the virtual character in the current frame image and the previous two frames image corresponding to the current frame image in the world space. Further, the determining the first sampling offset according to the position offset in the world space generated by the virtual character in the current frame image and the previous frame image corresponding to the current frame image includes: dividing the position offset in the world space generated by the virtual character in the current frame image and the previous frame image by the size of the near-view water surface model in the world space to obtain a first division result; multiplying the first division result by the transformation matrix from the world space to the near-view water surface model space to obtain the first sampling offset; at the same time, the determining the second sampling offset according to the position offset in the world space generated by the virtual character in the current frame image and the previous two frames image corresponding to the current frame image includes: dividing the position offset in the world space generated by the virtual character in the current frame image and the previous two frames image by the size of the near-view water surface model in the world space to obtain a second division result; and multiplying the second division result by the transformation matrix from the world space to the near-view water surface model space to obtain a second sampling offset.

[0091] Specifically, the sampling offset formula for calculating the vertices of the near-view water surface model is as follows:

[0092] L=–A / S*`M0

[0093] Among them, L is the first sampling offset, A is the position offset of the virtual character in the world space generated in the current frame image and the previous frame image, S is the size of the near-view water surface model in the world space, and `M0 is the transformation matrix from the world space to the near-view water surface model space. According to the above formula, the first sampling offset corresponding to the near-view water surface model vertex can be obtained. Similarly, the position offset of the virtual character in the world space generated in the current frame image and the previous two frames image, as well as the size of the near-view water surface model in the world space are substituted into the above formula to obtain the second sampling offset of the near-view water surface model vertex.

[0094] Furthermore, since the distant water surface model is a ring, it is divided into inner vertices and outer vertices. The inner vertices are attached to the near water surface model and move with the near water surface model. Although the outer vertices of the distant water surface model will also move with the character in the model space, in order to ensure that the entire large area of ​​water seen by the virtual character in the game scene is fixed, it is necessary to calculate the reverse offset of the outer vertices of the distant water surface model, and then control the outer vertices of the distant water surface model to perform reverse offset. For the specific calculation process of the offset in this direction, please see step 203.

[0095] 103. Based on the sampling offset and the reverse offset, render the near-view water surface model and the far-view water surface model respectively.

[0096] For the embodiment of the present invention, in order to ensure the rendering effect of water surface ripples, it is necessary to perform vertex perturbation on the near-view water surface model. Regarding the specific process of vertex perturbation, as an optional embodiment, the method includes: sampling the height map corresponding to the previous frame image according to the texture coordinates corresponding to any vertex in the near-view water surface model and the first sampling offset, to obtain the target pixel corresponding to any vertex in the near-view water surface model; determining the first vertex heights corresponding to four pixels adjacent to the target pixel according to the height map corresponding to the previous frame image; sampling the height maps corresponding to the previous two frames of images according to the texture coordinates corresponding to any vertex in the near-view water surface model and the second sampling offset, to obtain the second vertex height corresponding to any vertex in the near-view water surface model; mixing the first vertex height and the second vertex height to obtain the third vertex height corresponding to any vertex in the near-view water surface model; performing vertex perturbation on the near-view water surface model based on the third vertex height to achieve rendering of the near-view water surface model.

[0097] Specifically, after determining the first sampling offset and the second sampling offset, the texture coordinates corresponding to any vertex are adjusted based on the first sampling offset to obtain the first adjusted texture coordinates corresponding to any vertex, and the target pixel corresponding to any vertex is determined based on the first adjusted texture coordinates and the height map corresponding to the previous frame image, and then the first vertex height corresponding to the four pixels adjacent to the target pixel is determined based on the height map corresponding to the previous frame image, wherein the height map stores pixel values, and the pixel values ​​are used to represent the height of the vertex. Similarly, the texture coordinates corresponding to any vertex are adjusted based on the second sampling offset to obtain the second adjusted texture coordinates corresponding to any vertex, and then the height maps corresponding to the previous two frames of images are sampled based on the second adjusted texture coordinates to obtain the second vertex height. It should be noted that the texture coordinates of each vertex in the near-field water surface model need to be adjusted, and the height map needs to be sampled.

[0098] Furthermore, after obtaining the first vertex height and the second vertex height corresponding to any vertex in the near-view water surface model, the first vertex height and the second vertex height are mixed to obtain the height of any vertex in the near-view water surface model in the current frame image, that is, the third vertex height. The specific formula for mixing the first vertex height and the second vertex height is as follows:

[0099] Current0=(Up1+Down1+Right1+Left1) / 2-Current2

[0100] Among them, Current0 is the height of any vertex in the near-view water surface model in the current frame image (third vertex height), Current2 is the height of any vertex in the near-view water surface model in the previous two frames image (second vertex height), Up1, Down1, Right1 and Left1 are the heights of the four pixels adjacent to the target pixel in the height map corresponding to the previous frame image (first vertex height). Thus, according to the above formula, the height of any vertex in the near-view water surface model in the current frame image can be obtained.

[0101] Furthermore, after determining the height of the third vertex corresponding to any vertex in the near-view water surface model, the vertex fluctuation distance of the near-view water surface model is adjusted using the third vertex height. Specifically, if the third vertex height corresponding to any vertex is greater than 0, the vertex is shifted upward; if the third vertex height corresponding to any vertex is less than 0, the vertex is shifted downward. In this way, the vertex disturbance of the near-view water surface model can form water ripples, and the rendering effect of the water surface can be guaranteed.

[0102] In a specific application scenario, after determining the height of the third vertex corresponding to any vertex in the near-field water surface model, it is also necessary to draw a height map corresponding to the current frame image according to the height of the third vertex corresponding to any vertex, so that when performing vertex perturbation for the next frame image, the height map corresponding to the current frame image is sampled. Specifically, when drawing, the texture coordinates corresponding to each vertex in the near-field water surface model and the height of the third vertex are stored in correspondence.

[0103] When rendering the foreground water surface, in addition to vertex perturbation to simulate water ripples, it is also necessary to sample various non-tiled maps to simulate the water surface effect. The non-tiled maps specifically include water flow direction maps, water flow depth maps, etc. The above-mentioned process of performing vertex perturbation on the foreground water surface model is executed by the CPU. When the CPU completes the vertex perturbation of the foreground water surface model, it will send a sampling instruction for the non-tiled map to the GPU, that is, the sampling process of the non-tiled map is executed in the GPU. Specifically, when sampling a non-tiled map, it is necessary to calculate the correct texture coordinates according to the coordinates of any vertex in the foreground water surface model in the world space, and then sample the non-tiled map according to the correct texture coordinates. Based on this, the method includes: determining the first world space coordinates of the target vertex of the foreground water surface model, and the second world space coordinates corresponding to any vertex in the foreground water surface model, wherein the target vertex is the vertex in the foreground water surface model corresponding to the origin of the texture space coordinates corresponding to the foreground water surface model; determining the first corrected texture coordinates corresponding to any vertex in the foreground water surface model according to the first world space coordinates, the second world space coordinates, the size of the foreground water surface model in the world space and the transformation matrix from the world space to the foreground water surface model space; sampling the non-tiled map based on the first corrected texture coordinates to achieve rendering of the foreground water surface model.

[0104] The formula for calculating the first modified texture coordinates corresponding to any vertex in the near-view water surface model is as follows:

[0105] UV(P)=((W P –W0) / S0)*`M0

[0106] Among them, UV(P) is the first corrected texture coordinate corresponding to any vertex in the near-view water surface model, W P is the coordinate of any vertex in the near-view water surface model in the world space, i.e., the second world space coordinate, W0 is the coordinate of the target vertex in the near-view water surface model in the world space, i.e., the first world space coordinate, S0 is the size of the near-view water surface model, and M0 is the transformation matrix from the world space to the near-view water surface model space. Thus, the first corrected texture coordinate corresponding to any vertex in the near-view water surface model can be calculated by the above formula. It should be noted that the second world space coordinate corresponding to any vertex in the near-view water surface model and the first world space coordinate corresponding to the target vertex can be directly obtained from the system, and each vertex in the near-view water surface model needs to be calculated through the above-mentioned first corrected texture coordinate. After obtaining the first corrected texture coordinate corresponding to any vertex in the near-view water surface model, various non-tiled maps are sampled to simulate the flow direction and depth of the water flow on the near-view water surface.

[0107] The present invention provides a water surface rendering method according to an embodiment. Compared with the current method of simply using vertex perturbation or normal perturbation, the present invention can determine the inter-frame position offset of a virtual character located in a target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; at the same time, according to the inter-frame position offset of the virtual character in the world space, the sampling offset when the vertex perturbation of the near water surface model is determined, and the reverse offset of the vertices of the distant water surface model when the virtual character has a position offset is determined; finally, based on the sampling offset and the reverse offset, the near water surface model and the distant water surface model are rendered respectively. Since the water surface model is split into a near-field water surface model with a higher triangular mesh density and a far-field water surface model with a lower triangular mesh density, when the near-field water surface model moves with the character, the sampling offsets of the vertices of the near-field water surface model are calculated to perturb its vertices to simulate water surface ripples, thereby ensuring the rendering effect of the water surface. At the same time, since the triangular mesh density in the far-field water surface model is lower, the memory pressure can be reduced, the increase in performance overhead can be avoided, and the rendering efficiency of the water surface can be improved. When the virtual character moves, the reverse offset of the far-field water surface model vertices is controlled by calculating the reverse offset, thereby achieving the effect that the far-field water surface model does not move with the virtual character.

[0108] Further, in order to better illustrate the above water surface rendering process, as a refinement and extension of the above embodiment, the embodiment of the present invention provides another water surface rendering method, such as Figure 2 As shown, the method includes:

[0109] 201. Determine an inter-frame position offset of a virtual character located in a target virtual water surface in a world space.

[0110] The water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model embedded in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model. For the embodiment of the present invention, in order to ensure the water surface rendering effect, it is necessary to perform vertex perturbation on the near water surface model. In the process of performing vertex perturbation, it is necessary to first determine the inter-frame position offset of the virtual character in the world space.

[0111] 202. Determine a sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space.

[0112] In the embodiment of the present invention, the specific process of determining the near-view water surface model sampling offset is the same as step 102 and will not be described in detail herein.

[0113] 203. Determine the offset of the current position of the outer vertex relative to the original position when the virtual character is offset, determine the weight corresponding to the outer vertex according to the virtual texture coordinates corresponding to the outer vertex, and determine the reverse offset corresponding to the outer vertex based on the weight and the offset.

[0114] The vertices of the distant water surface model include inner vertices and outer vertices. The inner vertices move with the near water surface model. When the near water surface model and the distant water surface model are both quadrilaterals, the distant water surface model can include four inner vertices and four outer vertices. The four inner vertices can be pasted on the four vertices of the near water surface model, and the four outer vertices are fixed in the virtual scene. When the virtual character moves in the water, the near water surface model moves with the virtual character, the four inner vertices move with the near water surface model, and the four outer vertices also move with the character in the model space. However, in order to ensure that the entire large water surface is fixed in the world space It is necessary to control the four outer vertices to perform reverse offset. It can be seen that the movement logic of the inner and outer vertices of the distant water surface is different. In order to control the inner and outer vertices to move different distances, the embodiment of the present invention sets a set of virtual texture coordinates. Since the inner vertices move with the near water surface model, the inner vertices do not need to calculate the reverse offset, and only the outer vertices need to calculate the reverse offset. In order to implement different processing logics for the inner and outer vertices, the virtual texture coordinates corresponding to the inner vertices can be set to (0,0), which is equivalent to not calculating the reverse offset for the inner vertices. For the outer vertices, the virtual texture coordinates corresponding to the four outer vertices can be set to (0,1), (1,1), (1,0), (0,0) respectively.

[0115] When the virtual character moves, the outer vertices of the distant water surface will also move in the model space. However, since the four outer vertices are in different corners, the reverse offsets corresponding to the four vertices are also different. Specifically, according to the virtual texture coordinates corresponding to the four outer vertices, the weights corresponding to the four outer vertices can be determined, and then the reverse offsets corresponding to the four outer vertices can be obtained according to the offsets of the current positions of the four outer vertices relative to the original positions and the corresponding weight values.

[0116] 204. Render the near-view water surface model and the far-view water surface model respectively based on the sampling offset and the reverse offset.

[0117] For the embodiment of the present invention, in order to ensure that the distant water surface does not appear to move with the virtual character in the world space, it is necessary to control the four outer vertices to move in the opposite direction according to the calculated opposite offsets corresponding to the four outer vertices.

[0118] In a specific application scenario, since the vertex positions of the distant water surface model will change, the fixed texture coordinates on the vertices can no longer be used. The correct texture coordinates can be calculated according to the coordinates of any vertex in the distant water surface model in the world space, so as to sample various non-tiled maps. Based on this, the method includes: determining the third world space coordinates corresponding to the origin of the texture space coordinates of the distant water surface model, and the fourth world space coordinates corresponding to any vertex in the distant water surface model; determining the second corrected texture coordinates corresponding to any vertex in the distant water surface model according to the third world space coordinates, the fourth world space coordinates, the size of the distant water surface model in the world space, and the transformation matrix from the world space to the distant water surface model space; sampling the non-tiled map based on the second corrected texture coordinates to achieve the rendering of the distant water surface model. Among them, the non-tiled map includes a normal map, a water flow direction map, and a water flow depth map.

[0119] The formula for calculating the second modified texture coordinates corresponding to any vertex in the distant water surface model is as follows:

[0120] UV(M)=((W M –W Q ) / S Q )*`M0

[0121] UV(M) is the second modified texture coordinate corresponding to any vertex (including inner and outer vertices) in the distant water surface model, W M is the coordinate of any vertex in the distant water surface model in the world space, that is, the fourth world space coordinate, W Q is the coordinate of the target vertex in the distant water surface model in the world space, that is, the third world space coordinate, S Qis the size of the distant water surface model, `M0 is the transformation matrix from the world space to the near water surface model space. Therefore, the second corrected texture coordinates corresponding to any vertex in the distant water surface model can be calculated through the above formula. It should be noted that the fourth world space coordinates corresponding to any vertex in the distant water surface model and the third world space coordinates corresponding to the target vertex can be directly obtained from the system, and each vertex in the distant water surface model needs to be calculated by the above second corrected texture coordinates. After obtaining the second corrected texture coordinates corresponding to any vertex in the distant water surface model, various non-tiled maps are sampled to simulate the flow direction and depth of the distant water surface. Since the area of ​​the distant water surface is huge, but there are very few vertices, the overhead will not increase significantly. The embodiment of the present invention takes into account both performance and rendering effect. The water surface rendering effect diagram obtained by the embodiment of the present invention is as follows Figure 3 shown.

[0122] Furthermore, in the process of water surface rendering, many calculations in the material use the normals in the tangent space. However, the virtual texture coordinates of the vertices in the distant water surface model are customized and not standardized. Therefore, the calculations in the tangent space are no longer correct. In the embodiments of the present invention, it is necessary to modify the places where the tangent space normals are used for calculations to use the world space normals. That is, all places where the tangent space normals need to be involved in the calculation are replaced with the world space normals. For example, the tangent space normals in the lighting calculations are replaced with the world space normals.

[0123] The present invention is another water surface rendering method provided by an embodiment. Compared with the current method of simply using vertex perturbation or normal perturbation, the present invention can determine the inter-frame position offset of a virtual character located in a target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; at the same time, according to the inter-frame position offset of the virtual character in the world space, the sampling offset when the vertex perturbation of the near water surface model is determined, and the reverse offset of the vertices of the distant water surface model when the virtual character has a position offset is determined; finally, based on the sampling offset and the reverse offset, the near water surface model and the distant water surface model are rendered respectively. Since the water surface model is split into a near-field water surface model with a higher triangular mesh density and a far-field water surface model with a lower triangular mesh density, when the near-field water surface model moves with the character, the sampling offsets of the vertices of the near-field water surface model are calculated to perturb its vertices to simulate water surface ripples, thereby ensuring the rendering effect of the water surface. At the same time, since the triangular mesh density in the far-field water surface model is lower, the memory pressure can be reduced, the increase in performance overhead can be avoided, and the rendering efficiency of the water surface can be improved. When the virtual character moves, the reverse offset of the far-field water surface model vertices is controlled by calculating the reverse offset, thereby achieving the effect that the far-field water surface model does not move with the virtual character.

[0124] Further, as Figure 1 In a specific implementation, an embodiment of the present invention provides a water surface rendering device, such as Figure 4 As shown, the device includes: a first determining unit 31, a second determining unit 32 and a rendering unit 33.

[0125] The first determination unit 31 can be used to determine the inter-frame position offset of a virtual character located in a target virtual water surface in a world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and the triangular mesh density of the near water surface model is greater than the triangular mesh density of the distant water surface model.

[0126] The second determination unit 32 can be used to determine the sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space, and determine the reverse offset of the vertices of the distant water surface model when the position of the virtual character is offset.

[0127] The rendering unit 33 may be configured to render the near view water surface model and the far view water surface model respectively based on the sampling offset and the reverse offset.

[0128] In a specific application scenario, the sampling offset includes a first sampling offset and a second sampling offset, and the second determining unit 32, such as Figure 5 As shown, it includes: a first determination module 321 and a second determination module 322.

[0129] The first determination module 321 may be configured to determine the first sampling offset according to a position offset of the virtual character in the world space generated in a current frame image and a previous frame image corresponding to the current frame image.

[0130] The second determination module 322 is used to determine the second sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of images corresponding to the current frame image.

[0131] Further, the first determination module 321 may be specifically configured to divide the position offset of the virtual character in the world space generated in the current frame image and the previous frame image by the size of the near-view water surface model in the world space to obtain a first division result; and multiply the first division result by the transformation matrix from the world space to the near-view water surface model space to obtain a first sampling offset;

[0132] The second determination module 322 can be specifically used to divide the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of image by the size of the foreground water surface model in the world space to obtain a second division result; multiply the second division result by the transformation matrix from the world space to the foreground water surface model space to obtain a second sampling offset.

[0133] In a specific application scenario, the rendering unit 33 includes: a sampling module 331 , a superposition module 332 and a disturbance module 333 .

[0134] The sampling module 331 can sample the height map corresponding to the previous frame image according to the texture coordinates corresponding to any vertex in the foreground water surface model and the first sampling offset to obtain the target pixel corresponding to any vertex in the foreground water surface model; and determine the first vertex heights corresponding to the four pixels adjacent to the target pixel according to the height map corresponding to the previous frame image.

[0135] The sampling module 331 can also be used to sample the height maps corresponding to the previous two frames of images according to the texture coordinates corresponding to any vertex in the near-view water surface model and the second sampling offset to obtain the second vertex height corresponding to any vertex in the near-view water surface model.

[0136] The superposition module 332 may be used to mix the first vertex height and the second vertex height to obtain a third vertex height corresponding to any vertex in the near-view water surface model.

[0137] The disturbance module 333 may be used to perform vertex disturbance on the near-view water surface model based on the third vertex height to achieve rendering of the near-view water surface model.

[0138] Furthermore, the rendering unit 33 also includes: a drawing module 334 .

[0139] The drawing module 334 may be used to draw a height map corresponding to the current frame of image according to the height of the third vertex corresponding to any vertex in the near-view water surface model.

[0140] Furthermore, the rendering unit 33 further includes: a third determination module 335 .

[0141] The third determination module 335 can be used to determine the first world space coordinates of the target vertex of the foreground water surface model and the second world space coordinates corresponding to any vertex in the foreground water surface model, wherein the target vertex is the vertex in the foreground water surface model corresponding to the texture space coordinate origin corresponding to the foreground water surface model.

[0142] The third determination module 335 may also be used to determine a first modified texture coordinate corresponding to any vertex in the near-view water surface model according to the first world space coordinate, the second world space coordinate, the size of the near-view water surface model in the world space, and the transformation matrix from the world space to the near-view water surface model space;

[0143] The sampling module 331 may also be used to sample a non-tiled map based on the first modified texture coordinates to achieve rendering of the near-field water surface model.

[0144] In a specific application scenario, the vertices of the distant water surface model include inner vertices and outer vertices, and the inner vertices move with the near water surface model. The first determination module 321 can also be used to determine the offset of the current position of the outer vertex relative to the original position when the virtual character shifts its position.

[0145] The first determination module 321 may also be used to determine the weight corresponding to the outer layer vertex according to the defined virtual texture coordinates corresponding to the outer layer vertex.

[0146] The second determination module 322 may also be configured to determine a reverse offset corresponding to the outer vertex based on the weight and the offset.

[0147] Furthermore, the rendering unit 33 further includes: an offset module 336 .

[0148] The offset module 336 may be used to control the outer layer vertices to move in reverse based on the reverse offset, so as to control the distant water surface model not to move in the world space when the virtual character is offset in position.

[0149] The third determination module 335 may also be used to determine a third world space coordinate corresponding to the texture space coordinate origin of the distant water surface model, and a fourth world space coordinate corresponding to any vertex in the distant water surface model.

[0150] The third determination module 335 can also be used to determine the second corrected texture coordinates corresponding to any vertex in the distant water surface model based on the third world space coordinates, the fourth world space coordinates, the size of the distant water surface model in the world space and the transformation matrix from the world space to the distant water surface model space.

[0151] The sampling module 331 may also be used to sample the non-tiled map based on the second modified texture coordinates to achieve rendering of the distant water surface model.

[0152] It should be noted that for other corresponding descriptions of the functional modules involved in the water surface rendering device provided in the embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.

[0153] Based on the above Figure 1 The method shown, accordingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented: determining the inter-frame position offset of a virtual character located in a target virtual water surface in a world space, wherein a water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; determining a sampling offset when performing vertex perturbation on the near water surface model according to the inter-frame position offset of the virtual character in the world space, and determining a reverse offset of the vertices of the distant water surface model when the virtual character has a position offset; and rendering the near water surface model and the distant water surface model respectively based on the sampling offset and the reverse offset.

[0154] Based on the above Figure 1 The method shown and Figure 4 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 6As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43; when the processor 41 executes the program, the following steps are implemented: determining the inter-frame position offset of a virtual character located in a target virtual water surface in a world space, wherein a water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and a triangle mesh density of the near water surface model is greater than a triangle mesh density of the distant water surface model; determining a sampling offset when performing vertex perturbation on the near water surface model according to the inter-frame position offset of the virtual character in the world space, and determining a reverse offset of the vertices of the distant water surface model when the position offset of the virtual character occurs; and rendering the near water surface model and the distant water surface model respectively based on the sampling offset and the reverse offset.

[0155] Through the technical solution of the present invention, the inter-frame position offset of a virtual character located in a target virtual water surface in the world space can be determined, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; at the same time, according to the inter-frame position offset of the virtual character in the world space, the sampling offset when the vertex perturbation of the near water surface model is determined, and the reverse offset of the vertices of the distant water surface model when the position offset of the virtual character occurs is determined; finally, based on the sampling offset and the reverse offset, the near water surface model and the distant water surface model are rendered respectively. Since the water surface model is split into a near-field water surface model with a higher triangular mesh density and a far-field water surface model with a lower triangular mesh density, when the near-field water surface model moves with the character, the sampling offsets of the vertices of the near-field water surface model are calculated to perturb its vertices to simulate water surface ripples, thereby ensuring the rendering effect of the water surface. At the same time, since the triangular mesh density in the far-field water surface model is lower, the memory pressure can be reduced, the increase in performance overhead can be avoided, and the rendering efficiency of the water surface can be improved. When the virtual character moves, the reverse offset of the far-field water surface model vertices is controlled by calculating the reverse offset, thereby achieving the effect that the far-field water surface model does not move with the virtual character.

[0156] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0157] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A water surface rendering method, characterized in that: include: Determining an inter-frame position offset of a virtual character located in a target virtual water surface in a world space, wherein a water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model nested in the distant water surface model and moving with the virtual character, and a triangle mesh density of the near water surface model is greater than a triangle mesh density of the distant water surface model; Determine, according to the inter-frame position offset of the virtual character in the world space, a sampling offset when performing vertex perturbation on the near-view water surface model, and determine a reverse offset of the vertices of the far-view water surface model when the position offset of the virtual character occurs; Based on the sampling offset and the reverse offset, the near-view water surface model and the far-view water surface model are rendered respectively.

2. The method according to claim 1, characterized in that The sampling offset includes a first sampling offset and a second sampling offset, and determining the sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space includes: Determine the first sampling offset according to a position offset of the virtual character in a world space generated in a current frame image and a previous frame image corresponding to the current frame image; The second sampling offset is determined according to a position offset of the virtual character in the world space generated in a current frame image and two previous frames of images corresponding to the current frame image.

3. The method according to claim 2, characterized in that The determining the first sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous frame image corresponding to the current frame image includes: Dividing the position offset of the virtual character in the world space generated in the current frame image and the previous frame image by the size of the near-field water surface model in the world space to obtain a first division result; Multiplying the first division result by the transformation matrix from the world space to the near-view water surface model space to obtain a first sampling offset; The determining the second sampling offset according to the position offset of the virtual character in the world space generated in the current frame image and the previous two frames of images corresponding to the current frame image includes: Dividing the position offset of the virtual character in the world space generated in the current frame image and the previous two frames image by the size of the near-view water surface model in the world space to obtain a second division result; The second division result is multiplied by the transformation matrix from the world space to the near-view water surface model space to obtain a second sampling offset.

4. The method according to claim 2, characterized in that: Rendering the near-view water surface model based on the sampling offset includes: According to the texture coordinates corresponding to any vertex in the near-view water surface model and the first sampling offset, sampling the height map corresponding to the previous frame image to obtain a target pixel corresponding to any vertex in the near-view water surface model; Determine, according to the height map corresponding to the previous frame image, first vertex heights corresponding to four pixels adjacent to the target pixel respectively; According to the texture coordinates corresponding to any vertex in the near-view water surface model and the second sampling offset, the height maps corresponding to the previous two frames of images are sampled to obtain a second vertex height corresponding to any vertex in the near-view water surface model; The first vertex height and the second vertex height are mixed to obtain a third vertex height corresponding to any vertex in the near-view water surface model; The near-view water surface model is perturbed by vertices based on the third vertex height to achieve rendering of the near-view water surface model.

5. The method according to claim 4, characterized in that The method further comprises: According to the height of the third vertex corresponding to any vertex in the near-view water surface model, a height map corresponding to the current frame image is drawn.

6. The method according to claim 4, characterized in that The method further comprises: Determine the first world space coordinates of the target vertex of the near-view water surface model and the second world space coordinates corresponding to any vertex in the near-view water surface model, wherein the target vertex is the vertex in the near-view water surface model corresponding to the texture space coordinate origin corresponding to the near-view water surface model; Determine a first modified texture coordinate corresponding to any vertex in the near-view water surface model according to the first world space coordinate, the second world space coordinate, the size of the near-view water surface model in the world space, and a transformation matrix from the world space to the near-view water surface model space; The non-tiled map is sampled based on the first modified texture coordinates to achieve rendering of the near-field water surface model.

7. The method according to claim 1, characterized in that The distant water surface model vertices include inner vertices and outer vertices, the inner vertices follow the near water surface model to move, and the determining of the reverse offset of the distant water surface model vertices when the virtual character is offset in position includes: Determine the offset of the current position of the outer layer vertex relative to the original position when the position of the virtual character is offset; Determining weights corresponding to the outer-layer vertices according to virtual texture coordinates corresponding to the outer-layer vertices; Based on the weight and the offset, a reverse offset corresponding to the outer vertex is determined.

8. The method according to claim 7, characterized in that Rendering the distant water surface model based on the reverse offset includes: The outer layer vertices are controlled to move in reverse based on the reverse offset, so that when the position of the virtual character is offset, the distant water surface model is controlled not to move in the world space.

9. The method according to claim 8, characterized in that The method further comprises: Determine the third world space coordinates corresponding to the texture space coordinate origin of the distant water surface model, and the fourth world space coordinates corresponding to any vertex in the distant water surface model; Determine a second modified texture coordinate corresponding to any vertex in the distant water surface model according to the third world space coordinate, the fourth world space coordinate, the size of the distant water surface model in the world space, and a transformation matrix from the world space to the distant water surface model space; The non-tiled map is sampled based on the second modified texture coordinates to achieve rendering of the distant water surface model.

10. A water surface rendering device, characterized in that: include: A first determining unit is used to determine the inter-frame position offset of the virtual character located in the target virtual water surface in the world space, wherein the water surface model of the target virtual water surface includes a ring-shaped distant water surface model and a near water surface model embedded in the distant water surface model and moving with the virtual character, and the triangle mesh density of the near water surface model is greater than the triangle mesh density of the distant water surface model; A second determining unit is used to determine a sampling offset when performing vertex perturbation on the near-view water surface model according to the inter-frame position offset of the virtual character in the world space, and to determine a reverse offset of the vertices of the far-view water surface model when the position offset of the virtual character occurs; A rendering unit is used to render the near-view water surface model and the far-view water surface model respectively based on the sampling offset and the reverse offset.

11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Water surface rendering method and apparatus

    CN108470369A

  • Three-dimensional virtual cloud model processing method, storage medium, processor and electronic device

    CN111145326A