Image generation method, device, medium and program product for virtual scene
By dividing plane areas according to the terrain slope in a virtual scene and adjusting the grid density for rendering, the problem of low terrain display efficiency in the prior art is solved, and efficient and detailed virtual scene terrain display is achieved.
Patent Information
- Application Number
- CN202311296015.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-08
- Publication Date
- 2025-04-08
AI Technical Summary
The prior art shows the terrain in virtual scenes with high complexity and high hardware requirements, resulting in poor display efficiency.
By dividing each plane area in the XY plane, the grid density is obtained based on the terrain slope in each plane area, and each plane area is rendered based on the grid density to generate a scene image containing the virtual scene terrain.
It realizes taking into account both the terrain display efficiency and display effect in virtual scenes, and retains details at high slopes by adjusting the grid density and improving rendering efficiency at low slopes.
Smart Images

Figure CN119770958A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual world technology, and in particular to an image generation method, device, medium and program product for a virtual scene. Background Art
[0002] In an application program including a virtual scene, the terrain display in the virtual scene is usually implemented by using a surface tessellation technology.
[0003] Surface subdivision refers to the technology of automatically embedding new vertices between vertices. It can automatically create vertices inside the graphics chip to refine the model. After automatically inserting a large number of new vertices, the surface of the model will be divided very finely and look smoother and denser.
[0004] However, the surface subdivision solution is complex to implement and has high requirements on hardware capabilities, which results in poor display efficiency in terrain display scenarios. Summary of the invention
[0005] Each embodiment of the present application provides an image generation method, device, medium and program product for a virtual scene, and the technical solution is as follows:
[0006] According to one aspect of the present application, a method for generating an image of a virtual scene is provided, the method comprising:
[0007] Acquire each plane area in the virtual scene, wherein the plane area is a rectangular area in the XY plane of the virtual scene;
[0008] Obtaining the terrain slope within each plane area;
[0009] Based on the terrain slope in each plane area, obtaining the grid density of the terrain grid of each plane area; the grid density is positively correlated with the terrain slope;
[0010] Based on the grid density of the terrain grid of each of the plane areas, each of the plane areas is submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
[0011] According to another aspect of the present application, there is provided an image generation device for a virtual scene, the device comprising:
[0012] A plane acquisition module, used to acquire each plane area in the virtual scene, wherein the plane area is a rectangular area in the XY plane of the virtual scene;
[0013] A slope acquisition module, used to acquire the terrain slope in each plane area;
[0014] A grid density acquisition module, used to acquire the grid density of the terrain grid of each plane area based on the terrain slope in each plane area; the grid density is positively correlated with the terrain slope;
[0015] The image generation module is used to render the terrain grids in each plane area based on the grid density of the terrain grids in each plane area, so as to obtain a scene image containing the terrain in the virtual scene.
[0016] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the above-mentioned image generation method for a virtual scene.
[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned image generation method for a virtual scene.
[0018] In another aspect, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the image generation method for a virtual scene provided in the above-mentioned various optional implementations.
[0019] The beneficial effects of the technical solution provided by this application include at least:
[0020] The virtual scene is divided into various plane areas in the XY plane, and based on the terrain slope in each plane area, the grid density of the terrain grid of each plane area is obtained, and then based on the grid density of the terrain grid of each plane area, each plane area is submitted for rendering to obtain a scene image containing the terrain in the virtual scene. Since the grid density of each plane area is positively correlated with the terrain slope, through the above scheme, a higher terrain grid density can be set at a location with a higher terrain slope, and a lower terrain grid density can be set at a location with a lower terrain slope, so that a denser terrain grid is used for rendering at a location with a higher terrain slope to ensure the detail display effect, and a sparser terrain grid is used for rendering at a location with a lower terrain slope to ensure rendering efficiency, thereby taking into account both the display efficiency and display effect of the terrain of the virtual scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a structural block diagram of a computer system provided by an exemplary embodiment of the present application;
[0022] Figure 2 is a flow chart of an image generation method for a virtual scene provided by an exemplary embodiment of the present application;
[0023] Figure 3 It is a terrain effect map displayed by surface subdivision technology involved in this application;
[0024] Figure 4 It is a terrain effect map displayed by a grid plus a surface map involved in this application;
[0025] Figure 5 It is a topographic effect map achieved through the solution provided by this application;
[0026] Figure 6 is a flow chart of an image generation method for a virtual scene provided by an exemplary embodiment of the present application;
[0027] Figure 7 It is a schematic diagram of a quadtree block involved in this application;
[0028] Figure 8 It is a schematic diagram of a uniform block division involved in this application;
[0029] Fig. 9 is a schematic diagram of terrain restoration involved in this application;
[0030] Fig.10 It is a schematic diagram of quadtree partitioning involved in this application;
[0031] Fig.11 It is the grid and rendering effect diagram involved in this application;
[0032] Fig.12 It is a schematic diagram of the concealer processing involved in the present application;
[0033] Fig.13 It is a schematic diagram of the suturing process involved in the present application;
[0034] Fig.14 It is a schematic diagram of the implementation of the suturing process involved in the present application;
[0035] Fig.15 It is a schematic diagram of the grid division coding involved in this application;
[0036] Fig.16 It is a schematic diagram of OuterLOD and InnerLOD involved in this application;
[0037] Fig.17 is a schematic diagram of the suturing process involved in the present application;
[0038] Fig.18is a flow chart of an image generation method for a virtual scene provided by an exemplary embodiment of the present application;
[0039] Fig.19 This is a schematic diagram of a process for obtaining a slope map involved in this application;
[0040] Fig. 20 It is a schematic diagram of terrain grid settings of different slopes involved in this application;
[0041] Fig.21 is a schematic diagram of the virtual scene terrain involved in this application;
[0042] Fig. 22 It is a schematic diagram of the relationship between a material and a mesh density involved in this application;
[0043] Fig.23 is a schematic diagram of a visibility judgment involved in this application;
[0044] Fig.24 is a schematic diagram of another visibility judgment involved in the present application;
[0045] Fig.25 It is the overall flow chart involved in this application;
[0046] Fig.26 It is an overall framework diagram involved in this application;
[0047] Fig. 27 It is a schematic diagram for comparing the effects involved in this application;
[0048] Fig.28 is a structural block diagram of an image generation device for a virtual scene provided by the present application;
[0049] Fig.29 It is a structural block diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0052] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0053] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the object behaviors such as attack operations involved in this application are all obtained with full authorization.
[0054] It should be understood that although the terms first, second, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first parameter may also be referred to as the second parameter, and similarly, the second parameter may also be referred to as the first parameter. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0055] For ease of understanding, several terms involved in this application are explained below.
[0056] 1) Virtual scene: A virtual scene is a virtual scene displayed (or provided) when an application is running on a terminal. The virtual scene can be a simulated environment scene of the real world, a semi-simulated and semi-fictitious three-dimensional environment scene, or a purely fictitious three-dimensional environment scene. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, and a three-dimensional virtual scene. The following embodiments are illustrated by taking the virtual scene as a three-dimensional virtual scene, but are not limited to this. Optionally, the virtual scene can also be used for a virtual scene battle between at least two virtual characters. Optionally, the virtual scene can also be used for a battle between at least two virtual characters using virtual props. Optionally, the virtual scene can also be used for a battle between at least two virtual characters using virtual props within a target area, and the target area will continue to shrink as time passes in the virtual scene.
[0057] The virtual scene is usually generated by an application in a computer device such as a terminal and displayed based on the hardware in the terminal (such as a screen). The terminal can be a mobile terminal such as a smart phone, tablet computer or e-book reader; or, the terminal can also be a personal computer device such as a laptop or a fixed computer.
[0058] 2) Rendering pipeline: refers to a series of processing steps that convert three-dimensional scene data into two-dimensional images in computer graphics and game development.
[0059] 3) Quad Tree: A data structure used to manage a two-dimensional plane, and is used to manage terrain in this application.
[0060] 4)Soft Tessellation: A tessellation solution that does not rely on hardware tessellation capabilities.
[0061] 5) Disp Map / Displacement Map: Uses a single channel to represent the offset of the material in the Z direction, generally used to represent the degree of convexity of the material.
[0062] 6) Mesh: The basic unit for rendering objects in the game engine, composed of triangles.
[0063] 7) Cluster: In this application, it refers to small quadrilaterals divided equally from a quadrilateral.
[0064] 8) Quad: In this application, it represents the child node of the quadtree and its corresponding game world.
[0065] 9) Level of Detail (LOD): generally used to indicate the level of a mesh, and in the solution involved in this application, used to indicate the subdivision level of a quadtree.
[0066] Figure 1 The structure block diagram of a computer system provided by an exemplary embodiment of the present application is shown. The computer system 100 includes: a first terminal 110, a server 120, and a second terminal 130.
[0067] The first terminal 110 is installed and runs a client 111 that supports virtual scenes, and the client 111 may be a multiplayer online battle program. When the first terminal runs the client 111, the user interface of the client 111 is displayed on the screen of the first terminal 110.
[0068] The second terminal 130 is installed and runs a client 131 that supports virtual scenes, and the client 131 may be a multiplayer online battle program. When the second terminal 130 runs the client 131, a user interface of the client 131 is displayed on the screen of the second terminal 130.
[0069] Optionally, the client installed on the first terminal 110 and the second terminal 130 is the same, or the client installed on the two terminals is the same type of client on different operating system platforms (Android or IOS). The first terminal 110 may refer to one of a plurality of terminals, and the second terminal 130 may refer to another of a plurality of terminals. This embodiment is only illustrated by taking the first terminal 110 and the second terminal 130 as examples. The device types of the first terminal 110 and the second terminal 130 are the same or different, and the device type includes at least one of: a smart phone, a tablet computer, an e-book reader, an MP3 player, an MP4 player, a laptop portable computer, and a desktop computer.
[0070] Figure 1 Only two terminals are shown, but in different embodiments, there are multiple other terminals 140 that can access the server 120. Optionally, there are one or more terminals 140 corresponding to the developer, and a development and editing platform for the client supporting the virtual scene is installed on the terminal 140. The developer can edit and update the client on the terminal 140, and transmit the updated client installation package to the server 120 via a wired or wireless network. The first terminal 110 and the second terminal 130 can download the client installation package from the server 120 to update the client.
[0071] The first terminal 110 , the second terminal 130 , and other terminals 140 are connected to the server 120 via a wireless network or a wired network.
[0072] The server 120 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The server 120 is used to provide background services for clients that support three-dimensional virtual scenes. Optionally, the server 120 undertakes the main computing work, and the terminal undertakes the secondary computing work; or, the server 120 undertakes the secondary computing work, and the terminal undertakes the main computing work; or, the server 120 and the terminal adopt a distributed computing architecture for collaborative computing.
[0073] In an illustrative example, the server 120 includes a processor 122, a user account database 123, a battle service module 124, and a user-oriented input / output interface (I / O interface) 125. The processor 122 is used to load instructions stored in the server 120 and process data in the user account database 123 and the battle service module 124; the user account database 123 is used to store data of user accounts used by the first terminal 110, the second terminal 130, and other terminals 140, such as the user account's avatar, the user account's nickname, the user account's combat power index, and the service area where the user account is located; the battle service module 124 is used to provide multiple battle rooms for users to fight, such as 1V1 battle, 3V3 battle, 5V5 battle, etc.; the user-oriented I / O interface 125 is used to establish communication and exchange data with the first terminal 110 and / or the second terminal 130 through a wireless network or a wired network.
[0074] Figure 2 A flowchart of a method for generating an image of a virtual scene provided by an exemplary embodiment of the present application is shown. The method may be executed by a computer device. The computer device may be Figure 1 The first terminal 110 and the second terminal 130 in the system shown in the figure, or the computer device can also be Figure 1 The server 120 in the system shown, or the computer device may also include the above Figure 1 In the system shown, a first terminal 110, a server 120 and a second terminal 130; the method includes:
[0075] Step 210: Acquire each plane area in the virtual scene. The plane area is a rectangular area in the XY plane of the virtual scene.
[0076] In an embodiment of the present application, the above-mentioned virtual scene can be a three-dimensional virtual scene or a 2.5-dimensional virtual scene, and the scene space of the above-mentioned virtual scene can be represented by a three-dimensional coordinate system, wherein the plane formed by the X-axis and the Y-axis in the three-dimensional coordinate system can be called the XY plane, which can correspond to the horizontal plane in the virtual scene, and the Z-axis direction can represent the height in the virtual scene.
[0077] In the above virtual scene, the terrain data may consist of two parts, one part is the horizontal position information consisting of the coordinate information in the XY plane, and the other part is the height information consisting of the height of each horizontal position.
[0078] Among them, for the coordinate information in the XY plane in the terrain data, when displaying the scene image, the computer device can first obtain various rectangular areas in the XY plane in the virtual scene as the above-mentioned various plane areas.
[0079] Step 220: Obtain the terrain slope in each plane area.
[0080] After acquiring the above-mentioned plane areas, the computer device can further acquire the terrain slope within each plane area.
[0081] The terrain slope in the plane area may be a value representing the overall terrain slope in the current plane area, for example, a value between 0 and 1.
[0082] Step 230: Based on the terrain slope in each plane area, the grid density of the terrain grid of each plane area is obtained; the grid density is positively correlated with the terrain slope.
[0083] The above-mentioned terrain mesh refers to a mesh used to represent the terrain of a virtual scene.
[0084] The grid density of the terrain grid of a planar region may refer to the number of terrain grids contained in the planar region.
[0085] In an embodiment of the present application, for each plane area, the computer device can set the grid density of the terrain grid for each plane area separately according to the terrain slope within the plane area, wherein the larger the terrain slope of a plane area, the steeper the terrain of the plane area, and the higher the detail required for display. Accordingly, the grid density of the terrain grid determined by the computer device for the plane area is higher (that is, the denser the terrain grid, the greater the number of grids in the terrain grid). Conversely, the smaller the terrain slope of a plane area, the flatter the terrain of the plane area, and the lower the detail required for display. Accordingly, the grid density of the terrain grid determined by the computer device for the plane area is lower (that is, the sparser the terrain grid, the fewer the number of grids in the terrain grid).
[0086] Step 240: Based on the grid density of the terrain grid of each plane area, each plane area is submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
[0087] In an embodiment of the present application, a computer device may set a terrain grid within each plane area based on the grid density of the terrain grid of each plane area, and submit the terrain grid for rendering to obtain a scene image containing the terrain in the virtual scene.
[0088] To summarize, the scheme shown in the embodiment of the present application divides the virtual scene into various plane areas in the XY plane, and obtains the grid density of the terrain grid of each plane area based on the terrain slope in each plane area, and then submits rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene. Since the grid density of each of the above-mentioned plane areas is positively correlated with the terrain slope, through the above-mentioned scheme, a higher terrain grid density can be set at a location with a higher terrain slope, and a lower terrain grid density can be set at a location with a lower terrain slope, so that a denser terrain grid is used for rendering at a location with a higher terrain slope to ensure the detail display effect, and a sparser terrain grid is used for rendering at a location with a lower terrain slope to ensure rendering efficiency, thereby taking into account the display efficiency and display effect of the terrain of the virtual scene.
[0089] Terrain rendering has always been an important part of the development of virtual scenes (such as game scenes). Generally speaking, it has the following characteristics.
[0090] (1) Large scope: Even for the mobile game market, there are projects that have / planned terrain maps of thousands of square kilometers.
[0091] (2) Permanence: During the display of a virtual scene, the terrain of the virtual scene is permanent most of the time.
[0092] (3) High pixel ratio: Most of the time, the terrain of the virtual scene has a high pixel ratio displayed on the screen.
[0093] (4) Basicity: Many other systems in the virtual scene rely on the terrain to provide basic information, such as surface mapping, normals, vegetation distribution, slope, etc.
[0094] (5) High quality: The increasingly improved quality of virtual scenes places higher and higher requirements on terrain display.
[0095] It is precisely because of the above characteristics that, through the optimization of the terrain rendering process, it is possible to improve the display quality of the terrain while effectively optimizing the rendering efficiency of the entire virtual scene.
[0096] The hardware of PC / host and mobile terminals is very different. For power consumption, the architecture and computing power of GPU on mobile terminals are far behind those of PC and host. Correspondingly, for terrain rendering, the rendering solutions adopted by PC / host and mobile terminals are also completely different.
[0097] On PC / console, terrain rendering is usually achieved through techniques such as tessellation and geometric shading. Figure 3, which shows the terrain effect map displayed by the surface subdivision technology involved in the present application.
[0098] On mobile devices, terrain rendering is usually achieved through a larger-grained grid plus a surface map. That is, the terrain of the virtual scene is divided into multiple grids, each grid corresponds to a terrain map, and the grid accuracy is often low. For example, a grid represents a square area with a side length of 1 meter or 2 meters. Figure 4 , which shows the terrain effect map displayed by the grid plus surface map involved in the present application.
[0099] Essentially, terrain meshes are no different from ordinary models. Here are the basic steps for displaying terrain in a 3D engine:
[0100] S1, initialize the 3D engine.
[0101] S2, prepare a mesh in the 3D engine. The vertices of the mesh have their own positions. Three vertices form a triangular patch. Multiple triangular patches are connected to form a mesh.
[0102] S3, after rasterization, converts to screen coordinates to form pixels.
[0103] S4, for each pixel obtained in the above step S3, calculate its coordinates on the map (this coordinate is generally called UV coordinate), sample to obtain a specific color value, and this color value is the value finally presented on the screen (optionally, this color value can also be used for lighting calculation, post-processing, etc.).
[0104] This application Figure 2 The solution shown in the embodiment shown in the figure can be implemented in the above step S2 by the above application Figure 2 The solution shown in the embodiment shown can take into account the display efficiency and display effect of the terrain of the virtual scene, and can achieve the terrain display effect on the mobile terminal that is comparable to that on the PC / host terminal. For example, please refer to Figure 5 , which shows a terrain effect diagram achieved by the solution provided by this application.
[0105] Figure 6 FIG. 1 is a flowchart of a method for generating an image of a virtual scene provided by an exemplary embodiment of the present application, and the method can be executed by a computer device. Figure 6 As shown above Figure 2 In the illustrated embodiment, step 210 may include the following steps 210a to 210c:
[0106] Step 210a: Obtain the current position of the camera observing the virtual scene.
[0107] Step 210b: Based on the camera position, the XY plane of the virtual scene is divided into blocks by a quadtree block method to obtain a plurality of block nodes.
[0108] The above quadtree block means that the XY plane of the virtual scene is organized in the form of a quadtree. The size of the block is determined according to the distance from the current observation camera. Each block is a square, and the side length of the square is 2 times the relationship. Please refer to Figure 7 , which shows a schematic diagram of a quadtree block involved in this application. Figure 7 As shown, quadtree partitioning is performed starting from camera position 71, wherein the sizes of partition nodes 72, 73, 74, and 75 increase in order from small to large in distance from camera position 71, and among partition nodes 72, 73, 74, and 75, the multiple of the side length of two adjacent partition nodes is 2.
[0109] In the solution shown in the present application, managing blocks in a quadtree manner can significantly reduce the number of blocks, and the number of blocks is positively correlated with the number of batches finally submitted for rendering, which can reduce rendering batches and improve rendering efficiency.
[0110] In another possible implementation of the present application, the computer device may also divide the XY plane of the virtual scene into uniform blocks, for example, please refer to Figure 8 , which shows a schematic diagram of a uniform block division involved in the present application; Figure 8 As shown, the 32KM*32KM plot 801 is evenly divided, and each plot has the same size, for example, divided into 1KM*1KM plots 802, so that the virtual scene is divided into 32*32=1024 plots.
[0111] In ordinary grids, the position of vertices is usually stored in the vertex data. However, terrain grids have certain special features, and the height in the Z direction can be stored in the form of a height map. The position in the XY direction can be calculated through a regular grid, which can implicitly simplify the vertex position that originally requires three values (x, y, z) to only require the height value in the z direction. In this way, the height of the surface can be stored in a single-channel grayscale image, which is called a height map.
[0112] For example, please refer to Fig. 9 , which shows a schematic diagram of terrain restoration involved in this application. Fig. 9 As shown, when restoring the terrain mesh, first determine the position 901 in the XY direction, calculate and obtain the UV on the height map 902, and then sample the height map to obtain the position in the Z direction, thereby restoring the terrain mesh 903.
[0113] Step 210c: Divide the multiple block nodes respectively to obtain various plane areas.
[0114] In the embodiment of the present application, the computer device further divides each block node (that is, the quadtree node (Node) obtained by quadtree block), and each block node is divided into multiple sub-nodes to obtain the above-mentioned plane areas, and each plane area corresponds to one of the above-mentioned sub-nodes. Among them, each of the above-mentioned plane areas can also be called a block sub-node (Sub-Node).
[0115] In the scheme shown in the embodiment of the present application, further division of multiple block nodes can improve the accuracy of the plane area and ensure that in the subsequent process of determining the grid density of the plane area, the grid density of each plane area can be determined with a smaller granularity, thereby ensuring the display effect of the area with a larger slope.
[0116] In the solution shown in the embodiment of the present application, there is a data preparation process before submitting for rendering. Taking quadtree blocking as an example, the data preparation process can be as follows.
[0117] S1, prepare the data in the Z direction, that is, the height map, which can be generated during the offline production period. For example, a 32KM*32KM map is evenly divided into 32*32=1024 height maps. Figure 1 K*1K resolution is used to represent the Z-direction height of a 1km*1km terrain, that is, 1 pixel represents 1 meter in height.
[0118] S2, prepares data in the XY horizontal plane direction, that is, the segmentation data of the quadtree.
[0119] This part of data is generated during runtime. Please refer to Fig.10 , which shows a schematic diagram of quadtree block division involved in this application, such as Fig.10 As shown, there is only one data source for this step, namely the closest distance (DistanceMin) 1001 between the camera position of the observation camera and the vertex of the quadtree node. The LOD level closest to the closest distance is found in the configuration array as the LOD of this quadtree node.
[0120] like Fig.10 As shown in the figure, the subdivision of the quadtree is explained with actual distance. The closest distance between the 4 vertices of a quadtree node (quadtree nodes are square, so there are 4 vertices in total) and the camera is DistMin. The LOD configuration is a distance array LOD_Cfg, the array length is 10, and the values are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 respectively.
[0121] Compare DistMin with the 10 values in LOD_Cfg respectively, and take the array subscript of the first value that is smaller than it as the LOD level of the quadtree node.
[0122] To illustrate with actual numerical values: the DistMin value of a quadtree node is 9.35 meters. Compare it with the values in LOD_Cfg one by one. When LOD_Cfg[4]=16, 9.35<16, so the LOD level of the node is level 4.
[0123] S3, when running, takes the data in the Z direction and combines it with the data in S2 into data in the (x, y, z) coordinate system to obtain the terrain grid.
[0124] After the plane area is divided, the mesh determined for each plane area will have cracks. For example, please refer to Fig.11 , which shows the grid and rendering effect diagram involved in this application, in Fig.11 There will be cracks between different plane areas. Fig.11 As shown in the figure, this phenomenon is called T-Junction. The reason for T-Junction is that at the junction of plane areas of different LODs, the number of vertices of the meshes belonging to different plane areas is different. The number of vertices in the plane area of low-density LOD is less than that in the plane area of high-density LOD, which leads to the mesh cracking at the junction of plane areas of different LODs, that is, the mesh at the junction of plane areas of different LODs is discontinuous, resulting in cracks. There are generally two types of optimization methods:
[0125] (1) Concealer, that is, to cover the cracks with additional patches.
[0126] (2) Stitching is to move the mesh vertices in the plane area of different LODs at the junction to the same position as much as possible. The processing principle is to eliminate cracks.
[0127] Please refer to Fig.12 , which shows a schematic diagram of the concealer processing involved in the present application, such as Fig.12 As shown, there are generally three ways to conceal concealer: inserts, slits, and hems.
[0128] Insert: Add a patch 1201 at the edge. This patch has a certain inclination and needs to face the high-density grid and intersperse with it.
[0129] Seam: Generate a simple triangle 1202 that just covers the seam.
[0130] Skirt: Use a patch 1203 perpendicular to the XY plane, which will not intersect with any grid and is easy to calculate.
[0131] Please refer to Fig.13 , which shows a schematic diagram of the suture processing involved in the present application, such as Fig.13 As shown, there are generally two methods of stitching: hemming and locking. The idea of stitching is not to add extra patches, but to adjust the vertex position at the junction to achieve seam filling.
[0132] In some possible implementations, before submitting rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image including the terrain in the virtual scene, the method further includes:
[0133] The borders of two adjacent block nodes are locked; the locking process refers to setting the points at fixed positions on the borders of the block nodes uniformly as mesh vertices on the borders of the block nodes; that is, the locking process refers to setting the fixed points on the borders of each block node as mesh vertices. For any block node, when the block node determines the terrain mesh at the border with another block node, the fixed points on the border are directly used as mesh vertices. After such processing, for two adjacent block nodes, the mesh vertices at the border of the two nodes will be uniformly set to one or more pre-specified position points, and there will be no seams caused by inconsistent mesh density at the border;
[0134] The boundary of two adjacent plane areas in the same block node is subjected to seam processing; seam processing refers to moving mesh vertices belonging to different plane areas on the boundary of two adjacent plane areas to the same point on the boundary of the two adjacent plane areas; that is, for example, assuming that the two plane areas are set with terrain grids according to their respective grid densities, there are three mesh vertices on the boundary of the two plane areas, wherein mesh vertex 1 is the vertex of the terrain grid in plane area A, mesh vertex 2 and mesh vertex 3 are the vertices of the terrain grid in plane area B, and mesh vertex 1, mesh vertex 2 and mesh vertex 3 are located at different positions on the boundary, at this time, through seam processing, mesh vertex 2 and mesh vertex 3 can be moved to the position of mesh vertex 1, or mesh vertex 1, mesh vertex 2 and mesh vertex 3 can be moved to one end point of the boundary.
[0135] The solution shown in the embodiment of the present application can merge the seams on the basis of locking, that is, for the boundaries between block nodes, the seams are eliminated by locking, and for the boundaries of each sub-node within the block node, the seams are eliminated by sewing, thereby ensuring that the seams between adjacent plane areas within the block node and between the block nodes can be eliminated, thereby improving subsequent rendering effects.
[0136] Please refer to Fig.14 , which shows a schematic diagram of the implementation of the suturing process involved in this application. Fig.14 As shown, Fig.14On the left is a quadtree node corresponding to a regular grid 1401. Fig.14 In the middle, each quadtree node is divided into N*N ( Fig.14 4*4) blocks 1402 are shown in FIG. 1 , each block 1402 corresponds to a regular grid, and the density of the regular grids of different blocks 1402 is the same. Fig.14 On the right is the adaptively distributed block 1403, each block corresponds to a regular grid, and the density of the regular grids of different blocks 1403 may be different. Fig.14 In the scheme on the right, each block node is divided into 4 plane areas, and each plane area has its own number of grids adaptively. That is to say, the grid density in each plane area is dynamically distributed. The grid density can be increased where high-precision grids are required to ensure the subsequent rendering effect. Where high-precision grids are not required, a lower grid density can be used to reduce rendering complexity and improve rendering efficiency.
[0137] Please refer to Fig.15 , which shows a schematic diagram of the grid division coding involved in this application, such as Fig.15 As shown, taking each block node (ie, quadtree node) being divided into four plane areas as an example, the subdivision coding scheme involved in this scheme is introduced below.
[0138] S1, divide the quadtree node 1501 into 2*2 parts, that is, divide a quadtree node into 4 blocks, each block is called a Sub-Node 1502.
[0139] S2, each Sub-Node can be further dynamically divided into N*N grids as needed. To save runtime memory consumption, each Sub-Node is subdivided with 2 bits of encoding. Each quadtree node has 4 Sub-Nodes, so in total, each quadtree node can record the subdivision level of its 4 internal Sub-Nodes through 1 byte, corresponding to Fig.15 Inner LOD in the block.
[0140] As mentioned in step S2, each Sub-Node uses 2 bits to record the subdivision level, such as Fig.15 As shown in the figure, 0b00 / 0b01 / 0b10 / 0b11 are all binary representations, corresponding to decimal 0 / 1 / 2 / 3 respectively. This is also the upper limit of the data that can be represented by 2 bits.
[0141] Among them, 0 means that the current Sub-Node is not further subdivided, and 1 regular grid is used to fill the current Sub-Node; 1 means that the current Sub-Node is subdivided at level 1, and 2*2 regular grids are used to fill it; 2 means that the current Sub-Node is subdivided at level 2, and 4*4 regular grids are used to fill it; 3 means that the current Sub-Node is subdivided at level 3, and 8*8 grids are used to fill it.
[0142] This ensures that the difference between all grid densities is 2 or an integer multiple of 2.
[0143] S3, records the LOD of each quadtree node itself.
[0144] Please refer to Fig.16 , which shows a schematic diagram of the inter-block LOD (Outer LOD) 1601 and the intra-block LOD (Inner LOD) 1602 involved in this application. Fig.16 As shown in the figure, Outer LOD is the LOD of the quadtree node mentioned above. Inner LOD is the subdivision level of the 4 sibling Sub-Nodes subdivided inside the quadtree node. Outer LOD is used to lock the edges, which is equivalent to locking the edges between the current quadtree node and the neighboring quadtree nodes to ensure that no cracks will appear. Inner LOD is used to maintain the seam edges between the sibling nodes inside the quadtree to ensure that no cracks will appear between the sibling nodes inside the quadtree.
[0145] This design ensures that no matter how the internal nodes of the quadtree are subdivided, there will be no cracks inside or outside the quadtree nodes. Among them, the design of Outer LOD can avoid the extremely complex problem of quadtree nearest neighbor search, which is an extremely complex process and has a high performance pressure on mobile terminals. After this simplification, it can also be quickly implemented on mobile terminals.
[0146] Please refer to Fig.17 , which shows a schematic diagram of the suturing process involved in the present application, such as Fig.17 As shown, we focus on the edge-locking effect between different levels of LOD. The grid in the frame line 1701 is in the edge-locking mode. It is located between two quadtree nodes. Both quadtrees are subdivided inside, but the subdivision level of the Outer LOD is still followed at the boundary, so the grid density shows a high-low-high phenomenon.
[0147] With the above-mentioned seam edge processing solution, the surface mesh supports transition and stitching between any level of LOD without any crack problems.
[0148] based on Figure 2 or Figure 6 The scheme shown, Fig.18FIG. 1 is a flowchart of a method for generating an image of a virtual scene provided by an exemplary embodiment of the present application, and the method can be executed by a computer device. Fig.17 As shown above Figure 2 or Figure 6 Step 220 in the illustrated embodiment may include the following steps 220a:
[0149] Step 220a: querying a slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area; the slope map contains the terrain slope corresponding to each coordinate information.
[0150] In an embodiment of the present application, a slope map may be pre-set in a computer device, and the slope map stores the terrain slope corresponding to each coordinate information in the coordinate system corresponding to each XY plane. During the rendering process, the computer device can quickly determine the terrain slope in each plane area by querying the slope map. For example, the above slope map may store the coordinate information of each plane area, and the terrain slope corresponding to the coordinate information of each plane area. When querying the terrain slope, the slope map can be queried through the coordinate information of the plane area, and the terrain slope of the plane area can be obtained, which improves the efficiency of obtaining the terrain slope and thus improves the rendering efficiency.
[0151] In a possible implementation, the slope map includes slope results of multiple levels of regional size granularity; wherein the regional size granularity may represent the size of a plane region;
[0152] Based on the coordinate information of each plane area, the slope map is queried to obtain the terrain slope in each plane area, including:
[0153] Based on the coordinate information of each plane area, the slope result of the area size granularity corresponding to the plane area in the slope map is queried to obtain the terrain slope in each plane area.
[0154] In the above scheme, since the plane area can have different area size granularities, for example, a 32KM*32KM plot can be divided into 32×32 plane areas according to the area size granularity of 1KM*1KM, that is, the size of each plane area is 1KM*1KM, or it can be divided into 16×16 plane areas according to the granularity of 1KM*1KM, that is, the size of each plane area is 2KM*2KM. Under different area size granularities, the size of the plane area is also different, and plane areas of different sizes or different area size granularities can coexist. For example, according to Figure 6In the scheme shown, in the XY plane, the sizes of the block nodes after the quadtree block are different. Correspondingly, after the block nodes of different sizes are further divided into plane areas, the sizes of the plane areas / area size granularities in the block nodes of different sizes are also different. In this regard, the above slope map can set corresponding slope results for various possible area size granularities. The slope result of each area size granularity can include the coordinate information of each plane area divided according to the current area size granularity (such as the center coordinates of the plane area / the coordinates of a vertex), and the terrain slope corresponding to the coordinate information of each plane area. When querying the terrain slope, the slope map can be queried in the slope result corresponding to the area size granularity of the plane area through the coordinate information of the plane area, that is, the terrain slope of the plane area can be obtained, thereby supporting the division of plane areas of different size granularities and ensuring the efficiency of terrain slope query in scenarios with plane areas of different sizes.
[0155] In a possible implementation, before querying the slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area, the method further includes:
[0156] S1, obtaining a height map of the terrain in the virtual scene, wherein the height map is used to indicate the terrain height of each position point in the XY plane of the virtual scene.
[0157] S2, based on the height map, obtaining the terrain height of each position point in the XY plane of the virtual scene.
[0158] Among them, each of the above-mentioned position points can be a pixel point in the height map. For example, assuming that each pixel point in the height map corresponds to a 1M (meter) * 1M square area (that is, a 1M * 1M plane area), the value of each pixel point in the height map can be the terrain height of the square area corresponding to the pixel point.
[0159] S3, based on the terrain height of each position point in the XY plane of the virtual scene, obtain the slope result of the first-level regional size granularity in the slope map; the terrain slope of the first plane area of the virtual scene at the first-level regional size granularity is obtained based on the height of each position point in the plane area.
[0160] Among them, the terrain slope of the first plane area under the first-level area size granularity can be the cosine value of the angle between the normal direction of the first plane area and the Z-axis direction (vertically upward) in the coordinate system of the virtual scene. Among them, the normal direction of the first plane area can be obtained by the height of multiple (for example, 8) plane areas of the first-level area size granularity around the first plane area. For example, assuming that on the height map, 8 plane areas around the first plane area (above, below, left, right, upper left, upper right, lower left, and lower right) can obtain 8 height values, and the vector obtained by subtracting the height of the upper plane area and the lower plane area from the vector obtained by subtracting the height of the left plane area and the right plane area is normalized after cross multiplication to obtain a normal direction 1. Similarly, the vector obtained by subtracting the height of the upper left plane area and the lower right plane area is normalized after cross multiplication to obtain a normal direction 2. The normal direction 1 and the normal direction 2 are averaged and normalized to obtain the normal direction of the current first plane area.
[0161] S4, based on the slope result of the first-level area size granularity, obtain the slope results of the multi-level area size granularity step by step; for the area size granularity of two adjacent levels in the multi-level area size granularity, a second plane area of the virtual scene at the latter-level area size granularity in the two adjacent levels of area size granularity includes multiple third plane areas of the virtual scene at the previous-level area size granularity in the two adjacent levels of area size granularity, and the terrain slope of the second plane area is obtained based on the terrain slopes of the corresponding multiple third plane areas.
[0162] In the embodiment of the present application, in two adjacent levels of regional size granularity, a plane area of the next level regional size granularity may include multiple (for example, 4) plane areas of the previous level regional size granularity, wherein the terrain slope of a plane area of the next level regional size granularity may be determined by the terrain slopes of multiple plane areas of the previous level regional size granularity included in the plane area; for example, the terrain slope of a plane area of the next level regional size granularity may be the minimum value of the terrain slopes of multiple plane areas of the previous level regional size granularity included in the plane area, or the terrain slope of a plane area of the next level regional size granularity may be the maximum value of the terrain slopes of multiple plane areas of the previous level regional size granularity included in the plane area, or the terrain slope of a plane area of the next level regional size granularity may be the average value of the terrain slopes of multiple plane areas of the previous level regional size granularity included in the plane area. Through the above scheme, the terrain slopes of multiple plane areas of the next level regional size granularity can be quickly determined through the terrain slopes of multiple plane areas of the previous level regional size granularity, thereby ensuring the efficiency of generating the slope map.
[0163] In a possible implementation, based on the terrain slope in each plane area, the grid density of the terrain grid of each plane area is obtained, including:
[0164] Get the slope interval of the terrain slope in each plane area;
[0165] The grid density corresponding to the slope interval of the terrain slope in each plane area is obtained as the grid density of the terrain grid of each plane area.
[0166] In an embodiment of the present application, the computer device can pre-set corresponding grid densities for various slope intervals. For a certain divided plane area, when the terrain slope of the plane area is determined, the corresponding grid density can be determined by the slope interval where the terrain slope is located. On the one hand, different grid densities can be set for plane areas with different terrain slopes to ensure the setting effect of the grid density. On the other hand, the grid density is limited to a limited number of types to reduce the complexity of subsequent processing and ensure subsequent rendering efficiency.
[0167] Please refer to Fig.19 , which shows a schematic diagram of a slope map acquisition process involved in the present application, such as Fig.19 As shown, in the embodiment of the present application, the steps of obtaining the slope of the terrain can be as follows:
[0168] S1, calculates normals for all 1K*1K height maps 1901 with a granularity of 1 meter.
[0169] The principle of this step is to sample the height map pixel by pixel. After obtaining the height value of the current pixel, sample the heights of the surrounding 8 pixels. The difference between the vectors composed of these heights is the normal direction of the current pixel. After normalization, the normal of the current pixel is obtained.
[0170] S2, based on the normal map 1902 obtained in S1, calculate the slope with a granularity of 8 meters.
[0171] S3, based on the slope result of the current granularity, calculate the slope of the next granularity, and save the result as the current granularity.
[0172] The slope granularity calculation in this step is to calculate the cosine value of the angle between the world normal direction of the current pixel and the world Z direction. The smaller the value, the more drastic the slope change, which is used to evaluate the degree of change in the terrain slope.
[0173] S4, repeat S3 until the current granularity is 1024 meters, and obtain the slope map 1903.
[0174] The first level Mip in the Slope Map stores the slope in units of 8 meters, and each subsequent level is the minimum of the four slope values of the parent Mip.
[0175] With the evaluation dimension of Slope Map, the grid density of each child node in the quadtree node is adjusted according to the slope of the terrain. For example, the grid density of the terrain grid of the current plane area is determined according to the range of the slope value corresponding to the current plane area. Use a higher subdivision grid density at the foot of the mountain, ridge, gully, etc., and reduce the grid density in other places. Please refer to Fig. 20 , which shows a schematic diagram of terrain grid settings for different slopes involved in this application.
[0176] The solution provided in this application can take into account and utilize the characteristics of the terrain of the virtual scene. Please refer to Fig.21 , which shows a schematic diagram of the virtual scene terrain involved in this application, such as Fig.21 As shown, the virtual scene can be divided into close-up, mid-range and distant views. The close-up requires a grid with as high a density as possible to show surface details. The distant view requires a higher density grid to avoid jagged defects and obtain a better silhouette. In the mid-range, especially in plains or gently sloping areas, there is actually a great waste of grids. In this regard, the solution shown in the embodiment of the present application can be used for the mid-range part according to Figure 2 , Figure 6 or Fig.18 The scheme shown adaptively determines the grid density of the terrain grid in each plane area according to the slope.
[0177] based on Figure 2 , Figure 6 or Fig.18 In a possible implementation of the solution shown, based on the grid density of the terrain grid of each plane area, before submitting rendering to each plane area and obtaining a scene image containing the terrain in the virtual scene, the method further includes:
[0178] For each of the plane regions, a fourth plane region within the near view range is obtained, where the terrain information within the fourth plane region includes at least one of a terrain material and a terrain map;
[0179] Get the grid density corresponding to the terrain information;
[0180] Based on the grid density corresponding to the terrain information, the grid density of the terrain grid in the fourth plane area is refined.
[0181] In a possible implementation, based on the grid density corresponding to the terrain information, the grid density of the terrain grid of the fourth plane area is refined, including:
[0182] The smaller value of the grid density corresponding to the terrain information and the grid density of the terrain grid of the fourth plane area is updated as the new grid density of the terrain grid of the fourth plane area.
[0183] For the near view, which is the area closest to the player, the highest mesh density is required to show the details. At this time, you can also consider that the physical properties / textures of different materials have different requirements for mesh density. For example, please refer to Fig. 22 , which shows a schematic diagram of the relationship between a material and a grid density involved in the present application, such as Fig. 22 As shown, taking the physical properties of the material as an example, the requirement for the mesh density of the mossy flat ground is 12cm per grid (the side length of each grid can be 12cm), while the requirement for the mesh density of the pebbles may require 1.5cm per grid (the side length of each grid can be 1.5cm). At this time, the material ID of the surface can be read to determine the subdivision level of the grid, and the grid density corresponding to the material ID and the minimum value of the grid density determined by the slope are taken as the grid density of the terrain grid in the current plane area, thereby achieving more delicate grid accuracy control. In addition, the requirements for the mesh density corresponding to the map are similar to those for the material. Different maps can correspond to different mesh density requirements, which will not be repeated here.
[0184] In another possible implementation, when the computer device refines the grid density of the terrain grid of the fourth plane area based on the grid density corresponding to the terrain information, it can also be updated in other ways, for example, the larger value of the grid density corresponding to the terrain information and the grid density of the terrain grid of the fourth plane area is updated as the new grid density of the terrain grid of the fourth plane area, thereby reducing the complexity of rendering and improving the rendering efficiency; or, the average value of the grid density corresponding to the terrain information and the grid density of the terrain grid of the fourth plane area is updated as the new grid density of the terrain grid of the fourth plane area, thereby taking into account both the complexity of rendering and the grid accuracy.
[0185] based on Figure 2 , Figure 6 or Fig.18 In a possible implementation of the solution shown, based on the grid density of the terrain grid of each plane area, before submitting rendering to each plane area and obtaining a scene image containing the terrain in the virtual scene, the method further includes:
[0186] For a fifth plane area in the distant view range among the plane areas, a grid density of the terrain grid of the fifth plane area is increased by a specified multiple.
[0187] For distant scenes, we can use empirical values, for example, when the LOD level of the quadtree node is ≥ 7, it is determined to be distant scenes. For all distant scenes, we can offset the subdivision levels of all Sub-Nodes of the quadtree node based on the original density, for example, offsetting by 2 levels is equivalent to increasing the distant scene density by 4 times to obtain a better silhouette effect.
[0188] Based on the above Figure 6 In a possible implementation of the solution shown, based on the grid density of the terrain grid of each plane area, each plane area is submitted for rendering to obtain a scene image containing the terrain in the virtual scene, including:
[0189] Perform cone detection in units of plane areas to obtain the plane area within the current camera viewing angle;
[0190] Based on the grid density of the terrain grid in the plane area within the current camera viewing angle, the terrain grid in the plane area within the current camera viewing angle is submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
[0191] In the above Figure 6 In the scheme shown, the computer device first performs quadtree block processing on the XY plane of the virtual scene to obtain multiple block nodes, and then further divides each block node to obtain the above-mentioned plane areas. On this basis, when submitting for rendering, cone detection can be performed according to the plane area, and the terrain meshes in the plane area within the current camera viewing angle range are submitted for rendering. For the terrain meshes in the plane area outside the current camera viewing angle range, it is not necessary to submit for rendering, thereby reducing unnecessary rendering processes and improving rendering efficiency.
[0192] In a possible implementation, in the above step 210c, when multiple block nodes are divided separately to obtain various plane areas, cone detection is performed on the block nodes as units to obtain the block nodes within the current camera viewing angle, and the block nodes within the current camera viewing angle are divided to obtain various plane areas; for the block nodes outside the current camera viewing angle, there is no need to divide them, and there is no need to determine the terrain grids within these block nodes subsequently, thereby avoiding unnecessary terrain grid determination processes and improving the efficiency of terrain grid determination.
[0193] In the embodiment of the present application, when submitting the rendering, visibility judgment can also be performed to reduce the number of grids submitted for rendering. Fig.23 , which shows a schematic diagram of a visibility judgment involved in this application. Fig.23 As shown, wireframe 2301 is a quadtree node, and different wireframes 2301 represent different LODs of the quadtree node. Straight line 2302 represents the range of the viewing cone.
[0194] For any quadtree node, perform a cone intersection test with the view frustum. The intersecting quadtree node proves that it can be seen by the camera in the current frame, otherwise it is not seen by the camera and there is no need to submit for rendering.
[0195] The steps of frustum clipping are as follows:
[0196] S1, take the XY plane positions of the four vertices of the quadtree node and obtain the bounding box BoundBox_XY of the XY plane.
[0197] S2, take the highest and lowest points of all Z within the coverage of the quadtree node, Z_Max and Z_Min.
[0198] S3, combining the values obtained in S1 / 2 to obtain the bounding box BoundBox_XYZ of the quadtree node in three-dimensional space. This bounding box can accurately describe the range of the quadtree node in the world space.
[0199] S4, perform intersection detection on the bounding box obtained in S3 and the six faces of the viewing cone. If any one of them intersects, it proves that the quadtree node can be seen by the camera viewing cone and needs to be submitted for rendering in the current frame.
[0200] S5, traverse all quadtree nodes, execute S1-S4, and save a list of all quadtree nodes that intersect with the view cone for rendering in this frame.
[0201] Depend on Fig.23 It can be found that there is a lot of waste when submitting rendering according to its frustum detection results, such as Fig. 22 The bold nodes only intersect the viewing frustum a little bit, but the entire quadtree node needs to be submitted for submission, so there is a waste.
[0202] In this regard, the solution shown in this application has been optimized on this basis, please refer to Fig.24 , which shows another schematic diagram of visibility judgment involved in the present application. Fig.24 As shown, all quadtree nodes 2401 are divided into N*N parts according to a rule, each of which is called a cluster (Cluster) 2401a, and each cluster corresponds to one of the above-mentioned plane areas.
[0203] The above Fig.23 The corresponding steps in S1 are changed to get the BoundBox_XY of the Cluster; the steps in S2 are changed to get the Z_Max and Z_Min in the Cluster; the steps in S5 are changed to record all Clusters that intersect with the view frustum for submission to rendering. The modified steps are as follows:
[0204] S1, divide the quadtree nodes into N*N clusters.
[0205] S2, take the XY plane positions of the four vertices of Cluster and obtain the bounding box BoundBox_XY on the XY plane.
[0206] S3, take the highest and lowest points of all Z within the coverage of the Cluster, Z_Max and Z_Min.
[0207] S4, combines the values obtained in S2 / 3 to obtain the bounding box BoundBox_XYZ of the Cluster in the three-dimensional space. This bounding box can accurately describe the range of the Cluster in the world space.
[0208] S5, perform intersection detection on the bounding box obtained in S4 and the six faces of the viewing cone. If any one of them intersects, it proves that the Cluster can be seen by the camera viewing cone and needs to be submitted for rendering in the current frame.
[0209] S6, traverse all quadtree nodes, execute S2-S5, and save the list of all Clusters intersecting with the view cone for rendering submission in this frame.
[0210] Further, in Fig.23 In the corresponding scheme, before executing S1, the intersection detection of the bounding box and the view cone can be performed on each quadtree node, a list of all quadtree nodes intersecting with the view cone is saved, and the steps of S1 are executed on the quadtree nodes intersecting with the view cone, that is, the quadtree nodes intersecting with the view cone are divided into N*N Clusters, and the terrain grids are subsequently determined for the divided Clusters respectively.
[0211] Please refer to Fig.25 , which shows the overall flow chart involved in this application. Based on the input of height map, quadtree, decal control map, ID map, etc., the complexity of quadtree nodes is calculated in Compute Shader (CS), and the distribution of regular grids on the XY plane is determined. Finally, the data in the world Z direction is assembled according to the height map and DisplacementMap in Vertex Shader (VS), so as to obtain the geometric grid.
[0212] The purpose of each input is introduced as follows:
[0213] Height Map: Used as data in the Z direction and also participates in the calculation of world normals.
[0214] Slope Map: Calculated based on the world normal, used in the level assessment of mid-ground subdivision.
[0215] Material ID Map (MatID Map): Participates in the evaluation of the foreground subdivision level.
[0216] Decal Control Map: Used to control the subdivision level of the surface decal area.
[0217] Material displacement map: It stores the offset details of the material in the Z direction in grayscale form, providing cm-level vertex offset.
[0218] like Fig.25 As shown, the input data includes a height map 2501, a quadtree 2502, a decal control map 2503, a material ID map 2504, and a material displacement map 2505; wherein, when first loaded, a normal map 2506 is calculated through the height map 2501, and a slope map 2507 is generated through the normal map 2506; thereafter, each time rendering is performed, the maximum complexity 2508 of each plane area in each quadtree node (that is, the grid density of each plane area is determined) is determined through the quadtree 2502, the decal control map 2503, the material ID map 2504, and the slope map 2507 generated when first loaded, and then the distribution 2509 of the terrain grid of each plane area is determined, and finally, the grid is assembled based on the height map 2501, the distribution 2509 of the terrain grid of each plane area, and the displacement map 2505, the data in the Z direction is introduced, and the geometric grid 2510 of the terrain is obtained by vertex shading.
[0219] Please refer to Fig.26 , which shows an overall framework diagram involved in this application, and the execution process of this solution is as follows.
[0220] S1, prepare the quadtree data on the CPU side and prepare to submit it to the GPU in batches.
[0221] S2, initiates the execution of Compute Shader on the CPU side, and the execution parameters are equal to the number of quadtree nodes. Among them, in this step, the CPU side initiates the execution of Compute Shader (CS for short), and the execution of CS requires execution parameters, and its execution parameters determine how the GPU will schedule and allocate CS tasks. For example: in a CS execution initiated by the CPU side, the number of quadtree nodes is 400, then the execution parameter of CS is 400 times, and each CS thread handles the subsequent processing of a quadtree node.
[0222] S3, execute CS on the GPU side. The execution of CS takes into account the subdivision logic of the near view, mid view, and far view mentioned in the above process to obtain the subdivision of the final quadtree node.
[0223] Please refer to Fig. 27 , which shows a schematic diagram of the effect comparison involved in this application. Fig. 27 As shown, through the above solution of the present application, the highest grid accuracy can eventually reach 1.5cm, and the number of DCs remains in single digits.
[0224] The above solution of this application can solve the contradiction between the ultra-large open world terrain and the ultra-high precision grid on the mobile terminal, and can obtain extremely high-detail surface grid performance on the mobile terminal, which provides a guarantee for the improvement of game quality and greatly enhances the player's gaming experience.
[0225] Fig.28 A block diagram of an image generation device for a virtual scene provided by an exemplary embodiment of the present application is shown. The device includes:
[0226] A plane acquisition module 2801 is used to acquire each plane area in the virtual scene, where the plane area is a rectangular area in the XY plane of the virtual scene;
[0227] The slope acquisition module 2802 is used to acquire the terrain slope in each plane area;
[0228] A grid density acquisition module 2803 is used to acquire the grid density of the terrain grid of each plane area based on the terrain slope in each plane area; the grid density is positively correlated with the terrain slope;
[0229] The image generation module 2804 is used to render the terrain grids in each of the plane areas based on the grid density of the terrain grids in each of the plane areas, so as to obtain a scene image including the terrain in the virtual scene.
[0230] In a possible implementation, the slope acquisition module 2802 is used to query a slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area; the slope map contains the terrain slope corresponding to each coordinate information.
[0231] In a possible implementation, the slope map includes slope results of multiple levels of regional size granularity;
[0232] The slope acquisition module 2802 is used to query the slope results of the area size granularity corresponding to the plane area in the slope map based on the coordinate information of each plane area, and obtain the terrain slope in each plane area.
[0233] In a possible implementation manner, the device further includes:
[0234] The slope result acquisition module is used for obtaining the terrain slope in each plane area before the slope acquisition module 2802 queries the slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area.
[0235] Acquire a height map of the terrain in the virtual scene, wherein the height map is used to indicate the terrain height of each position point in the XY plane of the virtual scene;
[0236] Based on the height map, obtaining the terrain slope of each position point in the XY plane of the virtual scene through the terrain height of each position point in the XY plane of the virtual scene;
[0237] Based on the terrain slope of each position point in the XY plane of the virtual scene, the slope result of the first level of regional size granularity in the slope map is obtained; the terrain slope of the first plane area of the virtual scene at the first level of regional size granularity is obtained based on the height of each position point in the plane area;
[0238] Based on the slope results of the first-level area size granularity, the slope results of the multi-level area size granularity are obtained step by step; for the area size granularity of two adjacent levels in the multi-level area size granularity, a second plane area of the virtual scene at the latter-level area size granularity in the two adjacent levels of area size granularity includes multiple third plane areas of the virtual scene at the previous-level area size granularity in the two adjacent levels of area size granularity, and the terrain slope of the second plane area is obtained based on the corresponding terrain slopes of the multiple third plane areas.
[0239] In a possible implementation, the grid density acquisition module 2803 is used to:
[0240] Obtaining the slope interval of the terrain slope in each plane area;
[0241] The grid density corresponding to the slope interval where the terrain slope in each plane area is located is obtained as the grid density of the terrain grid of each plane area.
[0242] In a possible implementation manner, the device further includes:
[0243] The first updating module is used for, before the image generation module 2804 submits rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene,
[0244] For a fourth plane area in the near view range among the plane areas, obtaining terrain information in the fourth plane area, wherein the terrain information includes at least one of a terrain material and a terrain map;
[0245] Obtaining a grid density corresponding to the terrain information;
[0246] Based on the grid density corresponding to the terrain information, the grid density of the terrain grid of the fourth plane area is further refined.
[0247] In a possible implementation, the first updating module is used to update the smaller value of the grid density corresponding to the terrain information and the grid density of the terrain grid of the fourth plane area to a new grid density of the terrain grid of the fourth plane area.
[0248] In a possible implementation manner, the device further includes:
[0249] The second updating module is used to increase the grid density of the terrain grid of the fifth plane area in the distant view range by a specified multiple for each plane area among the plane areas before the image generation module 2804 submits the rendering of each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene.
[0250] In a possible implementation, the plane acquisition module 2801 is used to:
[0251] Obtaining the current camera position observing the virtual scene;
[0252] Based on the camera position, the XY plane of the virtual scene is divided into blocks by a quadtree block method to obtain a plurality of block nodes;
[0253] The plurality of block nodes are divided respectively to obtain the respective plane areas.
[0254] In a possible implementation manner, the device further includes:
[0255] The boundary processing module is used for submitting the rendering of each plane area based on the grid density of the terrain grid of each plane area to obtain the scene image containing the terrain in the virtual scene before the image generation module 2804 submits the rendering of each plane area based on the grid density of the terrain grid of each plane area.
[0256] Performing edge locking processing on the boundaries of two adjacent block nodes;
[0257] The boundary between two adjacent plane areas in the same block node is subjected to seam edge processing.
[0258] In a possible implementation, the image generation module 2804 is used to:
[0259] Dividing each of the plane regions into a plurality of clusters;
[0260] Performing cone detection with the cluster as a unit to obtain clusters within the current camera viewing angle;
[0261] Based on the grid density of the terrain grids of each of the plane areas, the terrain grids in the cluster within the current camera viewing angle are submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
[0262] One point that needs to be explained is that the device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example to implement its functions. In actual applications, the above-mentioned functions can be assigned to different functional modules according to actual needs, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0263] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method; the technical effects achieved by each module performing operations are the same as those in the embodiment of the method, and will not be elaborated here.
[0264] Fig.29 The block diagram of the structure of a computer device 2900 provided by an exemplary embodiment of the present application is shown. The computer device 2900 may be a portable mobile terminal, such as a smart phone or a tablet computer. The computer device 2900 may also be called a user device, a portable terminal, or other names.
[0265] Typically, the computer device 2900 includes a processor 2901 and a memory 2902 .
[0266] The processor 2901 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 2901 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 2901 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 2901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 2901 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0267] The memory 2902 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 2902 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 2902 is used to store at least one instruction, which is used to be executed by the processor 2901 to implement the image generation method for a virtual scene provided in the embodiment of the present application.
[0268] In some embodiments, the computer device 2900 may further include: a peripheral device interface 2903 and at least one peripheral device. Specifically, the peripheral device includes: at least one of a radio frequency circuit 2904 , a touch display screen 2905 , a camera 2906 , an audio circuit 2907 and a power supply 2908 .
[0269] In some embodiments, the computer device 2900 further includes one or more sensors 2909 , including but not limited to: an acceleration sensor 2910 , a gyroscope sensor 2911 , a pressure sensor 2912 , an optical sensor 2913 , and a proximity sensor 2914 .
[0270] Those skilled in the art will appreciate that the structure shown above does not constitute a limitation on the computer device 2900 , and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0271] In an exemplary embodiment, a chip is also provided, which includes a programmable logic circuit and / or program instructions. When the chip runs on a computer device, it is used to implement the image generation method for a virtual scene described in the above aspects.
[0272] In an exemplary embodiment, a computer program product is also provided, the computer program product includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor reads and executes the computer instructions from the computer-readable storage medium to implement the image generation method for a virtual scene provided by each of the above method embodiments.
[0273] In an exemplary embodiment, a computer-readable storage medium is further provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the image generation method for a virtual scene provided by the above-mentioned method embodiments.
[0274] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0275] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.
[0276] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for generating an image of a virtual scene, characterized in that: The method comprises: Acquire each plane area in the virtual scene, wherein the plane area is a rectangular area in the XY plane of the virtual scene; Obtaining the terrain slope within each plane area; Based on the terrain slope in each plane area, obtaining the grid density of the terrain grid of each plane area; the grid density is positively correlated with the terrain slope; Based on the grid density of the terrain grid of each of the plane areas, each of the plane areas is submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
2. The method according to claim 1, characterized in that: The obtaining of the terrain slope in each plane area includes: The slope map is queried based on the coordinate information of each plane area to obtain the terrain slope in each plane area; the slope map contains the terrain slope corresponding to each coordinate information.
3. The method according to claim 2, characterized in that The slope map contains slope results of multiple levels of regional size granularity; The querying of the slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area includes: Based on the coordinate information of each plane area, the slope result of the area size granularity corresponding to the plane area in the slope map is queried to obtain the terrain slope in each plane area.
4. The method according to claim 3, characterized in that Before querying the slope map based on the coordinate information of each plane area to obtain the terrain slope in each plane area, the method further includes: Acquire a height map of the terrain in the virtual scene, wherein the height map is used to indicate the terrain height of each position point in the XY plane of the virtual scene; Based on the height map, obtaining the terrain height of each position point in the XY plane of the virtual scene; Based on the terrain height of each position point in the XY plane of the virtual scene, the slope result of the first level of regional size granularity in the slope map is obtained; the terrain slope of the first plane area of the virtual scene at the first level of regional size granularity is obtained based on the height of each position point in the plane area; Based on the slope results of the first-level area size granularity, the slope results of the multi-level area size granularity are obtained step by step; for the area size granularity of two adjacent levels in the multi-level area size granularity, a second plane area of the virtual scene at the latter-level area size granularity in the two adjacent levels of area size granularity includes multiple third plane areas of the virtual scene at the previous-level area size granularity in the two adjacent levels of area size granularity, and the terrain slope of the second plane area is obtained based on the corresponding terrain slopes of the multiple third plane areas.
5. The method according to claim 1, characterized in that The obtaining, based on the terrain slope in each plane area, the grid density of the terrain grid of each plane area includes: Obtaining the slope interval of the terrain slope in each plane area; The grid density corresponding to the slope interval where the terrain slope in each plane area is located is obtained as the grid density of the terrain grid of each plane area.
6. The method according to any one of claims 1 to 5, characterized in that: Before submitting rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene, the method further includes: For a fourth plane area in the near view range among the plane areas, obtaining terrain information in the fourth plane area, wherein the terrain information includes at least one of a terrain material and a terrain map; Obtaining a grid density corresponding to the terrain information; Based on the grid density corresponding to the terrain information, the grid density of the terrain grid of the fourth plane area is further refined.
7. The method according to claim 6, characterized in that The step of refining the grid density of the terrain grid of the fourth plane area based on the grid density corresponding to the terrain information includes: A smaller value between the grid density corresponding to the terrain information and the grid density of the terrain grid of the fourth plane area is updated as a new grid density of the terrain grid of the fourth plane area.
8. The method according to any one of claims 1 to 5, characterized in that: Before submitting rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene, the method further includes: For a fifth plane area in the distant view range among the plane areas, the grid density of the terrain grid of the fifth plane area is increased by a specified multiple.
9. The method according to any one of claims 1 to 5, characterized in that: The step of obtaining each plane area in the virtual scene includes: Obtaining the current camera position observing the virtual scene; Based on the camera position, the XY plane of the virtual scene is divided into blocks by a quadtree block method to obtain a plurality of block nodes; The plurality of block nodes are divided respectively to obtain the respective plane areas.
10. The method according to claim 9, characterized in that Before submitting rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene, the method further includes: Performing edge locking processing on the boundaries of two adjacent block nodes; the edge locking processing refers to uniformly setting the points at fixed positions on the boundaries of the block nodes as mesh vertices on the boundaries of the block nodes; The boundary of two adjacent plane areas within the same block node is subjected to edge processing; the edge processing refers to moving mesh vertices belonging to different plane areas on the boundary of two adjacent plane areas to the same point on the boundary of the two adjacent plane areas.
11. The method according to claim 9, characterized in that The step of submitting rendering to each plane area based on the grid density of the terrain grid of each plane area to obtain a scene image containing the terrain in the virtual scene includes: Performing a frustum detection with the plane area as a unit to obtain the plane area within the current camera viewing angle; Based on the grid density of the terrain grid in the plane area within the current camera viewing angle, the terrain grid in the plane area within the current camera viewing angle is submitted for rendering to obtain a scene image containing the terrain in the virtual scene.
12. An image generation device for a virtual scene, characterized in that: The device comprises: A plane acquisition module, used to acquire each plane area in the virtual scene, wherein the plane area is a rectangular area in the XY plane of the virtual scene; A slope acquisition module, used to acquire the terrain slope in each plane area; A grid density acquisition module, used to acquire the grid density of the terrain grid of each plane area based on the terrain slope in each plane area; the grid density is positively correlated with the terrain slope; The image generation module is used to render the terrain grids in each plane area based on the grid density of the terrain grids in each plane area, so as to obtain a scene image containing the terrain in the virtual scene.
13. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one computer instruction, and the at least one computer instruction is loaded and executed by the processor to implement the image generation method for a virtual scene as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer instruction, and the computer instruction is loaded and executed by a processor to implement the image generation method for a virtual scene as described in any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium; the computer instructions are read and executed by a processor of a computer device to implement the image generation method for a virtual scene as described in any one of claims 1 to 11.