[go: up one dir, main page]

CN117475053A - Grass rendering method and device - Google Patents

Grass rendering method and device Download PDF

Info

Publication number
CN117475053A
CN117475053A CN202311172742.8A CN202311172742A CN117475053A CN 117475053 A CN117475053 A CN 117475053A CN 202311172742 A CN202311172742 A CN 202311172742A CN 117475053 A CN117475053 A CN 117475053A
Authority
CN
China
Prior art keywords
grass
rendering
unit area
area
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311172742.8A
Other languages
Chinese (zh)
Other versions
CN117475053B (en
Inventor
刘立
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Yiju Future Network Technology Co ltd
Original Assignee
Guangzhou Yiju Future Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Yiju Future Network Technology Co ltd filed Critical Guangzhou Yiju Future Network Technology Co ltd
Priority to CN202311172742.8A priority Critical patent/CN117475053B/en
Publication of CN117475053A publication Critical patent/CN117475053A/en
Application granted granted Critical
Publication of CN117475053B publication Critical patent/CN117475053B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Graphics (AREA)
  • Image Generation (AREA)

Abstract

The application discloses a grassland rendering method and device, which acquire a rendering center in a rendering area; determining 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 inversely related to the rendering distance; a grass blade is inserted into the unit area. The method reduces the risk of processing expenditure caused by excessive number of the vertexes of the rendering due to more vertexes of each inserted grass insert sheet, also reduces the risk of poor rendering effect caused by excessive number of the vertexes of the rendering due to too few vertexes of each inserted grass insert sheet, gives consideration to the rendering effect and the processing expenditure of the rendering, improves the performance and the resource utilization efficiency of a computer as far as possible without sacrificing the rendering effect, and improves the density of grass at the same time, so that the virtual scene is more vivid and fine.

Description

草地渲染方法及装置Grass rendering method and device

技术领域Technical field

本申请涉及计算机技术领域,具体涉及一种草地渲染方法及装置。The present application relates to the field of computer technology, and specifically to a grass rendering method and device.

背景技术Background technique

为了在地形中渲染出草地的效果,通常会人工在渲染区域中选定渲染区域,在选定的渲染区域中插入草插片。每个草插片是顶点数量固定的多边形网格。例如,要么插入的每个草插片均是具有三个顶点的三角形,要么插入的每个草插片均是四个顶点和两个三角形构成的菱形。In order to render the effect of grass in the terrain, the rendering area is usually manually selected in the rendering area and grass inserts are inserted into the selected rendering area. Each grass patch is a polygon mesh with a fixed number of vertices. For example, either each inserted grass patch is a triangle with three vertices, or each inserted grass patch is a rhombus with four vertices and two triangles.

然而,在采用上述方法时,如果插入的每个草插片均是具有三个顶点的三角形,会导致渲染效果较差,难以逼真地模拟草的形态;如果插入的每个草插片均是具有四个顶点的菱形,则计算设备中负责进行渲染的硬件所需渲染的顶点数量过多,导致计算设备由于渲染产生的处理开销过大。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 simulate the shape of grass realistically; if each inserted grass insert is a triangle For 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 rendering on the computing device.

有鉴于此,在渲染草地的场景下,针对如何一定程度上兼顾渲染效果以及渲染的处理开销,还需要进一步研究讨论。In view of this, in the scene of rendering grass, further research and discussion are needed on how to take into account the rendering effect and rendering processing overhead to a certain extent.

发明内容Contents of the invention

本申请提供了一种草地渲染方法及装置,能够一定程度上兼顾渲染效果以及渲染的处理开销。所述技术方案如下。This application provides a grassland rendering method and device, which can take into account the rendering effect and rendering processing overhead to a certain extent. The technical solution is as follows.

第一方面,提供了一种草地渲染方法,所述方法包括:In a first aspect, a grass rendering method is provided, and the method includes:

获取渲染区域中的渲染中心;Get the rendering center in the rendering area;

基于所述渲染区域中单位区域与所述渲染中心之间的渲染距离,确定草插片,所述草插片包括至少一个顶点,所述草插片中的顶点数量与所述渲染距离负相关;Based on the rendering distance between the unit area in the rendering area and the rendering center, a grass patch is determined, the grass patch includes at least one vertex, and the number of vertices in the grass patch is negatively related to the rendering distance. ;

向所述单位区域中插入所述草插片。Insert the grass insert into the unit area.

在一种可能的实现方式中,所述草插片包括第一草插片以及第二草插片,所述第一草插片中的顶点数量大于所述第二草插片中的顶点数量,所述基于所述渲染区域中单位区域与所述渲染中心之间的渲染距离,确定草插片,包括:In a possible implementation, the grass insert includes a first grass insert and a second grass insert, and the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert. , the step of determining grass inserts 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 patch; or,

响应于确定所述渲染距离大于或等于距离阈值,确定所述第二草插片。The second grass insert is determined in response to determining that the rendering distance is greater than or equal to a distance threshold.

在一种可能的实现方式中,所述基于所述渲染区域中单位区域与所述渲染中心之间的渲染距离,确定草插片,包括:In a possible implementation, determining 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 correspondence, the first correspondence indicates a correspondence between the rendering distance and a first number, the number of vertices in the grass patch is the third A quantity.

在一种可能的实现方式中,所述向所述单位区域中插入所述草插片,包括:In a possible implementation, inserting the grass insert into the unit area includes:

基于所述单位区域内的渲染数据,确定所述草插片的数量;Determine the number of grass inserts based on the rendering data within the unit area;

向所述单位区域中插入所述数量的所述草插片。The said number of said grass inserts are inserted into said unit area.

在一种可能的实现方式中,所述渲染数据包括所述单位区域内草地纹理的占比,所述基于所述单位区域的渲染数据,确定所述草插片的数量,包括:In a possible implementation, the rendering data includes the 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 grass inserts is determined based on the proportion of grass texture in the unit area, and the number of grass inserts is positively related to the proportion of grass texture.

在一种可能的实现方式中,所述渲染数据包括所述单位区域内像素点的颜色数据,所述基于所述单位区域内的渲染数据,确定所述草插片的数量,包括: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:

基于所述像素点的颜色数据与草地颜色阈值之间的比值,确定所述草插片的数量。The number of grass inserts is determined based on the ratio between the color data of the pixel and the grass color threshold.

在一种可能的实现方式中,所述基于所述像素点的颜色数据与草地颜色阈值之间的比值,确定所述草插片的数量,包括:In a possible implementation, determining the number of grass inserts based on the ratio between the color data of the pixel and the grass color threshold includes:

基于所述单位区域内每个像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定所述草插片的数量;或者,Determine the number of grass inserts based on the ratio between the average color data of each pixel in the unit area and the grass color threshold; or,

基于所述单位区域内中心像素点的颜色数据与草地颜色阈值之间的比值,确定所述草插片的数量;或者,Determine the number of grass inserts based on the ratio between the color data of the central pixel in the unit area and the grass color threshold; or,

基于所述单位区域内各个角点的像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定所述草插片的数量。The number of grass inserts is determined based on the ratio between the average color data of the pixels at each corner point in the unit area and the grass color threshold.

在一种可能的实现方式中,所述基于所述渲染区域中单位区域与所述渲染中心之间的渲染距离,确定草插片之前,所述方法还包括: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:

确定所述单位区域的渲染数据满足草地纹理特征。It is determined that the rendering data of the unit area satisfies the grass texture characteristics.

在一种可能的实现方式中,所述获取渲染区域中的渲染中心之前,所述方法还包括:In a possible implementation, before obtaining the rendering center in the rendering area, the method further includes:

基于虚拟对象所处的位置以及预设半径,确定渲染区域,所述渲染区域的边界与所述虚拟对象所处的位置之差为所述预设半径。A rendering area is determined based on the location of the virtual object and a preset radius, and the difference between the boundary of the rendering area and the location of the virtual object is the preset radius.

在一种可能的实现方式中,所述获取渲染区域中的渲染中心,包括:In a possible implementation, obtaining the rendering center in the rendering area includes:

获取虚拟对象所处的位置,作为渲染中心。Get the position of the virtual object as the rendering center.

第二方面,提供了一种草地渲染装置,所述装置包括:In a second aspect, a grass rendering device is provided, which device includes:

获取模块,用于获取渲染区域中的渲染中心;Get module, used to get the rendering center in the rendering area;

确定模块,用于基于所述渲染区域中单位区域与所述渲染中心之间的渲染距离,确定草插片,所述草插片包括至少一个顶点,所述草插片中的顶点数量与所述渲染距离负相关;Determining module, configured to determine grass inserts based on the rendering distance between the unit area in the rendering area and the rendering center. The grass inserts include at least one vertex, and the number of vertices in the grass inserts is equal to the number of vertices in the grass inserts. The rendering distance is negatively related;

渲染模块,用于向所述单位区域中插入所述草插片。A rendering module, configured to insert the grass insert into the unit area.

在一种可能的实现方式中,所述草插片包括第一草插片以及第二草插片,所述第一草插片中的顶点数量大于所述第二草插片中的顶点数量,所述确定模块,用于响应于确定所述渲染距离小于或等于距离阈值,确定所述第一草插片;或者,响应于确定所述渲染距离大于或等于距离阈值,确定所述第二草插片。In a possible implementation, the grass insert includes a first grass insert and a second grass insert, and the number of vertices in the first grass insert is greater than the number of vertices in the second grass insert. , the determination module is configured to determine the first grass patch in response to determining that the rendering distance is less than or equal to a distance threshold; or, in response to determining that the rendering distance is greater than or equal to a distance threshold, determine the second Grass inserts.

在一种可能的实现方式中,所述确定模块,用于基于所述渲染距离以及第一对应关系,确定草插片,所述第一对应关系指示所述渲染距离以及第一数量之间的对应关系,所述草插片中的顶点数量为所述第一数量。In a possible implementation, the determining module is configured to determine grass inserts based on the rendering distance and a first correspondence, the first correspondence indicating the rendering distance and a first number of Correspondingly, the number of vertices in the grass insert is the first number.

在一种可能的实现方式中,所述确定模块,用于基于所述单位区域内的渲染数据,确定所述草插片的数量;所述渲染模块,用于向所述单位区域中插入所述数量的所述草插片。In a possible implementation, the determining module is used to determine the number of grass inserts based on the rendering data in the unit area; the rendering module is used to insert all the grass inserts into the unit area. The stated number of said grass inserts.

在一种可能的实现方式中,所述渲染数据包括所述单位区域内草地纹理的占比,所述确定模块,用于基于所述单位区域内草地纹理的占比,确定所述草插片的数量,所述草插片的数量与所述草地纹理的占比正相关。In a possible implementation, the rendering data includes a proportion of grass texture in the unit area, and the determination module is configured to determine the grass insert based on the proportion of grass texture in the unit area. The number of grass inserts is positively related to the proportion of the grass texture.

在一种可能的实现方式中,所述渲染数据包括所述单位区域内像素点的颜色数据,所述确定模块,用于基于所述像素点的颜色数据与草地颜色阈值之间的比值,确定所述草插片的数量。In a possible implementation, the rendering data includes color data of pixels in the unit area, and the determination module is configured to determine based on the ratio between the color data of the pixels and the grass color threshold. The number of grass inserts.

在一种可能的实现方式中,所述确定模块,用于基于所述单位区域内每个像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定所述草插片的数量;或者,基于所述单位区域内中心像素点的颜色数据与草地颜色阈值之间的比值,确定所述草插片的数量;或者,基于所述单位区域内各个角点的像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定所述草插片的数量。In a possible implementation, the determination module is configured to determine the number of grass inserts based on the ratio between the average color data of each pixel in the unit area and the grass color threshold; Or, determine the number of grass inserts based on the ratio between the color data of the central pixel in the unit area and the grass color threshold; or, determine the number of grass inserts based on the color data of the pixels at each corner point in the unit area. The ratio between the average and the grass color threshold determines the number of grass inserts.

在一种可能的实现方式中,所述确定模块,用于确定所述单位区域的渲染数据满足草地纹理特征。In a possible implementation, the determination module is configured to determine that the rendering data of the unit area satisfies grass texture characteristics.

在一种可能的实现方式中,所述确定模块,还用于基于虚拟对象所处的位置以及预设半径,确定渲染区域,所述渲染区域的边界与所述虚拟对象所处的位置之差为所述预设半径。In a possible implementation, the determination module is also used to determine the rendering area based on the location of the virtual object and the preset radius. The difference between the boundary of the rendering area and the location of the virtual object is the preset radius.

在一种可能的实现方式中,所述获取模块,用于获取虚拟对象所处的位置,作为渲染中心。In a possible implementation, the obtaining module is used to obtain the position of the virtual object as a rendering center.

第三方面,提供了一种服务器,所述服务器包括:处理器,所述处理器与存储器耦合,所述存储器中存储有至少一条计算机程序指令,所述至少一条计算机程序指令由所述处理器加载并执行,以使所述服务器实现上述第一方面或第一方面任一种可选方式所述的方法。In a third aspect, a server is provided. The server includes: a processor, the processor is coupled to a memory, and at least one computer program instruction is stored in the memory. The at least one computer program instruction is generated by the processor. Load and execute, so that the server implements the method described in the above first aspect or any optional method of the first aspect.

第四方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令,所述指令在计算机上运行时,使得计算机执行上述第一方面或第一方面任一种可选方式所述的方法。In a fourth aspect, a computer-readable storage medium is provided. At least one instruction is stored in the storage medium. When the instruction is run on a computer, it causes the computer to execute the above-mentioned first aspect or any one of the first optional aspects. method as described.

第五方面,提供了一种计算机程序产品,所述计算机程序产品包括一个或多个计算机程序指令,当所述计算机程序指令被计算机加载并运行时,使得所述计算机执行上述第一方面或第一方面任一种可选方式所述的方法。In a fifth aspect, 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 by a computer, they cause the computer to execute the first aspect or the third aspect. On the one hand, the method described in any of the optional ways.

第六方面,提供一种芯片,该芯片包括可编程逻辑电路和/或程序指令,当该芯片运行时用于实现如上述第一方面或第一方面任一种可选方式所述的方法。In a sixth aspect, a chip is provided. The chip includes programmable logic circuits and/or program instructions. When the chip is run, it is used to implement the method described in the above-mentioned first aspect or any alternative method of the first aspect.

第七方面,提供一种服务器集群,该服务器集群包括第一服务器以及第二服务器,第一服务器以及第二服务器用于协同实现如上述第一方面或第一方面任一种可选方式所述的方法。A seventh aspect provides a server cluster. The server cluster includes a first server and a second server. The first server and the second server are used to collaboratively implement the above-mentioned first aspect or any optional method of the first aspect. Methods.

由此可见,本申请实施例具有如下有益效果:It can be seen that the embodiments of the present application have the following beneficial effects:

由于草插片中的顶点数量与所述渲染距离负相关,距离渲染中心越远的单位区域可以插入较少的草插片数量越少,距离渲染中心越近的单位区域插入的草插片数量越多,从而降低插入的每个草插片都有较多的顶点导致渲染的顶点数量过多造成渲染产生的处理开销的风险,也降低插入的每个草插片的顶点过少导致渲染的顶点数量过多造成渲染效果较差的风险,兼顾渲染效果以及渲染的处理开销,尽可能在不牺牲渲染效果的情况下,提高计算机的性能和资源利用效率,同时提高草的密度,使得虚拟场景更加逼真和细致。Since the number of vertices in the grass patch is inversely related to the rendering distance, the farther the unit area is from the rendering center, the smaller the number of grass inserts that can be inserted, and the unit area closer to the rendering center can insert the number of grass inserts. The more vertices are inserted, the risk of processing overhead caused by too many vertices being rendered will be reduced, and the risk of rendering processing overhead caused by too few vertices being inserted for each grass insert will be reduced. Excessive number of vertices leads to the risk of poor rendering effect. Taking into account the rendering effect and rendering processing overhead, try to improve the computer performance and resource utilization efficiency without sacrificing the rendering effect, and at the same time increase the density of grass to make the virtual scene More realistic and detailed.

附图说明Description of the drawings

图1是本申请实施例提供的一种草地渲染方法的流程图;Figure 1 is a flow chart of a grass rendering method provided by an embodiment of the present application;

图2是本申请实施例提供的一种地形网格数据的示意图;Figure 2 is a schematic diagram of terrain grid data provided by an embodiment of the present application;

图3是本申请实施例提供的一种草地渲染装置的结构示意图;Figure 3 is a schematic structural diagram of a grass rendering device provided by an embodiment of the present application;

图4是本申请实施例提供的一种服务器的结构示意图。Figure 4 is a schematic structural diagram of a server provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

图1是本申请实施例提供的一种草地渲染方法的流程图。图1所示方法包括如下步骤S110至步骤S130。Figure 1 is a flow chart of a grass rendering method provided by an embodiment of the present application. The method shown in Figure 1 includes the following steps S110 to S130.

步骤S110,获取渲染区域中的渲染中心。Step S110: Obtain the rendering center in the rendering area.

渲染区域可以是地形网格区域中的子区域。一个地形网格区域包括一个或多个渲染区域。在一种可能的实现中,按照预设规则对地形网格区域进行划分,得到一个或多个渲染区域。The rendering area can be a sub-area within the terrain grid area. A terrain grid area consists of one or more rendering areas. In one possible implementation, the terrain grid area is divided according to preset rules to obtain one or more rendering areas.

在确定渲染区域的一种可能实现方式中,确定渲染区域的尺寸。根据地形网格区域的总尺寸以及渲染区域的尺寸,确定需要划分的渲染区域的数量。根据确定的渲染区域大小和数量,对完整的地形网格区域进行划分。可以使用均等划分的方法,将地形网格区域分割为尺寸相同的渲染区域。也可以根据特定需求和地形特征将地形网格区域进行不均匀划分,以更好地适应地形的不同部分。例如,当地形变化较大或者细节较多时,可以将渲染区域的尺寸设置得较小,以更精细地描绘地形的细节。而当地形变化较平缓或者细节较少时,可以将渲染区域的尺寸设置得较大,以减少渲染的计算量。In one possible implementation of determining the rendering area, the size of the rendering area is determined. Determine the number of rendering areas that need to be divided based on the total size of the terrain grid area and the size of the rendering area. The complete terrain grid area is divided according to the determined size and number of rendering areas. You can use the equal division method to divide the terrain grid area into rendering areas of the same size. Terrain grid areas can also be divided unevenly based on specific needs and terrain characteristics to better fit different parts of the terrain. For example, when the terrain changes greatly or there are many details, the size of the rendering area can be set smaller to depict the details of the terrain more finely. When the terrain changes slowly or there are few details, the size of the rendering area can be set larger to reduce the amount of rendering calculations.

通过将地形网格区域划分出一个或多个渲染区域,有助于将复杂的地形渲染过程(针对整个地形网格区域进行渲染)拆分为多个较小的渲染任务(针对一个渲染区域进行渲染),从而便于并行处理(例如并行渲染多个渲染区域),从而提高渲染性能和效率。通过对每个渲染区域均进行渲染,从而实现整个地形网格区域的渲染。By dividing the terrain grid area into one or more rendering areas, it helps to split the complex terrain rendering process (rendering for the entire terrain grid area) into multiple smaller rendering tasks (rendering for one rendering area). rendering), thereby facilitating parallel processing (such as rendering multiple rendering areas in parallel), thereby improving rendering performance and efficiency. By rendering each rendering area, the entire terrain grid area is rendered.

在确定渲染区域的另一种可能实现方式中,根据需要从地形网格区域中确定渲染区域。例如,基于虚拟对象在地形网格区域所处的位置以及预设半径,从地形网格区域确定渲染区域,渲染区域的边界与虚拟对象所处的位置之差为预设半径。可选地,在地形网格区域中存在N个虚拟对象的情况下,基于N个虚拟对象确定N个渲染区域,N个渲染区域中第i个渲染区域包括第i个虚拟对象,其中N为大于或等于1的正整数,i为小于或等于N的正整数。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 the 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 among the N rendering areas includes the i-th virtual object, where N is A positive integer greater than or equal to 1, i is a positive integer less than or equal to N.

虚拟对象例如是游戏中的对象。虚拟对象例如是虚拟人物,例如虚拟对象为游戏角色。游戏角色具有模型、动画和交互行为,可以在游戏世界中自由移动和与其他对象进行互动。又如,虚拟对象为虚拟道具物品,例如虚拟对象为可收集的宝藏、武器、装备或其他增益物品。或者,虚拟对象是敌人或怪物,敌人或怪物被设计为与玩家进行战斗或其他形式的交互。或者,虚拟对象是游戏场景中的环境物体,例如虚拟树木、虚拟建筑物、虚拟岩石等。或者,虚拟对象是NPC(非玩家角色),NPC是由游戏程序控制的虚拟对象。NPC可以是提供任务、对话或购买等服务的商人、居民或其他角色,用户可以与NPC进行互动,获取任务、获得信息或交换物品。或者,虚拟对象是游戏任务目标。Virtual objects are, for example, objects in a game. The virtual object is, for example, a virtual character, for example, the virtual object is a game character. Game characters have models, animations, and interactive behaviors that allow them to move freely in the game world and interact with other objects. For another example, the virtual object is a virtual prop item, for example, the virtual object is a collectible treasure, weapon, equipment or other gain item. Alternatively, the virtual object is an enemy or monster designed to engage in combat or other forms of interaction with the player. Alternatively, the virtual object is an environmental object in the game scene, such as virtual trees, virtual buildings, virtual rocks, etc. Alternatively, the virtual object is an NPC (non-player character), and the NPC is a virtual object controlled by the game program. NPCs can be merchants, residents, or other characters that provide services such as tasks, conversations, or purchases. Users can interact with NPCs to obtain tasks, obtain information, or exchange items. Alternatively, the virtual object is a game mission goal.

虚拟对象所处的位置例如为虚拟对象的二维坐标或者三维坐标。作为基于虚拟对象所处的位置确定渲染区域的一种可能实现方式,使用虚拟对象的位置作为球心,设置一个半径,将所有与球心距离小于等于半径的像素点被选取为渲染区域内的像素点。像素点与球心的距离可以通过计算欧几里得距离获得。例如,虚拟对象的位置为(x,y,z),预设半径为r,那么渲染区域的边界可以定义为一个以虚拟对象位置为中心,半径为r的球形区域。作为基于虚拟对象所处的位置确定渲染区域的另一种可能实现方式,使用虚拟对象的位置作为矩形中心点,设置一个宽度和长度,通过计算虚拟对象与某个像素点的横向距离和纵向距离来判断该像素点是否在矩形区域内,从而确定该像素点是否属于渲染区域。作为基于虚拟对象所处的位置确定渲染区域的再一种可能实现方式,使用虚拟对象的位置作为圆心,设置一个半径,将与圆心距离小于等于半径的像素点被选取为渲染区域内的像素点。The location of the virtual object is, for example, the two-dimensional coordinates or the three-dimensional coordinates of the virtual object. As a possible implementation method to determine the rendering area based on the position of the virtual object, use the position of the virtual object as the center of the sphere, set a radius, and select all pixels that are less than or equal to the radius from the center of the sphere as within the rendering area. pixel. The distance between a pixel 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 with the virtual object position as the center and a radius of r. As another possible way to determine the rendering area based on the position of the virtual object, use the position of the virtual object as the center point of the rectangle, set a width and length, and calculate the horizontal and vertical distances between the virtual object and a certain pixel. To determine whether the pixel is within the rectangular area, thereby determining whether the pixel belongs to the rendering area. As another possible way to determine the rendering area based on the position of the virtual object, use the position of the virtual object as the center of the circle, set a radius, and select pixels that are less than or equal to the radius from the center of the circle as pixels in the rendering area. .

由于将渲染区域限制在虚拟对象周围的区域,相较于对整个地形网格区域都进行渲染而言,不需要对远离虚拟对象的区域进行渲染,因此降低了处理器渲染的计算量,节省渲染过程占用的内存空间,降低渲染所需的计算机硬件要求。此外,通过将虚拟人物周围的区域渲染草地纹理,使得虚拟人物周围的区域与其他区域形成鲜明对比,比如草地纹理的绿色和丰富细节可以使虚拟人物更加显眼,有助于玩家将注意力集中在虚拟人物身上,提升虚拟人物在游戏场景中的存在感。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 areas far away from the virtual object, thus reducing the calculation amount of processor rendering and saving rendering time. The memory space occupied by the process reduces the computer hardware requirements required for rendering. In addition, by rendering the area around the avatar with a grass texture, the area around the avatar is in sharp contrast with other areas. For example, the green color and rich details of the grass texture can make the avatar more conspicuous and help players focus on On virtual characters, it enhances the presence of virtual characters in the game scene.

在一种可能的实现方式中,获取虚拟对象在渲染区域所处的位置,将虚拟对象在渲染区域所处的位置作为渲染中心。通过将虚拟对象在渲染区域所处的位置作为渲染中心,在基于虚拟对象所处的位置确定渲染区域的情况下,由于之前将地形网格区域划分为多个渲染区域的时候,也是用到了虚拟对象所在位置的参数,因此在确定渲染中心时可以直接复用之前获取到的虚拟对象的位置,而无需再次获取虚拟对象的的位置,降低了数据处理的量,从而提高了效率。In one 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 determining the rendering area based on the position of the virtual object, virtual objects were also used when the terrain grid area was divided into multiple rendering areas. Parameters of the location of the object, so when determining the rendering center, the previously obtained position of the virtual object can be directly reused without having to obtain the position of the virtual object again, which reduces the amount of data processing and thus improves efficiency.

步骤S120,基于渲染区域中单位区域与渲染中心之间的渲染距离,确定草插片。Step S120, determine the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center.

草插片为用来表示草地的小片状元素。草插片代表着真实草地中的一小片草丛或草叶。草插片通常采用平面或近似平面的几何形状。草插片包括至少一个顶点。例如,一个草插片可以具有四个顶点,草插片可以具有菱形的几何形状或者矩形的几何形状。一个草插片也可以具有三个顶点,草插片可以具有三角形的几何形状。当然,三个顶点以及四个顶点仅是草插片的顶点数量的举例,一个草插片也可以具有五个顶点,草插片可以具有一个不规则的多边形形状,或者,一个草插片也可以具有六个顶点,草插片可以凸六边形的形状。草插片也可以为3D模型。Grass inserts are small patch-like elements used to represent grass. A grass insert represents a small clump or blade of grass in a real meadow. Grass inserts usually have a flat or nearly flat geometry. Grass inserts include at least one vertex. For example, a grass patch can have four vertices, and a grass patch can have a rhombus geometry or a rectangle geometry. A grass patch can also have three vertices, and a grass patch can have a triangular geometry. Of course, three vertices and four vertices are only examples of the number of vertices of a grass patch. A grass patch can also have five vertices, a grass patch can have an irregular polygon shape, or a grass patch can also have five vertices. Can have six vertices, and grass inserts can have a convex hexagonal shape. Grass inserts are also available as 3D models.

在获取草插片的一种可能实现方式中,确定草插片的顶点数量,基于草插片的顶点数量,创建具有该顶点数量的几何体;将草的贴图映射到该几何体上,得到一个草插片。其中,草的贴图包括草的特征,如草的颜色、草的纹理和透明度等。In one possible implementation of obtaining the grass insert, determine the number of vertices of the grass insert, and create a geometry with the number of vertices based on the number of vertices of the grass insert; map the grass texture to the geometry to obtain a grass Insert. Among them, the grass map includes the characteristics of the grass, such as the color of the grass, the texture and transparency of the grass, etc.

通常情况下,草插片的顶点数量越多,可以提供更丰富的几何细节、更光滑的曲面和更细致的纹理映射,精度越高,渲染效果越好,但是增加草插片的顶点数量也导致更多的顶点计算和渲染操作,导致对硬件的要求越高;反之,草插片的顶点数量越少,草的外观相对简化或粗糙一些,精度越低,导致渲染效果有所下降,但是也能减少顶点计算和渲染操作,从而降低硬件的要求。Generally, the greater the number of vertices of a grass patch, the richer geometric details, smoother surfaces, and more detailed texture mapping can be provided. The higher the accuracy, the better the rendering effect, but increasing the number of vertices of the grass patch will also This leads to more vertex calculations and rendering operations, resulting in higher hardware requirements; conversely, the fewer the number of vertices of the grass insert, the appearance of the grass is relatively simplified or rough, and the lower the precision, resulting in a decrease in the rendering effect, but It can also reduce vertex calculation and rendering operations, thus reducing hardware requirements.

例如,当使用四个顶点构成两个三角形的菱形草插片,使得草插片更接近真实草的外观,但每个草插片需要渲染四个顶点,这对硬件的要求较高。相比之下,采用三个顶点构成三角形的草插片在逼真效果上稍有差距,但能降低对硬件的要求。For example, when four vertices are used to form two triangular diamond-shaped grass patches, the grass patch is closer to the appearance of real grass, but each grass patch needs to render four vertices, which has higher hardware requirements. In contrast, grass inserts that use three vertices to form a triangle are slightly less realistic, but can reduce hardware requirements.

为了兼顾渲染效果以及渲染的处理开销,可以基于渲染区域中单位区域与渲染中心之间的渲染距离,确定需要向单位区域中插入的草插片,草插片中的顶点数量与单位区域与渲染中心之间的渲染距离负相关。换句话说,单位区域与渲染中心之间的渲染距离越近,则向单位区域插入的草插片的顶点数量越多,使得渲染效果更加逼真,单位区域与渲染中心之间的渲染距离越远,则向单位区域插入的草插片的顶点数量越少,从而降低渲染产生的处理开销,降低硬件要求。尤其是,在以虚拟人物所处的位置作为渲染中心的情况下,使得虚拟人物远处的草地呈现细节较少、较少顶点数量的形态,而近处的草地则呈现更多的细节和顶点数量的形态,从而模拟出一种视觉透视效果,提升游戏的真实感和立体感。In order to take into account the rendering effect and rendering processing overhead, 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. The number of vertices in the grass inserts and the relationship between the unit area and the rendering The rendering distance between centers is negatively correlated. 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 the vertices of the grass inserts inserted into the unit area, thereby reducing the processing overhead caused by rendering and reducing hardware requirements. In particular, when the position of the virtual character is used as the rendering center, the grass far away from the virtual character appears with less details and a smaller number of vertices, while the grass near the virtual character appears with more details and vertices. Quantitative forms, thereby simulating a visual perspective effect and enhancing the realism and three-dimensionality of the game.

在一种可能的实现中,草插片包括第一草插片以及第二草插片,第一草插片中的顶点数量大于第二草插片中的顶点数量,对渲染距离与距离阈值进行比较;响应于确定渲染距离小于或等于距离阈值,确定第一草插片;或者,响应于确定渲染距离大于或等于距离阈值,确定第二草插片。例如,当确定渲染距离小于或等于距离阈值,确定具有四个顶点的草插片(第一草插片),向单位区域插入具有四个顶点的草插片,当确定渲染距离大于或等于距离阈值,确定具有三个顶点的草插片(第二草插片),向单位区域插入具有三个顶点的草插片。距离阈值可以根据地形网格区域或者渲染区域的尺寸或者渲染效果的要求来设定。In a possible implementation, the grass patch includes a first grass patch and a second grass patch. The number of vertices in the first grass patch is greater than the number of vertices in the second grass patch. The rendering distance and distance threshold are A comparison is made; in response to determining that the rendering distance is less than or equal to the distance threshold, a first grass patch is determined; or in response to determining that the rendering distance is greater than or equal to the distance threshold, a second grass patch is determined. For example, when it is determined that the rendering distance is less than or equal to the distance threshold, a grass patch with four vertices (the first grass patch) is determined, a grass patch with four vertices is inserted into the unit area, and when it is determined that the rendering distance is greater than or equal to the distance Threshold, determine the grass patch with three vertices (the second grass patch), and insert the grass patch with three vertices into the unit area. The distance threshold can be set according to the size of the terrain grid area or rendering area or the requirements of the rendering effect.

在另一种可能的实现中,基于渲染距离以及第一对应关系,确定草插片。第一对应关系指示渲染距离以及第一数量之间的对应关系,草插片中的顶点数量为第一数量。对应关系可以使用数组、表格或函数来表示。例如,以渲染距离为索引,查找表格形式的第一对应关系,获得第一数量;从候选草插片中筛选具有第一数量的顶点的草插片。渲染距离以及第一数量之间的对应关系可以使用线性插值的方式计算得到。或者,使用指数函数来表示渲染距离和顶点数量之间的对应关系,让远距离的顶点数量呈指数减少。或者,使用曲线函数、多项式等拟合出非线性函数形式的第一对应关系,以获得更精确的顶点数量。In another possible implementation, the grass insert is determined based on the rendering distance and the first correspondence. The first correspondence indicates a correspondence between the rendering distance and a first number, the number of vertices in the grass patch being the first number. Correspondence can be expressed using arrays, tables or functions. For example, using the rendering distance as an index, the first correspondence relationship in table form is searched to obtain the first number; the grass inserts having the first number of vertices are screened from the candidate grass inserts. The correspondence between the rendering distance and the first quantity can be calculated using linear interpolation. Alternatively, use an exponential function to represent the correspondence between the rendering distance and the number of vertices, so that the number of vertices at far distances decreases exponentially. Or, use curve functions, polynomials, etc. to fit the first correspondence relationship in the form of a nonlinear function to obtain a more accurate number of vertices.

步骤S130,向单位区域中插入草插片。Step S130: Insert grass inserts into the unit area.

在一种可能的实现方式中,在插入草插片之前,判断单位区域的渲染数据是否满足草地纹理特征;如果单位区域的渲染数据满足草地纹理特征,则执行基于渲染距离确定草插片的步骤;如果单位区域的渲染数据不满足草地纹理特征,则取消执行确定草插片的步骤。由于无需人工选定草地区域,从而节省人工选定草地区域带来的人力成本,提高渲染效率。此外,当单位区域的渲染数据不满足草地纹理特征则无需插入草插片,相当于插入草插片之前过滤掉了一些不适合插入草插片的区域,从而降低在不必要的区域上插入草插片的概率,从而减少了渲染负荷和资源消耗。In one possible implementation, before inserting the grass inserts, it is determined whether the rendering data of the unit area satisfies the grass texture characteristics; if the rendering data of the unit area satisfies the grass texture characteristics, then the step of determining the grass inserts based on the rendering distance is performed. ; If the rendering data of the unit area does not meet the grass texture characteristics, the step of determining the grass inserts is cancelled. 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 grass inserts. This is equivalent to filtering out some areas that are not suitable for inserting grass inserts before inserting grass inserts, thereby reducing the need to insert grass in unnecessary areas. The probability of inserting slices, thereby reducing rendering load and resource consumption.

在确定单位区域的渲染数据满足草地纹理特征的一种可能实现方式中,基于单位区域内像素点的色彩数据以及草地色彩区间,确定单位区域内目标像素点的数量;基于单位区域内目标像素点的数量,确定单位区域的渲染数据满足草地纹理特征,向单位区域内插入草插片。In one possible implementation method of determining that the rendering data of the 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 interval; based on the target pixels in the unit area quantity, determine that the rendering data of the unit area satisfies the grass texture characteristics, and insert grass inserts into the unit area.

草地色彩区间是指用于描述草地颜色特征的一个范围。例如,在RGB空间下,草地色彩区间可以包括R、G、B三个分量的范围;在HSV空间下,草地色彩区间可以包括H(色相)、S(饱和度)和V(亮度)等分量的范围。在确定草地色彩区间的一种可能实现方式中,对真实草地图片进行采样从而确定草地色彩区间。例如,收集多种真实草地图片,包括不同场景、不同光照条件下的草地照片。从这些真实草地图片中选择代表草地颜色的样本图像,从样本图像中提取出色彩数据,作为草地色彩区间。可选地,基于草地图像对应的环境条件,如阳光强度、阴影、周围物体反射等因素,对确定出的草地色彩区间的范围进行调整,使草地色彩区间能够包括不同环境下的草地颜色变化。The grass color range refers to a range used to describe the color characteristics of grass. For example, in the RGB space, the grass color interval can include the range of R, G, and B components; in the HSV space, the grass color interval can include H (hue), S (saturation), and V (brightness) components. range. In one possible implementation manner of determining the grass color interval, real grass images are sampled to determine the grass color interval. For example, collect a variety of real grass pictures, including photos of grass in different scenes and under different lighting conditions. Select sample images representing grass color from these real grass pictures, and extract color data from the sample images as grass color intervals. Optionally, based on environmental conditions corresponding to the grass image, such as sunlight intensity, shadows, reflections of surrounding objects and other factors, the determined range of the grass color interval is adjusted so that the grass color interval can include changes in grass color under different environments.

目标像素点是指色彩数据属于草地色彩区间的像素点。例如,比较一个像素点的色彩数据与草地颜色区间的上下界。如果像素点的色彩数据在草地颜色区间之内,则该像素点为目标像素点。考虑到色彩数据通常通过多个色彩通道定义,在一种可能的实现方式中,比较一个像素点的色彩数据中的每个色彩通道的值与草地颜色区间中对应通道的区间上下界,如果一个像素点的色彩数据中的每个色彩通道的值均属于对应通道的区间上下界,则该像素点为目标像素点。以在RGB空间为例,例如,如果一个像素点在红色通道的值在草地颜色区间的红色通道的上下界内,且该像素点在绿色通道的值在草地颜色区间的绿色通道的上下界内,且该像素点在蓝色通道的值在草地颜色区间的在蓝色通道的上下界内,则该像素点为目标像素点。The target pixel refers to the 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 range. If the color data of the pixel is within the grass color range, the pixel is the target pixel. Considering that color data is usually defined through multiple color channels, in one possible implementation, the value of each color channel in the color data of a pixel is compared with the upper and lower bounds of the corresponding channel in the grass color interval. If a If the value of each color channel in the color data of a pixel belongs to the upper and lower bounds of the corresponding channel, then the pixel is the target pixel. Taking the RGB space as an example, if the value of a pixel in the red channel is within the upper and lower bounds of the red channel of the grass color interval, and the value of the pixel in the green channel is within the upper and lower bounds of the green channel of the grass color interval, , and the value of the pixel in the blue channel is within the upper and lower bounds of the blue channel in the grass color interval, then the pixel is the target pixel.

在一种可能的实现方式中,遍历单位区域内的每个像素点,对于当前遍历到的像素点,如果像素点的色彩数据在定义的草地颜色区间内,则将该像素点判定为目标像素点,对已记录的目标像素点的数量加一,直到遍历到单位区域中的最后一个像素点,输出已记录的目标像素点的数量。In one possible implementation, each pixel in the unit area is traversed. For the currently traversed pixel, if the color data of the pixel is within the defined grass color interval, the pixel is determined to be the target pixel. point, add one to the number of recorded target pixels, until the last pixel in the unit area is traversed, and output the number of recorded target pixels.

在一种可能的实现方式中,对单位区域内目标像素点的数量与数量阈值进行比较。当确定单位区域内目标像素点的数量大于或等于数量阈值,则确定单位区域的渲染数据满足草地纹理特征,向单位区域内插入草插片。当确定单位区域内目标像素点的数量小于数量阈值,则确定单位区域的渲染数据不满足草地纹理特征,无需向单位区域内插入草插片。通过比较单位区域内目标像素点的数量与数量阈值,可以快速判断是否满足草地纹理特征,这种方法相对简单,易于实现。且相比手动处理,能够自动化选定待渲染为草地的区域,因此更快速、准确。In one possible implementation, the number of target pixels in the unit area is compared with a quantity threshold. When it is determined that the number of target pixels in the unit area is greater than or equal to the quantity threshold, it is determined that the rendering data of the unit area satisfies the grass texture characteristics, and grass inserts are inserted into the unit area. When it is determined that the number of target pixels 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 characteristics, and there is no need to insert grass inserts into the unit area. By comparing the number of target pixels in the unit area with the quantity threshold, you can quickly determine whether the grass texture characteristics are met. This method is relatively simple and easy to implement. Compared with manual processing, the area to be rendered as grass can be automatically selected, so it is faster and more accurate.

在另一种可能的实现方式中,获取单位区域内目标像素点的数量与单位区域内像素点的总数量之间的比值,对比值与第一比值阈值进行比较;当比值大于或等于第一比值阈值,则确定单位区域的渲染数据满足草地纹理特征,向单位区域内插入草插片。当比值小于第一比值阈值,则确定单位区域的渲染数据不满足草地纹理特征,无需向单位区域内插入草插片。在一个示例性场景下,在单位区域使用了多个地形纹理图(如5个地形纹理图)进行渲染,该多个地形纹理图包括草地纹理图,草地纹理图的占比就决定了是否向该单位区域插入草插片。草地纹理图的占比例如为草地纹理所占据的像素点(目标像素点)数量与像素点总数量之间的比值,即单位区域内目标像素点的数量与单位区域内像素点的总数量之间的比值。如果草地纹理占据了大部分的像素点,那么草地纹理的占比就会比较高。例如,第一比值阈值为20%,当草坪纹理占比大于20%,表示该单位区域内有足够多的草坪纹理存在,则向单位区域内插入草插片,从而增加草地的真实感。此外,通过比较目标像素点的数量与单位区域内像素点的总数量之间的比值,可以更好地把握渲染数据中草地的相对比例,此外,在不同缩放级别或视角下,单位区域内像素点的总数量可能发生变化,而目标像素点的数量与单位区域内像素点的总数量之间的比值具有相对不变性,因此有助于适应不同尺度下的渲染要求。且相比手动处理,能够自动化选定待渲染为草地的区域,因此更快速、准确。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 comparison value is compared with the 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 characteristics, and grass inserts are 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 characteristics, and there is no need to insert grass inserts into the unit area. In an exemplary scenario, multiple terrain texture maps (such as 5 terrain texture maps) are used for rendering in the unit area. The multiple terrain texture maps include grass texture maps. The proportion of the grass texture map determines whether to Insert grass inserts into this unit area. For example, the proportion of the grass texture map is the ratio between the number of pixels (target pixels) occupied by the grass texture and the total number of pixels, that is, the number of target pixels in the unit area and the total number of pixels in the unit area. the ratio between. If the grass texture occupies most of the pixels, then 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 is enough lawn texture 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 pixels in the unit area The total number of points may change, but the ratio between the number of target pixels and the total number of pixels in the unit area is relatively invariant, thus helping to adapt to rendering requirements at different scales. Compared with manual processing, the area to be rendered as grass can be automatically selected, so it is faster and more accurate.

在一种可能的实现方式中,基于单位区域内每个像素点的色彩数据,获取单位区域内像素点的色彩数据的统计值,确定色彩数据的统计值与草地色彩阈值之间的比值,对色彩数据的统计值与草地色彩阈值之间的比值与第二比值阈值进行比较;如果色彩数据的统计值与草地色彩阈值之间的比值大于或等于第二比值阈值,则确定单位区域的渲染数据满足草地纹理特征,向单位区域内插入草插片。如果色彩数据的统计值与草地色彩阈值之间的比值小于第二比值阈值,则确定单位区域的渲染数据不满足草地纹理特征,无需向单位区域内插入草插片。色彩数据的统计值与草地色彩阈值之间的比值可以理解为草坪纹理占比。以第二比值阈值为20%为例,如果草坪纹理占比大于或等于20%,则向单位区域内插入草插片。In one 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 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, the rendering data of the unit area is determined To meet the grass texture characteristics, insert 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, it is determined that the rendering data of the unit area does not satisfy the grass texture characteristics, and there is no need to insert grass inserts into the unit area. The ratio between the statistical value of color data and the grass color threshold can be understood as the proportion of lawn texture. Taking the second ratio threshold as 20% as an example, if the proportion of lawn texture is greater than or equal to 20%, grass inserts are inserted into the unit area.

获取单位区域内像素点的色彩数据的统计值的方式例如为:获取单位区域内每个像素点的色彩数据的平均值。例如,对单位区域内所有像素点的色彩数据进行相加,将色彩数据的总和除以像素点数量,得到色彩数据的平均值;相应地,如果单位区域内色彩数据的平均值大于或等于第二比值阈值,则向单位区域内插入草插片。由于利用了单位区域内所有像素点的色彩数据,相当于考虑了单位区域整体的色彩特征,从而更加准确。同时通过计算平均值作为判断是否应该选定为草地区域或者说插入草插片的量化条件,降低了噪声干扰的影响,使得结果较为平滑和稳定。The method of obtaining the statistical value of the color data of the pixels in the unit area is, for example, obtaining the average value of the color data of each pixel in the unit area. For example, add the color data of all pixels in the unit area, divide the sum of the color data by the number of pixels, and obtain the average color data; accordingly, if the average color data in the unit area is greater than or equal to the If the ratio threshold is 2, grass inserts will be inserted into the unit area. Since the color data of all pixels in the unit area is used, it is equivalent to considering the color characteristics of the entire unit area, making it 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 inserted, the impact of noise interference is reduced, making the results smoother and more stable.

获取单位区域内像素点的色彩数据的统计值的方式又如为:获取单位区域内中心像素点的色彩数据。相应地,如果单位区域内内中心像素点的色彩数据大于或等于第二比值阈值,则向单位区域内插入草插片。由于利用中心像素点的色彩数据,而无需利用单位区域内所有像素点的色彩数据,从而减少了需要处理的数据量,提高计算效率。并且,能够更好地捕捉到单位区域边角的色彩特征,适用于草地边缘较为明显的场景。Another way to obtain the statistical value of the color data of the pixels in the unit area is to obtain the color data of the center pixel in the unit area. Correspondingly, if the color data of the central pixel 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 is used instead of the color data of all pixels in the unit area, the amount of data that needs to be processed is reduced and the calculation efficiency is improved. Moreover, it can better capture the color characteristics of the corners of the unit area, and is suitable for scenes with obvious grass edges.

获取单位区域内像素点的色彩数据的统计值的方式再如为:获取单位区域内各个角点的像素点的色彩数据的平均值。例如,获取单位区域内左上角点、左下角点、右上角点、右下角点这四个角点的色彩数据的平均值。相应地,如果单位区域内各个角点的像素点的色彩数据的平均值大于或等于第二比值阈值,则向单位区域内插入草插片。Another way to obtain the statistical value of the color data of the pixels in the unit area is to obtain the average value of the color data of the pixels at each corner point in the unit area. For example, obtain the average value of the color data of the four corner points of the unit area: the upper left corner point, the lower left corner point, the upper right corner point, and the lower right corner point. Correspondingly, if the average value of the color data of the pixels at each corner point in the unit area is greater than or equal to the second ratio threshold, the grass insert is inserted into the unit area.

在另一种可能的实现方式中,渲染数据包括单位区域内像素点的纹理数据。可以根据单位区域内像素点的纹理数据判断是否向单位区域插入草插片。草地的材质通常具有一定的细密度,可能包括细小的纹理元素(如草叶、草茎等)。可以检测单位区域的纹理数据中是否存在符合草地特征的纹理元素(如细小而规律的纹理,比如说细长的斑点、斑驳的形状等),如果单位区域的纹理数据中是否存在符合草地特征的纹理元素,则将该单位区域判断为草地区域,向单位区域内插入草插片。In another possible implementation, the rendering data includes texture data of pixels in the unit area. Whether to insert grass inserts into the unit area can be determined based on the texture data of the pixels in the unit area. The grass material usually has a certain density and may include small texture elements (such as grass blades, grass stems, etc.). It can detect whether there are texture elements in the texture data of the unit area that conform to the characteristics of grass (such as small and regular textures, such as elongated spots, mottled shapes, etc.). If there are texture elements in the texture data of the unit area that conform to the characteristics of grass, texture element, the unit area is judged to be a grass area, and grass inserts are inserted into the unit area.

在另一种可能的实现方式中,渲染数据包括单位区域内像素点的光照数据。可以根据单位区域内像素点的光照数据判断是否向单位区域插入草插片。草地通常呈现出受到光照的明暗变化,具有一定的高光和阴影效果。可以检测单位区域内的光照数据是否存在符合草地特征的光照分布和阴影效果,从而判断是否向单位区域内插入草插片。例如,如果单位区域内的光照数据呈现具有较亮的光照反射特征,而且会在不同光照角度下产生反射变化,则将该单位区域判断为草地区域,向单位区域内插入草插片。In another possible implementation, the rendering data includes lighting data of pixels in the unit area. You can determine whether to insert grass inserts into the unit area based on the lighting data of the pixels in the unit area. Grass usually shows changes in light and dark when illuminated, with certain highlights and shadows. It can detect whether the lighting data in the unit area has lighting distribution and shadow effects that match the characteristics of grass, thereby determining whether to insert grass inserts into the unit area. For example, if the lighting data in a unit area has bright light reflection characteristics and will produce reflection changes under different lighting angles, then the unit area is determined to be a grass area and grass inserts are inserted into the unit area.

在另一种可能的实现方式中,结合单位区域的色彩数据、纹理数据、光照数据、材质数据以及几何数据中至少两项判断单位区域是否满足草地纹理特征,当单位区域满足草地纹理特征则向单位区域内插入草插片,当单位区域不满足草地纹理特征则无需向单位区域内插入草插片。In another possible implementation, at least two of the unit area's color data, texture data, lighting data, material data and geometric data are combined to determine whether the unit area satisfies the grass texture characteristics. When the unit area satisfies the grass texture characteristics, the unit area is Insert grass inserts into the unit area. When the unit area does not meet the grass texture characteristics, there is no need to insert grass inserts into the unit area.

在一种可能的实现方式中,基于单位区域内的渲染数据,确定草插片的数量;获取该数量个草插片;向单位区域中插入数量的草插片。通过这种方式,使得单位区域内草插片的数量与单位区域的渲染数据更加匹配,使得草插片的分布与单位区域整体的环境相协调。且,使得草插片数量较为合适,降低由于插入的草插片数量过多导致增加渲染负担、性能下降的概率,并降低由于草插片数量过少导致渲染效果不佳的概率。In one 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 closely matched with the rendering data of the unit area, so that the distribution of grass inserts is coordinated with the overall environment of the unit area. Moreover, making the number of grass inserts more appropriate reduces the probability of increased rendering burden and performance degradation due to too many inserted grass inserts, and reduces the probability of poor rendering results due to too few grass inserts.

在一种可能的实现方式中,渲染数据包括单位区域内草地纹理的占比,基于单位区域内草地纹理的占比,确定草插片的数量。草插片的数量与草地纹理的占比正相关。也即是,草地纹理的占比越大,草插片的数量越多。示例性地,预先设定草插片的数量与草地纹理的占比之间的第二对应关系,该第二对应关系的输入参数包括单位区域内草地纹理的占比,该第二对应关系的输出参数包括草插片的数量。基于单位区域内草地纹理的占比以及第二对应关系,确定草插片的数量。草插片的数量与草地纹理的占比之间的第二对应关系可以为函数,可以是线性第二对应关系,也可以是指数函数、对数函数或者分段函数等来非线性函数作为第二对应关系。由于草插片的数量与草地纹理的占比正相关,从而实现模拟现实中草地更绿的地方对应的草就会更多的情况,使得草的数量与草地颜色更加适配。In a possible implementation, the rendering data includes the proportion of grass texture in the 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 related to the proportion of grass texture. That is to say, 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 the grass texture is preset. The input parameters of the second correspondence include the proportion of the grass texture in the unit area. The second correspondence is Output parameters include the number of grass inserts. Based on the proportion of grass texture in the unit area and the second corresponding relationship, the number of grass inserts is determined. The second corresponding relationship between the number of grass inserts and the proportion of grass texture can be a function, it can be a linear second corresponding relationship, or it can be an exponential function, a logarithmic function or a piecewise function. The nonlinear function can be used as the third Two corresponding relationships. Since the number of grass inserts is positively related to the proportion of grass texture, it is possible to simulate the situation where greener grass corresponds to more grass in reality, making the number of grass more suitable for the color of the grass.

在一种可能的实现方式中,渲染数据包括单位区域内像素点的色彩数据,获取像素点的色彩数据与草地色彩阈值之间的比值,基于像素点的色彩数据与草地色彩阈值之间的比值,确定草插片的数量。草地色彩阈值用于确定属于草地的色彩范围。获取像素点的色彩数据与草地色彩阈值之间的比值的方式例如为距离比较,比如说计算像素点的色彩值与草地色彩阈值之间的距离(例如欧氏距离、差异度等),将距离转换为比值。获取像素点的色彩数据与草地色彩阈值之间的比值的方式又如为计算像素点的色彩值与草地色彩阈值之间的相似度,将相似度转换为比值。获取像素点的色彩数据与草地色彩阈值之间的比值的方式又如为将像素点的色彩值与草地色彩阈值进行比较,得到一个布尔值,布尔值表示该像素点的色彩值是否处于草地色彩阈值指示的色彩范围内。In a possible implementation, the rendering data includes color data of pixels in the unit area, and the ratio between the color data of the pixels and the grass color threshold is obtained, based on the ratio between the color data of the pixels and the grass color threshold. , determine the number of grass inserts. The grass color threshold is used to determine the range of colors that belong to grass. The method of obtaining the ratio between the color data of the pixel and the grass color threshold is, for example, distance comparison. For example, calculating the distance between the color value of the pixel and the grass color threshold (such as Euclidean distance, degree of difference, etc.), and calculating the distance Convert to ratio. The method of obtaining the ratio between the color data of the pixel and the grass color threshold is also to calculate the similarity between the color value of the pixel and the grass color threshold, and convert the similarity into a ratio. Another way to obtain the ratio between the color data of the pixel and the grass color threshold is to compare the color value of the pixel with the grass color threshold and obtain a Boolean value. The Boolean value indicates whether the color value of the pixel is in the grass color. Within the color range indicated by the threshold.

在一种可能的实现方式中,基于单位区域内每个像素点的色彩数据的平均值与草地色彩阈值之间的比值,确定草插片的数量。例如,设定像素点的色彩数据的平均值以及草插片的数量之间的第三对应关系,基于像素点的色彩数据的平均值以及第三对应关系,确定草插片的数量。又如,当单位区域内每个像素点的色彩数据的平均值与草地色彩阈值之间的比值大于或等于阈值时,确定草插片的数量为第一数量;当单位区域内每个像素点的色彩数据的平均值与草地色彩阈值之间的比值小于阈值时,确定草插片的数量为第二数量。草插片的数量可以与每个像素点的色彩数据的平均值与草地色彩阈值之间的比值正相关。这样,当色彩数据的平均值增加时,草插片的数量也会相应增加,从而模拟草地更绿的地方对应的草就会更多。In one possible implementation, the number of grass inserts is determined based on the ratio between the average color data of each pixel in the unit area and the grass color threshold. For example, a third corresponding relationship between the average color data of pixel points 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 pixel points and the third corresponding relationship. For another example, when the ratio between the average 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 each pixel in the unit area When the ratio between the average value of the color data 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 related to the ratio between the average 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, so that areas with greener simulated grass will have more grass.

在一种可能的实现方式中,基于单位区域内中心像素点的色彩数据与草地色彩阈值之间的比值,确定草插片的数量。例如,设定中心像素点的色彩数据以及草插片的数量之间的第四对应关系,基于中心像素点的色彩数据以及第四对应关系,确定草插片的数量。又如,当单位区域内中心像素点的色彩数据与草地色彩阈值之间的比值大于或等于阈值时,确定草插片的数量为第一数量;单位区域内中心像素点的色彩数据与草地色彩阈值之间的比值小于阈值时,确定草插片的数量为第二数量。草插片的数量可以与每个像素点的色彩数据的平均值与草地色彩阈值之间的比值正相关。草插片的数量可以与中心像素点的色彩数据与草地色彩阈值之间的比值正相关。这样,当中心像素点的色彩数据增加时,草插片的数量也会相应增加,从而模拟草地更绿的地方对应的草就会更多。In one possible implementation, the number of grass inserts is determined based on the ratio between the color data of the central pixel in the unit area and the grass color threshold. For example, a fourth correspondence between the color data of the center pixel and the number of grass inserts is set, and the number of grass inserts is determined based on the color data of the center pixel and the fourth correspondence. For another example, when the ratio between the color data of the center 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; the color data of the center pixel in the unit area is the same as the grass color. When the ratio between the thresholds 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 related to the ratio between the average color data of each pixel and the grass color threshold. The number of grass inserts can be positively related to the ratio between the color data of the center pixel and the grass color threshold. In this way, when the color data of the center pixel increases, the number of grass inserts will also increase accordingly, thus simulating greener areas with more grass.

在一种可能的实现方式中,基于单位区域内各个角点的像素点的色彩数据的平均值与草地色彩阈值之间的比值,确定草插片的数量。例如,设定各个角点的像素点的色彩数据的平均值以及草插片的数量之间的第五对应关系,基于各个角点的像素点的色彩数据的平均值以及第五对应关系,确定草插片的数量。又如,当各个角点的像素点的色彩数据的平均值与草地色彩阈值之间的比值大于或等于阈值时,确定草插片的数量为第一数量;当各个角点的像素点的色彩数据的平均值与草地色彩阈值之间的比值小于阈值时,确定草插片的数量为第二数量。草插片的数量可以与各个角点的像素点的色彩数据的平均值与草地色彩阈值之间的比值正相关。这样,当各个角点的色彩数据增加时,草插片的数量也会相应增加,从而模拟草地更绿的地方对应的草就会更多。In one possible implementation, the number of grass inserts is determined based on the ratio between the average color data of the pixels at each corner point in the unit area and the grass color threshold. For example, a fifth correspondence relationship between the average color data of pixel points at each corner point and the number of grass inserts is set, and based on the average value of color data of pixel points at each corner point and the fifth correspondence relationship, determine Number of grass inserts. For another example, when the ratio between the average color data of the pixels at 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 color of the pixels at each corner point is When the ratio between the average value of the data 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 related to the ratio between the average color data of the pixels at 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, so that there will be more grass corresponding to greener simulated grass.

本实施例提供的方法,由于草插片中的顶点数量与渲染距离负相关,距离渲染中心越远的单位区域可以插入较少的草插片数量越少,距离渲染中心越近的单位区域插入的草插片数量越多,从而降低插入的每个草插片都有较多的顶点导致渲染的顶点数量过多造成渲染产生的处理开销的风险,也降低插入的每个草插片的顶点过少导致渲染的顶点数量过多造成渲染效果较差的风险,兼顾渲染效果以及渲染的处理开销,尽可能在不牺牲渲染效果的情况下,提高计算机的性能和资源利用效率,同时提高草的密度,使得虚拟场景更加逼真和细致。In the method provided by this embodiment, since the number of vertices in the grass inserts is negatively correlated with the rendering distance, the unit area further away from the rendering center can insert fewer grass inserts, and the unit area closer to the rendering center can be inserted. The greater the number of grass tiles, thereby reducing the risk of processing overhead caused by rendering too many vertices due to each inserted grass tile having more vertices, and also reducing the risk of each inserted grass tile having more vertices. Too few will lead to the risk of poor rendering effect due to too many vertices being rendered. Taking into account the rendering effect and rendering processing overhead, we should try our best to improve computer performance and resource utilization efficiency without sacrificing the rendering effect, and at the same time improve the quality of the grass. Density makes virtual scenes more realistic and detailed.

此外,在围绕虚拟对象进行动态渲染的时候,渲染区域选择性渲染以及草插片精度渲染可以同步执行。例如,地形网格区域中存在第一虚拟对象和第二虚拟对象,在通过第一线程以第一虚拟对象所处的位置、预设半径范围内的区域作为渲染区域进行渲染的同时,通过第二线程基于第二虚拟对象所在的渲染区域中单位区域与第二虚拟对象之间的渲染距离,确定与渲染距离对应的顶点数量,并通过第二线程插入具有该顶点数量的草插片。In addition, when dynamically rendering around virtual objects, rendering area selective rendering and grass patch precision rendering can be performed simultaneously. For example, there are a first virtual object and a second virtual object in the terrain grid area. While rendering through the first thread, the location of the first virtual object and the area within the preset radius range are used as the rendering area. 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 grass inserts with the number of vertices through the second thread.

在另一种可能的实现方式中,获取相机位置作为渲染中心。基于渲染区域中单位区域与相机位置之间的渲染距离,确定草插片,草插片包括至少一个顶点,草插片中的顶点数量与渲染距离负相关;向单位区域中插入草插片。由于相机位置与用户视角有关,通过以相机位置为中心进行渲染,草插片的顶点数量与相机位置之间的渲染距离负相关,从而能够让草插片的精度随着视角离开或接近单位区域而变化,这样可以在视觉上实现一种逐渐过渡的效果,使得场景的细节渲染更加真实,此外视角离开单位区域时使用顶点数量少的草插片从而降低渲染产生的处理开销,降低硬件要求。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, the grass insert is determined. The grass insert includes at least one vertex. The number of vertices in the grass insert is negatively related to 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 related to the rendering distance between the camera positions, thus allowing the accuracy of the grass insert to move away from or approach the unit area as the viewing angle changes. This change can achieve a gradual transition effect visually, making the detailed rendering of the scene more realistic. In addition, when the perspective leaves the unit area, grass inserts with a small number of vertices are used to reduce the processing overhead caused by rendering and reduce hardware requirements.

在另一种可能的实现方式中,获取光源位置作为光源位置。基于渲染区域中单位区域与光源位置之间的渲染距离,确定草插片,草插片包括至少一个顶点,草插片中的顶点数量与渲染距离负相关;向单位区域中插入草插片。换句话说,单位区域与光源位置之间的渲染距离越近,则向单位区域插入的草插片的顶点数量越多,使得渲染效果更加逼真,单位区域与光源位置之间的渲染距离越远,则向单位区域插入的草插片的顶点数量越少,从而降低渲染产生的处理开销,降低硬件要求。此外,使得离光源较近的区域拥有更高细节的草插片,这样能够让光源周围的区域更加真实、自然地呈现草的分布,提升视觉效果。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, the grass insert is determined. The grass insert includes at least one vertex. The number of vertices in the grass insert is negatively related to 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 inserts 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 the vertices of the grass inserts inserted into the unit area, thereby reducing the processing overhead caused by rendering and reducing hardware requirements. In addition, the area closer to the light source has higher-detailed grass inserts, which allows the area around the light source to present the distribution of grass more realistically and naturally, improving the visual effect.

在另一种可能的实现方式中,获取用户交互位置作为用户交互位置。基于渲染区域中单位区域与用户交互位置之间的渲染距离,确定草插片,草插片包括至少一个顶点,草插片中的顶点数量与渲染距离负相关;向单位区域中插入草插片。换句话说,单位区域与用户交互位置之间的渲染距离越近,则向单位区域插入的草插片的顶点数量越多,使得渲染效果更加逼真,单位区域与用户交互位置之间的渲染距离越远,则向单位区域插入的草插片的顶点数量越少,从而降低渲染产生的处理开销,降低硬件要求。此外,当用户进行移动或操作时,草插片的顶点数量会相应变化,从而让用户感觉到场景中的变化是基于自己的位置和行动而发生的,更加动态性。此外,用户可以通过自己的交互选择决定渲染的中心,从而有助于根据用户实际需求进行定制化的渲染。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, determine the grass insert. The grass insert includes at least one vertex. The number of vertices in the grass insert is negatively related to the rendering distance; insert the grass insert into the unit area. . In other words, the closer the rendering distance between the unit area and the user interaction position, the greater the number of vertices of the grass inserts inserted into the unit area, making the rendering effect more realistic. The further away, the fewer vertices of the grass inserts inserted into the unit area, thereby reducing the processing overhead caused by rendering and reducing hardware requirements. In addition, when the user moves or operates, the number of vertices of the grass insert will change accordingly, allowing the user to feel that the changes in the scene are based on their own position and actions, making it more dynamic. In addition, users can determine the center of the rendering through their own interactive choices, which facilitates customized rendering based on the user's actual needs.

在一种可能的实现中,基于渲染区域中单位区域与渲染中心之间的距离,确定纹理贴图的分辨率,纹理贴图的分辨率与距离负相关;确定具有纹理贴图的分辨率的草插片。In one possible implementation, the resolution of the texture map is determined based on the distance between the unit area in the rendering area and the rendering center. The resolution of the texture map is negatively related to the distance; the grass insert with the resolution of the texture map is determined. .

纹理贴图的分辨率是指纹理贴图包括的像素数量,纹理贴图的分辨率越高,表示纹理图像中的像素越密集,草插片的细节更加清晰。由于根据从单位区域到渲染中心的距离来动态地确定纹理贴图的分辨率,使得距离渲染中心较近的单位区域需要更高分辨率的纹理贴图,而距离较远的单位区域则可以使用较低分辨率的纹理贴图。对于远离渲染中心的单位区域,使用低分辨率的纹理贴图可以降低内存占用和渲染开销,提高渲染性能。对于靠近渲染中心的单位区域,使用高分辨率的纹理贴图使得草插片具有较高精度细节,营造出更真实的视觉效果。The resolution of the texture map refers to the number of pixels included in the texture map. The higher the resolution of the texture map, the denser the pixels in the texture image are, 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, unit areas closer to the rendering center require higher-resolution texture maps, while unit areas farther away can use lower-resolution texture maps. Resolution texture map. For unit areas far away from the rendering center, using low-resolution texture maps can reduce memory usage and rendering overhead, and improve rendering performance. For the unit area close to the rendering center, high-resolution texture maps are used to make the grass inserts have higher-precision details, creating a more realistic visual effect.

在一种可能的实现中,对地形网格区域中多个渲染区域之间的边界进行平滑处理。平滑处理是指对渲染区域之间的边界进行处理以减少不连续性、锯齿状或明显的过渡,使渲染边界更加自然和平滑。平滑处理的方式包括而不限于融合接缝、纹理过渡、法线平均、顶点缩放或者边缘模糊中至少一项。In one possible implementation, the boundaries between multiple rendering areas in a terrain mesh area are smoothed. Smoothing refers to processing the boundaries between rendering areas to reduce discontinuities, jagged or obvious transitions, making the rendering boundaries more natural and smooth. The smoothing processing method includes, but is not limited to, at least one of seam fusion, texture transition, normal averaging, vertex scaling, or edge blurring.

融合接缝例如通过融合相邻渲染区域的纹理、颜色或其他属性来实现平滑过渡,可以通过在边界处绘制一个接缝区域,在接缝区域内进行纹理插值、颜色混合等操作来实现。接缝区域可以使用渐变和过渡效果以将相邻渲染区域的特征逐渐融合。纹理过渡例如使用多个纹理并通过混合技术将多个纹理进行过渡,以平滑渲染区域之间的边界。纹理过渡可以使用贴图融合、权重混合等技术来实现,通过调整纹理的透明度或使用Alpha贴图,可以控制不同纹理之间的过渡效果。法线平均例如使相邻渲染区域之间的法线向量平滑过渡。通过计算相邻面的法线方向,并进行平均化或插值处理,可以减少法线差异,并使边界更加平滑,使用平滑的法线可以产生更真实的渲染效果。顶点缩放例如通过调整相邻渲染区域边界上的顶点位置,使其在相邻区域之间逐渐过渡平滑,顶点缩放可以通过插值或权重化等方法来实现,使得相邻区域的高度和形状变化平滑过渡。边缘模糊例如在渲染边界周围应用模糊效果,以减少边缘的锯齿感和硬边缘现象。边缘模糊可以使用高斯模糊等算法对边界像素进行处理,并将边缘像素的颜色与周围像素进行平滑混合。Fusion seams, for example, achieve smooth transitions by fusing 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 mixing, and other operations within the seam area. Seam areas can use gradients and transition effects to gradually blend the features of adjacent rendered areas. Texture transitions, for example, use multiple textures and transition them through blending techniques to smooth the boundaries between rendered areas. Texture transition can be achieved using techniques such as texture fusion and weight blending. By adjusting the transparency of the texture or using Alpha maps, the transition effect between different textures can be controlled. Normal averaging makes for example a smooth transition of normal vectors between adjacent rendering areas. By calculating the normal directions of adjacent faces and averaging or interpolating them, you can reduce the normal differences and make the boundaries smoother. Using smooth normals can produce a more realistic rendering. Vertex scaling, for example, adjusts the vertex positions on the boundaries of adjacent rendering areas to make the gradual transition between adjacent areas smooth. Vertex scaling can be achieved through methods such as interpolation or weighting to smooth the changes in height and shape of adjacent areas. transition. Edge Blur applies a blur effect around the render boundary to reduce jagged edges and hard edge artifacts. Edge blur can use algorithms such as Gaussian blur to process boundary pixels and smoothly blend the color of edge pixels with surrounding pixels.

下面对构建地形网格区域的过程举例说明。The following is an example of the process of constructing a terrain grid area.

地形网格区域是用于表示地形的离散化区域,通常用于地形渲染和模拟。在计算机图形学中,地形网格区域可以看作是一个二维或三维的网格,由一系列相邻的顶点和连接它们的边组成。在二维情况下,地形网格区域是一个网格平面,由一系列的顶点和边构成。每个顶点代表地形表面的一个点,边表示相邻点之间的连接关系。可以为每个顶点分配一个高度值,以模拟地形的高度变化。使用插值算法可以通过已知的高度值来推断未知的点的高度,以形成一个平滑的地形模型。在三维情况下,地形网格区域是一个由三角形(或其他多边形)连接而成的网格,类似于网格的表面。每个顶点代表地形表面的一个点,每个三角形代表地形的一个小片段。可以为每个顶点分配一个高度值,以模拟地形的高度变化,通过在每个三角形上插值和平滑高度值,可以得到一个连续的地形表面模型。地形网格区域的精细度取决于网格的分辨率,即顶点的数量。较高的分辨率可以提供更详细和真实的地形表现,但也会增加计算和渲染的复杂性。较低的分辨率可以提高性能,但会导致地形表面的精细度降低。A terrain grid area is a discretized area used to represent terrain, typically used for terrain rendering and simulation. In computer graphics, a terrain grid area can be viewed as a two- or three-dimensional grid, consisting of a series of adjacent vertices and the edges connecting them. In the two-dimensional case, the terrain grid area is a grid plane consisting of a series of vertices and edges. Each vertex represents a point on the terrain surface, and edges represent the connections between adjacent points. Each vertex can be assigned a height value to simulate elevation changes in 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 3D, a terrain grid area is a grid of connected 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. Each vertex can be assigned a height value to simulate the height changes of the terrain. By interpolating and smoothing the height value on each triangle, a continuous terrain surface model can be obtained. The fineness of the terrain mesh area depends on the resolution of the mesh, that is, the number of vertices. Higher resolutions provide more detailed and realistic representations of terrain, but also increase computational and rendering complexity. Lower resolution improves performance but results in less detailed terrain surfaces.

在一种可能的实现中,在选定的网格中,通过预设的序列数组确定网格中每个像素点的高度值以及每个像素点的位置信息。基于像素点的高度值以及像素点的位置信息构建地形网格区域。In a possible implementation, in the selected grid, the height value of each pixel in the grid and the position information of each pixel are determined through a preset sequence array. Construct a terrain grid area based on the height value of the pixel and the position information of the pixel.

在一种可能的实现中,地形网格数据的表现与灰度图类似。例如,使用高度地形图中的色彩明暗程度(灰度)表示地形的高度变化。具体来说,当高度地形图中某个区域的区域越白,就表示该区域的高度值越大,也就是该区域的地形越高。相反,当高度地形图中某区域的色彩越黑或者色彩较深,就表示该区域的高度值越小,即地形越低。例如,请参考附图2,附图2是本申请实施例提供的一种地形网格数据的示意图,通过观察图2中色彩的明暗程度,可以直观地了解地形的高度变化情况。In one possible implementation, terrain grid data behaves like a grayscale image. For example, use the color brightness (grayscale) in a height terrain map to represent the height changes of the terrain. Specifically, when 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 of 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 Figure 2, which is a schematic diagram of terrain grid data provided by an embodiment of the present application. By observing the lightness and darkness of the colors in Figure 2, you can intuitively understand the height changes of the terrain.

序列数组是指由序列作为数据的数组。换句话说,序列数组中的每个元素都是序列类型的数据。序列数组中每个元素(即序列)的位数可以根据精度要求而设置。例如,序列的位数可以是8位或者16位等。序列的位数越大,可以提供更精细的高度值表示。序列的数值就对应着高度值。序列是二进制的格式。A sequence array refers to an array with sequences as data. In other words, each element in the sequence array is sequence type data. The number of bits per element (i.e. sequence) in the sequence array can be set according to precision requirements. For example, the number of bits in the sequence can be 8 bits or 16 bits, etc. A larger number of bits in the sequence provides a finer representation of the height value. The numerical value of the sequence corresponds to the height value. The sequence is in binary format.

数组的存储形式就意味着序列的分布是有序的。数组的每行每列的序列数据数量分别对应地形网格中像素点的数量。例如,数组的每行的序列数据数量指示地形网格中每行像素点的数量。数组的每列的序列数据数量指示地形网格中每列像素点的数量。例如,数组每行有1080个序列,数组每列有960个序列,则表示地形网格的数据包含1080*960个像素点,且地形网格每行有1080个像素点,每列有960个像素点。每个像素点之间的水平距离是相同的,因此将序列作为像素点的高度值则可以渲染出高度地形图。The storage form 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 respectively. For example, the number of sequence data per row of the array indicates the number of pixels per row in the terrain grid. The number of sequence data per column of the array indicates the number of pixels per column in 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 in each column. pixel. 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.

下面对构建渲染区域的过程举例说明。The following is an example of the process of building a rendering area.

在一种可能的实现方式中,基于地形网格数据中的顶点数据以及纹理特征配置,对地形网格区域进行渲染,得到渲染区域。In a possible implementation, the terrain grid area is rendered based on the vertex data and texture feature configuration in the terrain grid data to obtain the rendering area.

在一种可能的实现方式中,基于地形网格数据中的像素点的坐标信息和像素点的高度值,获得地形网格数据中的顶点数据。取样图像中每一个像素点均作为地形网格区域中一个顶点。顶点的数据包括坐标信息和高度值,后续用于顶点的纹理渲染。In a possible implementation, the vertex data in the terrain grid data is obtained based on the coordinate information of the pixel points in the terrain grid data and the height value of the pixel points. Each pixel in the sampled image is regarded as a vertex in the terrain grid area. Vertex data includes coordinate information and height values, which are subsequently used for texture rendering of the vertex.

服务器获取地形网格区域的全部顶点数据,然后根据需要渲染的纹理特征配置,对地形网格区域的全部顶点进行纹理渲染。The server obtains all vertex data of the terrain grid area, and then performs texture rendering on all vertices of the terrain grid area according to the texture feature configuration that needs to be rendered.

通常情况下,需要对整个地形网格区域都进行纹理渲染,但是有的地形因为较大,受限于硬件的问题,无法一次性对整个地形网格区域同时进行渲染,或者不希望占用太多硬件,不会一次性对地形网格区域进行渲染。因此将完整的地形网格区域划分为多个渲染区域,然后按照预设的规则对多个渲染区域进行先后渲染,从而实现整个地形网格区域的渲染。或者,也可以不同时对整个地形网格区域都进行渲染,而是根据需要对特定的渲染区域进行渲染,例如以指定虚拟人物的位置在预设半径内所涉及的渲染区域作为特定的渲染区域进行渲染,从而能够降低渲染所需的硬件要求。Normally, the entire terrain grid area needs to be rendered with texture. However, some terrains are large and limited by hardware issues, so the entire terrain grid area cannot be rendered at the same time, or we do not want to occupy too much space. Hardware, terrain grid areas will not be rendered all at once. Therefore, the complete terrain grid area is divided into multiple rendering areas, and then the multiple rendering areas are rendered successively according to the preset rules, thereby realizing the rendering of the entire terrain grid area. Alternatively, the entire terrain grid area may not be rendered at the same time, but a specific rendering area may be rendered as needed. For example, the rendering area involved in the specified virtual character's position within a preset radius may be used as a specific rendering area. rendering, thereby reducing the hardware requirements required for rendering.

纹理特征配置是通过地形纹理图作为地形纹理数据。具体的,对地形纹理图进行解析,得到地形纹理图中所有像素点的色彩分布数据,色彩的数据为RGB数据,然后将该些色彩分布数据作为地形纹理数据(包括像素点数量、像素点对应的色彩)。Texture feature configuration is through terrain texture map as terrain texture data. Specifically, the terrain texture map is analyzed 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 corresponding pixels). color).

在一种可能的实现中,对待渲染的地形网格区域,通过将地形纹理数据在该地形网格区域中进行密铺,使得该地形网格区域全部完成渲染。In one possible implementation, the terrain grid area to be rendered is completely rendered by densely paving the terrain texture data in the terrain grid area.

密铺是指将地形纹理数据(或者说地形纹理图)在地形网格区域内进行平铺填充,使得地形网格区域整个区域表面被地形纹理图完全覆盖。Dense tiling refers to tiling and filling terrain texture data (or terrain texture map) in the terrain grid area, so that the entire surface of the terrain grid area is completely covered by the terrain texture map.

在一种可能的实现中,通过配置平铺度参数来调整密铺的精度。例如地形纹理图的像素尺寸是20*20,需要在一个尺寸为40*40的渲染区域内进行平铺,根据平铺度的不同,可以在40*40的渲染区域内选择1:1的平铺度,此时则40*40的渲染区域内每个像素点都被一一覆盖渲染到,此时平铺地形纹理图的数量是4张;当选择1:4的平铺度,则40*40的渲染区域内只有四分之一的像素点被覆盖到,也即每4个像素点中有一个像素点被渲染。In one possible implementation, the accuracy of dense tiling is adjusted by configuring tiling parameters. For example, the pixel size of the terrain texture map is 20*20, and it needs to be tiled in a rendering area of 40*40 size. Depending on the tiling degree, a 1:1 tiling 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. At this time, the number of tiled terrain texture maps is 4; when the tiling ratio of 1:4 is selected, then 40 Only a quarter of the pixels in the *40 rendering area are covered, that is, one pixel out of every four pixels is rendered.

可选地,图1所示方法由一个计算设备执行。或者,图1所示方法由包括多个计算设备的计算设备集群协同执行。例如,计算设备A执行图1所示方法中S110,计算设备B执行图1所示方法中S120。计算设备例如为终端或者服务器。在一种可能的实现中,附图1所示方法由计算设备通过运行应用程序执行。应用程序例如为浏览器软件或者客户端软件,本实施例对图1所示方法的执行主体不做限定。Optionally, the method shown in Figure 1 is performed by a computing device. Alternatively, the method shown in FIG. 1 is collaboratively executed by a computing device cluster including multiple computing devices. For example, computing device A executes S110 in the method shown in FIG. 1 , and computing device B executes S120 in the method shown in FIG. 1 . The computing device is, for example, a terminal or a server. In a possible implementation, the method shown in Figure 1 is executed by a computing device by running an application program. The application program is, for example, browser software or client software. This embodiment does not limit the execution subject of the method shown in Figure 1 .

图3是本申请实施例提供的一种草地渲染装置的结构示意图,图3所示的装置200包括:Figure 3 is a schematic structural diagram of a grass rendering device provided by an embodiment of the present application. The device 200 shown in Figure 3 includes:

获取模块210,用于获取渲染区域中的渲染中心;Obtaining module 210 is used to obtain the rendering center in the rendering area;

确定模块220,用于基于渲染区域中单位区域与渲染中心之间的渲染距离,确定草插片,草插片包括至少一个顶点,草插片中的顶点数量与渲染距离负相关;The determination module 220 is configured to determine the grass insert based on the rendering distance between the unit area in the rendering area and the rendering center. The grass insert includes at least one vertex, and the number of vertices in the grass insert is negatively related to the rendering distance;

渲染模块230,用于向单位区域中插入草插片。The rendering module 230 is used to insert grass inserts into the unit area.

在一种可能的实现方式中,草插片包括第一草插片以及第二草插片,第一草插片中的顶点数量大于第二草插片中的顶点数量,确定模块220,用于响应于确定渲染距离小于或等于距离阈值,确定第一草插片;或者,响应于确定渲染距离大于或等于距离阈值,确定第二草插片。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. The determination module 220 uses In response to determining that the rendering distance is less than or equal to the distance threshold, a first grass patch is determined; or in response to determining that the rendering distance is greater than or equal to the distance threshold, a second grass patch is determined.

在一种可能的实现方式中,确定模块220,用于基于渲染距离以及第一对应关系,确定草插片,第一对应关系指示渲染距离以及第一数量之间的对应关系,草插片中的顶点数量为第一数量。In a possible implementation, the determining module 220 is configured to determine the grass inserts based on the rendering distance and the first correspondence. The first correspondence indicates the correspondence between the rendering distance and the first quantity. In the grass inserts The number of vertices is the first number.

在一种可能的实现方式中,确定模块220,用于基于单位区域内的渲染数据,确定草插片的数量;渲染模块230,用于向单位区域中插入数量的草插片。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; the rendering module 230 is used to insert the number of grass inserts into the unit area.

在一种可能的实现方式中,渲染数据包括单位区域内草地纹理的占比,确定模块220,用于基于单位区域内草地纹理的占比,确定草插片的数量,草插片的数量与草地纹理的占比正相关。In a possible implementation, the rendering data includes the proportion of grass texture in the unit area, and the determination module 220 is configured to determine the number of grass inserts based on the proportion of grass texture in the unit area. The number of grass inserts is equal to The proportion of grass texture is positively related.

在一种可能的实现方式中,渲染数据包括单位区域内像素点的颜色数据,确定模块220,用于基于像素点的颜色数据与草地颜色阈值之间的比值,确定草插片的数量。In a possible implementation, the rendering data includes color data of pixels in the unit area, and the determination module 220 is configured to determine the number of grass inserts based on the ratio between the color data of the pixels and the grass color threshold.

在一种可能的实现方式中,确定模块220,用于基于单位区域内每个像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定草插片的数量;或者,基于单位区域内中心像素点的颜色数据与草地颜色阈值之间的比值,确定草插片的数量;或者,基于单位区域内各个角点的像素点的颜色数据的平均值与草地颜色阈值之间的比值,确定草插片的数量。In a possible implementation, the determination module 220 is configured to determine the number of grass inserts based on the ratio between the average color data of each pixel in the unit area and the grass color threshold; or, based on the unit area The number of grass inserts is determined by the ratio between the color data of the central pixel and the grass color threshold; or, based on the ratio between the average color data of the pixels at each corner point in the unit area and the grass color threshold, Determine the number of grass inserts.

在一种可能的实现方式中,确定模块220,用于确定单位区域的渲染数据满足草地纹理特征。In a possible implementation, the determining module 220 is configured to determine that the rendering data of the unit area satisfies the grass texture characteristics.

在一种可能的实现方式中,确定模块220,还用于基于虚拟对象所处的位置以及预设半径,确定渲染区域,渲染区域的边界与虚拟对象所处的位置之差为预设半径。In a possible implementation, the determination module 220 is also used to determine the rendering area based on the location of the virtual object and the preset radius. The difference between the boundary of the rendering area and the location of the virtual object is the preset radius.

在一种可能的实现方式中,获取模块210,用于获取虚拟对象所处的位置,作为渲染中心。In a possible implementation, the obtaining module 210 is used to obtain the position of the virtual object as the rendering center.

图4是本申请实施例提供的一种服务器的结构示意图,服务器300包括:处理器301,处理器301与存储器302耦合,存储器302中存储有至少一条计算机程序指令,至少一条计算机程序指令由处理器301加载并执行,以使服务器300实现图1实施例提供的方法。Figure 4 is a schematic structural diagram of a server 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. The at least one computer program instruction is processed by The server 301 is loaded and executed, so that the server 300 implements the method provided by the embodiment of FIG. 1 .

本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分可互相参考,每个实施例重点说明的都是与其他实施例的不同之处。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. Each embodiment focuses on its differences from other embodiments.

A参考B,指的是A与B相同或者A为B的简单变形。A refers to B, which means that A is the same as B or that A is a simple transformation of B.

本申请实施例的说明书和权利要求书中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序,也不能理解为指示或暗示相对重要性。例如,第一草插片和第二草插片用于区别不同的草插片,而不是用于描述草插片的特定顺序,也不能理解为第一草插片比第二草插片更重要。The terms "first" and "second" in the description and claims of the embodiments of this application are used to distinguish different objects, rather than to describe a specific order of objects, and cannot be understood to indicate or imply relative importance. sex. For example, the first grass insert and the second grass insert are used to distinguish different grass inserts, rather than describing a specific order of grass inserts, nor should it be understood that the first grass insert is more advanced than the second grass insert. important.

本申请实施例所涉及的信息(包括但不限于用户设备信息、用户个人信息等)、数据(包括但不限于用于分析的数据、存储的数据、展示的数据等)以及信号,均为经用户授权或者经过各方充分授权的,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。The information (including but not limited to user equipment 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 this application are all processed. Authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

上述实施例可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例描述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘SolidState Disk(SSD))等。The above embodiments may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may 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 accordance with the embodiments of the present application are 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 or transmitted from one computer-readable storage medium to another, e.g., the computer instructions may be transferred from a website, computer, server, or data center Transmission to another website, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), etc.

以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。The above embodiments are only used to illustrate the technical solutions of the present application, but 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. Modifications may be made to the recorded technical solutions, or equivalent substitutions may be made to some of the technical features; however, these modifications or substitutions do not cause the essence of the corresponding technical solutions to depart from the scope of the technical solutions of the embodiments of the present application.

Claims (15)

1. A method of grass rendering, the method comprising:
acquiring a rendering center in a rendering area;
determining a grass insert based on a rendering distance between a unit area in the rendering area and the rendering center, the grass insert comprising at least one vertex, the number of vertices in the grass insert being inversely related to the rendering distance;
the grass blades are inserted into the unit areas.
2. The method of claim 1, wherein the grass blades include a first grass blade and a second grass blade, the number of vertices in the first grass blade being greater than the number of vertices in the second grass blade, the determining a grass blade based on a rendering distance between a unit area in the rendering area and the rendering center comprising:
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 insert sheet is determined.
3. The method of claim 1, wherein the determining a grass insert based on a rendering distance between a unit area of the rendering area and the rendering center comprises:
and determining a grass insert based on the rendering distance and a first corresponding relation, wherein the first corresponding relation indicates a corresponding relation between the rendering distance and a first quantity, and the quantity of vertexes in the grass insert is the first quantity.
4. The method of claim 1, wherein said inserting the grass blades into the unit area comprises:
determining the number of grass blades based on the rendering data within the unit area;
inserting said number of said grass blades into said unit area.
5. The method of claim 4, wherein the rendering data includes a duty cycle of a grass texture within the unit area, and wherein determining the number of grass blades based on the rendering data of the unit area includes:
And determining the number of the grass blades based on the duty ratio of the grass texture in the unit area, wherein the number of the grass blades is positively correlated with the duty ratio of the grass texture.
6. The method of claim 4, wherein the rendering data includes color data for pixels within the unit area, and wherein the determining the number of grass blades based on the rendering data within the unit area includes:
and determining the number of the grass blades based on the ratio between the color data of the pixel points and the grass color threshold.
7. The method of claim 4, wherein the determining the number of grass blades based on a ratio between the color data of the pixel points and a grass color threshold comprises:
determining the number of the grass blades 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 value; or,
determining the number of the grass blades based on the ratio between the color data of the central pixel point in the unit area and the grass color threshold; or,
and determining the number of the grass inserting sheets based on the ratio between the average value of the color data of the pixel points of each angular point in the unit area and the grassland color threshold value.
8. The method of claim 1, wherein the determining a grass blade is preceded by determining a grass blade based on a rendering distance between a unit area of the rendering area and the rendering center, the method further comprising:
determining that the rendered data for the unit area satisfies a grass texture feature.
9. The method of claim 1, wherein prior to the acquiring the rendering center in the rendering region, the method further comprises:
and determining 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.
10. The method of claim 1, wherein the obtaining a rendering center in a rendering region comprises:
and acquiring the position of the virtual object as a rendering center.
11. The method of claim 1, wherein the obtaining a rendering center in a rendering region comprises:
acquiring a camera position as a rendering center; or,
acquiring a light source position as a rendering center; or,
and acquiring the user interaction position as a rendering center.
12. The method of claim 1, wherein the determining a grass insert based on a distance between a unit area in the rendering area and the rendering center comprises:
Determining a resolution of a texture map based on a distance between a unit area in the rendering area and the rendering center, the resolution of the texture map being inversely related to the distance;
a grass insert having a resolution of the texture map is determined.
13. A lawn rendering device, comprising:
the acquisition module is used for acquiring a rendering center in the rendering area;
a determining module for determining a grass blade based on a rendering distance between a unit area in the rendering area and the rendering center, the grass blade comprising at least one vertex, the number of vertices in the grass blade being inversely related to the rendering distance;
an insertion module for inserting the grass blades into the unit area.
14. A server, the server comprising: a processor coupled to a memory having stored therein at least one computer program instruction that is loaded and executed by the processor to cause the server to implement the method of any of claims 1-12.
15. A computer readable storage medium, characterized in that at least one instruction is stored in the storage medium, which instructions, when run on a computer, cause the computer to perform the method according to any of claims 1-12.
CN202311172742.8A 2023-09-12 2023-09-12 Grass rendering method and device Active CN117475053B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311172742.8A CN117475053B (en) 2023-09-12 2023-09-12 Grass rendering method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311172742.8A CN117475053B (en) 2023-09-12 2023-09-12 Grass rendering method and device

Publications (2)

Publication Number Publication Date
CN117475053A true CN117475053A (en) 2024-01-30
CN117475053B CN117475053B (en) 2025-02-11

Family

ID=89622835

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311172742.8A Active CN117475053B (en) 2023-09-12 2023-09-12 Grass rendering method and device

Country Status (1)

Country Link
CN (1) CN117475053B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118710776A (en) * 2024-06-18 2024-09-27 北京达佳互联信息技术有限公司 Image rendering method, device, electronic device and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120313937A1 (en) * 2010-01-18 2012-12-13 Disney Enterprises, Inc. Coupled reconstruction of hair and skin
CN105913476A (en) * 2016-06-14 2016-08-31 腾讯科技(深圳)有限公司 Rendering method and device of vegetation image
US20170193690A1 (en) * 2016-01-04 2017-07-06 Samsung Electronics Co., Ltd. 3d rendering method and apparatus
CN110264553A (en) * 2019-07-19 2019-09-20 网易(杭州)网络有限公司 The method and apparatus of surface vegetation processing
CN110288688A (en) * 2019-06-20 2019-09-27 网易(杭州)网络有限公司 Rendering method, device, storage medium and the electronic equipment of virtual vegetation
CN114028807A (en) * 2021-11-05 2022-02-11 腾讯科技(深圳)有限公司 Rendering method, device and equipment of virtual object and readable storage medium
CN114387378A (en) * 2021-12-30 2022-04-22 中国电信股份有限公司 Image generation method and device based on digital twin rendering engine and electronic equipment
CN115439577A (en) * 2022-09-29 2022-12-06 Oppo广东移动通信有限公司 Image rendering method and device, terminal equipment and storage medium
CN115564881A (en) * 2022-10-21 2023-01-03 网易(杭州)网络有限公司 Terrain model rendering method, device, equipment and computer readable storage medium
CN115738246A (en) * 2022-10-25 2023-03-07 网易(杭州)网络有限公司 Method and device for constructing insert piece combination model and electronic equipment
CN115937389A (en) * 2022-12-30 2023-04-07 网易(杭州)网络有限公司 Shadow rendering method, device, storage medium and electronic equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120313937A1 (en) * 2010-01-18 2012-12-13 Disney Enterprises, Inc. Coupled reconstruction of hair and skin
US20170193690A1 (en) * 2016-01-04 2017-07-06 Samsung Electronics Co., Ltd. 3d rendering method and apparatus
CN105913476A (en) * 2016-06-14 2016-08-31 腾讯科技(深圳)有限公司 Rendering method and device of vegetation image
CN110288688A (en) * 2019-06-20 2019-09-27 网易(杭州)网络有限公司 Rendering method, device, storage medium and the electronic equipment of virtual vegetation
CN110264553A (en) * 2019-07-19 2019-09-20 网易(杭州)网络有限公司 The method and apparatus of surface vegetation processing
CN114028807A (en) * 2021-11-05 2022-02-11 腾讯科技(深圳)有限公司 Rendering method, device and equipment of virtual object and readable storage medium
CN114387378A (en) * 2021-12-30 2022-04-22 中国电信股份有限公司 Image generation method and device based on digital twin rendering engine and electronic equipment
CN115439577A (en) * 2022-09-29 2022-12-06 Oppo广东移动通信有限公司 Image rendering method and device, terminal equipment and storage medium
CN115564881A (en) * 2022-10-21 2023-01-03 网易(杭州)网络有限公司 Terrain model rendering method, device, equipment and computer readable storage medium
CN115738246A (en) * 2022-10-25 2023-03-07 网易(杭州)网络有限公司 Method and device for constructing insert piece combination model and electronic equipment
CN115937389A (en) * 2022-12-30 2023-04-07 网易(杭州)网络有限公司 Shadow rendering method, device, storage medium and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118710776A (en) * 2024-06-18 2024-09-27 北京达佳互联信息技术有限公司 Image rendering method, device, electronic device and storage medium

Also Published As

Publication number Publication date
CN117475053B (en) 2025-02-11

Similar Documents

Publication Publication Date Title
US11386528B2 (en) Denoising filter
CN113658316B (en) Rendering method and device of three-dimensional model, storage medium and computer equipment
CN103218846B (en) The ink and wash analogy method of Three-dimension Tree model
CN109087369A (en) Virtual objects display methods, device, electronic device and storage medium
CN110115841B (en) Rendering method and device for vegetation object in game scene
WO2023185262A1 (en) Illumination rendering method and apparatus, computer device, and storage medium
CN106898040A (en) Virtual resource object rendering intent and device
CN108805971A (en) A kind of ambient light masking methods
WO2024212849A1 (en) Full-viewing-angle depth information construction method and apparatus, device, and storage medium
CN117475053B (en) Grass rendering method and device
US10909752B2 (en) All-around spherical light field rendering method
CN112516595B (en) Magma rendering method, device, equipment and storage medium
EP3437072B1 (en) System and method for rendering points without gaps
WO2023184139A1 (en) Methods and systems for rendering three-dimensional scenes
CN111462343B (en) Data processing method and device, electronic equipment and storage medium
CN117197276A (en) Grassland rendering method and device
CN117197275A (en) Terrain rendering method and device
CN115035231A (en) Shadow baking method, shadow baking device, electronic apparatus, and storage medium
CN113144591A (en) Virtual character edge drawing method and device and electronic equipment
CN118710820B (en) Model optimization method and device and electronic equipment
US20240193864A1 (en) Method for 3d visualization of sensor data
CN115439314A (en) Stylization method, equipment and storage medium
CN107481184A (en) A kind of low polygon style figure generation interactive system
CN117333603A (en) Virtual model rendering method, device, equipment and storage medium
CN117861199A (en) Color difference processing method and device in game, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant