Grassland Rendering Method and Device
By automatically determining whether the rendering data meets the grass texture characteristics and inserting grass inserts, the high cost and inefficiency problems caused by manual selection of grass areas are solved, and efficient rendering and realism are achieved.
Patent Information
- Application Number
- CN202311172716.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-09-12
AI Technical Summary
The prior art requires manual selection of grass areas when rendering grass fields, resulting in high labor costs and low rendering efficiency.
By obtaining the rendering data of the rendering area, it is automatically judged whether the unit area satisfies the grass texture characteristics, and inserts the grass insert when the conditions are met.
Save labor costs for manually selected grass areas, improve rendering efficiency, and enhance rendering realism and detail.
Smart Images

Figure CN117197276B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a grassland rendering method and apparatus. Background Art
[0002] In order to render the effect of grassland in the terrain, usually the grassland area is manually selected in the rendering area, and grass inserts are inserted in the selected grassland area.
[0003] However, when using the above method, since it is necessary to manually select the grassland area, when the entire rendering area is relatively large, it requires a lot of manpower, resulting in low rendering efficiency. Summary of the Invention
[0004] Embodiments of this application provide a grassland rendering method and apparatus, which can save the labor cost caused by manually selecting the grassland area and improve the rendering efficiency. The technical solutions are as follows.
[0005] In a first aspect, a grassland rendering method is provided, and the method includes:
[0006] Obtain the rendering data in a unit area in the rendering area;
[0007] In response to determining that the rendering data of the unit area meets the grassland texture characteristics, insert the grass inserts into the unit area.
[0008] In a possible implementation, the rendering data includes the color data of the pixel points in the unit area, and determining that the rendering data of the unit area meets the grassland texture characteristics includes:
[0009] Based on the color data of the pixel points in the unit area and the grassland color interval, determine the number of target pixel points in the unit area, and the color data of the target pixel points belongs to the grassland color interval;
[0010] Based on the number of target pixel points in the unit area, determine that the rendering data of the unit area meets the grassland texture characteristics.
[0011] In a possible implementation, the determining that the rendering data of the unit area meets the grassland texture characteristics based on the number of target pixel points in the unit area includes:
[0012] Determine that the number of target pixel points in the unit area is greater than or equal to a number threshold; or,
[0013] Determine that the ratio between the number of target pixel points in the unit area and the total number of pixel points in the unit area is greater than or equal to a first ratio threshold.
[0014] In a possible implementation, the rendering data includes color data of pixel points within the unit area, and determining that the rendering data of the unit area meets the grass texture feature includes:
[0015] Obtaining a statistical value of the color data of pixel points within the unit area;
[0016] Determining that the ratio between the statistical value of the color data and the grass color threshold is greater than or equal to a second ratio threshold.
[0017] In a possible implementation, obtaining the statistical value of the color data of pixel points within the unit area includes at least one of the following:
[0018] Obtaining the average value of the color data of each pixel point within the unit area; or,
[0019] Obtaining the color data of the central pixel point within the unit area; or,
[0020] Obtaining the average value of the color data of pixel points at each corner within the unit area.
[0021] In a possible implementation, inserting the grass inserts into the unit area includes:
[0022] Based on the rendering data within the unit area, determining the number of the grass inserts;
[0023] Inserting the determined number of the grass inserts into the unit area.
[0024] In a possible implementation, the rendering data includes the proportion of the grass texture within the unit area, and based on the rendering data of the unit area, determining the number of the grass inserts includes:
[0025] Based on the proportion of the grass texture within the unit area, determining the number of the grass inserts, where the number of the grass inserts is positively correlated with the proportion of the grass texture.
[0026] In a possible implementation, the rendering data includes color data of pixel points within the unit area, and based on the rendering data within the unit area, determining the number of the grass inserts includes:
[0027] Based on the ratio between the color data of the pixel points and the grass color threshold, determining the number of the grass inserts.
[0028] In a possible implementation, based on the ratio between the color data of the pixel points and the grass color threshold, determining the number of the grass inserts includes:
[0029] Determine the number of the grass inserts based on the ratio between the average value of the color data of each pixel point in the unit area and the grass color threshold; or,
[0030] Determine 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,
[0031] Determine the number of the grass inserts based on the ratio between the average value of the color data of the pixel points at each corner in the unit area and the grass color threshold.
[0032] In a possible implementation manner, before obtaining the rendering data in the unit area of the rendering area, the method further includes:
[0033] Determine the rendering area based on the position of the virtual object and a preset radius, where the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.
[0034] In a second aspect, a grassland rendering device is provided, and the device includes:
[0035] An obtaining module, configured to obtain the rendering data in the unit area of the rendering area;
[0036] A determining module, configured to determine that the rendering data of the unit area meets the grassland texture feature;
[0037] A rendering module, configured to insert the grass inserts into the unit area.
[0038] In a possible implementation manner, the rendering data includes the color data of the pixel points in the unit area, and the determining module is configured to determine the number of target pixel points in the unit area based on the color data of the pixel points in the unit area and a grassland color interval, where the color data of the target pixel points belongs to the grassland color interval; and determine that the rendering data of the unit area meets the grassland texture feature based on the number of target pixel points in the unit area.
[0039] In a possible implementation manner, the determining module is configured to determine that the number of target pixel points in the unit area is greater than or equal to a quantity threshold; or determine that the ratio between the number of target pixel points in the unit area and the total number of pixel points in the unit area is greater than or equal to a first ratio threshold.
[0040] In a possible implementation manner, the rendering data includes the color data of the pixel points in the unit area, and the determining module is configured to obtain a statistical value of the color data of the pixel points in the unit area; and determine that the ratio between the statistical value of the color data and the grass color threshold is greater than or equal to a second ratio threshold.
[0041] In a possible implementation, the obtaining module is configured to perform at least one of the following:
[0042] Obtain the average value of the color data of each pixel point in the unit area; or,
[0043] Obtain the color data of the central pixel point in the unit area; or,
[0044] Obtain the average value of the color data of the pixel points at the respective corner points in the unit area.
[0045] In a possible implementation, the determining module is configured to determine the number of the grass inserts based on the rendering data in the unit area; the rendering module is configured to insert the number of the grass inserts into the unit area.
[0046] In a possible implementation, the rendering data includes the proportion of the grass texture in the unit area, and the determining module is configured to determine the number of the grass inserts 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.
[0047] In a possible implementation, the rendering data includes the color data of the pixel points in the unit area, and the determining module is configured to determine the number of the grass inserts based on the ratio between the color data of the pixel points and the grass color threshold.
[0048] In a possible implementation, the determining module is configured to determine the number of the grass inserts based on the ratio between the average value of the color data of each pixel point in the unit area and the grass color threshold; or based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or based on the ratio between the average value of the color data of the pixel points at the respective corner points in the unit area and the grass color threshold.
[0049] In a possible implementation, the determining module is further configured to determine the rendering area based on the position of the virtual object and a preset radius, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.
[0050] In a third aspect, a server is provided, the server includes: a processor, the processor is coupled with a memory, and at least one computer program instruction is stored in the memory, and the at least one computer program instruction is loaded and executed by the processor so that the server implements the method according to the first aspect or any optional implementation manner of the first aspect.
[0051] Fourthly, a computer-readable storage medium is provided. At least one instruction is stored in the storage medium. When the instruction runs on a computer, the computer is enabled to execute the method described in the first aspect or any optional manner of the first aspect above.
[0052] Fifthly, a computer program product is provided. The computer program product includes one or more computer program instructions. When the computer program instructions are loaded and run on a computer, the computer is enabled to execute the method described in the first aspect or any optional manner of the first aspect above.
[0053] Sixthly, a chip is provided. The chip includes a programmable logic circuit and / or program instructions, and is used to implement the method described in the first aspect or any optional manner of the first aspect above when the chip runs.
[0054] Seventhly, a server cluster is provided. The server cluster includes a first server and a second server, and the first server and the second server are used to cooperate to implement the method described in the first aspect or any optional manner of the first aspect above.
[0055] Thus, the embodiments of the present application have the following beneficial effects:
[0056] Since the criterion for determining the insertion of grass inserts is that the rendering data meets the grass texture characteristics, and grass inserts are automatically inserted when the rendering data in a unit area meets the grass texture characteristics, there is no need to manually select the grass area, thus saving the labor cost brought by manually selecting the grass area and improving the rendering efficiency.
[0057] In addition, since the grass inserts can simulate the distribution and shape of plants in real grasslands, after the grass inserts are inserted, the unit area visually presents the characteristics of a grassland, rendering the effect of a grassland, and enhancing the realism and details of the rendering. Description of the Drawings
[0058] Figure 1 is a flowchart of a grassland rendering method provided by an embodiment of the present application;
[0059] Figure 2 is a schematic diagram of a terrain mesh data provided by an embodiment of the present application;
[0060] Figure 3 is a schematic structural diagram of a grassland rendering device provided by an embodiment of the present application;
[0061] Figure 4 is a schematic structural diagram of a server provided by an embodiment of the present application. Detailed Embodiments
[0062] To make the objectives, technical solutions, and advantages of this application more clear, the following will further describe the embodiments of this application in detail with reference to the accompanying drawings.
[0063] Figure 1 It is a flowchart of a grassland rendering method provided by an embodiment of this application. Figure 1 The method shown includes the following steps S110 to step S120.
[0064] Step S110, obtain the rendering data within a unit area in the rendering area.
[0065] The rendering area is the terrain mesh area after rendering. The rendering area can be a sub-area within the terrain mesh area, or in other words, a part of the terrain mesh area. A terrain mesh area includes one or more rendering areas.
[0066] In a possible implementation, divide the terrain mesh area according to a preset rule to obtain one or more rendering areas. For example, determine the size of the rendering area. According to the total size of the terrain mesh area and the size of the rendering area, determine the number of rendering areas to be divided. According to the determined size and number of the rendering areas, divide the complete terrain mesh area. The equal division method can be used to divide the terrain mesh area into rendering areas of the same size. Or the terrain mesh area can be unevenly divided according to specific requirements and terrain features to better adapt to different parts of the terrain. For example, when the terrain changes greatly or has more details, the size of the rendering area can be set smaller to more finely depict the details of the terrain. And when the terrain changes gently or has fewer details, the size of the rendering area can be set larger to reduce the rendering calculation amount.
[0067] By dividing the terrain mesh area into one or more rendering areas, it helps to split the complex terrain rendering process (rendering the entire terrain mesh area) into multiple smaller rendering tasks (rendering one rendering area), thus facilitating parallel processing (such as parallel rendering of multiple rendering areas), and thereby improving the rendering performance and efficiency. By rendering each rendering area, the rendering of the entire terrain mesh area is achieved.
[0068] In another possible implementation manner of determining the rendering area, determine the rendering area from the terrain mesh area as needed. For example, based on the position of the virtual object and a preset radius, determine the rendering area, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.
[0069] The virtual object is, for example, an object in a game. The virtual object is, for example, a virtual character, such as a game character. The game character has a model, animations, and interaction behaviors, and can move freely in the game world and interact with other objects. For another example, the virtual object is a virtual prop item, such as a collectible treasure, weapon, equipment, or other buff item. Or, the virtual object is an enemy or a monster, which is designed to fight or interact with the player in other forms. Or, the virtual object is an environmental object in the game scene, such as a virtual tree, a virtual building, a virtual rock, etc. Or, the virtual object is an NPC (non-player character), which is a virtual object controlled by the game program. The NPC can be a merchant, a resident, or other characters that provide services such as tasks, dialogues, or purchases. The user can interact with the NPC to obtain tasks, get information, or exchange items. Or, the virtual object is a game task objective.
[0070] The position where the virtual object is located is, for example, the two-dimensional coordinates or three-dimensional coordinates of the virtual object. As a possible implementation 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 a sphere, and a radius is set. All pixel points whose distance from the center of the sphere is less than or equal to the radius are selected as the pixel points within 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, if 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 centered at the position of the virtual object with a radius of r. As another possible implementation 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 a rectangle, and a width and a length are set. By calculating the horizontal distance and vertical distance between the virtual object and a certain pixel point, it is determined whether the pixel point is within the rectangular area, thereby determining whether the pixel point belongs to the rendering area. As yet another possible implementation 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 a circle, and a radius is set. Pixel points whose distance from the center of the circle is less than or equal to the radius are selected as the pixel points within the rendering area.
[0071] Since the rendering area is restricted to the area around the virtual object, compared with rendering the entire terrain mesh area, there is no need to render the area far from the virtual object. Therefore, the computational load of the processor for rendering is reduced, the memory space occupied during the rendering process is saved, and the computer hardware requirements for rendering are reduced. In addition, by rendering the grass texture in the area around the virtual character, a distinct contrast is formed between the area around the virtual character and other areas. For example, the green color and rich details of the grass texture can make the virtual character more prominent, helping the player to focus on the virtual character and enhancing the presence of the virtual character in the game scene.
[0072] A unit area refers to a small independent area divided from the rendering area. Each unit area contains a part of the terrain and has a certain size and position. For example, the entire rendering area is divided into unit areas of a fixed size. For example, the size of the unit area is set according to actual needs, such as a square or rectangle. The side length or width and height of each unit area can be a fixed pixel value or based on a relative ratio. For another example, the unit area can be adaptively divided according to the visible range around the virtual object or the camera field of view.
[0073] In a possible implementation, the rendering data includes the color data of the pixels in the unit area. The color data includes the values of multiple color channels. For example, the color data of a pixel includes the value of the pixel in the red channel (Red, referred to as R value), the value of the pixel in the green channel (Green, referred to as G value), the value of the pixel in the blue channel (Blue, referred to as B value), and the value of the pixel in the opaque channel (Alpha value, referred to as A value). The combination of the four parameters of R value, G value, B value and A value is also called RGBA value. For another example, the color data of a pixel includes the value of the pixel in the cyan channel, the value of the pixel in the magenta channel, the value of the pixel in the yellow channel, and the value of the pixel in the black (Key, i.e. K) channel. For another example, the color data of a pixel includes the value of the pixel in the hue channel, the value of the pixel in the saturation channel, and the value of the pixel in the lightness channel. For another example, the color data of a pixel includes the value of the pixel in the hue channel, the value of the pixel in the saturation channel, and the value of the pixel in the value channel.
[0074] Step S120 , in response to determining that the rendering data of the unit area meets the grass texture feature, inserting a grass insert into the unit area.
[0075] 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.
[0076] In a possible implementation of obtaining a grass insert, determine the number of vertices of the grass insert, and based on the number of vertices of the grass insert, create a geometric body with that number of vertices; map the texture of the grass onto the geometric body to obtain a grass insert. Among them, the texture of the grass includes the characteristics of the grass, such as the color, texture and transparency of the grass, etc.
[0077] In a possible implementation of determining that the rendering data of a unit area meets the grassland texture characteristics, based on the color data of the pixel points in the unit area and the grassland color interval, determine the number of target pixel points in the unit area; based on the number of target pixel points in the unit area, determine that the rendering data of the unit area meets the grassland texture characteristics, and insert grass inserts into the unit area.
[0078] The grassland color interval refers to a range used to describe the color characteristics of the grassland. For example, in the RGB space, the grassland color interval can include the ranges of the three components of R, G, and B; in the HSV space, the grassland color interval can include the ranges of components such as H (hue), S (saturation), and V (brightness). In a possible implementation of determining the grassland color interval, sample real grassland pictures to determine the grassland color interval. For example, collect a variety of real grassland pictures, including grassland photos under different scenes and different lighting conditions. Select sample images representing the grassland color from these real grassland pictures, and extract the color data from the sample images as the grassland color interval. Optionally, based on the environmental conditions corresponding to the grassland image, such as factors such as sunlight intensity, shadows, and reflections of surrounding objects, adjust the range of the determined grassland color interval so that the grassland color interval can include the grassland color changes under different environments.
[0079] A target pixel point refers to a pixel point whose color data belongs to the grassland color interval. For example, compare the color data of a pixel point with the upper and lower bounds of the grassland color interval. If the color data of the pixel point is within the grassland color interval, then the pixel point is a target pixel point. Considering that color data is usually defined by multiple color channels, in a possible implementation, compare the values of each color channel in the color data of a pixel point with the upper and lower bounds of the corresponding channel in the grassland color interval. If the values of each color channel in the color data of a pixel point all belong to the upper and lower bounds of the corresponding channel, then the pixel point is a target pixel point. Taking the RGB space as an example, for example, if the value of a pixel point in the red channel is within the upper and lower bounds of the red channel of the grassland color interval, and the value of the pixel point in the green channel is within the upper and lower bounds of the green channel of the grassland color interval, and the value of the pixel point in the blue channel is within the upper and lower bounds of the blue channel of the grassland color interval, then the pixel point is a target pixel point.
[0080] In a possible implementation, each pixel point in the unit area is traversed. For the currently traversed pixel point, if the color data of the pixel point is within the defined grass color range, then the pixel point is determined as the target pixel point, and the count of the recorded target pixel points is incremented by one until the last pixel point in the unit area is traversed, and the count of the recorded target pixel points is output.
[0081] In a possible implementation, the number of target pixel points in the unit area is compared with a quantity threshold. When it is determined that the number of target pixel points in the 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 the grass inserts are inserted into the unit area. When it is determined that the number of target pixel points in the 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 the grass inserts into the unit area. By comparing the number of target pixel points in the 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. And compared with manual processing, it can automatically select the area to be rendered as grass, so it is faster and more accurate.
[0082] In another possible implementation, obtain the ratio between the number of target pixels in a unit area and the total number of pixels in the unit area, and compare the ratio with a first ratio threshold; when the ratio is greater than or equal to the first ratio threshold, determine that the rendering data of the unit area meets the grass texture feature, and insert the grass inserts into the unit area. When the ratio is less than the first ratio threshold, determine that the rendering data of the unit area does not meet the grass texture feature, and there is no need to insert the grass inserts into the unit area. In an exemplary scenario, when rendering a unit area using multiple terrain texture maps (such as 5 terrain texture maps), the proportion of the grass texture map among these multiple terrain texture maps determines whether to insert grass inserts 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, then the proportion of the grass texture will be relatively high. For example, when the first ratio threshold is 20%, when the proportion of the lawn texture is greater than 20%, it indicates that there is enough lawn texture in the unit area, and grass inserts are inserted into the unit area to enhance the realism of the grassland. 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. Moreover, 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, which helps to meet the rendering requirements at different scales. And compared with manual processing, it can automatically select the area to be rendered as grassland, so it is faster and more accurate.
[0083] In a possible implementation, based on the color data of each pixel in a unit area, obtain the statistical value of the color data of the pixels in the unit area, determine the ratio between the statistical value of the color data and the grass color threshold, and compare the ratio between the statistical value of the color data and the grass color threshold with a 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, determine that the rendering data of the unit area meets the grass texture feature, and insert the grass inserts 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, determine that the rendering data of the unit area does not meet the grass texture feature, and there is no need to insert the grass inserts 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 the lawn texture. Taking the second ratio threshold as 20% as an example, if the proportion of the lawn texture is greater than or equal to 20%, then the grass inserts are inserted into the unit area.
[0084] The method for obtaining the statistical value of the color data of the pixel points within the unit area is, for example: obtaining the average value of the color data of each pixel point within the unit area. For example, adding up the color data of all pixel points within the unit area, dividing the sum of the color data by the number of pixel points to obtain the average value of the color data; correspondingly, if the average value of the color data within the unit area is greater than or equal to the second ratio threshold, then insert the grass insert piece into the said unit area. Since the color data of all pixel points within the unit area is utilized, it is equivalent to considering the overall color characteristics of the unit area, thus being more accurate. At the same time, by calculating the average value as the quantization condition for determining whether it should be selected as the grassland area or in other words, inserting the grass insert piece, the influence of noise interference is reduced, making the result relatively smooth and stable.
[0085] Another method for obtaining the statistical value of the color data of the pixel points within the unit area is: obtaining the color data of the central pixel point within the unit area. Correspondingly, if the color data of the central pixel point within the unit area is greater than or equal to the second ratio threshold, then insert the grass insert piece into the said unit area. Since the color data of the central pixel point is utilized without the need to use the color data of all pixel points within the unit area, the amount of data to be processed is reduced, improving the calculation efficiency. And it can better capture the color characteristics of the corners of the unit area, being applicable to the scenario where the grassland edge is relatively obvious.
[0086] Another method for obtaining the statistical value of the color data of the pixel points within the unit area is: obtaining the average value of the color data of the pixel points at each corner within the unit area. For example, obtaining the average value of the color data of the four corner points, namely the upper left corner point, the lower left corner point, the upper right corner point, and the lower right corner point, within the unit area. Correspondingly, if the average value of the color data of the pixel points at each corner within the unit area is greater than or equal to the second ratio threshold, then insert the grass insert piece into the said unit area.
[0087] In another possible implementation, the rendering data includes the texture data of the pixel points within the unit area. It is possible to determine whether to insert the grass insert piece into the unit area according to the texture data of the pixel points within the unit area. The material of the grassland usually has a certain fineness and may include fine texture elements (such as grass leaves, grass stems, etc.). It is possible to detect whether there are texture elements that conform to the grassland characteristics (such as fine and regular textures, such as slender spots, mottled shapes, etc.) in the texture data of the unit area. If there are texture elements that conform to the grassland characteristics in the texture data of the unit area, then determine the said unit area as the grassland area and insert the grass insert piece into the unit area.
[0088] In another possible implementation, the rendering data includes the lighting data of the pixels within the unit area. It is possible to determine whether to insert the grass inserts into the unit area based on the lighting data of the pixels within the unit area. Grass usually exhibits light and dark changes under illumination, with certain specular highlights and shadow effects. It is possible to detect whether there is a lighting distribution and shadow effect that conforms to the characteristics of grass in the lighting data within the unit area, thereby determining whether to insert the grass inserts into the unit area. For example, if the lighting data within the unit area exhibits characteristics of relatively bright light reflection and changes in reflection under different lighting angles, then the unit area is determined as a grassland area, and the grass inserts are 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 grassland texture characteristics. When the unit area meets the grassland texture characteristics, the grass inserts are inserted into the unit area. When the unit area does not meet the grassland texture characteristics, there is no need to insert the grass inserts into the unit area.
[0090] In one possible implementation, based on the rendering data within the unit area, the number of grass inserts is determined; the number of such grass inserts is obtained; and the number of grass inserts is inserted into the unit area. In this way, the number of grass inserts within the unit area is made more matched with the rendering data of the unit area, and the distribution of the grass inserts is made more coordinated with the overall environment of the unit area. Moreover, the number of grass inserts is made more appropriate, reducing the probability of increased rendering burden and performance degradation due to excessive number of inserted grass inserts, and reducing the probability of poor rendering effect due to too few grass inserts.
[0091] In one possible implementation, the rendering data includes the proportion of the grassland texture within the unit area. Based on the proportion of the grassland texture within the unit area, the number of grass inserts is determined. The number of grass inserts is positively correlated with the proportion of the grassland texture. That is, the larger the proportion of the grassland texture, the more the number of grass inserts. Exemplarily, a first mapping relationship between the number of grass inserts and the proportion of the grassland texture is preset. The input parameter of this first mapping relationship includes the proportion of the grassland texture within the unit area, and the output parameter of this first mapping relationship includes the number of grass inserts. Based on the proportion of the grassland texture within the unit area and the first mapping relationship, the number of grass inserts is determined. The first mapping relationship between the number of grass inserts and the proportion of the grassland texture can be a function, which can be a linear first mapping relationship, or a non-linear function such as an exponential function, a logarithmic function, or a piecewise function as the first mapping relationship. Since the number of grass inserts is positively correlated with the proportion of the grassland texture, it is thus possible to simulate the situation in reality where there are more grasses in greener areas of the grassland, making the number of grasses more adaptable to the grassland color.
[0092] In a possible implementation, the rendering data includes color data of pixel points within a unit area. The ratio between the color data of a pixel point and the grass color threshold is obtained, and based on the ratio between the color data of the pixel point 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 a pixel point and the grass color threshold is, for example, distance comparison. For instance, calculate the distance (such as Euclidean distance, difference degree, etc.) between the color value of the pixel point and the grass color threshold, and convert the distance into a ratio. Another method of obtaining the ratio between the color data of a pixel point and the grass color threshold is to calculate the similarity between the color value of the pixel point and the grass color threshold and convert the similarity into a ratio. Another method of obtaining the ratio between the color data of a pixel point and the grass color threshold is to compare the color value of the pixel point with the grass color threshold to obtain a Boolean value, and the Boolean value indicates whether the color value of the pixel point is within the color range indicated by the grass color threshold.
[0093] In a possible implementation, based on the ratio between the average value of the color data of each pixel point within the unit area and the grass color threshold, the number of grass inserts is determined. For example, set a second mapping relationship between the average value of the color data of the pixel point and the number of grass inserts, and based on the average value of the color data of the pixel point and the second mapping relationship, determine the number of grass inserts. Another example is that when the ratio between the average value of the color data of each pixel point within the unit area and the grass color threshold is greater than or equal to a threshold, determine that the number of grass inserts is a first quantity; when the ratio between the average value of the color data of each pixel point within the unit area and the grass color threshold is less than the threshold, determine that the number of grass inserts is a second quantity. The number of grass inserts can be positively correlated with the ratio between the average value of the color data of each pixel point 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, so that more grass will correspond to the greener places of the grassland.
[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 within the unit area and the grass color threshold. For example, a third mapping relationship between the color data of the central pixel point and the number of grass inserts is set, and based on the color data of the central pixel point and the third mapping relationship, the number of grass inserts is determined. Also, when the ratio between the color data of the central pixel point within 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 within 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 can 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 can 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, so that more grass will correspond to the greener areas of the grassland being simulated.
[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 at each corner within the unit area and the grass color threshold. For example, a fourth mapping relationship between the average value of the color data of the pixel points at each corner and the number of grass inserts is set, and based on the average value of the color data of the pixel points at each corner and the fourth mapping relationship, the number of grass inserts is determined. Also, when the ratio between the average value of the color data of the pixel points at each corner 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 at each corner 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 can be positively correlated with the ratio between the average value of the color data of the pixel points at each corner and the grass color threshold. In this way, when the color data of each corner increases, the number of grass inserts will also increase accordingly, so that more grass will correspond to the greener areas of the grassland being simulated.
[0096] In the method provided in this embodiment, since the rendering data meeting the grassland texture characteristics is used as the standard for determining the insertion of grass inserts, grass inserts are automatically inserted when the rendering data of the unit area meets the grassland texture characteristics. Since there is no need to manually select the grassland area, the labor cost brought by manually selecting the grassland area is saved, and the rendering efficiency is improved.
[0097] In addition, when the rendering data of the unit area does not meet the grassland texture characteristics, there is no need to insert grass inserts, which is equivalent to filtering out some areas that are not suitable for inserting grass inserts before inserting the grass inserts, thereby reducing the probability of inserting grass inserts in unnecessary areas, and thus reducing the rendering load and resource consumption.
[0098] In addition, since the grass inserts can simulate the distribution and morphology of plants in real grasslands, after inserting the grass inserts, the unit area visually presents the characteristics of a grassland, rendering the grassland effect and enhancing the realism and details of the rendering.
[0099] The following gives an example of the implementation method for constructing terrain grid data.
[0100] The terrain grid area is a discretized area used to represent the terrain, usually used for terrain rendering and simulation. In computer graphics, the terrain grid area can be regarded as a two-dimensional or three-dimensional grid, composed of a series of adjacent vertices and the edges connecting them. In the two-dimensional case, the terrain grid area is a grid plane composed of a series of vertices and edges. Each vertex represents a point on the terrain surface, and the edges represent the connection relationships between adjacent points. A height value can be assigned to each vertex to simulate the height changes of the terrain. Using an interpolation algorithm, the height of unknown points can be inferred from the known height values to form a smooth terrain model. In the three-dimensional case, the terrain grid area is a grid connected by triangles (or other polygons), similar to the surface of a grid. Each vertex represents a point on the terrain surface, and each triangle represents a small segment of the terrain. A height value can be assigned to each vertex to simulate the height changes of the terrain. By interpolating and smoothing the height values on each triangle, a continuous terrain surface model can be obtained. The fineness of the terrain grid area depends on the resolution of the grid, that is, the number of vertices. A higher resolution can provide a more detailed and realistic terrain representation, but it will also increase the complexity of calculation and rendering. A lower resolution can improve performance but will result in a reduction in the fineness of the terrain surface.
[0101] In a possible implementation, in the selected grid, the height value of each pixel point in the grid and the position information of each pixel point are determined through a preset sequence array. The terrain grid area is constructed based on the height value of the pixel point and the position information of the pixel point.
[0102] In a possible implementation, the representation of the terrain grid data is similar to that of a grayscale image. For example, the height changes of the terrain are represented by the light and dark degrees (gray levels) of the colors in the height topographic map. Specifically, when a certain area in the height topographic map is whiter, it means that the height value of that area is larger, that is, the terrain in that area is higher. On the contrary, when the color of a certain area in the height topographic map is darker or has a deeper color, it means that the height value of that area is smaller, that is, the terrain is lower. For example, please refer to Appendix Figure 2 , Appendix Figure 2 is a schematic diagram of a terrain grid data provided by an embodiment of the present application. By observing Figure 2 the light and dark degrees of the colors in it, the height change situation of the terrain can be intuitively understood.
[0103] A sequence array refers to an array with sequences as data. In other words, each element in the sequence array is data of the sequence type. The number of bits of each element (i.e., sequence) in the sequence array can be set according to the precision requirements. For example, the number of bits of the sequence can be 8 bits or 16 bits, etc. The larger the number of bits of the sequence, the more refined the representation of the height value can be provided. The numerical value of the sequence corresponds to the height value. The sequence is in binary format.
[0104] The storage form of the array means that the distribution of the sequences is ordered. The number of sequence data in each row and each column of the array respectively corresponds to the number of pixel points in the terrain grid. For example, the number of sequence data in each row of the array indicates the number of pixel points in each row of the terrain grid. The number of sequence data in each column of the array indicates the number of pixel points 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 pixel points, and there are 1080 pixel points in each row of the terrain grid and 960 pixel points in each column of the terrain grid. The horizontal distance between each pixel point is the same. Therefore, taking the sequence as the height value of the pixel point can render the height topographic map.
[0105] The following gives an example of the way to construct the rendering area.
[0106] In a possible implementation, based on the vertex data and texture feature configuration in the terrain grid data, the terrain grid area is rendered to obtain the rendering area.
[0107] In a possible implementation, based on the coordinate information and height value of the pixel points in the terrain grid data, the vertex data in the terrain grid data is obtained. Each pixel point in the sampled image is used as a vertex in the terrain grid area. The data of the vertex includes coordinate information and height value, which are subsequently used for vertex texture rendering.
[0108] The server obtains all the vertex data of the terrain grid area, and then performs texture rendering on all the vertices of the terrain grid area according to the texture feature configuration to be rendered.
[0109] Under normal circumstances, texture rendering needs to be performed on the entire terrain mesh area. However, some terrains are too large and, due to hardware limitations, cannot be rendered simultaneously for the entire terrain mesh area at once, or one does not want to occupy too much hardware and thus will not render the terrain mesh area all at once. Therefore, the complete terrain mesh area is divided into multiple rendering areas, and then the multiple rendering areas are rendered sequentially according to a preset rule, thereby achieving the rendering of the entire terrain mesh area. Alternatively, instead of rendering the entire terrain mesh area all at once, one can render specific rendering areas as needed. For example, the rendering area involved within a preset radius centered at the position of a specified virtual character can be used as a specific rendering area for rendering, thereby reducing the hardware requirements for rendering.
[0110] The texture feature configuration uses the terrain texture map as terrain texture data. Specifically, the terrain texture map is parsed to obtain the color distribution data of all pixel points in the terrain texture map. The color data is RGB data, and then this color distribution data is used as terrain texture data (including the number of pixel points and the colors corresponding to the pixel points).
[0111] In one possible implementation, for the terrain mesh area to be rendered, the terrain texture data is tiled within this terrain mesh area so that the entire terrain mesh area is completely rendered.
[0112] Tiling means tiling and filling the terrain texture data (or rather, the terrain texture map) within the terrain mesh area so that the entire surface of the terrain mesh area is completely covered by the terrain texture map.
[0113] In one possible implementation, the tiling precision is adjusted by configuring the tiling degree parameter. For example, if the pixel size of the terrain texture map is 20*20 and it needs to be tiled within a rendering area with a size of 40*40, depending on the tiling degree, a tiling degree of 1:1 can be selected within the 40*40 rendering area. In this case, each pixel point within the 40*40 rendering area is covered and rendered one by one, and the number of terrain texture maps tiled at this time is 4; when a tiling degree of 1:4 is selected, only one-fourth of the pixel points within the 40*40 rendering area are covered, that is, one pixel point out of every 4 pixel points is rendered.
[0114] In one possible implementation, the boundaries between multiple rendering areas in the terrain mesh area are smoothed. Smoothing means processing the boundaries between rendering areas to reduce discontinuities, jaggedness, or obvious transitions, making the rendering boundaries more natural and smooth. The ways of smoothing include but are not limited to at least one of blending seams, texture transitions, normal averaging, vertex scaling, or edge blurring.
[0115] The fusion seam achieves smooth transitions, for example, by fusing the textures, colors, or other properties of adjacent rendering regions. This can be accomplished by drawing a seam area at the boundary and performing operations such as texture interpolation and color blending within the seam area. The seam area can use gradient and transition effects to gradually blend the features of adjacent rendering regions. Texture transition, for example, uses multiple textures and blends them through blending techniques to smooth the boundary between rendering regions. Texture transition can be achieved using techniques such as texture mapping 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, for example, smooths the normal vectors between adjacent rendering regions. By calculating the normal directions of adjacent faces and performing averaging or interpolation, the normal differences can be reduced and the boundary can be made smoother. Using smooth normals can produce a more realistic rendering effect. Vertex scaling, for example, adjusts the vertex positions on the boundary of adjacent rendering regions to make the transition between adjacent regions smooth. Vertex scaling can be achieved through methods such as interpolation or weighting, enabling a smooth transition in the height and shape changes between adjacent regions. Edge blurring, for example, applies a blurring effect around the rendering boundary to reduce edge jaggedness and hard edges. Edge blurring can use algorithms such as Gaussian blur to process the boundary pixels and smoothly blend the colors of the edge pixels with the surrounding pixels.
[0116] In a possible implementation, before performing step S130, the following steps A to C are executed.
[0117] Step A: In the selected grid, determine the height value of each pixel point and the position information of each pixel point in the grid through a preset sequence array. Based on the height value of the pixel point and the position information of the pixel point, construct a terrain grid area.
[0118] A terrain grid region is a discretized region used to represent terrain, commonly used for terrain rendering and simulation. In computer graphics, a terrain grid region can be regarded as a two-dimensional or three-dimensional grid, consisting of a series of adjacent vertices and the edges connecting them. In the two-dimensional case, the terrain grid region is a grid plane composed of a series of vertices and edges. Each vertex represents a point on the terrain surface, and the edges represent the connection relationships between adjacent points. A height value can be assigned to each vertex to simulate the height variations of the terrain. Interpolation algorithms can be used to infer the heights of unknown points based on the known height values to form a smooth terrain model. In the three-dimensional case, the terrain grid region is a grid formed by connecting triangles (or other polygons), similar to the surface of a grid. Each vertex represents a point on the terrain surface, and each triangle represents a small segment of the terrain. A height value can be assigned to each vertex to simulate the height variations of the terrain. By interpolating and smoothing the height values on each triangle, a continuous terrain surface model can be obtained. The fineness of the terrain grid region depends on the resolution of the grid, that is, the number of vertices. A higher resolution can provide a more detailed and realistic terrain representation, but it will also increase the complexity of calculation and rendering. A lower resolution can improve performance but will result in a reduction in the fineness of the terrain surface.
[0119] In a possible implementation, the representation of terrain grid data is similar to a grayscale image. For example, the height variations of the terrain are represented by the light and dark degrees (gray levels) of the colors in a height terrain map. Specifically, the whiter a certain area in the height terrain map is, the larger the height value of that area, which means the terrain in that area is higher. On the contrary, the darker or deeper the color of a certain area in the height terrain map is, the smaller the height value of that area, that is, the terrain is lower. For example, please refer to the attached Figure 4 , the attached Figure 4 is a schematic diagram of a terrain grid data provided by an embodiment of this application. By observing Figure 4 the light and dark degrees of the colors in it, the height variation situation of the terrain can be intuitively understood.
[0120] A sequence array refers to an array with sequences as data. In other words, each element in the sequence array is data of the sequence type. The number of bits of each element (i.e., the sequence) in the sequence array can be set according to the precision requirements. For example, the number of bits of the sequence can be 8 bits or 16 bits, etc. The larger the number of bits of the sequence, the more refined the height value representation can be provided. The value of the sequence corresponds to the height value. The sequence is in binary format.
[0121] The storage form of the array means that the distribution of the sequence is ordered. The number of sequence data in each row and each column of the array respectively corresponds to the number of pixel points in the terrain grid. For example, the number of sequence data in each row of the array indicates the number of pixel points in each row of the terrain grid. The number of sequence data in each column of the array indicates the number of pixel points 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 pixel points, and there are 1080 pixel points in each row of the terrain grid and 960 pixel points in each column of the terrain grid. The horizontal distance between each pixel point is the same. Therefore, by using the sequence as the height value of the pixel point, a height terrain map can be rendered.
[0122] Step B: Based on the coordinate information and height value of the pixel points in the grid, obtain the vertex data in the grid.
[0123] In a possible implementation, each pixel point in the sampled image is used as a vertex in the terrain grid area. The data of the vertex includes coordinate information and height value, which are subsequently used for texture rendering of the vertex.
[0124] Step C: Obtain all the vertex data of the terrain grid area, and then perform texture rendering on all the vertices of the terrain grid area according to the configured texture features to be rendered.
[0125] Optionally, Figure 1 The method shown is executed by a computing device. Or, Figure 1 The method shown is executed collaboratively by a computing device cluster including multiple computing devices. For example, computing device A executes Figure 1 S110 in the method shown, and computing device B executes Figure 1 S120 in the method shown. The computing device is, for example, a terminal or a server. In a possible implementation, Figure 1 The method shown is executed by the computing device by running an application program. The application program is, for example, browser software or client software. This embodiment does not limit Figure 1 the execution entity of the method shown.
[0126] Figure 3 It is a schematic structural diagram of a grassland rendering device provided by an embodiment of the present application. Figure 3 The device 200 shown includes:
[0127] An acquisition module 210, configured to acquire rendering data within a unit area in the rendering area;
[0128] A determination module 220, configured to determine that the rendering data of the unit area meets the grassland texture features;
[0129] A rendering module 230, configured to insert grass inserts into the unit area.
[0130] In a possible implementation, the rendering data includes the color data of the pixel points in the unit area. The determining module 220 is configured to determine the number of target pixel points in the unit area based on the color data of the pixel points in the unit area and the grass color range, where the color data of the target pixel points belongs to the grass color range; and determine that the rendering data of the unit area meets the grass texture feature based on the number of target pixel points in the unit area.
[0131] In a possible implementation, the determining module 220 is configured to determine that the number of target pixel points in the unit area is greater than or equal to the number threshold; or determine that the ratio between the number of target pixel points in the unit area and the total number of pixel points in the unit area is greater than or equal to the first ratio threshold.
[0132] In a possible implementation, the rendering data includes the color data of the pixel points in the unit area. The determining module 220 is configured to obtain the statistical value of the color data of the pixel points in the unit area; and determine that 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.
[0133] In a possible implementation, the obtaining module 210 is configured to perform at least one of the following:
[0134] Obtain the average value of the color data of each pixel point in the unit area; or,
[0135] Obtain the color data of the central pixel point in the unit area; or,
[0136] Obtain the average value of the color data of the pixel points at each corner point in the unit area.
[0137] In a possible implementation, the determining module 220 is configured to determine the number of grass inserts based on the rendering data in the unit area; and the rendering module 230 is configured to insert the number of grass inserts into the unit area.
[0138] In a possible implementation, the rendering data includes the proportion of the grass texture in the unit area. The determining module 220 is configured to determine the number of grass inserts based on the proportion of the grass texture in the unit area, and the number of grass inserts is positively correlated with the proportion of the grass texture.
[0139] In a possible implementation, the rendering data includes the color data of the pixel points in the unit area. The determining module 220 is configured to determine the number of grass inserts based on the ratio between the color data of the pixel points and the grass color threshold.
[0140] In a possible implementation, a determination module 220 is configured to determine the number of grass inserts based on the ratio between the average value of the color data of each pixel point within a unit area and a grass color threshold; or determine the number of grass inserts based on the ratio between the color data of the central pixel point within a unit area and the grass color threshold; or determine the number of grass inserts based on the ratio between the average value of the color data of the pixel points at each corner within a unit area and the grass color threshold.
[0141] 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, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius.
[0142] When rendering the terrain, the terrain rendering device provided in the above embodiments is only illustrated by taking the division of the above functional modules as an example. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the terrain rendering device is divided into different functional modules to complete all or part of the functions described above. In addition, the terrain rendering device provided in the above embodiments and the embodiments of the terrain rendering method belong to the same concept. For the specific implementation process, please refer to the method embodiments, which will not be elaborated here.
[0143] Figure 4 FIG. 10 is a schematic structural diagram of a server provided in an embodiment of the present application. The server 300 includes: a processor 301, the processor 301 is coupled to a memory 302, and at least one computer program instruction is stored in the memory 302. The at least one computer program instruction is loaded and executed by the processor 301 so that the server 300 implements Figure 1 the method provided in the embodiment.
[0144] The embodiments in this specification are all described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments.
[0145] A refers to B, which means that A is the same as B or A is a simple deformation of B.
[0146] 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 the objects, nor can they be understood as indicating or implying relative importance. For example, the first ratio threshold and the second ratio threshold are used to distinguish different ratio thresholds, rather than to describe a specific order of the ratio thresholds, nor can it be understood that the first ratio threshold is more important than the second ratio threshold.
[0147] 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 processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0148] The above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A grassland rendering method, characterized in that, The method comprises: Determine a rendering area based on the position of the virtual object and a preset radius, wherein the center of the rendering area is the position of the virtual object, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius; Acquire color data of pixels in a unit area of the rendering area and a proportion of grass texture in the unit area, wherein the color data includes values of multiple color channels; Determine the number of target pixels in the unit area based on the color data of the pixels in the unit area and the grass color interval, wherein the value of each color channel in the color data of the target pixels is within the upper and lower limits of the interval corresponding to the color channel in the grass color interval; Determining, based on the number of target pixels in the unit area, that the rendering data of the unit area meets the grass texture feature; Determining the number of grass inserts based on the proportion of grass texture in the unit area or color data of pixels in the unit area, wherein the grass inserts are small sheet-shaped elements used to represent grass; Insert the number of grass inserts into the unit area.
2. The method according to claim 1, wherein The determining, based on the number of target pixels in the unit area, that the rendering data of the unit area meets the grass texture feature includes: Determine that the number of target pixels in the unit area is greater than or equal to a number threshold; or, It is determined that a ratio between the number of target pixels in the unit area and the total number of pixels in the unit area is greater than or equal to a first ratio threshold.
3. The method according to claim 1, characterized in that, The method further comprises: Obtaining statistical values of color data of pixels within the unit area; Based on the ratio between the statistical value of the color data and the grass color threshold being greater than or equal to a second ratio threshold, it is determined that the rendering data of the unit area meets the grass texture feature.
4. The method according to claim 3, wherein The obtaining of the statistical value of the color data of the pixels in the unit area includes at least one of the following: Obtaining the average value of the color data of each pixel in the unit area; or, Acquire the color data of the central pixel point in the unit area; or, The average value of the color data of the pixel points at each corner point in the unit area is obtained.
5. The method according to claim 1, wherein The number of the grass inserts is positively correlated with the proportion of the grass texture.
6. The method according to claim 1, wherein The determining the number of grass inserts based on the proportion of grass texture in the unit area or the color data of pixels in the unit area includes: determining the number of grass inserts based on a ratio between the color data of the pixel point and a grass color threshold; When the ratio is greater than or equal to a threshold, the number of the grass inserts is a first number, and when the ratio is less than the threshold, the number of the grass inserts is a second number; The step of determining the number of grass inserts based on the ratio between the color data of the pixel point and the grass color threshold value includes: determining the number of the grass inserts based on the ratio between the average value of the color data of each pixel point in the unit area and the 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. A grassland rendering device, characterized in that, include: A determination module, configured to determine a rendering area based on the position of the virtual object and a preset radius, wherein the center of the rendering area is the position of the virtual object, and the difference between the boundary of the rendering area and the position of the virtual object is the preset radius; An acquisition module, used to acquire color data of pixels in a rendering area and a proportion of grass texture in a unit area, wherein the color data includes values of multiple color channels; The determination module is further used to determine the number of target pixels in the unit area based on the color data of the pixels in the unit area and the grass color interval, wherein the value of each color channel in the color data of the target pixels is within the upper and lower limits of the interval corresponding to the color channel of the grass color interval; and determine that the rendering data of the unit area meets the grass texture feature based on the number of target pixels in the unit area; Determining the number of grass inserts based on the proportion of grass texture in the unit area or color data of pixels in the unit area, wherein the grass inserts are small sheet-shaped elements used to represent grass; A rendering module is used to insert the number of grass inserts into the unit area.
8. 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 6.
9. 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 6.
Citation Information
Patent Citations
Image processing method and device, equipment and medium
CN114549733A
Method and device for constructing insert combination model and electronic equipment
CN115738246A
Terrain model rendering method and device, electronic equipment and readable storage medium
CN116402932A