Game terrain rendering method and device, electronic equipment and storage medium

Through the combination of quad-tree and LOD page table, the unit to be rendered is determined and the target height parameter index is obtained, which solves the problem of low rendering efficiency of game terrain, and realizes efficient synchronous rendering of multiple rendering units, improving user experience.

CN120346523APending Publication Date: 2025-07-22BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510568452.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In the prior art, the rendering efficiency of game terrain is low, resulting in poor user experience, making it difficult to effectively render multiple rendering units at once.

Method used

Using a combination of quad-tree and LOD page table, the unit to be rendered is determined through the camera position, the target height parameter index is obtained, and the rendering parameters are obtained from the height texture map using the GPU to realize the synchronous rendering of multiple units to be rendered.

Benefits of technology

It improves the efficiency of game terrain rendering, improves user experience, reduces waste of computing resources, and reduces frame interval time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120346523A_ABST
    Figure CN120346523A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a game terrain rendering method and device, electronic equipment and a storage medium, and relates to the technical field of computers. Determining a plurality of units to be rendered from the plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain; obtaining a target parameter index corresponding to each to-be-rendered target height parameter according to the LOD level and the LOD page table of each to-be-rendered unit; and determining a storage position corresponding to each target height parameter according to each target parameter index, and sending the storage position corresponding to each target height parameter to the GPU, so that the GPU obtains the target height parameter from the height texture map according to each storage position, and renders the game terrain according to the target height parameter. In this way, the multiple target height parameters can be obtained at a time to render the multiple to-be-rendered units in the game terrain, so that the rendering efficiency can be improved, and the user experience feeling is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular, to a method, device, electronic device, and storage medium for rendering game terrain. Background Art

[0002] In order to ensure the user's gaming experience, mathematical algorithms and randomness can be used during the game to create a realistic natural terrain through rendering. In the prior art, height parameters are generally generated for the plots to be rendered, and the game terrain is rendered according to the height parameters. However, since each rendering unit has its own height parameter, it is often necessary to draw each rendering unit independently, and it is difficult to render multiple rendering units at one time, resulting in low rendering efficiency and poor user experience. Summary of the Invention

[0003] In view of this, the purpose of the present application is to provide a method, device, electronic device, and storage medium for rendering game terrain to improve the rendering efficiency and thus improve the user experience.

[0004] To achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:

[0005] In a first aspect, the present application provides a method for rendering game terrain, which is applied to an electronic device. A quadtree, a LOD page table, and a height texture map corresponding to the game terrain are stored in the electronic device. The height texture map is stored in the GPU. The quadtree includes a plurality of quadtree units, each quadtree unit corresponding to a LOD level. A plurality of height parameters are stored in the height texture map. The LOD page table stores the correspondence between each LOD level and a parameter index, and the parameter index represents the storage position of the height parameter corresponding to the LOD level in the height texture map. The method includes:

[0006] Determine a plurality of units to be rendered from the plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain;

[0007] Obtain the target parameter index corresponding to the target height parameter to be rendered for each according to the LOD level of each unit to be rendered and the LOD page table;

[0008] Determine the storage position corresponding to each target height parameter according to each target parameter index, and send the storage position corresponding to each target height parameter to the GPU, so that the GPU obtains the target height parameter from the height texture map according to each storage position and renders the game terrain according to the target height parameter.

[0009] In an alternative embodiment, determining a plurality of units to be rendered from a plurality of the quadtree units according to the current camera position and the quadtree corresponding to the game terrain includes:

[0010] Determining a camera frustum according to the current camera position;

[0011] Traversing the quadtree, and for each of the quadtree units, determining whether a bounding box of the quadtree unit intersects with the camera frustum;

[0012] If the bounding box of the quadtree unit intersects with the camera frustum, determining the quadtree unit as the unit to be rendered when a distance between the quadtree unit and the current camera position is less than a rendering distance corresponding to the quadtree unit.

[0013] In an alternative embodiment, obtaining a target parameter index corresponding to a target height parameter according to LOD levels of the units to be rendered and the LOD page table includes:

[0014] For each of the units to be rendered, determining whether a parameter index corresponding to the unit to be rendered is empty according to the LOD level of the unit to be rendered and the LOD page table;

[0015] If the parameter index is empty, taking a previous LOD level of the LOD level of the unit to be rendered as a target LOD level, and determining whether a parameter index corresponding to the target LOD level is empty according to the target LOD level and the LOD page table;

[0016] If the parameter index corresponding to the target LOD level is empty, taking a previous LOD level of the target LOD level as a new target LOD level, and determining whether a parameter index corresponding to the new target LOD level is empty according to the new target LOD level and the LOD page table until the parameter index is not empty;

[0017] If the parameter index is not empty, determining the parameter index as the target parameter index.

[0018] In an alternative embodiment, the storage location includes a starting coordinate and a scaling factor;

[0019] According to the target parameter indexes, determining storage locations corresponding to the target height parameters, and sending the storage locations corresponding to the target height parameters to the GPU, so that the GPU obtains the target height parameters from the height texture map according to the storage locations includes:

[0020] For each of the target parameter indices, calculate the starting coordinates corresponding to the target height parameter according to the target parameter index, and calculate the scaling factor corresponding to the target height parameter according to the target LOD level corresponding to the target parameter index and the LOD level corresponding to the unit to be rendered.

[0021] Send the starting coordinates and the scaling factor to the GPU, so that the GPU calculates the UV coordinate position of the target height parameter in the height texture map according to the starting coordinates and the scaling factor, and obtains the target height parameter from the height texture map according to the UV coordinate position.

[0022] In an alternative embodiment, the method further includes:

[0023] If the target LOD level corresponding to the storage location of the height parameter is inconsistent with the LOD level of the unit to be rendered, generate a height parameter corresponding to the LOD level of the unit to be rendered.

[0024] Determine a target parameter index in the height texture map, store the height parameter in the height texture map according to the target parameter index, and update the LOD page table according to the target parameter index and the LOD level.

[0025] In an alternative embodiment, determining a target parameter index in the height texture map includes:

[0026] If there is at least one blank storage location in the height texture map, determine the parameter index corresponding to any one of the blank storage locations as the target parameter index;

[0027] If there is no blank storage location in the height texture map, obtain the application duration corresponding to each storage location, and determine a target parameter index from the parameter indices corresponding to multiple storage locations according to the application duration; wherein, the application duration represents the duration from the moment when the height parameter stored at the storage location is rendered to the current moment.

[0028] In a second aspect, the present application provides a game terrain rendering device, which is applied to an electronic device. The electronic device stores a quadtree, an LOD page table, and a height texture map corresponding to the game terrain. The height texture map is stored in the GPU. The quadtree includes multiple quadtree units, and each quadtree unit corresponds to an LOD level. The height texture map stores multiple height parameters. The LOD page table stores the corresponding relationship between each LOD level and a parameter index. The parameter index represents the storage location of the height parameter corresponding to the LOD level in the height texture map. The device includes:

[0029] A determination module, configured to determine a plurality of units to be rendered from a plurality of the quadtree units according to the current camera position and the quadtree corresponding to the game terrain;

[0030] An acquisition module, configured to obtain a target parameter index corresponding to a target height parameter to be rendered for each according to the LOD level of each unit to be rendered and the LOD page table;

[0031] The determination module is further configured to determine a storage location corresponding to each target height parameter according to each target parameter index, and send the storage location corresponding to each target height parameter to the GPU, so that the GPU obtains the target height parameter from the height texture map according to each storage location, and renders the game terrain according to the target height parameter.

[0032] In an optional implementation manner, the determination module is further configured to determine a camera frustum according to the current camera position; traverse the quadtree, and respectively determine whether the bounding box of each quadtree unit intersects with the camera frustum; if the bounding box of the quadtree unit intersects with the camera frustum, when the distance between the quadtree unit and the current camera position is less than the rendering distance corresponding to the quadtree unit, determine the quadtree unit as the unit to be rendered.

[0033] In a third aspect, the present application provides an electronic device, including a processor and a memory, the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the method according to any one of the foregoing embodiments.

[0034] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method according to any one of the foregoing embodiments is implemented.

[0035] The game terrain rendering method, device, electronic device, and storage medium provided by the embodiments of the present application. In the electronic device, a quadtree, an LOD page table, and a height texture map corresponding to the game terrain are stored. Among them, the height texture map is stored in the GPU. Then, the electronic device can determine multiple units to be rendered from multiple quadtree units according to the current camera position and the quadtree corresponding to the game terrain. After that, according to the LOD levels and the LOD page table of each unit to be rendered, the target parameter index corresponding to the target height parameter of each unit to be rendered can be obtained. Thus, the storage location corresponding to each target height parameter can be determined according to each target parameter index, and the storage location corresponding to each target height parameter is sent to the GPU. The GPU obtains the target height parameter from the height texture map according to this storage location and renders the game terrain according to this target height parameter. In this way, multiple target height parameters can be obtained at one time to render multiple units to be rendered in the game terrain. Therefore, the rendering efficiency can be improved, and the user experience can be improved accordingly.

[0036] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required in the embodiments. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative efforts.

[0038] Figure 1 The block diagram of the electronic device 10 provided by the embodiments of the present application is shown;

[0039] Figure 2 A flowchart of a game terrain rendering method provided by the embodiments of the present application is shown;

[0040] Figure 3 An example diagram of rendering the game terrain using the target height parameter is shown;

[0041] Figure 4 The functional module diagram of a game terrain rendering device provided by the embodiments of the present application is shown.

[0042] Markings: 10 - electronic device; 100 - memory; 110 - processor; 120 - communication module; 200 - determination module; 210 - acquisition module. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0043] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations.

[0044] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but merely represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.

[0045] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0046] Please refer to Figure 1 , which is a block diagram of an electronic device 10 provided by an embodiment of the present application. The electronic device 10 includes a memory 100, a processor 110, and a communication module 120. The elements of the memory 100, the processor 110, and the communication module 120 are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines.

[0047] Among them, the memory 100 is used to store computer programs or data that can be executed by the processor. The memory 100 can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electric Erasable Programmable Read-Only Memory (EEPROM), etc.

[0048] The processor 110 is used to read / write the data or computer programs stored in the memory and execute the computer program to implement the game terrain rendering method provided by the embodiments of the present application.

[0049] The communication module 120 is used to establish a communication connection between the electronic device and other communication terminals through the network and is used to send and receive data through the network.

[0050] Optionally, a quadtree, a LOD page table, and a height texture map corresponding to the game terrain can be stored in the electronic device.

[0051] In this embodiment, a GPU can be provided in the electronic device, and the height texture map can be stored in the GPU. Multiple height parameters are stored in the height texture map.

[0052] Optionally, the quadtree can include multiple quadtree units, and each quadtree unit corresponds to a Level of Detail (LOD) level.

[0053] In this embodiment, the entire game terrain can be divided in a quadtree manner in advance to obtain a quadtree corresponding to the game terrain. The quadtree can include multiple quadtree units, and each quadtree unit includes a parent node and four child nodes corresponding to the parent node.

[0054] Optionally, the depth of the quadtree can be determined according to the maximum number of vertices of each rendering unit. For example, if each rendering unit is 32*32 vertices, the quadtree depth corresponding to a 128*128 game terrain can be

[0055] Optionally, the LOD page table stores the corresponding relationship between each LOD level and the parameter index, and the parameter index represents the storage position of the height parameter corresponding to the LOD level in the height texture map.

[0056] Optionally, physical video memory textures for the game terrain can be allocated in the GPU in advance. In this embodiment, the larger the texture size, the more height data can be cached, the lower the update frequency, and the more performance can be saved. However, the occupied video memory space will also increase accordingly. Therefore, appropriate-sized physical video memory textures can be allocated according to the number of terrain meshes and the size of the device's video memory.

[0057] In this embodiment, the electronic device can store the terrain height map generated according to the camera position into the physical video memory texture to obtain a height texture map. It can be understood that the physical video memory texture includes multiple storage locations, and each storage location corresponds to a parameter index. For the convenience of querying, the electronic device can generate a LOD page table to record the storage locations of the height parameters corresponding to each LOD level.

[0058] Optionally, the parameter index can be the index number, index ID, etc. in the height texture map.

[0059] It should be understood that Figure 1 the structure shown is only a schematic diagram of the electronic device, and the electronic device may also include more or fewer components than those shown in Figure 1 or have a configuration different from that shown in Figure 1 The components shown in can be implemented using hardware, software, or a combination thereof. Figure 1 The components shown in can be implemented using hardware, software, or a combination thereof.

[0060] Next, taking the electronic device in the above Figure 1 as the execution subject, the game terrain rendering method provided by the embodiments of the present application will be introduced exemplarily in combination with the flow diagram. Specifically, Figure 2 is a flow diagram of a game terrain rendering method provided by the embodiments of the present application. Please refer to Figure 2 The method includes:

[0061] Step S20, determining a plurality of units to be rendered from a plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain.

[0062] Optionally, since the position or perspective of the character will change during the game, the camera position will also change. Based on this, the electronic device can determine the units to be rendered in real time according to the camera position and the quadtree corresponding to the game terrain, and render the game terrain.

[0063] Step S21, obtaining the target parameter index corresponding to the target height parameter to be rendered for each unit to be rendered according to the LOD level of each unit to be rendered and the LOD page table.

[0064] Optionally, the height parameters can include terrain height data and normal data.

[0065] Step S22: Determine the storage locations corresponding to the target height parameters according to each target parameter index, and send the storage locations corresponding to the target height parameters to the GPU, so that the GPU can obtain the target height parameters from the height texture map according to each storage location, and render the game terrain according to the target height parameters.

[0066] Optionally, since the target parameter index is only the index of the storage location of the target height parameter, in order to facilitate the GPU to accurately obtain the corresponding height parameter, the electronic device can determine the storage location of the target height parameter according to the target parameter index.

[0067] In this embodiment, the GPU can obtain the corresponding height data and normal data through the height texture map according to the storage location of the target height parameter in the vertex shader of the rendering pipeline, so as to render the game terrain.

[0068] In the game terrain rendering method provided by the embodiments of the present application, a quadtree, an LOD page table, and a height texture map corresponding to the game terrain are stored in the electronic device. Among them, the height texture map is stored in the GPU. Then, the electronic device can determine multiple units to be rendered from multiple quadtree units according to the current camera position and the quadtree corresponding to the game terrain. After that, according to the LOD levels and the LOD page table of each unit to be rendered, obtain the target parameter indexes corresponding to the target height parameters to be rendered for each unit, so as to determine the storage locations corresponding to the target height parameters according to each target parameter index, and send the storage locations corresponding to the target height parameters to the GPU. The GPU obtains the target height parameters from the height texture map according to the storage location, and renders the game terrain according to the target height parameters. In this way, multiple target height parameters can be obtained at one time to render multiple units to be rendered in the game terrain, so the rendering efficiency can be improved, and thus the user experience can be improved.

[0069] Next, a possible implementation manner is provided for how to determine multiple units to be rendered from multiple quadtree units according to the current camera position and the quadtree corresponding to the game terrain.

[0070] Specifically, the electronic device can determine the camera frustum according to the current camera position, traverse the quadtree, and for each quadtree unit, determine whether the bounding box of the quadtree unit intersects the camera frustum. If the bounding box of the quadtree unit intersects the camera frustum, when the distance between the quadtree unit and the current camera position is less than the rendering distance corresponding to the quadtree unit, determine the quadtree unit as the unit to be rendered.

[0071] Optionally, the electronic device can perform an intersection operation on the bounding box of each quadtree unit and the camera frustum to determine whether the bounding box of the quadtree unit intersects the camera frustum.

[0072] In this embodiment, if the bounding box of a quadtree unit intersects with the camera frustum, it indicates that the quadtree unit is within the camera's line of sight.

[0073] In a possible implementation, if the bounding box of a certain quadtree unit does not intersect with the camera frustum, it indicates that the bounding boxes of the lower-level quadtree units of this quadtree unit also do not intersect with the camera frustum. Therefore, there is no need to continue traversing downwards at this time. Optionally, after determining that a quadtree unit is within the camera's line of sight, it is also necessary to determine the distance between the quadtree unit and the camera position.

[0074] Optionally, the rendering distance corresponding to each quadtree unit can be determined according to the maximum field of view range and the highest precision range during program initialization.

[0075] It can be understood that the unit to be rendered refers to a quadtree unit that is within the camera's field of view and is relatively close to the camera position.

[0076] In an example, the following is a code example for determining the unit to be rendered:

[0077] for(auto it:mKarstBlocks){

[0078] it.second->instance->checkRenderNodes(pCamera,renderNodes);

[0079] }

[0080] Next, a possible implementation is provided for how to obtain the target parameter index corresponding to the target height parameter according to the LOD levels and LOD page tables of each unit to be rendered.

[0081] In this embodiment, the electronic device can respectively determine for each unit to be rendered whether the parameter index corresponding to the unit to be rendered is empty according to the LOD level and LOD page table of the unit to be rendered. If the parameter index is empty, the upper LOD level of the LOD level of the unit to be rendered is used as the target LOD level, and according to the target LOD level and LOD page table, it is determined whether the parameter index corresponding to the target LOD level is empty. If the parameter index corresponding to the target LOD level is empty, the upper LOD level of the target LOD level is used as the new target LOD level, and according to the new target LOD level and LOD page table, it is determined whether the parameter index corresponding to the new target LOD level is empty until the parameter index is not empty.

[0082] In this embodiment, if the parameter index is not empty, the electronic device can determine that the parameter index is the target parameter index.

[0083] Optionally, considering that the camera position in the game changes almost every frame, different levels of LOD height parameters may be required for rendering according to different camera positions. To avoid occupying excessive video memory resources, the height texture map may not store the height parameters corresponding to each LOD level. Therefore, when the camera position changes, there may be a problem that the height parameters corresponding to the LOD level to be rendered are not stored in the height texture map. At this time, to avoid the situation where the game terrain cannot be rendered and thus affect the user's gaming experience, the electronic device can first render the game terrain according to the height parameters corresponding to the higher LOD level.

[0084] Optionally, the electronic device can look up in the LOD page table according to the LOD level of the unit to be rendered to determine the parameter index corresponding to the unit to be rendered. If the parameter index is empty, it means that the height parameters corresponding to this LOD level are not stored in the height texture map. Therefore, the electronic device can sequentially look up the parameter index according to the higher LOD level of this LOD level until the corresponding parameter index is found.

[0085] Optionally, to avoid the situation where height parameters cannot be obtained, the height parameters corresponding to the lowest LOD level are added first during game initialization.

[0086] In an example, if the LOD level of the unit to be rendered is 5 and the parameter index corresponding to this LOD level is empty, the electronic device can first use 4 as the target LOD level to look up and determine whether the parameter index corresponding to 4 is empty. If it is still empty, then use 3 as the target LOD level to look up, and so on, until the corresponding parameter index is found. It can be understood that the accuracy of the height parameters corresponding to the higher LOD level is lower than that of the height parameters corresponding to the current LOD level. In this embodiment, if there is no high-precision height parameter corresponding to the current LOD level, the lower-precision height parameter can be obtained first to render the game terrain to avoid the situation where the game terrain cannot be rendered and thus affect the user's gaming experience.

[0087] Optionally, if the parameter index is not empty, the target height data can be directly obtained according to the parameter index for rendering.

[0088] Optionally, the target parameter index can be used to determine the storage location of the target height parameter.

[0089] In a possible implementation, the storage location may include a starting coordinate and a scaling factor. After obtaining the target parameter index, the electronic device can, for each target parameter index, calculate the starting coordinate corresponding to the target height parameter according to the target parameter index, and calculate the scaling factor corresponding to the target height parameter according to the target LOD level corresponding to the target parameter index and the LOD level corresponding to the unit to be rendered. Then, the starting coordinate and the scaling factor are sent to the GPU, so that the GPU can calculate the UV coordinate position of the target height parameter in the height texture map according to the starting coordinate and the scaling factor, and obtain the target height parameter from the height texture map according to the UV coordinate position.

[0090] Optionally, since the parameter index can be the index number in the height texture map, the electronic device can determine the starting position coordinate of the target height parameter in the height texture map according to the parameter index.

[0091] Optionally, the scaling factor can be calculated according to the difference between the target LOD level corresponding to the target parameter index and the LOD level corresponding to the unit to be rendered. For example, if the difference is d, then the scaling factor s = pow(2, d).

[0092] It can be understood that if the electronic device can directly obtain the parameter index corresponding to the LOD level of the rendering unit, the scaling factor should be empty, and the GPU can directly obtain the target height parameter from the height texture map according to the starting coordinate.

[0093] In an example, the following is a code example for obtaining the target parameter index, the starting coordinate, and the scaling factor:

[0094]

[0095]

[0096] In this example, the following is a code example for obtaining the UV coordinate position:

[0097] KarstElementInfo info;

[0098] info.nodeUV = Vector2((float)node->mQuadtreeNode->mXOffset, (float)node->mQuadtreeNode->mYOffset) / (float)options->mGridNum;

[0099] info.basePostion = node->mBasePosition;

[0100] KarstVTCoord vtCoord;

[0101] vTexture->getNodeTexture(vtCoord, node);

[0102] mRenderBatchInfo.push_back(info);

[0103] In this example, Figure 3 It is an example diagram for rendering the game terrain using the target height parameter.

[0104] Optionally, in order to ensure the generation effect of the game terrain, if the height parameter corresponding to the LOD level to be rendered is not stored in the height texture map, it is also necessary to generate the corresponding height parameter for this LOD level for storage for subsequent use. Specifically, if the target LOD level corresponding to the storage location of the height parameter is inconsistent with the LOD level of the unit to be rendered, the electronic device can generate the height parameter corresponding to the LOD level of the unit to be rendered, determine the target parameter index in the height texture map, store the height parameter into the height texture map according to the target parameter index, and update the LOD page table according to the target parameter index and the LOD level.

[0105] It can be understood that if the target LOD level corresponding to the storage location of the height parameter is inconsistent with the LOD level of the unit to be rendered, it means that the height parameter corresponding to the LOD level to be rendered is not stored in the height texture map. At this time, it is also necessary to generate the height parameter corresponding to this LOD level, store it in the height texture map, and update the LOD page table at the same time.

[0106] In this embodiment, considering that when the CPU generates the height parameter, it often needs to perform cyclic sampling in the CPU, and the efficiency is low. Therefore, the game terrain rendering method provided in the embodiment of the present application utilizes the texture parallel sampling characteristic of the GPU to generate the new height parameter through bilinear sampling, which can greatly improve the sampling efficiency compared with the CPU and shorten the frame interval time.

[0107] Optionally, the storage location corresponding to the target parameter index can be a blank location or a location where the stored height parameter has not been used for a long time.

[0108] Specifically, if there is at least one blank storage location in the height texture map, the parameter index corresponding to any blank storage location is determined as the target parameter index. If there is no blank storage location in the height texture map, the application duration corresponding to each storage location is obtained, and the target parameter index is determined from the parameter indexes corresponding to multiple storage locations according to the application duration; where the application duration represents the duration from the moment when the height parameter stored at the storage location is rendered to the current moment.

[0109] It can be understood that if there are blank positions in the height texture map, the newly generated height parameters can be stored at these blank positions. If there are no blank positions in the height texture map, the newly generated height parameters can replace the height parameters that have not been used for a long time.

[0110] Optionally, the electronic device may determine the parameter index corresponding to the index position where the application duration exceeds the preset duration as the target parameter index.

[0111] In this embodiment, the preset duration can be set according to the actual application situation.

[0112] It can be understood that actually a part of the height data that does not need to be rendered currently is cached and redundant in the height texture map.

[0113] Considering that in the prior art, when generating height parameters, it is often necessary to continuously generate and destroy data, and frequently operate on the memory and repeatedly create data buffers to store the height parameters, so there is a serious problem of waste of computing resources. However, in the game terrain rendering method provided by the embodiments of the present application, since a part of the height parameters that do not need to be rendered currently are cached and redundant in the height texture map stored in the GPU, when these height parameters are needed, they can be directly used. Therefore, the waiting time for generating new height parameters can be reduced, the frequency of repeatedly generating height parameters can be reduced, and thus the computing resources can be reduced. At the same time, the dynamic update of the height parameters in the height texture map can be realized, so that the height parameters that have not been used for a long time can be dynamically replaced by new height parameters. Therefore, there is no need to repeatedly create data buffers, and the waste of computing resources can be avoided.

[0114] In an example, the following is a code example for storing new height parameters into the height texture map:

[0115]

[0116]

[0117] To execute the corresponding steps in the above embodiments and various possible ways, an implementation manner of a game terrain rendering device is given below. Further, please refer to Figure 4 , Figure 4 is a functional module diagram of a game terrain rendering device provided by an embodiment of the present application. It should be noted that the basic principle and the technical effects generated by the game terrain rendering device provided in this embodiment are the same as those in the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding content in the above embodiments. The game terrain rendering device includes: a determination module 200 and an acquisition module 210.

[0118] The determination module 200 is configured to determine a plurality of units to be rendered from a plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain.

[0119] It can be understood that the determination module 200 can also be used to execute the above step S20.

[0120] The acquisition module 210 is configured to obtain a target parameter index corresponding to a target height parameter to be rendered according to the LOD level and the LOD page table of each unit to be rendered.

[0121] It can be understood that the acquisition module 210 can also be used to execute the above step S21.

[0122] The determination module 200 is further configured to determine a storage location corresponding to each target height parameter according to each target parameter index, and send the storage location corresponding to each target height parameter to the GPU, so that the GPU can obtain the target height parameter from the height texture map according to each storage location, and render the game terrain according to the target height parameter.

[0123] It can be understood that the determination module 200 can also be used to execute the above step S22.

[0124] Optionally, the determination module 200 is further configured to determine a camera frustum according to the current camera position; traverse the quadtree, and respectively determine whether the bounding box of each quadtree unit intersects with the camera frustum; if the bounding box of the quadtree unit intersects with the camera frustum, then when the distance between the quadtree unit and the current camera position is less than the rendering distance corresponding to the quadtree unit, determine the quadtree unit as a unit to be rendered.

[0125] Optionally, the acquisition module 210 is further configured to respectively determine whether the parameter index corresponding to each unit to be rendered is empty according to the LOD level and the LOD page table of the unit to be rendered; if the parameter index is empty, then use the LOD level one level higher than the LOD level of the unit to be rendered as the target LOD level, and determine whether the parameter index corresponding to the target LOD level is empty according to the target LOD level and the LOD page table; if the parameter index corresponding to the target LOD level is empty, then use the LOD level one level higher than the target LOD level as the new target LOD level, and determine whether the parameter index corresponding to the new target LOD level is empty according to the new target LOD level and the LOD page table until the parameter index is not empty; if the parameter index is not empty, then determine the parameter index as the target parameter index.

[0126] Optionally, the determination module 200 is further configured to, for each target parameter index, calculate the starting coordinates corresponding to the target height parameter according to the target parameter index, and calculate the scaling factor corresponding to the target height parameter according to the target LOD level corresponding to the target parameter index and the LOD level corresponding to the unit to be rendered; send the starting coordinates and the scaling factor to the GPU, so that the GPU calculates the UV coordinate position of the target height parameter in the height texture map according to the starting coordinates and the scaling factor, and obtains the target height parameter from the height texture map according to the UV coordinate position.

[0127] Optionally, if the target LOD level corresponding to the storage location of the height parameter is inconsistent with the LOD level of the unit to be rendered, the determination module 200 is further configured to generate the height parameter corresponding to the LOD level of the unit to be rendered; determine the target parameter index in the height texture map, store the height parameter in the height texture map according to the target parameter index, and update the LOD page table according to the target parameter index and the LOD level. Optionally, if there is at least one blank storage location in the height texture map, the determination module 200 is further configured to determine the parameter index corresponding to any blank storage location as the target parameter index; if there is no blank storage location in the height texture map, obtain the application duration corresponding to each storage location, and determine the target parameter index from the parameter indexes corresponding to multiple storage locations according to the application duration; wherein the application duration represents the duration from the moment when the height parameter stored at the storage location is rendered to the current moment.

[0128] Optionally, the above modules may be stored in the Figure 1 memory shown in the form of software or firmware and solidified in the operating system (OS) of the electronic device, and can be executed by the Figure 1 processor therein. At the same time, the data, program code, etc. required to execute the above modules can be stored in the memory.

[0129] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the game terrain rendering method provided by the embodiment of the present application can be implemented.

[0130] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0131] In addition, each functional module in various embodiments of the present application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0132] If the above functions are implemented in the form of software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0133] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for rendering a game terrain, characterized in that, Applied to an electronic device, in which a quadtree, an LOD page table, and a height texture map corresponding to a game terrain are stored. The height texture map is stored in a GPU. The quadtree includes a plurality of quadtree units, each quadtree unit corresponding to an LOD level. The height texture map stores a plurality of height parameters. The LOD page table stores the correspondence between each LOD level and a parameter index. The parameter index represents the storage position of the height parameters corresponding to the LOD level in the height texture map. The method includes: Determine a plurality of units to be rendered from the plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain; Obtain a target parameter index corresponding to a target height parameter to be rendered for each according to the LOD level of each unit to be rendered and the LOD page table; Determine the storage position corresponding to each target height parameter according to each target parameter index, and send the storage position corresponding to each target height parameter to the GPU, so that the GPU obtains the target height parameter from the height texture map according to each storage position, and renders the game terrain according to the target height parameter.

2. The method according to claim 1, wherein The determining a plurality of units to be rendered from the plurality of quadtree units according to the current camera position and the quadtree corresponding to the game terrain includes: Determine a camera frustum according to the current camera position; Traverse the quadtree, and for each quadtree unit, determine whether the bounding box of the quadtree unit intersects with the camera frustum; If the bounding box of the quadtree unit intersects with the camera frustum, determine the quadtree unit as the unit to be rendered when the distance between the quadtree unit and the current camera position is less than the rendering distance corresponding to the quadtree unit.

3. The method according to claim 1, wherein The obtaining a target parameter index corresponding to a target height parameter according to the LOD level of each unit to be rendered and the LOD page table includes: For each unit to be rendered, determine whether the parameter index corresponding to the unit to be rendered is empty according to the LOD level of the unit to be rendered and the LOD page table; If the parameter index is empty, use the LOD level one level higher than the LOD level of the unit to be rendered as the target LOD level, and determine whether the parameter index corresponding to the target LOD level is empty according to the target LOD level and the LOD page table; If the parameter index corresponding to the target LOD level is empty, use the LOD level one level higher than the target LOD level as the new target LOD level, and determine whether the parameter index corresponding to the new target LOD level is empty according to the new target LOD level and the LOD page table until the parameter index is not empty; If the parameter index is not empty, determine the parameter index as the target parameter index.

4. The method according to claim 1, wherein The storage position includes a starting coordinate and a scaling factor; Determining the storage locations corresponding to each of the target height parameters according to each of the target parameter indexes, and sending the storage locations corresponding to each of the target height parameters to the GPU, so that the GPU obtains the target height parameters from the height texture map according to each of the storage locations, includes: For each of the target parameter indexes, calculating the starting coordinates corresponding to the target height parameter according to the target parameter index, and calculating the scaling factor corresponding to the target height parameter according to the target LOD level corresponding to the target parameter index and the LOD level corresponding to the unit to be rendered; Sending the starting coordinates and the scaling factor to the GPU, so that the GPU calculates the UV coordinate position of the target height parameter in the height texture map according to the starting coordinates and the scaling factor, and obtains the target height parameter from the height texture map according to the UV coordinate position.

5. The method according to claim 1, characterized in that The method further includes: If the target LOD level corresponding to the storage location of the height parameter is inconsistent with the LOD level of the unit to be rendered, generating a height parameter corresponding to the LOD level of the unit to be rendered; Determining a target parameter index in the height texture map, storing the height parameter into the height texture map according to the target parameter index, and updating the LOD page table according to the target parameter index and the LOD level.

6. The method according to claim 5, characterized in that The determining a target parameter index in the height texture map includes: If there is at least one blank storage location in the height texture map, determining the parameter index corresponding to any one of the blank storage locations as the target parameter index; If there is no blank storage location in the height texture map, obtaining the application duration corresponding to each storage location, and determining the target parameter index from the parameter indexes corresponding to multiple storage locations according to the application duration; wherein, the application duration represents the duration from the moment when the height parameter stored at the storage location is rendered to the current moment.

7. A game terrain rendering device, characterized in that, Applied to an electronic device, the electronic device stores a quadtree, an LOD page table and a height texture map corresponding to a game terrain, the height texture map is stored in the GPU, the quadtree includes a plurality of quadtree units, each quadtree unit corresponds to an LOD level, the height texture map stores a plurality of height parameters, the LOD page table stores the correspondence between each LOD level and a parameter index, the parameter index represents the storage location of the height parameter corresponding to the LOD level in the height texture map, the device includes: A determining module, configured to determine a plurality of units to be rendered from a plurality of the quadtree units according to the current camera position and the quadtree corresponding to the game terrain; An obtaining module, configured to obtain the target parameter indexes corresponding to the target height parameters to be rendered for each according to the LOD levels of each of the units to be rendered and the LOD page table; The determining module is further configured to determine the storage locations corresponding to the respective target height parameters according to the respective target parameter indexes, and send the storage locations corresponding to the respective target height parameters to the GPU, so that the GPU obtains the target height parameters from the height texture map according to the respective storage locations, and renders the game terrain according to the target height parameters.

8. The device according to claim 7, characterized in that, The determining module is further configured to determine a camera frustum according to the current camera position; traverse the quadtree, and for each of the quadtree cells, determine whether the bounding box of the quadtree cell intersects with the camera frustum; if the bounding box of the quadtree cell intersects with the camera frustum, then when the distance between the quadtree cell and the current camera position is less than the rendering distance corresponding to the quadtree cell, determine the quadtree cell as the cell to be rendered.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the method according to any one of claims 1-6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method according to any one of claims 1-6.