Grass rendering method and device

By dynamically determining the negative correlation between the number of vertices of grass inserts and the rendering distance, the problem of too many or too few vertices when rendering grass in the prior art is solved, and efficient rendering effect and good computing device performance are achieved.

CN117475053BActive Publication Date: 2025-02-11GUANGZHOU YIJU FUTURE NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311172742.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-12
Publication Date
2025-02-11
Estimated Expiration
2043-09-12

AI Technical Summary

Technical Problem

In the prior art, when rendering grass, it is difficult to take into account both the rendering effect and processing overhead. The number of inserted grass insert vertices is too large or too small, resulting in poor rendering effect or excessive burden on computing devices.

Method used

By obtaining the rendering distance between the rendering center and unit area in the rendering area and the rendering center, dynamically determine the number of vertices of the grass insert, making it negatively correlated with the rendering distance, thereby reducing processing overhead without sacrificing the rendering effect.

Benefits of technology

It realizes that without reducing the rendering effect, improves computer performance and resource utilization efficiency, enhances grass density, and makes the virtual scene more realistic and detailed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117475053B_ABST
    Figure CN117475053B_ABST
Patent Text Reader

Abstract

The present application discloses a grass rendering method and device, which obtains the rendering center in the rendering area; determines a grass insert based on the rendering distance between the unit area in the rendering area and the rendering center, wherein the grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively correlated with the rendering distance; and inserts the grass insert into the unit area. The method reduces the risk of excessive number of rendered vertices and processing overhead caused by too many vertices in each inserted grass insert, and also reduces the risk of poor rendering effect caused by too few vertices in each inserted grass insert, which leads to excessive number of rendered vertices. The rendering effect and the processing overhead of the rendering are taken into consideration, and the computer performance and resource utilization efficiency are improved as much as possible without sacrificing the rendering effect, while increasing the density of the grass, making the virtual scene more realistic and detailed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a grass rendering method and device. Background Art

[0002] In order to render the effect of grass in the terrain, a rendering area is usually manually selected in the rendering area, and grass inserts are inserted in the selected rendering area. Each grass insert is a polygon mesh with a fixed number of vertices. For example, either each inserted grass insert is a triangle with three vertices, or each inserted grass insert is a rhombus consisting of four vertices and two triangles.

[0003] However, when using the above method, if each inserted grass insert is a triangle with three vertices, the rendering effect will be poor and it will be difficult to realistically simulate the shape of the grass; if each inserted grass insert is a rhombus with four vertices, the hardware responsible for rendering in the computing device needs to render too many vertices, resulting in excessive processing overhead for the computing device due to rendering.

[0004] In view of this, in the scene of rendering grass, how to balance the rendering effect and the rendering processing overhead to a certain extent needs further research and discussion. Summary of the invention

[0005] The present application provides a grass rendering method and device, which can take into account both rendering effect and rendering processing overhead to a certain extent. The technical solution is as follows.

[0006] In a first aspect, a grass rendering method is provided, the method comprising:

[0007] Get the rendering center in the rendering area;

[0008] Determine a grass patch based on a rendering distance between a unit area in the rendering area and the rendering center, the grass patch including at least one vertex, and the number of vertices in the grass patch is negatively correlated with the rendering distance;

[0009] The grass insert is inserted into the unit area.

[0010] In a possible implementation, the grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the determining of the grass insert based on a rendering distance between a unit area in the rendering area and the rendering center includes:

[0011] In response to determining that the rendering distance is less than or equal to a distance threshold, determining the first grass insert; or,

[0012] In response to determining that the rendering distance is greater than or equal to a distance threshold, the second grass patch is determined.

[0013] In a possible implementation manner, determining the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center includes:

[0014] A grass patch is determined based on the rendering distance and a first corresponding relationship, wherein the first corresponding relationship indicates a corresponding relationship between the rendering distance and a first number, and the number of vertices in the grass patch is the first number.

[0015] In a possible implementation manner, inserting the grass insert into the unit area includes:

[0016] Determining the number of the grass inserts based on the rendering data within the unit area;

[0017] The number of grass inserts is inserted into the unit area.

[0018] In a possible implementation, the rendering data includes a proportion of grass texture in the unit area, and determining the number of grass inserts based on the rendering data of the unit area includes:

[0019] The number of the grass inserts is determined based on the proportion of the grass texture in the unit area, and the number of the grass inserts is positively correlated with the proportion of the grass texture.

[0020] In a possible implementation, the rendering data includes color data of pixels in the unit area, and determining the number of grass inserts based on the rendering data in the unit area includes:

[0021] The number of the grass inserts is determined based on a ratio between the color data of the pixel point and a grass color threshold.

[0022] In a possible implementation manner, determining the number of the grass inserts based on a ratio between the color data of the pixel point and a grass color threshold includes:

[0023] determining the number of the grass inserts based on a ratio between an average value of color data of each pixel point in the unit area and a grass color threshold; or,

[0024] determining the number of the grass inserts based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or,

[0025] The number of the grass inserts is determined based on a ratio between an average value of color data of pixel points at each corner point in the unit area and a grass color threshold.

[0026] In a possible implementation, before determining the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center, the method further includes:

[0027] It is determined that the rendering data of the unit area meets the grass texture feature.

[0028] In a possible implementation, before obtaining the rendering center in the rendering area, the method further includes:

[0029] Based on the position of the virtual object and a preset radius, a rendering area is determined, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.

[0030] In a possible implementation, obtaining a rendering center in a rendering area includes:

[0031] Get the position of the virtual object as the rendering center.

[0032] In a second aspect, a grass rendering device is provided, the device comprising:

[0033] An acquisition module, used for acquiring a rendering center in a rendering area;

[0034] A determination module, configured to determine a grass insert based on a rendering distance between a unit area in the rendering area and the rendering center, wherein the grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively correlated with the rendering distance;

[0035] A rendering module is used to insert the grass insert into the unit area.

[0036] In one possible implementation, the grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the determination module is used to determine the first grass insert in response to determining that the rendering distance is less than or equal to a distance threshold; or determine the second grass insert in response to determining that the rendering distance is greater than or equal to a distance threshold.

[0037] In a possible implementation, the determination module is used to determine the grass patch based on the rendering distance and a first correspondence relationship, where the first correspondence relationship indicates a correspondence between the rendering distance and a first quantity, and the number of vertices in the grass patch is the first quantity.

[0038] In a possible implementation, the determination module is used to determine the number of the grass inserts based on the rendering data in the unit area; and the rendering module is used to insert the number of the grass inserts into the unit area.

[0039] In a possible implementation, the rendering data includes a proportion of grass texture in the unit area, and the determination module is used to determine the number of grass inserts based on the proportion of grass texture in the unit area, and the number of grass inserts is positively correlated with the proportion of grass texture.

[0040] In a possible implementation, the rendering data includes color data of pixels in the unit area, and the determination module is used to determine the number of the grass inserts based on a ratio between the color data of the pixels and a grass color threshold.

[0041] In one possible implementation, the determination module is used to determine the number of grass inserts based on the ratio between the average value of color data of each pixel point in the unit area and the grass color threshold; or, to determine the number of grass inserts based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or, to determine the number of grass inserts based on the ratio between the average value of color data of pixel points at each corner point in the unit area and the grass color threshold.

[0042] In a possible implementation, the determination module is used to determine whether the rendering data of the unit area meets the grass texture feature.

[0043] In a possible implementation, the determination module is further configured to determine a rendering area based on the position of the virtual object and a preset radius, and a difference between a boundary of the rendering area and the position of the virtual object is the preset radius.

[0044] In a possible implementation, the acquisition module is used to acquire the position of the virtual object as a rendering center.

[0045] In a third aspect, a server is provided, comprising: a processor, the processor being coupled to a memory, the memory storing at least one computer program instruction, the at least one computer program instruction being loaded and executed by the processor so that the server implements the method described in the first aspect or any optional method of the first aspect.

[0046] In a fourth aspect, a computer-readable storage medium is provided, wherein the storage medium stores at least one instruction, and when the instruction is executed on a computer, the computer executes the method described in the first aspect or any optional method of the first aspect.

[0047] In a fifth aspect, a computer program product is provided, which includes one or more computer program instructions. When the computer program instructions are loaded and executed by a computer, the computer executes the method described in the first aspect or any optional method of the first aspect.

[0048] In a sixth aspect, a chip is provided, which includes a programmable logic circuit and / or program instructions, and when the chip is running, it is used to implement the method described in the first aspect or any optional method of the first aspect.

[0049] In a seventh aspect, a server cluster is provided, the server cluster comprising a first server and a second server, the first server and the second server being used to collaboratively implement the method described in the first aspect or any optional method of the first aspect.

[0050] It can be seen that the embodiments of the present application have the following beneficial effects:

[0051] Since the number of vertices in a grass insert is negatively correlated with the rendering distance, a unit area farther from the rendering center can have fewer grass inserts, and a unit area closer to the rendering center can have more grass inserts. This reduces the risk of each inserted grass insert having more vertices, resulting in an excessive number of rendered vertices and causing processing overhead for rendering, and also reduces the risk of each inserted grass insert having too few vertices, resulting in an excessive number of rendered vertices and causing poor rendering effect. Both the rendering effect and the rendering processing overhead are taken into account, and the computer's performance and resource utilization efficiency are improved as much as possible without sacrificing the rendering effect, while the density of the grass is increased, making the virtual scene more realistic and detailed. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 is a flow chart of a grass rendering method provided by an embodiment of the present application;

[0053] Figure 2 is a schematic diagram of terrain grid data provided by an embodiment of the present application;

[0054] Figure 3 is a structural schematic diagram of a grass rendering device provided in an embodiment of the present application;

[0055] Figure 4 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0057] Figure 1This is a flow chart of a grass rendering method provided in an embodiment of the present application. Figure 1 The method shown includes the following steps S110 to S130.

[0058] Step S110, obtaining a rendering center in the rendering area.

[0059] The rendering area may be a sub-area of ​​the terrain grid area. A terrain grid area includes one or more rendering areas. In a possible implementation, the terrain grid area is divided according to a preset rule to obtain one or more rendering areas.

[0060] In one possible implementation of determining a rendering area, the size of the rendering area is determined. The number of rendering areas to be divided is determined based on the total size of the terrain grid area and the size of the rendering area. The complete terrain grid area is divided based on the determined size and number of rendering areas. The terrain grid area can be divided into rendering areas of the same size using an equal division method. The terrain grid area can also be divided unevenly according to specific needs and terrain features to better adapt to different parts of the terrain. For example, when the terrain changes greatly or there are more details, the size of the rendering area can be set smaller to more finely depict the details of the terrain. When the terrain changes more gently or there are fewer details, the size of the rendering area can be set larger to reduce the amount of rendering calculations.

[0061] By dividing the terrain grid area into one or more rendering areas, it helps to split the complex terrain rendering process (rendering the entire terrain grid area) into multiple smaller rendering tasks (rendering one rendering area), so as to facilitate parallel processing (such as rendering multiple rendering areas in parallel), thereby improving rendering performance and efficiency. By rendering each rendering area, the rendering of the entire terrain grid area can be achieved.

[0062] In another possible implementation of determining the rendering area, the rendering area is determined from the terrain grid area as needed. For example, based on the position of the virtual object in the terrain grid area and a preset radius, the rendering area is determined from the terrain grid area, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius. Optionally, when there are N virtual objects in the terrain grid area, N rendering areas are determined based on the N virtual objects, and the i-th rendering area in the N rendering areas includes the i-th virtual object, where N is a positive integer greater than or equal to 1, and i is a positive integer less than or equal to N.

[0063] Virtual objects are, for example, objects in a game. Virtual objects are, for example, virtual characters, such as game characters. Game characters have models, animations, and interactive behaviors, and can move freely in the game world and interact with other objects. For another example, virtual objects are virtual props, such as collectible treasures, weapons, equipment, or other gain items. Alternatively, virtual objects are enemies or monsters, and enemies or monsters are designed to fight or interact with players in other forms. Alternatively, virtual objects are environmental objects in game scenes, such as virtual trees, virtual buildings, virtual rocks, etc. Alternatively, virtual objects are NPCs (non-player characters), which are virtual objects controlled by game programs. NPCs can be merchants, residents, or other characters that provide services such as tasks, dialogues, or purchases, and users can interact with NPCs to obtain tasks, obtain information, or exchange items. Alternatively, virtual objects are game task targets.

[0064] The position of the virtual object is, for example, the two-dimensional coordinates or three-dimensional coordinates of the virtual object. As a possible implementation method for determining the rendering area based on the position of the virtual object, the position of the virtual object is used as the center of the sphere, a radius is set, and all pixels whose distance from the center of the sphere is less than or equal to the radius are selected as pixels in the rendering area. The distance between the pixel point and the center of the sphere can be obtained by calculating the Euclidean distance. For example, the position of the virtual object is (x, y, z), and the preset radius is r, then the boundary of the rendering area can be defined as a spherical area with the virtual object position as the center and a radius of r. As another possible implementation method for determining the rendering area based on the position of the virtual object, the position of the virtual object is used as the center point of the rectangle, a width and length are set, and the horizontal distance and vertical distance between the virtual object and a certain pixel point are calculated to determine whether the pixel point is within the rectangular area, thereby determining whether the pixel point belongs to the rendering area. As another possible implementation method for determining the rendering area based on the position of the virtual object, the position of the virtual object is used as the center of the circle, a radius is set, and the pixel points whose distance from the center of the circle is less than or equal to the radius are selected as pixels in the rendering area.

[0065] Since the rendering area is limited to the area around the virtual object, compared to rendering the entire terrain grid area, there is no need to render the area far away from the virtual object, thus reducing the amount of computation required for the processor rendering, saving the memory space occupied by the rendering process, and reducing the computer hardware requirements for rendering. In addition, by rendering the area around the virtual character with grass texture, the area around the virtual character is in sharp contrast with other areas. For example, the green color and rich details of the grass texture can make the virtual character more conspicuous, which helps players focus on the virtual character and enhances the virtual character's presence in the game scene.

[0066] In a possible implementation, the position of the virtual object in the rendering area is obtained, and the position of the virtual object in the rendering area is used as the rendering center. By using the position of the virtual object in the rendering area as the rendering center, when the rendering area is determined based on the position of the virtual object, since the parameters of the position of the virtual object are also used when the terrain grid area is previously divided into multiple rendering areas, the position of the virtual object obtained previously can be directly reused when determining the rendering center, without having to obtain the position of the virtual object again, thereby reducing the amount of data processing and improving efficiency.

[0067] Step S120 , determining a grass insert based on a rendering distance between a unit area and a rendering center in the rendering area.

[0068] A grass insert is a small sheet-like element used to represent a grass field. A grass insert represents a small patch of grass or grass blades in a real grass field. A grass insert usually adopts a plane or a nearly plane geometric shape. A grass insert includes at least one vertex. For example, a grass insert may have four vertices, and the grass insert may have a diamond geometric shape or a rectangular geometric shape. A grass insert may also have three vertices, and the grass insert may have a triangular geometric shape. Of course, three vertices and four vertices are only examples of the number of vertices of a grass insert, and a grass insert may also have five vertices, and the grass insert may have an irregular polygonal shape, or a grass insert may have six vertices, and the grass insert may have a convex hexagonal shape. A grass insert may also be a 3D model.

[0069] In a possible implementation of obtaining a grass insert, the number of vertices of the grass insert is determined, and based on the number of vertices of the grass insert, a geometric body with the number of vertices is created; a grass map is mapped onto the geometric body to obtain a grass insert. The grass map includes grass features, such as grass color, grass texture, and transparency.

[0070] Generally speaking, the more vertices a grass insert has, the richer geometric details, smoother surfaces, and more detailed texture mapping it can provide. The higher the precision, the better the rendering effect. However, increasing the number of vertices of a grass insert also leads to more vertex calculations and rendering operations, resulting in higher hardware requirements. Conversely, the fewer vertices a grass insert has, the simpler or rougher the appearance of the grass is, the lower the precision is, resulting in a decrease in rendering effect, but it can also reduce vertex calculations and rendering operations, thereby reducing hardware requirements.

[0071] For example, when using four vertices to form two triangles of diamond-shaped grass inserts, the grass inserts are closer to the appearance of real grass, but each grass insert needs to render four vertices, which has higher hardware requirements. In contrast, using three vertices to form a triangle of grass inserts is slightly less realistic, but can reduce hardware requirements.

[0072] In order to take into account both the rendering effect and the processing overhead of rendering, the grass inserts that need to be inserted into the unit area can be determined based on the rendering distance between the unit area and the rendering center in the rendering area, and the number of vertices in the grass inserts is negatively correlated with the rendering distance between the unit area and the rendering center. In other words, the closer the rendering distance between the unit area and the rendering center, the more vertices of the grass inserts inserted into the unit area, making the rendering effect more realistic, and the farther the rendering distance between the unit area and the rendering center, the fewer vertices of the grass inserts inserted into the unit area, thereby reducing the processing overhead generated by the rendering and reducing the hardware requirements. In particular, when the position of the virtual character is used as the rendering center, the grass in the distance of the virtual character presents a form with fewer details and a smaller number of vertices, while the grass in the near distance presents a form with more details and a larger number of vertices, thereby simulating a visual perspective effect and enhancing the realism and three-dimensionality of the game.

[0073] In one possible implementation, the grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the rendering distance is compared with a distance threshold; in response to determining that the rendering distance is less than or equal to the distance threshold, the first grass insert is determined; or, in response to determining that the rendering distance is greater than or equal to the distance threshold, the second grass insert is determined. For example, when it is determined that the rendering distance is less than or equal to the distance threshold, a grass insert with four vertices (first grass insert) is determined, and the grass insert with four vertices is inserted into the unit area; when it is determined that the rendering distance is greater than or equal to the distance threshold, a grass insert with three vertices (second grass insert) is determined, and the grass insert with three vertices is inserted into the unit area. The distance threshold can be set according to the size of the terrain grid area or the rendering area or the requirements of the rendering effect.

[0074] In another possible implementation, the grass insert is determined based on the rendering distance and the first correspondence. The first correspondence indicates the correspondence between the rendering distance and the first quantity, and the number of vertices in the grass insert is the first quantity. The correspondence can be represented by an array, a table, or a function. For example, using the rendering distance as an index, the first correspondence in a tabular form is searched to obtain the first quantity; and the grass insert with the first number of vertices is screened from the candidate grass inserts. The correspondence between the rendering distance and the first quantity can be calculated using linear interpolation. Alternatively, an exponential function is used to represent the correspondence between the rendering distance and the number of vertices, so that the number of vertices at a long distance decreases exponentially. Alternatively, a curve function, a polynomial, etc. are used to fit the first correspondence in the form of a nonlinear function to obtain a more accurate number of vertices.

[0075] Step S130: inserting a grass insert into the unit area.

[0076] In a possible implementation, before inserting the grass insert, it is determined whether the rendering data of the unit area meets the grass texture characteristics; if the rendering data of the unit area meets the grass texture characteristics, the step of determining the grass insert based on the rendering distance is executed; if the rendering data of the unit area does not meet the grass texture characteristics, the step of determining the grass insert is canceled. Since there is no need to manually select the grass area, the labor cost caused by manually selecting the grass area is saved, and the rendering efficiency is improved. In addition, when the rendering data of the unit area does not meet the grass texture characteristics, there is no need to insert the grass insert, which is equivalent to filtering out some areas that are not suitable for inserting the grass insert before inserting the grass insert, thereby reducing the probability of inserting the grass insert in unnecessary areas, thereby reducing the rendering load and resource consumption.

[0077] In a possible implementation method of determining whether the rendering data of a unit area satisfies the grass texture characteristics, the number of target pixels in the unit area is determined based on the color data of the pixels in the unit area and the grass color range; based on the number of target pixels in the unit area, it is determined that the rendering data of the unit area satisfies the grass texture characteristics, and a grass insert is inserted into the unit area.

[0078] The grass color interval refers to a range used to describe the color characteristics of the grass. For example, in the RGB space, the grass color interval may include the ranges of the three components of R, G, and B; in the HSV space, the grass color interval may include the ranges of the components of H (hue), S (saturation), and V (brightness). In a possible implementation method for determining the grass color interval, a real grass picture is sampled to determine the grass color interval. For example, a variety of real grass pictures are collected, including grass pictures in different scenes and under different lighting conditions. Sample images representing the grass color are selected from these real grass pictures, and color data is extracted from the sample images as the grass color interval. Optionally, based on the environmental conditions corresponding to the grass image, such as sunlight intensity, shadows, reflections of surrounding objects, and other factors, the range of the determined grass color interval is adjusted so that the grass color interval can include grass color changes under different environments.

[0079] The target pixel refers to a pixel whose color data belongs to the grass color interval. For example, compare the color data of a pixel with the upper and lower bounds of the grass color interval. If the color data of the pixel is within the grass color interval, the pixel is the target pixel. Considering that color data is usually defined by multiple color channels, in a possible implementation, compare the value of each color channel in the color data of a pixel with the upper and lower bounds of the interval of the corresponding channel in the grass color interval. If the value of each color channel in the color data of a pixel belongs to the upper and lower bounds of the interval of the corresponding channel, the pixel is the target pixel. Taking the RGB space as an example, for example, if the value of the red channel of a pixel is within the upper and lower bounds of the red channel of the grass color interval, and the value of the green channel of the pixel is within the upper and lower bounds of the green channel of the grass color interval, and the value of the blue channel of the pixel is within the upper and lower bounds of the blue channel of the grass color interval, the pixel is the target pixel.

[0080] In one possible implementation, each pixel in the unit area is traversed, and for the currently traversed pixel, if the color data of the pixel is within the defined grass color range, the pixel is determined to be a target pixel, and the number of recorded target pixels is increased by one, until the last pixel in the unit area is traversed, and the number of recorded target pixels is output.

[0081] In one possible implementation, the number of target pixels in a unit area is compared with a quantity threshold. When it is determined that the number of target pixels in a unit area is greater than or equal to the quantity threshold, it is determined that the rendering data of the unit area meets the grass texture feature, and a grass insert is inserted into the unit area. When it is determined that the number of target pixels in a unit area is less than the quantity threshold, it is determined that the rendering data of the unit area does not meet the grass texture feature, and there is no need to insert a grass insert into the unit area. By comparing the number of target pixels in a unit area with the quantity threshold, it is possible to quickly determine whether the grass texture feature is met. This method is relatively simple and easy to implement. Moreover, compared to manual processing, the area to be rendered as grass can be automatically selected, so it is faster and more accurate.

[0082] In another possible implementation, the ratio between the number of target pixels in the unit area and the total number of pixels in the unit area is obtained, and the ratio is compared with a first ratio threshold; when the ratio is greater than or equal to the first ratio threshold, it is determined that the rendering data of the unit area meets the grass texture feature, and a grass insert is inserted into the unit area. When the ratio is less than the first ratio threshold, it is determined that the rendering data of the unit area does not meet the grass texture feature, and there is no need to insert a grass insert into the unit area. In an exemplary scenario, a plurality of terrain texture maps (such as 5 terrain texture maps) are used for rendering in the unit area, and the plurality of terrain texture maps include a grass texture map, and the proportion of the grass texture map determines whether to insert a grass insert into the unit area. The proportion of the grass texture map is, for example, the ratio between the number of pixels (target pixels) occupied by the grass texture and the total number of pixels, that is, the ratio between the number of target pixels in the unit area and the total number of pixels in the unit area. If the grass texture occupies most of the pixels, the proportion of the grass texture will be relatively high. For example, the first ratio threshold is 20%. When the proportion of lawn texture is greater than 20%, it means that there are enough lawn textures in the unit area, and grass inserts are inserted into the unit area to increase the realism of the grass. In addition, by comparing the ratio between the number of target pixels and the total number of pixels in the unit area, the relative proportion of grass in the rendering data can be better grasped. In addition, at different zoom levels or viewing angles, the total number of pixels in the unit area may change, while the ratio between the number of target pixels and the total number of pixels in the unit area is relatively invariant, so it helps to adapt to rendering requirements at different scales. And compared with manual processing, the area to be rendered as grass can be automatically selected, so it is faster and more accurate.

[0083] In a possible implementation, based on the color data of each pixel in the unit area, the statistical value of the color data of the pixel in the unit area is obtained, the ratio between the statistical value of the color data and the grass color threshold is determined, and the ratio between the statistical value of the color data and the grass color threshold is compared with the second ratio threshold; if the ratio between the statistical value of the color data and the grass color threshold is greater than or equal to the second ratio threshold, it is determined that the rendering data of the unit area meets the grass texture feature, and a grass insert is inserted into the unit area. If the ratio between the statistical value of the color data and the grass color threshold is less than the second ratio threshold, it is determined that the rendering data of the unit area does not meet the grass texture feature, and there is no need to insert a grass insert into the unit area. The ratio between the statistical value of the color data and the grass color threshold can be understood as the proportion of grass texture. Taking the second ratio threshold of 20% as an example, if the proportion of grass texture is greater than or equal to 20%, a grass insert is inserted into the unit area.

[0084] The method of obtaining the statistical value of the color data of the pixels in the unit area is, for example, to obtain the average value of the color data of each pixel in the unit area. For example, the color data of all the pixels in the unit area are added, and the sum of the color data is divided by the number of pixels to obtain the average value of the color data; accordingly, if the average value of the color data in the unit area is greater than or equal to the second ratio threshold, a grass insert is inserted into the unit area. Since the color data of all the pixels in the unit area are used, it is equivalent to considering the overall color characteristics of the unit area, which is more accurate. At the same time, by calculating the average value as a quantitative condition for judging whether the grass area should be selected or the grass insert should be inserted, the influence of noise interference is reduced, making the result smoother and more stable.

[0085] Another method for obtaining the statistical value of the color data of the pixel points in the unit area is as follows: obtaining the color data of the central pixel point in the unit area. Accordingly, if the color data of the central pixel point in the unit area is greater than or equal to the second ratio threshold, a grass insert is inserted into the unit area. Since the color data of the central pixel point is used instead of the color data of all the pixels in the unit area, the amount of data to be processed is reduced, and the calculation efficiency is improved. In addition, the color characteristics of the corners of the unit area can be better captured, which is suitable for scenes with obvious grass edges.

[0086] Another way to obtain the statistical value of the color data of the pixel points in the unit area is to obtain the average value of the color data of the pixel points at each corner point in the unit area. For example, the average value of the color data of the four corner points of the upper left corner point, the lower left corner point, the upper right corner point, and the lower right corner point in the unit area is obtained. Accordingly, if the average value of the color data of the pixel points at each corner point in the unit area is greater than or equal to the second ratio threshold, a grass insert is inserted into the unit area.

[0087] In another possible implementation, the rendering data includes texture data of pixels in the unit area. Whether to insert a grass insert into the unit area can be determined based on the texture data of the pixels in the unit area. Grass materials usually have a certain fineness and may include fine texture elements (such as grass leaves, grass stems, etc.). It can be detected whether there are texture elements that meet the characteristics of grass in the texture data of the unit area (such as small and regular textures, such as elongated spots, mottled shapes, etc.). If there are texture elements that meet the characteristics of grass in the texture data of the unit area, the unit area is determined to be a grass area, and a grass insert is inserted into the unit area.

[0088] In another possible implementation, the rendering data includes illumination data of pixels in the unit area. Whether to insert a grass insert into the unit area can be determined based on the illumination data of the pixels in the unit area. Grassland usually exhibits light and dark changes under illumination, and has certain highlight and shadow effects. It is possible to detect whether the illumination data in the unit area has illumination distribution and shadow effects that conform to the characteristics of grass, thereby determining whether to insert a grass insert into the unit area. For example, if the illumination data in the unit area exhibits brighter illumination reflection characteristics, and produces reflection changes at different illumination angles, the unit area is determined to be a grass area, and a grass insert is inserted into the unit area.

[0089] In another possible implementation, at least two of the color data, texture data, lighting data, material data and geometric data of the unit area are combined to determine whether the unit area meets the grass texture characteristics. When the unit area meets the grass texture characteristics, a grass insert is inserted into the unit area. When the unit area does not meet the grass texture characteristics, there is no need to insert a grass insert into the unit area.

[0090] In a possible implementation, the number of grass inserts is determined based on the rendering data in the unit area; the number of grass inserts is obtained; and the number of grass inserts is inserted into the unit area. In this way, the number of grass inserts in the unit area is more matched with the rendering data of the unit area, and the distribution of the grass inserts is coordinated with the overall environment of the unit area. In addition, the number of grass inserts is more appropriate, reducing the probability of increasing the rendering burden and reducing the performance due to too many inserted grass inserts, and reducing the probability of poor rendering effect due to too few grass inserts.

[0091] In a possible implementation, the rendering data includes the proportion of grass texture in a unit area, and the number of grass inserts is determined based on the proportion of grass texture in the unit area. The number of grass inserts is positively correlated with the proportion of grass texture. That is, the greater the proportion of grass texture, the greater the number of grass inserts. Exemplarily, a second correspondence between the number of grass inserts and the proportion of grass texture is preset, and the input parameters of the second correspondence include the proportion of grass texture in the unit area, and the output parameters of the second correspondence include the number of grass inserts. Based on the proportion of grass texture in the unit area and the second correspondence, the number of grass inserts is determined. The second correspondence between the number of grass inserts and the proportion of grass texture can be a function, which can be a linear second correspondence, or a nonlinear function such as an exponential function, a logarithmic function, or a piecewise function as the second correspondence. Since the number of grass inserts is positively correlated with the proportion of grass texture, it is possible to simulate the situation in reality that there will be more grass in places where the grass is greener, so that the amount of grass is more adapted to the color of the grass.

[0092] In a possible implementation, the rendering data includes color data of pixels in a unit area, and a ratio between the color data of the pixel and a grass color threshold is obtained. Based on the ratio between the color data of the pixel and the grass color threshold, the number of grass inserts is determined. The grass color threshold is used to determine the color range belonging to the grass. The method of obtaining the ratio between the color data of the pixel and the grass color threshold is, for example, distance comparison, such as calculating the distance between the color value of the pixel and the grass color threshold (such as Euclidean distance, difference, etc.), and converting the distance into a ratio. The method of obtaining the ratio between the color data of the pixel and the grass color threshold is also, for example, calculating the similarity between the color value of the pixel and the grass color threshold, and converting the similarity into a ratio. The method of obtaining the ratio between the color data of the pixel and the grass color threshold is also, for example, comparing the color value of the pixel with the grass color threshold to obtain a Boolean value, which indicates whether the color value of the pixel is within the color range indicated by the grass color threshold.

[0093] In one possible implementation, the number of grass inserts is determined based on the ratio between the average value of the color data of each pixel in the unit area and the grass color threshold. For example, a third correspondence between the average value of the color data of the pixel and the number of grass inserts is set, and the number of grass inserts is determined based on the average value of the color data of the pixel and the third correspondence. For another example, when the ratio between the average value of the color data of each pixel in the unit area and the grass color threshold is greater than or equal to the threshold, the number of grass inserts is determined to be the first number; when the ratio between the average value of the color data of each pixel in the unit area and the grass color threshold is less than the threshold, the number of grass inserts is determined to be the second number. The number of grass inserts may be positively correlated with the ratio between the average value of the color data of each pixel and the grass color threshold. In this way, when the average value of the color data increases, the number of grass inserts will also increase accordingly, thereby simulating that there will be more grass corresponding to places where the grass is greener.

[0094] In a possible implementation, the number of grass inserts is determined based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold. For example, a fourth corresponding relationship between the color data of the central pixel point and the number of grass inserts is set, and the number of grass inserts is determined based on the color data of the central pixel point and the fourth corresponding relationship. For another example, when the ratio between the color data of the central pixel point in the unit area and the grass color threshold is greater than or equal to the threshold, the number of grass inserts is determined to be the first number; when the ratio between the color data of the central pixel point in the unit area and the grass color threshold is less than the threshold, the number of grass inserts is determined to be the second number. The number of grass inserts may be positively correlated with the ratio between the average value of the color data of each pixel point and the grass color threshold. The number of grass inserts may be positively correlated with the ratio between the color data of the central pixel point and the grass color threshold. In this way, when the color data of the central pixel point increases, the number of grass inserts will also increase accordingly, thereby simulating that there will be more grass corresponding to places where the grass is greener.

[0095] In a possible implementation, the number of grass inserts is determined based on the ratio between the average value of the color data of the pixel points of each corner point in the unit area and the grass color threshold. For example, a fifth corresponding relationship between the average value of the color data of the pixel points of each corner point and the number of grass inserts is set, and the number of grass inserts is determined based on the average value of the color data of the pixel points of each corner point and the fifth corresponding relationship. For another example, when the ratio between the average value of the color data of the pixel points of each corner point and the grass color threshold is greater than or equal to the threshold, the number of grass inserts is determined to be the first number; when the ratio between the average value of the color data of the pixel points of each corner point and the grass color threshold is less than the threshold, the number of grass inserts is determined to be the second number. The number of grass inserts may be positively correlated with the ratio between the average value of the color data of the pixel points of each corner point and the grass color threshold. In this way, when the color data of each corner point increases, the number of grass inserts will also increase accordingly, thereby simulating that there will be more grass corresponding to places where the grass is greener.

[0096] The method provided in this embodiment has a negative correlation between the number of vertices in the grass insert and the rendering distance. The unit area farther away from the rendering center has fewer grass inserts, and the unit area closer to the rendering center has more grass inserts. This reduces the risk of each inserted grass insert having a large number of vertices, resulting in an excessive number of rendered vertices and causing processing overhead for rendering, and also reduces the risk of each inserted grass insert having too few vertices, resulting in an excessive number of rendered vertices and causing poor rendering effect. The method takes into account both the rendering effect and the rendering processing overhead, and improves the computer's performance and resource utilization efficiency as much as possible without sacrificing the rendering effect. At the same time, the density of the grass is increased, making the virtual scene more realistic and detailed.

[0097] In addition, when dynamic rendering is performed around a virtual object, selective rendering of the rendering area and precision rendering of the grass insert can be performed simultaneously. For example, there are a first virtual object and a second virtual object in the terrain grid area. While the first thread uses the location of the first virtual object and the area within a preset radius as the rendering area for rendering, the second thread determines the number of vertices corresponding to the rendering distance based on the rendering distance between the unit area in the rendering area where the second virtual object is located and the second virtual object, and inserts a grass insert with the number of vertices through the second thread.

[0098] In another possible implementation, the camera position is obtained as the rendering center. Based on the rendering distance between the unit area and the camera position in the rendering area, a grass insert is determined, the grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively correlated with the rendering distance; the grass insert is inserted into the unit area. Since the camera position is related to the user's perspective, by rendering with the camera position as the center, the number of vertices of the grass insert is negatively correlated with the rendering distance between the camera positions, so that the accuracy of the grass insert can change as the perspective leaves or approaches the unit area, so that a gradual transition effect can be achieved visually, making the rendering of the details of the scene more realistic. In addition, when the perspective leaves the unit area, a grass insert with a small number of vertices is used to reduce the processing overhead generated by the rendering and reduce the hardware requirements.

[0099] In another possible implementation, the light source position is obtained as the light source position. Based on the rendering distance between the unit area and the light source position in the rendering area, a grass insert is determined, the grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively correlated with the rendering distance; the grass insert is inserted into the unit area. In other words, the closer the rendering distance between the unit area and the light source position, the more vertices of the grass insert inserted into the unit area, making the rendering effect more realistic, and the farther the rendering distance between the unit area and the light source position, the fewer vertices of the grass insert inserted into the unit area, thereby reducing the processing overhead generated by the rendering and reducing the hardware requirements. In addition, the area closer to the light source has a grass insert with higher details, so that the area around the light source can present the distribution of grass more realistically and naturally, thereby improving the visual effect.

[0100] In another possible implementation, the user interaction position is obtained as the user interaction position. Based on the rendering distance between the unit area and the user interaction position in the rendering area, a grass insert is determined, the grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively correlated with the rendering distance; the grass insert is inserted into the unit area. In other words, the closer the rendering distance between the unit area and the user interaction position, the more vertices of the grass insert inserted into the unit area, making the rendering effect more realistic, and the farther the rendering distance between the unit area and the user interaction position, the fewer vertices of the grass insert inserted into the unit area, thereby reducing the processing overhead generated by the rendering and reducing the hardware requirements. In addition, when the user moves or operates, the number of vertices of the grass insert will change accordingly, so that the user feels that the changes in the scene are based on their own position and actions, which is more dynamic. In addition, the user can determine the center of the rendering through his own interactive selection, which helps to customize the rendering according to the actual needs of the user.

[0101] In a possible implementation, based on the distance between a unit area in the rendering area and the rendering center, the resolution of the texture map is determined, and the resolution of the texture map is negatively correlated with the distance; and a grass insert having the resolution of the texture map is determined.

[0102] The resolution of a texture map refers to the number of pixels included in the texture map. The higher the resolution of a texture map, the denser the pixels in the texture image, and the clearer the details of the grass insert. Since the resolution of the texture map is dynamically determined based on the distance from the unit area to the rendering center, a unit area closer to the rendering center requires a higher resolution texture map, while a unit area farther away can use a lower resolution texture map. For unit areas far from the rendering center, using low-resolution texture maps can reduce memory usage and rendering overhead, and improve rendering performance. For unit areas close to the rendering center, using high-resolution texture maps allows the grass insert to have higher-precision details, creating a more realistic visual effect.

[0103] In a possible implementation, the boundaries between multiple rendering areas in the terrain mesh area are smoothed. Smoothing refers to processing the boundaries between the rendering areas to reduce discontinuities, jagged or obvious transitions, so that the rendering boundaries are more natural and smooth. The smoothing method includes but is not limited to at least one of fusion seams, texture transitions, normal averaging, vertex scaling, or edge blurring.

[0104] The blending seam can achieve a smooth transition by blending the textures, colors or other attributes of adjacent rendering areas. This can be achieved by drawing a seam area at the boundary and performing texture interpolation, color blending and other operations in the seam area. The seam area can use gradient and transition effects to gradually blend the features of adjacent rendering areas. Texture transition can use multiple textures and transition multiple textures through blending technology to smooth the boundaries between rendering areas. Texture transition can be achieved using techniques such as map fusion and weight blending. By adjusting the transparency of the texture or using an alpha map, the transition effect between different textures can be controlled. Normal averaging can make the normal vectors between adjacent rendering areas smoothly transition. By calculating the normal directions of adjacent faces and averaging or interpolating them, the normal differences can be reduced and the boundaries can be smoother. Using smooth normals can produce more realistic rendering effects. Vertex scaling can adjust the vertex positions on the boundaries of adjacent rendering areas so that they gradually transition smoothly between adjacent areas. Vertex scaling can be achieved by interpolation or weighting, so that the height and shape changes of adjacent areas transition smoothly. Edge blurring can apply a blur effect around the rendering boundary to reduce the jaggedness and hard edge phenomenon of the edge. Edge blurring can use algorithms such as Gaussian blur to process boundary pixels and smoothly blend the colors of edge pixels with surrounding pixels.

[0105] The following is an example of the process of constructing a terrain grid area.

[0106] A terrain mesh region is a discretized region used to represent terrain, and is often used for terrain rendering and simulation. In computer graphics, a terrain mesh region can be viewed as a two-dimensional or three-dimensional grid consisting of a series of adjacent vertices and edges connecting them. In the two-dimensional case, a terrain mesh region is a grid plane consisting of a series of vertices and edges. Each vertex represents a point on the terrain surface, and the edges represent the connection relationship between adjacent points. A height value can be assigned to each vertex to simulate the height variation of the terrain. Interpolation algorithms can be used to infer the height of unknown points from known height values ​​to form a smooth terrain model. In the three-dimensional case, a terrain mesh region is a grid of triangles (or other polygons) connected together, similar to the surface of the grid. Each vertex represents a point on the terrain surface, and each triangle represents a small fragment of the terrain. A height value can be assigned to each vertex to simulate the height variation of the terrain, and a continuous terrain surface model can be obtained by interpolating and smoothing the height values ​​on each triangle. The fineness of the terrain mesh region depends on the resolution of the mesh, that is, the number of vertices. Higher resolutions can provide more detailed and realistic terrain representations, but they also increase the complexity of calculation and rendering. Lower resolutions can improve performance, but will result in less detailed terrain surfaces.

[0107] In a possible implementation, in a selected grid, the height value of each pixel point in the grid and the position information of each pixel point are determined by a preset sequence array, and a terrain grid area is constructed based on the height value of the pixel point and the position information of the pixel point.

[0108] In one possible implementation, the terrain grid data is represented similarly to a grayscale image. For example, the color brightness (grayscale) in the height terrain map is used to represent the height change of the terrain. Specifically, when the area in a certain area in the height terrain map is whiter, it means that the height value of the area is larger, that is, the terrain in the area is higher. On the contrary, when the color of a certain area in the height terrain map is darker or darker, it means that the height value of the area is smaller, that is, the terrain is lower. For example, please refer to the attached Figure 2 , attached Figure 2 is a schematic diagram of a terrain grid data provided by an embodiment of the present application. Figure 2 The brightness and darkness of the colors in the image can give you an intuitive understanding of the height changes of the terrain.

[0109] A sequence array is an array that uses a sequence as data. In other words, each element in a sequence array is a sequence type of data. The number of bits of each element (i.e., sequence) in a sequence array can be set according to the accuracy requirements. For example, the number of bits of a sequence can be 8 bits or 16 bits, etc. The larger the number of bits of a sequence, the more refined the height value representation can be. The value of the sequence corresponds to the height value. The sequence is in binary format.

[0110] The storage format of the array means that the distribution of the sequence is ordered. The number of sequence data in each row and column of the array corresponds to the number of pixels in the terrain grid. For example, the number of sequence data in each row of the array indicates the number of pixels in each row of the terrain grid. The number of sequence data in each column of the array indicates the number of pixels in each column of the terrain grid. For example, if there are 1080 sequences in each row of the array and 960 sequences in each column of the array, it means that the data of the terrain grid contains 1080*960 pixels, and the terrain grid has 1080 pixels in each row and 960 pixels in each column. The horizontal distance between each pixel is the same, so using the sequence as the height value of the pixel can render a height terrain map.

[0111] The following is an example of the process of building a rendering area.

[0112] In a possible implementation, the terrain mesh area is rendered based on vertex data and texture feature configuration in the terrain mesh data to obtain a rendering area.

[0113] In a possible implementation, vertex data in the terrain grid data is obtained based on the coordinate information of the pixel points and the height value of the pixel points in the terrain grid data. Each pixel point in the sampled image is used as a vertex in the terrain grid area. The vertex data includes coordinate information and height value, which are subsequently used for texture rendering of the vertex.

[0114] The server obtains all vertex data of the terrain mesh area, and then performs texture rendering on all vertices of the terrain mesh area according to the texture feature configuration that needs to be rendered.

[0115] Normally, the entire terrain grid area needs to be texture rendered, but some terrains are too large and limited by hardware issues to render the entire terrain grid area at once, or the terrain grid area does not want to take up too much hardware and will not be rendered at once. Therefore, the complete terrain grid area is divided into multiple rendering areas, and then the multiple rendering areas are rendered in sequence according to preset rules to achieve the rendering of the entire terrain grid area. Alternatively, the entire terrain grid area may not be rendered at the same time, but specific rendering areas may be rendered as needed, such as specifying the rendering area involved in the preset radius of the virtual character's position as a specific rendering area, thereby reducing the hardware requirements for rendering.

[0116] Texture feature configuration is to use the terrain texture map as terrain texture data. Specifically, the terrain texture map is parsed to obtain the color distribution data of all pixels in the terrain texture map. The color data is RGB data, and then the color distribution data is used as terrain texture data (including the number of pixels and the colors corresponding to the pixels).

[0117] In a possible implementation, for a terrain grid area to be rendered, the terrain texture data is densely laid in the terrain grid area so that the entire terrain grid area is rendered.

[0118] Tessellation refers to tiling terrain texture data (or terrain texture map) within a terrain grid area so that the entire surface of the terrain grid area is completely covered by the terrain texture map.

[0119] In a possible implementation, the precision of tiling is adjusted by configuring the tiling degree parameter. For example, if the pixel size of the terrain texture map is 20*20, it needs to be tiled in a rendering area of ​​40*40. According to different tiling degrees, a 1:1 tiling degree can be selected in the 40*40 rendering area. At this time, each pixel in the 40*40 rendering area is covered and rendered one by one, and the number of tiled terrain texture maps is 4; when a 1:4 tiling degree is selected, only a quarter of the pixels in the 40*40 rendering area are covered, that is, one pixel is rendered for every four pixels.

[0120] Optionally, Figure 1 The method is performed by a computing device. Figure 1 The method shown is performed collaboratively by a computing device cluster including multiple computing devices. For example, computing device A executes Figure 1 In the method shown in S110, computing device B executes Figure 1 In the method shown in S120. The computing device is, for example, a terminal or a server. In a possible implementation, the attached Figure 1 The method shown is performed by a computing device by running an application. The application is, for example, a browser software or a client software. Figure 1 The execution subject of the method shown is not limited.

[0121] Figure 3 is a structural schematic diagram of a grass rendering device provided in an embodiment of the present application, Figure 3 The device 200 shown comprises:

[0122] An acquisition module 210 is used to acquire a rendering center in a rendering area;

[0123] A determination module 220, configured to determine a grass patch based on a rendering distance between a unit area in the rendering area and a rendering center, wherein the grass patch includes at least one vertex, and the number of vertices in the grass patch is negatively correlated with the rendering distance;

[0124] The rendering module 230 is used to insert grass inserts into the unit area.

[0125] In one possible implementation, the grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the determination module 220 is used to determine the first grass insert in response to determining that the rendering distance is less than or equal to the distance threshold; or, determine the second grass insert in response to determining that the rendering distance is greater than or equal to the distance threshold.

[0126] In a possible implementation, the determination module 220 is used to determine the grass patch based on the rendering distance and a first correspondence relationship, where the first correspondence relationship indicates a correspondence between the rendering distance and a first quantity, and the number of vertices in the grass patch is the first quantity.

[0127] In a possible implementation, the determination module 220 is used to determine the number of grass inserts based on the rendering data in the unit area; and the rendering module 230 is used to insert a certain number of grass inserts into the unit area.

[0128] In a possible implementation, the rendering data includes a proportion of grass texture in a unit area, and the determination module 220 is used to determine the number of grass inserts based on the proportion of grass texture in the unit area, and the number of grass inserts is positively correlated with the proportion of grass texture.

[0129] In a possible implementation, the rendering data includes color data of pixels in a unit area, and the determination module 220 is used to determine the number of grass inserts based on a ratio between the color data of the pixels and a grass color threshold.

[0130] In one possible implementation, the determination module 220 is used to determine the number of grass inserts based on the ratio between the average value of color data of each pixel point in the unit area and the grass color threshold; or, to determine the number of grass inserts based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or, to determine the number of grass inserts based on the ratio between the average value of color data of the pixel points at each corner point in the unit area and the grass color threshold.

[0131] In a possible implementation, the determination module 220 is configured to determine whether the rendering data of the unit area meets the grass texture feature.

[0132] In a possible implementation, the determination module 220 is further configured to determine a rendering area based on the position of the virtual object and a preset radius, wherein the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.

[0133] In a possible implementation, the acquisition module 210 is used to acquire the position of the virtual object as a rendering center.

[0134] Figure 4 300 is a schematic diagram of a server structure provided by an embodiment of the present application. The server 300 includes: a processor 301, the processor 301 is coupled to a memory 302, the memory 302 stores at least one computer program instruction, and the at least one computer program instruction is loaded and executed by the processor 301 to enable the server 300 to implement Figure 1 The method provided by the embodiment.

[0135] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0136] A refers to B, which means that A is the same as B or A is a simple variant of B.

[0137] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order of objects, and cannot be understood as indicating or implying relative importance. For example, the first grass insert and the second grass insert are used to distinguish different grass inserts, rather than to describe a specific order of grass inserts, and cannot be understood as the first grass insert being more important than the second grass insert.

[0138] The information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of the present application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0139] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in accordance with the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk (SSD)), etc.

[0140] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A grass rendering method, characterized in that: The method comprises: Get the rendering center in the rendering area; Determine a grass insert based on a rendering distance between a unit area in the rendering area and the rendering center, the grass insert including at least one vertex, the number of vertices in the grass insert being negatively correlated with the rendering distance, and the grass insert being a small sheet-shaped element used to represent grass; inserting grass inserts into the unit area; The grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the determining of the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center includes: In response to determining that the rendering distance is less than or equal to a distance threshold, determining the first grass insert; or, In response to determining that the rendering distance is greater than or equal to a distance threshold, the second grass patch is determined.

2. The method according to claim 1, characterized in that The determining of the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center includes: A grass patch is determined based on the rendering distance and a first corresponding relationship, wherein the first corresponding relationship indicates a corresponding relationship between the rendering distance and a first number, and the number of vertices in the grass patch is the first number.

3. The method according to claim 1, characterized in that The inserting the grass insert into the unit area comprises: Determining the number of the grass inserts based on the rendering data within the unit area; The number of grass inserts is inserted into the unit area.

4. The method according to claim 3, characterized in that The rendering data includes a proportion of grass texture in the unit area, and determining the number of grass inserts based on the rendering data of the unit area includes: The number of the grass inserts is determined based on the proportion of the grass texture in the unit area, and the number of the grass inserts is positively correlated with the proportion of the grass texture.

5. The method according to claim 3, characterized in that: The rendering data includes color data of pixels in the unit area, and determining the number of grass inserts based on the rendering data in the unit area includes: The number of the grass inserts is determined based on a ratio between the color data of the pixel point and a grass color threshold.

6. The method according to claim 5, characterized in that The determining the number of the grass inserts based on the ratio between the color data of the pixel point and the grass color threshold value comprises: determining the number of the grass inserts based on a ratio between an average value of color data of each pixel point in the unit area and a grass color threshold; or, determining the number of the grass inserts based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or, The number of the grass inserts is determined based on a ratio between an average value of color data of pixel points at each corner point in the unit area and a grass color threshold.

7. The method according to claim 1, characterized in that Before determining the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center, the method further includes: It is determined that the rendering data of the unit area meets the grass texture feature.

8. The method according to claim 1, characterized in that Before obtaining the rendering center in the rendering area, the method further includes: Based on the position of the virtual object and a preset radius, a rendering area is determined, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.

9. The method according to claim 1, characterized in that: The obtaining of the rendering center in the rendering area includes: Get the position of the virtual object as the rendering center.

10. The method according to claim 1, characterized in that The obtaining of the rendering center in the rendering area includes: Get the camera position as the rendering center; or, Get the light source position as the rendering center; or, Get the user interaction position as the rendering center.

11. The method according to claim 1, characterized in that: The determining of the grass insert based on the distance between the unit area in the rendering area and the rendering center includes: Determining a resolution of a texture map based on a distance between a unit area in the rendering area and the rendering center, wherein the resolution of the texture map is negatively correlated with the distance; Determines a grass patch with the resolution of the texture map.

12. A grass rendering device, characterized in that: include: An acquisition module, used for acquiring a rendering center in a rendering area; A determination module, configured to determine a grass insert based on a rendering distance between a unit area in the rendering area and the rendering center, wherein the grass insert includes at least one vertex, the number of vertices in the grass insert is negatively correlated with the rendering distance, and the grass insert is a small sheet-shaped element used to represent grass; An insertion module, used for inserting grass inserts into the unit area; The grass insert includes a first grass insert and a second grass insert, the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert, and the determination module is used to determine the first grass insert in response to determining that the rendering distance is less than or equal to a distance threshold; or determine the second grass insert in response to determining that the rendering distance is greater than or equal to a distance threshold.

13. A server, characterized in that: The server comprises: a processor, the processor is coupled to a memory, the memory stores at least one computer program instruction, and the at least one computer program instruction is loaded and executed by the processor so that the server implements the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and when the instruction is executed on a computer, the computer executes the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Surface vegetation treatment method and device

    CN110264553A

  • Virtual vegetation rendering method and device, storage medium and electronic equipment

    CN110288688A